public CvObjectConverter(Institution institution, Class<C> intactCvClass, Class<T> psiCvClass) { super(institution); this.intactCvClass = intactCvClass; this.psiCvClass = psiCvClass; Class<?> aliasClass = AnnotatedObjectUtils.getAliasClassType(intactCvClass); Class<?> xrefClass = AnnotatedObjectUtils.getXrefClassType(intactCvClass); this.aliasConverter = new AliasConverter(institution, aliasClass); this.xrefConverter = new XrefConverter(institution, xrefClass); }
@Transient @Deprecated /** * @deprecated now it is always stored as a simple annotation */ public String getPostalAddress() { Annotation annot = AnnotatedObjectUtils.findAnnotationByTopicMiOrLabel(this, "postaladdress"); return annot != null ? annot.getAnnotationText() : null; }
/** * Gets the generic Xref type for an AnnotatedObject class * @param clazz an AnnotatedObject class * @return the Xref type used in the class */ public static Class<? extends Xref> getXrefClassType(Class<? extends AnnotatedObject> clazz) { clazz = CgLibUtil.removeCglibEnhanced(clazz); PropertyDescriptor propDesc = null; try { propDesc = new PropertyDescriptor("xrefs", clazz); } catch (IntrospectionException e) { e.printStackTrace(); } Method method = propDesc.getReadMethod(); return getParameterizedType(method.getGenericReturnType()); }
/** * Checks if two given annotated objects contain the same set of annotations, xrefs and aliases * * @param ao1 Annotated object 1 * @param ao2 Annotated object 2 * @return if the two annotated objects contain the same set of annnotations, xrefs and aliases */ public static boolean containSameCollections(AnnotatedObject ao1, AnnotatedObject ao2) { if (!containSameXrefs(ao1, ao2)) { return false; } if (!containSameAnnotations(ao1, ao2)) { return false; } if (!containSameAliases(ao1, ao2)) { return false; } return true; }
public static <X extends Xref> X getPsiMiIdentityXref(AnnotatedObject<X, ?> annotatedObject) { if (annotatedObject == null) { throw new NullPointerException("annotatedObject should not be null"); } X psiMiXref = null; Collection<X> identityXrefs = AnnotatedObjectUtils.searchXrefs(annotatedObject, CvDatabase.PSI_MI_MI_REF, CvXrefQualifier.IDENTITY_MI_REF); if (!identityXrefs.isEmpty()) { psiMiXref = identityXrefs.iterator().next(); } return psiMiXref; }
public static <X extends Xref> X newXrefInstanceFor(Class<? extends AnnotatedObject> aoClass) { Class<X> xrefClass = (Class<X>) AnnotatedObjectUtils.getXrefClassType(aoClass); return ClassUtils.newInstance(xrefClass); }
public static <A extends Alias> A newAliasInstanceFor(Class<? extends AnnotatedObject> aoClass) { Class<A> aliasClass = (Class<A>) AnnotatedObjectUtils.getAliasClassType(aoClass); return ClassUtils.newInstance(aliasClass); } }
if (log.isDebugEnabled()) log.debug("Populating identifier for: "+cvObject.getShortLabel()); Collection<CvObjectXref> miIdXrefs = AnnotatedObjectUtils.searchXrefs(cvObject, CvDatabase.PSI_MI_MI_REF, CvXrefQualifier.IDENTITY_MI_REF); identifier = miIdXrefs.iterator().next().getPrimaryId(); } else { Collection<CvObjectXref> idXrefs = AnnotatedObjectUtils.searchXrefsByQualifier(cvObject, CvXrefQualifier.IDENTITY_MI_REF);
List<InteractorXref> parents = AnnotatedObjectUtils.searchXrefs(interactor, xrefFilter1); List<InteractorXref> identities = AnnotatedObjectUtils.searchXrefs(interactor, xrefFilter); if (AnnotatedObjectUtils.containTheSameXrefs(xrefFilter, interactor, interactorCandidate)) { List<InteractorXref> parentsToCompare = AnnotatedObjectUtils.searchXrefs(possibleMatch, xrefFilter1);
/** * This method is an alternative equals to the CvObject.equals method, that basically checks * on the MI identifiers and then of the short label if the first check returns false * * @param cv1 One of the CvObjects * @param cv2 The other CvObject * @param includeCollectionsCheck if true, check if the annotations/xrefs/aliases are the same * @return True if (A) the MI are the same or (B) the short labels are the same in case A has failed * @since 1.9.0 */ public static boolean areEqual(CvObject cv1, CvObject cv2, boolean includeCollectionsCheck) { if (cv1 == null || cv2 == null) { return false; } if (includeCollectionsCheck && AnnotatedObjectUtils.isNewOrManaged(cv1) && AnnotatedObjectUtils.isNewOrManaged(cv2)) { if (!AnnotatedObjectUtils.containSameCollections(cv1, cv2)) { return false; } } if (cv1.getIdentifier() != null && cv2.getIdentifier() != null) { if (!cv1.getIdentifier().equals(cv2.getIdentifier())) { return false; } } if (cv1.getShortLabel() == null || cv2.getShortLabel() == null) { return false; } return cv1.getShortLabel().equals(cv2.getShortLabel()); }
/** * Constructor for subclass use only. Ensures that AnnotatedObjects cannot be * created without at least a shortLabel and an owner specified. * * @param shortLabel The memorable label to identify this AnnotatedObject * * @throws NullPointerException thrown if either parameters are not specified */ protected AnnotatedObjectImpl( String shortLabel ) { //super call sets creation time data super(); this.shortLabel = AnnotatedObjectUtils.prepareShortLabel( shortLabel ); }
public static boolean containSameAliases(AnnotatedObject ao1, AnnotatedObject ao2) { return areCollectionEqual(IntactCore.ensureInitializedAliases(ao1), IntactCore.ensureInitializedXrefs(ao2)); }
public static <X extends Xref> X getPsiMiIdentityXref(AnnotatedObject<X, ?> annotatedObject) { if (annotatedObject == null) { throw new NullPointerException("annotatedObject should not be null"); } X psiMiXref = null; Collection<X> identityXrefs = AnnotatedObjectUtils.searchXrefs(annotatedObject, CvDatabase.PSI_MI_MI_REF, CvXrefQualifier.IDENTITY_MI_REF); if (!identityXrefs.isEmpty()) { psiMiXref = identityXrefs.iterator().next(); } return psiMiXref; }
public static <X extends Xref> X newXrefInstanceFor(Class<? extends AnnotatedObject> aoClass) { Class<X> xrefClass = (Class<X>) AnnotatedObjectUtils.getXrefClassType(aoClass); return ClassUtils.newInstance(xrefClass); }
public static <A extends Alias> A newAliasInstanceFor(Class<? extends AnnotatedObject> aoClass) { Class<A> aliasClass = (Class<A>) AnnotatedObjectUtils.getAliasClassType(aoClass); return ClassUtils.newInstance(aliasClass); } }
/** * Checks if two given annotated objects contain the same set of annotations, xrefs and aliases * * @param ao1 Annotated object 1 * @param ao2 Annotated object 2 * @return if the two annotated objects contain the same set of annnotations, xrefs and aliases */ public static boolean containSameCollections(AnnotatedObject ao1, AnnotatedObject ao2) { if (!containSameXrefs(ao1, ao2)) { return false; } if (!containSameAnnotations(ao1, ao2)) { return false; } if (!containSameAliases(ao1, ao2)) { return false; } return true; }
if (log.isDebugEnabled()) log.debug("Populating identifier for: "+cvObject.getShortLabel()); Collection<CvObjectXref> miIdXrefs = AnnotatedObjectUtils.searchXrefs(cvObject, CvDatabase.PSI_MI_MI_REF, CvXrefQualifier.IDENTITY_MI_REF); identifier = miIdXrefs.iterator().next().getPrimaryId(); } else { Collection<CvObjectXref> idXrefs = AnnotatedObjectUtils.searchXrefsByQualifier(cvObject, CvXrefQualifier.IDENTITY_MI_REF);
List<InteractorXref> parents = AnnotatedObjectUtils.searchXrefs(interactor, xrefFilter1); List<InteractorXref> identities = AnnotatedObjectUtils.searchXrefs(interactor, xrefFilter); if (AnnotatedObjectUtils.containTheSameXrefs(xrefFilter, interactor, interactorCandidate)) { List<InteractorXref> parentsToCompare = AnnotatedObjectUtils.searchXrefs(possibleMatch, xrefFilter1);
/** * This method is an alternative equals to the CvObject.equals method, that basically checks * on the MI identifiers and then of the short label if the first check returns false * * @param cv1 One of the CvObjects * @param cv2 The other CvObject * @param includeCollectionsCheck if true, check if the annotations/xrefs/aliases are the same * @return True if (A) the MI are the same or (B) the short labels are the same in case A has failed * @since 1.9.0 */ public static boolean areEqual(CvObject cv1, CvObject cv2, boolean includeCollectionsCheck) { if (cv1 == null || cv2 == null) { return false; } if (includeCollectionsCheck && AnnotatedObjectUtils.isNewOrManaged(cv1) && AnnotatedObjectUtils.isNewOrManaged(cv2)) { if (!AnnotatedObjectUtils.containSameCollections(cv1, cv2)) { return false; } } if (cv1.getIdentifier() != null && cv2.getIdentifier() != null) { if (!cv1.getIdentifier().equals(cv2.getIdentifier())) { return false; } } if (cv1.getShortLabel() == null || cv2.getShortLabel() == null) { return false; } return cv1.getShortLabel().equals(cv2.getShortLabel()); }
/** * Constructor for subclass use only. Ensures that AnnotatedObjects cannot be * created without at least a shortLabel and an owner specified. * * @param shortLabel The memorable label to identify this AnnotatedObject * * @throws NullPointerException thrown if either parameters are not specified */ protected AnnotatedObjectImpl( String shortLabel ) { //super call sets creation time data super(); this.shortLabel = AnnotatedObjectUtils.prepareShortLabel( shortLabel ); }