public ActivitiesGroup(GroupableActivity activity) { groupKeys = new HashSet<GroupAble>(); activities = new HashSet<GroupableActivity>(); if (activity != null && activity.getExternalIdentifiers() != null) { for (GroupAble extId : activity.getExternalIdentifiers().getExternalIdentifier()) { // Dont add grouping keys that dont pass the validation if (extId.isGroupAble()) { groupKeys.add(extId); } } } activities.add(activity); }
/** * Filter the group external identifiers to match the external identifiers * that belongs to the activities it have after filtering * * @param group * The group we want to filter the external identifiers */ private void filterExternalIdentifiers(Group group) { // Iterate over every external identifier and check if it is still // present in the list of filtered elements ExternalIDs extIds = group.getIdentifiers(); Iterator<ExternalID> extIdsIt = extIds.getExternalIdentifier().iterator(); while (extIdsIt.hasNext()) { ExternalID extId = extIdsIt.next(); boolean found = false; for (GroupableActivity summary : group.getActivities()) { if (summary.getExternalIdentifiers() != null) { if (summary.getExternalIdentifiers().getExternalIdentifier().contains(extId)) { found = true; break; } } } // If the ext id is not found, remove it from the list of ext ids if (!found) { extIdsIt.remove(); } } }
if (activity.getExternalIdentifiers() == null || activity.getExternalIdentifiers().getExternalIdentifier() == null || activity.getExternalIdentifiers().getExternalIdentifier().isEmpty()) { for (GroupAble extId : activity.getExternalIdentifiers().getExternalIdentifier()) { if (extId.isGroupAble()) return false; ExternalIdentifiersContainer container = activity.getExternalIdentifiers(); if (container != null) { List<? extends GroupAble> extIds = (List<? extends GroupAble>) container.getExternalIdentifier();
public void add(GroupableActivity activity) { // Add new grouping keys ExternalIdentifiersContainer container = activity.getExternalIdentifiers(); if (container != null) { List<? extends GroupAble> extIds = (List<? extends GroupAble>) container.getExternalIdentifier(); for (GroupAble extId : extIds) { // Dont add grouping keys that dont pass the grouping // validation if (extId.isGroupAble()) { boolean hasId = false; for (GroupAble groupKey : groupKeys) if (groupKey.getGroupId() != null && groupKey.getGroupId().equals(extId.getGroupId())) hasId = true; if (!hasId) groupKeys.add(extId); } } } // Add activity activities.add(activity); }