List of usage examples for org.apache.commons.lang ArrayUtils removeElement
public static short[] removeElement(short[] array, short element)
Removes the first occurrence of the specified element from the specified array.
From source file:org.exoplatform.social.core.space.impl.SpaceServiceImpl.java
/** * {@inheritDoc}//from w w w.j a v a 2 s . com */ private Space removePending(Space space, String userId) { String[] pendingUsers = space.getPendingUsers(); if (ArrayUtils.contains(pendingUsers, userId)) { pendingUsers = (String[]) ArrayUtils.removeElement(pendingUsers, userId); space.setPendingUsers(pendingUsers); } return space; }
From source file:org.exoplatform.social.core.space.impl.SpaceServiceImpl.java
/** * {@inheritDoc}/*from ww w. j a v a 2s . co m*/ */ private Space removeInvited(Space space, String userId) { String[] invitedUsers = space.getInvitedUsers(); if (ArrayUtils.contains(invitedUsers, userId)) { invitedUsers = (String[]) ArrayUtils.removeElement(invitedUsers, userId); space.setInvitedUsers(invitedUsers); } return space; }
From source file:org.exoplatform.social.core.space.impl.SpaceServiceImpl.java
/** * {@inheritDoc}/*from w ww . j ava 2 s . c om*/ */ public void setManager(Space space, String userId, boolean isManager) { String[] managers = space.getManagers(); if (isManager) { if (!ArrayUtils.contains(managers, userId)) { managers = (String[]) ArrayUtils.add(managers, userId); space.setManagers(managers); this.updateSpace(space); SpaceUtils.addUserToGroupWithManagerMembership(userId, space.getGroupId()); spaceLifeCycle.grantedLead(space, userId); } } else { if (ArrayUtils.contains(managers, userId)) { managers = (String[]) ArrayUtils.removeElement(managers, userId); space.setManagers(managers); this.updateSpace(space); SpaceUtils.removeUserFromGroupWithManagerMembership(userId, space.getGroupId()); Space updatedSpace = getSpaceById(space.getId()); if (isMember(updatedSpace, userId)) { spaceLifeCycle.revokedLead(space, userId); } } } }
From source file:org.exoplatform.social.core.storage.ActivityStorage.java
/** * Delete an activity's comments/*from w w w . j a v a2 s .c o m*/ * All the comment ids are stored in an activity's replytoId * * @param activityId */ private void deleteActivityComments(String activityId) throws Exception { ExoSocialActivity activity = getActivity(activityId); String rawCommentIds = activity.getReplyToId(); //rawCommentIds can be: null || ,a,b,c,d if (rawCommentIds != null) { if (rawCommentIds.equals(ExoSocialActivity.IS_COMMENT)) return; String[] commentIds = rawCommentIds.split(COMMENT_IDS_DELIMITER); //remove the first empty element commentIds = (String[]) ArrayUtils.removeElement(commentIds, ""); for (String commentId : commentIds) { deleteActivity(commentId); } } }
From source file:org.exoplatform.social.core.storage.memory.InMemoryActivityStorageImpl.java
public void removeComment(ExoSocialActivity activity, ExoSocialActivity comment) throws ActivityStorageException { ///* ww w. j a v a2 s . c om*/ List<String> mentioners = new ArrayList<String>(); activity.setMentionedIds( processMentions(activity.getMentionedIds(), comment.getTitle(), mentioners, false)); // List<String> commenters = new ArrayList<String>(); activity.setCommentedIds( processCommenters(activity.getCommentedIds(), comment.getUserId(), commenters, false)); String[] replyIds = activity.getReplyToId(); activity.setReplyToId((String[]) ArrayUtils.removeElement(replyIds, comment.getId())); }
From source file:org.gitools.ui.app.analysis.groupcomparison.wizard.GroupComparisonGroupingPage.java
private void performMerge() { int[] selection = groupsTable.getSelectedRows(); List<IMatrixPredicate> predicateList = new ArrayList<>(); StringBuilder groupName = new StringBuilder(""); StringBuilder groupProperty = new StringBuilder(""); int size = 0; for (int i : selection) { DimensionGroup group = tableModel.getGroupAt(i); if (!groupName.toString().equals("")) { groupName.append(" + "); groupProperty.append(" + "); }/*from ww w . j a va2 s. co m*/ groupName.append(group.getName()); groupProperty.append(group.getProperty()); predicateList.add(group.getPredicate()); size += group.getGroupSize(); } MatrixPredicates.OrPredicate newpredicate = new MatrixPredicates.OrPredicate(predicateList); tableModel.setGroup(new DimensionGroup(groupName.toString(), newpredicate, DimensionGroupEnum.Annotation, groupProperty.toString(), size), selection[0]); tableModel.removeGroups(ArrayUtils.removeElement(selection, selection[0])); tableModel.fireTableDataChanged(); updateControls(); }
From source file:org.janusgraph.blueprints.process.BerkeleyProcessStandardSuite.java
private static final Class<?>[] getTestList() throws InitializationError { try {//from ww w .j a v a 2s .c om final Field field = ProcessStandardSuite.class.getDeclaredField("allTests"); field.setAccessible(true); return (Class<?>[]) ArrayUtils.removeElement((Class<?>[]) field.get(null), TraversalInterruptionTest.class); } catch (ReflectiveOperationException e) { throw new InitializationError("Unable to create test list"); } }
From source file:org.jboss.richfaces.integrationTest.extendedDataTable.SelectingTestCase.java
private void checkSelection(int[] selectedRows) { if (rows == -1) { rows = getJQueryCount(LOC_TR_SELECTED); }/*from w ww . jav a 2 s . c o m*/ int[] notSelectedRows = new int[rows]; // create an array with all rows for (int i = 0; i < rows; i++) { notSelectedRows[i] = i + 1; } // create an array with not selected rows for (int row : selectedRows) { notSelectedRows = ArrayUtils.removeElement(notSelectedRows, row); } for (final int row : selectedRows) { Wait.timeout(3000).interval(100).failWith(format("Row nr. {0} should be selected.", row)) .until(new Condition() { public boolean isTrue() { return selenium.isElementPresent(format(LOC_TR_SELECTED, row)); } }); } for (final int row : notSelectedRows) { Wait.timeout(3000).interval(100).failWith(format("Row nr. {0} should not be selected.", row)) .until(new Condition() { public boolean isTrue() { return !selenium.isElementPresent(format(LOC_TR_SELECTED, row)); } }); } }
From source file:org.kuali.rice.krad.service.impl.DictionaryValidationServiceImpl.java
/** * @param dataObject the object to get the collection from * @param reference the <code>ReferenceDefinition</code> of the collection to validate * @param displayFieldName the name of the field * @param intermediateCollections array containing the path to the collection as tokens * @param pathToAttributeI the rebuilt path to the ReferenceDefinition.attributeToHighlightOnFail which includes * the// w w w. j a v a2 s . c o m * index of * each subcollection * @return */ private boolean validateCollectionReferenceExistsAndIsActive(Object dataObject, ReferenceDefinition reference, String displayFieldName, String[] intermediateCollections, String pathToAttributeI) { boolean success = true; Collection<?> referenceCollection; String collectionName = intermediateCollections[0]; // remove current collection from intermediates intermediateCollections = (String[]) ArrayUtils.removeElement(intermediateCollections, collectionName); try { referenceCollection = (Collection) PropertyUtils.getProperty(dataObject, collectionName); } catch (Exception e) { throw new RuntimeException(e); } int pos = 0; Iterator<?> iterator = referenceCollection.iterator(); while (iterator.hasNext()) { String pathToAttribute = StringUtils.defaultString(pathToAttributeI) + collectionName + "[" + (pos++) + "]."; // keep drilling down until we reach the nested collection we want if (intermediateCollections.length > 0) { success &= validateCollectionReferenceExistsAndIsActive(iterator.next(), reference, displayFieldName, intermediateCollections, pathToAttribute); } else { String attributeToHighlightOnFail = pathToAttribute + reference.getAttributeToHighlightOnFail(); success &= validateReferenceExistsAndIsActive(iterator.next(), reference.getAttributeName(), attributeToHighlightOnFail, displayFieldName); } } return success; }
From source file:org.linagora.linshare.view.tapestry.pages.administration.lists.Index.java
public SelectModel getVisibilityTypeModel() { return new EnumSelectModel(VisibilityType.class, messages, (VisibilityType[]) ArrayUtils.removeElement(VisibilityType.values(), VisibilityType.AllMyLists)); }