@Override public int compare(GroupableActivity o1, GroupableActivity o2) { return o1.compareTo(o2); } }
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); }
public static void calculateLastModified(Group group) { Collection<? extends GroupableActivity> activities = group.getActivities(); if (activities != null && !activities.isEmpty()) { Iterator<? extends GroupableActivity> activitiesIterator = activities.iterator(); LastModifiedDate latest = null; while (activitiesIterator.hasNext()) { GroupableActivity activity = activitiesIterator.next(); if (activity.getLastModifiedDate() != null && activity.getLastModifiedDate().after(latest)) { latest = activity.getLastModifiedDate(); } } group.setLastModifiedDate(latest); } }
@Override public int compareTo(GroupableActivity activity) { Long index = Long.valueOf(this.getDisplayIndex() == null ? "0" : this.getDisplayIndex()); Long otherIndex = Long.valueOf(activity.getDisplayIndex() == null ? "0" : activity.getDisplayIndex()); if (index == null) { if (otherIndex == null) { return 0; } else { return -1; } } else { if (otherIndex == null) { return 1; } else if (index instanceof Comparable) { // Return opposite, since higher index goes first return index.compareTo(otherIndex) * -1; } else { return 0; } } }
public GroupPojo(List<T> summaries, int id, String orcid, ExternalIDs ids){ setGroupId(id); Long maxDisplayIndex = null; setActivities(new ArrayList<T>()); for (T summary : summaries) { getActivities().add(summary); Long displayIndex = Long.parseLong(summary.getDisplayIndex()); if (maxDisplayIndex == null || displayIndex > maxDisplayIndex) { maxDisplayIndex = displayIndex; setActivePutCode(summary.getPutCode()); setActiveVisibility(summary.getVisibility().name()); setDefaultActivity(summary); } if (summary.getSource().retrieveSourcePath().equals(orcid)) { setUserVersionPresent(true); } } if (ids != null) { for (ExternalID extId : ids.getExternalIdentifier()) { if (extId.getRelationship() == null) { extId.setRelationship(Relationship.SELF); } externalIdentifiers.add(ActivityExternalIdentifier.valueOf(extId)); } } }
@Override public int compareTo(GroupableActivity activity) { Long index = Long.valueOf(this.getDisplayIndex() == null ? "0" : this.getDisplayIndex()); Long otherIndex = Long.valueOf(activity.getDisplayIndex() == null ? "0" : activity.getDisplayIndex()); if (index == null) { if (otherIndex == null) { return 0; } else { return -1; } } else { if (otherIndex == null) { return 1; } else if (index instanceof Comparable) { // Return opposite, since higher index goes first return index.compareTo(otherIndex) * -1; } else { return 0; } } } }
@Override public int compareTo(GroupableActivity activity) { Long index = Long.valueOf(this.getDisplayIndex() == null ? "0" : this.getDisplayIndex()); Long otherIndex = Long.valueOf(activity.getDisplayIndex() == null ? "0" : activity.getDisplayIndex()); if (index == null) { if (otherIndex == null) { return 0; } else { return -1; } } else { if (otherIndex == null) { return 1; } else if (index instanceof Comparable) { //Return opposite, since higher index goes first return index.compareTo(otherIndex) * -1; } else { return 0; } } } }
/** * 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(); } } }
@Override public int compareTo(GroupableActivity activity) { Long index = Long.valueOf(this.getDisplayIndex() == null ? "0" : this.getDisplayIndex()); Long otherIndex = Long.valueOf(activity.getDisplayIndex() == null ? "0" : activity.getDisplayIndex()); if (index == null) { if (otherIndex == null) { return 0; } else { return -1; } } else { if (otherIndex == null) { return 1; } else if (index instanceof Comparable) { // Return opposite, since higher index goes first return index.compareTo(otherIndex) * -1; } else { return 0; } } } }
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();
@Override public int compareTo(GroupableActivity activity) { Long index = Long.valueOf(this.getDisplayIndex() == null ? "0" : this.getDisplayIndex()); Long otherIndex = Long.valueOf(activity.getDisplayIndex() == null ? "0" : activity.getDisplayIndex()); if (index == null) { if (otherIndex == null) { return 0; } else { return -1; } } else { if (otherIndex == null) { return 1; } else if (index instanceof Comparable) { //Return opposite, since higher index goes first return index.compareTo(otherIndex) * -1; } else { return 0; } } } }
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); }