List of usage examples for org.apache.commons.collections CollectionUtils containsAny
public static boolean containsAny(final Collection coll1, final Collection coll2)
true
iff at least one element is in both collections. From source file:info.magnolia.templating.elements.AreaElement.java
protected String resolveAvailableComponents() { if (StringUtils.isNotEmpty(availableComponents)) { return StringUtils.remove(availableComponents, " "); }/*from w w w . ja v a 2s . co m*/ if (areaDefinition != null && areaDefinition.getAvailableComponents().size() > 0) { Iterator<ComponentAvailability> iterator = areaDefinition.getAvailableComponents().values().iterator(); List<String> componentIds = new ArrayList<String>(); final Collection<String> userRoles = MgnlContext.getUser().getAllRoles(); while (iterator.hasNext()) { ComponentAvailability availableComponent = iterator.next(); if (availableComponent.isEnabled()) { // check roles final Collection<String> roles = availableComponent.getRoles(); if (!roles.isEmpty()) { if (CollectionUtils.containsAny(userRoles, roles)) { componentIds.add(availableComponent.getId()); } } else { componentIds.add(availableComponent.getId()); } } } return StringUtils.join(componentIds, ','); } return ""; }
From source file:net.sourceforge.fenixedu.domain.mobility.outbound.OutboundMobilityCandidacyContestGroup.java
private boolean intersect(final OutboundMobilityCandidacyContestGroup otherGroup) { return CollectionUtils.containsAny(getExecutionDegreeSet(), otherGroup.getExecutionDegreeSet()); }
From source file:com.marand.thinkmed.medications.business.impl.DefaultMedicationsBo.java
private boolean isSimilarSimpleTherapy(final OrderActivity orderActivity, final OrderActivity compareOrderActivity, final Map<Long, MedicationDataForTherapyDto> medicationsMap) { //therapy//from w w w. j a va 2 s. c om final List<DvCodedText> routes = orderActivity.getAdministrationDetails().getRoute(); final Long medicationId = getMainMedicationId(orderActivity); final String medicationName = orderActivity.getMedicine() != null ? orderActivity.getMedicine().getValue() : null; //compare therapy final List<DvCodedText> compareRoutes = compareOrderActivity.getAdministrationDetails().getRoute(); final Long compareMedicationId = getMainMedicationId(compareOrderActivity); final String compareMedicationName = compareOrderActivity.getMedicine() != null ? compareOrderActivity.getMedicine().getValue() : null; final boolean similarMedication = isSimilarMedication(medicationId, medicationName, compareMedicationId, compareMedicationName, medicationsMap); final boolean sameRoute = CollectionUtils.containsAny(routes, compareRoutes); return similarMedication && sameRoute; }
From source file:com.mirth.connect.client.ui.DashboardPanel.java
public synchronized void updateTableChannelNodes(List<DashboardStatus> intermediateStatuses) { ChannelTagInfo channelTagInfo = parent.getChannelTagInfo(true); if (channelTagInfo.isEnabled()) { List<DashboardStatus> filteredStatuses = new ArrayList<DashboardStatus>(); for (DashboardStatus currentStatus : intermediateStatuses) { if (channelTagInfo.isEnabled() && CollectionUtils.containsAny(channelTagInfo.getVisibleTags(), currentStatus.getTags())) { filteredStatuses.add(currentStatus); }//from w ww.ja v a 2 s . c om } intermediateStatuses = filteredStatuses; } DashboardTreeTableModel model = (DashboardTreeTableModel) dashboardTable.getTreeTableModel(); model.setStatuses(intermediateStatuses); model.setShowLifetimeStats(showLifetimeStatsButton.isSelected()); updateTableHighlighting(); }
From source file:com.mirth.connect.client.ui.DashboardPanel.java
public synchronized void finishUpdatingTable(List<DashboardStatus> finishedStatuses, Collection<ChannelGroupStatus> channelGroupStatuses) { DashboardTreeTableModel model = (DashboardTreeTableModel) dashboardTable.getTreeTableModel(); ChannelTagInfo channelTagInfo = parent.getChannelTagInfo(true); int totalChannelCount = finishedStatuses.size(); int totalGroupCount = channelGroupStatuses.size(); List<DashboardStatus> filteredDashboardStatuses = new ArrayList<DashboardStatus>(); List<ChannelGroupStatus> filteredGroupStatuses = new ArrayList<ChannelGroupStatus>(); if (channelTagInfo.isEnabled()) { for (DashboardStatus currentStatus : finishedStatuses) { if (channelTagInfo.isEnabled() && CollectionUtils.containsAny(channelTagInfo.getVisibleTags(), currentStatus.getTags())) { filteredDashboardStatuses.add(currentStatus); }/* ww w . ja v a 2 s.c o m*/ } finishedStatuses = filteredDashboardStatuses; } model.finishStatuses(finishedStatuses); model.setShowLifetimeStats(showLifetimeStatsButton.isSelected()); // The ListSelectionListener is not notified that the tree table model has changed so we must update the menu items manually. // If we switch everything to use a TreeSelectionListener then we should remove this. if (dashboardTable.getSelectedRowCount() == 0) { deselectRows(true); } else { updatePopupMenu(true); } updateTableHighlighting(); if (channelTagInfo.isEnabled()) { Map<String, DashboardStatus> statusMap = new HashMap<String, DashboardStatus>(); for (DashboardStatus status : parent.status) { statusMap.put(status.getChannelId(), status); } for (ChannelGroupStatus groupStatus : channelGroupStatuses) { ChannelGroup group = groupStatus.getGroup(); boolean addGroupStatus = false; for (Channel channel : group.getChannels()) { DashboardStatus dashboardStatus = statusMap.get(channel.getId()); if (dashboardStatus != null && CollectionUtils.containsAny(channelTagInfo.getVisibleTags(), dashboardStatus.getTags())) { addGroupStatus = true; break; } } if (addGroupStatus) { filteredGroupStatuses.add(groupStatus); } } model.setGroupStatuses(filteredGroupStatuses); } else { model.setGroupStatuses(channelGroupStatuses); } updateTagsLabel(totalGroupCount, filteredGroupStatuses.size(), totalChannelCount, filteredDashboardStatuses.size()); }
From source file:com.marand.thinkmed.medications.business.impl.DefaultMedicationsBo.java
private boolean isSimilarComplexTherapy(final OrderActivity orderActivity, final OrderActivity compareOrderActivity, final Map<Long, MedicationDataForTherapyDto> medicationsMap) { final boolean therapyBaselineInfusion = isBaselineInfusion(orderActivity); final boolean compareTherapyBaselineInfusion = isBaselineInfusion(compareOrderActivity); if (therapyBaselineInfusion && compareTherapyBaselineInfusion) { return true; }//from w w w .j a v a 2 s. c o m if (orderActivity.getIngredientsAndForm().getIngredient().size() == 1 && compareOrderActivity.getIngredientsAndForm().getIngredient().size() == 1) { //therapy final List<DvCodedText> routes = orderActivity.getAdministrationDetails().getRoute(); final Long medicationId = getMainMedicationId(orderActivity); final String medicationName = orderActivity.getIngredientsAndForm().getIngredient().get(0).getName() .getValue(); //compare therapy final List<DvCodedText> compareRoutes = compareOrderActivity.getAdministrationDetails().getRoute(); final Long compareMedicationId = getMainMedicationId(compareOrderActivity); final String compareMedicationName = compareOrderActivity.getIngredientsAndForm().getIngredient().get(0) .getName().getValue(); final boolean sameRoute = CollectionUtils.containsAny(routes, compareRoutes); final boolean similarMedication = isSimilarMedication(medicationId, medicationName, compareMedicationId, compareMedicationName, medicationsMap); return sameRoute && similarMedication; } return false; }
From source file:com.atlassian.jira.user.util.UserUtilImpl.java
private boolean canActivateUsersInternal(Collection<String> userNames) { Assertions.notNull("userNames", userNames); final LicenseDetails licenseDetails = getLicenseDetails(); if (!licenseDetails.isLicenseSet()) { return true; }/*from ww w. j a v a 2 s.co m*/ if (!licenseDetails.isUnlimitedNumberOfUsers()) { final Set<String> groupsWithUsePermission = getGroupsWithUsePermission(); int numInactiveUsers = 0; for (final Object element : userNames) { final String userName = (String) element; // if user is in any group that is a group with use permissions, then they are already active and do // not count towards the limit Collection<String> groupNames = new ArrayList<String>(); Iterable<Group> userGroups = getGroupsForUserFromCrowd(userName); for (Group group : userGroups) { groupNames.add(group.getName()); } if (!CollectionUtils.containsAny(groupNames, groupsWithUsePermission)) { numInactiveUsers++; } } final int userCount = getActiveUserCount(); //only if we are trying to add new inactive users and they'll exceed the license limit do we //return false. Otherwise, if we're not activating any new users, or we're under the license limit //we just return true. if ((numInactiveUsers != 0) && ((userCount + numInactiveUsers) > licenseDetails.getMaximumNumberOfUsers())) { return false; } } return true; }
From source file:net.sourceforge.fenixedu.domain.Person.java
public boolean isOptOutAvailable() { return !CollectionUtils.containsAny(getPersonRolesSet(), getOptOutRoles()); }
From source file:nl.strohalm.cyclos.services.transactions.InvoiceServiceImpl.java
private boolean hasTTPermission(final Invoice invoice, final boolean asUser) { TransferType transferType = invoice.getTransferType(); if (transferType != null && !transferType.getContext().isPayment()) { // The invoices sent with disabled TTs are those from account fee charges // We cannot check for permission, because disabled TTs cannot be assigned to permission groups return true; }/*ww w. j ava 2 s . c o m*/ Relationship fetch = asUser ? AdminGroup.Relationships.TRANSFER_TYPES_AS_MEMBER /* same relationship for brokers */ : Group.Relationships.TRANSFER_TYPES; List<TransferType> ttsWithPermission = PropertyHelper.get(fetchService.fetch(LoggedUser.group(), fetch), fetch.getName()); List<TransferType> possibleTransferTypes = getPossibleTransferTypes(invoice); return CollectionUtils.containsAny(possibleTransferTypes, ttsWithPermission); }
From source file:nl.strohalm.cyclos.utils.validation.AbstractValueValidation.java
public ValidationError validate(final Object object, final Object name, final Object value) { if (value != null && !"".equals(value)) { boolean contains; if (value instanceof Collection<?>) { final Collection<?> collection = (Collection<?>) value; if (collection.isEmpty()) { return null; }/*from ww w.j ava 2 s . c om*/ contains = CollectionUtils.containsAny(values, collection); } else { contains = values.contains(value); } if (contains != expected()) { return new InvalidError(); } } return null; }