Search in sources :

Example 1 with ExternalIdentifiersContainer

use of org.orcid.jaxb.model.v3.dev1.record.ExternalIdentifiersContainer in project ORCID-Source by ORCID.

the class ActivitiesGroup method belongsToGroup.

@Deprecated
public /**
 * This method is only used by tests to confirm accuracy of ActivitiesGroupGenerator and should not be used in production
 *
 * @param activity
 * @return
 */
boolean belongsToGroup(GroupableActivity activity) {
    boolean isPeerReview = PeerReviewSummary.class.isAssignableFrom(activity.getClass());
    // If there are no grouping keys
    if (groupKeys == null || groupKeys.isEmpty()) {
        if (isPeerReview) {
            return false;
        } else {
            if (activity.getExternalIdentifiers() == null || activity.getExternalIdentifiers().getExternalIdentifier() == null || activity.getExternalIdentifiers().getExternalIdentifier().isEmpty()) {
                // If the activity doesn't have any external identifier, check if the activity is in the group
                if (activities.contains(activity))
                    return true;
                else
                    return false;
            } else {
                // If any of the activities pass the grouping validation, the activity must belong to other group
                for (GroupAble extId : activity.getExternalIdentifiers().getExternalIdentifier()) {
                    if (extId.isGroupAble())
                        return false;
                }
                // If none of the activities pass the groupings validation, so, lets check if the group actually contains the activity
                if (activities.contains(activity))
                    return true;
                else
                    return false;
            }
        }
    }
    if (isPeerReview) {
        PeerReviewSummary peerReviewSummary = (PeerReviewSummary) activity;
        PeerReviewGroupKey prgk = new PeerReviewGroupKey();
        prgk.setGroupId(peerReviewSummary.getGroupId());
        if (prgk.isGroupAble()) {
            if (groupKeys.contains(prgk)) {
                return true;
            }
        }
    } else {
        // Check existing keys
        ExternalIdentifiersContainer container = activity.getExternalIdentifiers();
        if (container != null) {
            List<? extends GroupAble> extIds = (List<? extends GroupAble>) container.getExternalIdentifier();
            for (GroupAble extId : extIds) {
                // First check keys restrictions
                if (extId.isGroupAble()) {
                    // If any of the keys already exists on this group, return true
                    if (containsKey(extId))
                        return true;
                }
            }
        }
    }
    return false;
}
Also used : PeerReviewGroupKey(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroupKey) PeerReviewSummary(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary) ExternalIdentifiersContainer(org.orcid.jaxb.model.v3.dev1.record.ExternalIdentifiersContainer) List(java.util.List) GroupAble(org.orcid.jaxb.model.v3.dev1.record.GroupAble)

Example 2 with ExternalIdentifiersContainer

use of org.orcid.jaxb.model.v3.dev1.record.ExternalIdentifiersContainer in project ORCID-Source by ORCID.

the class ActivitiesGroupGeneratorBaseTest method checkExternalIdentifiers.

/**
 * Checks that all the external identifiers in the activity are contained in the group external identifiers
 */
public void checkExternalIdentifiers(GroupableActivity activity, ActivitiesGroup group) {
    ExternalIdentifiersContainer extIdsContainer = activity.getExternalIdentifiers();
    List<? extends GroupAble> extIds = extIdsContainer.getExternalIdentifier();
    Set<GroupAble> groupExtIds = group.getGroupKeys();
    for (Object o : extIds) {
        GroupAble extId = (GroupAble) o;
        // If the ext id pass the grouping validation, it must be in the ext ids list
        if (extId.isGroupAble())
            assertTrue(groupExtIds.contains(extId));
    }
}
Also used : ExternalIdentifiersContainer(org.orcid.jaxb.model.v3.dev1.record.ExternalIdentifiersContainer) GroupAble(org.orcid.jaxb.model.v3.dev1.record.GroupAble)

Aggregations

ExternalIdentifiersContainer (org.orcid.jaxb.model.v3.dev1.record.ExternalIdentifiersContainer)2 GroupAble (org.orcid.jaxb.model.v3.dev1.record.GroupAble)2 List (java.util.List)1 PeerReviewGroupKey (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroupKey)1 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)1