public static Collection<Annotation> getPublicAnnotations(final AnnotatedObject<?, ?> annotatedObject) { final Collection<Annotation> publicAnnotations = new ArrayList<Annotation>(annotatedObject.getAnnotations().size()); final Iterator<Annotation> i = IntactCore.ensureInitializedAnnotations(annotatedObject).iterator(); while (i.hasNext()) { Annotation annotation = i.next(); if (isCvTopicPublic(annotation.getCvTopic())) { publicAnnotations.add(annotation); } } return publicAnnotations; }
public static Collection<Annotation> getPublicAnnotations(final AnnotatedObject<?, ?> annotatedObject) { final Collection<Annotation> publicAnnotations = new ArrayList<Annotation>(annotatedObject.getAnnotations().size()); final Iterator<Annotation> i = IntactCore.ensureInitializedAnnotations(annotatedObject).iterator(); while (i.hasNext()) { Annotation annotation = i.next(); if (isCvTopicPublic(annotation.getCvTopic())) { publicAnnotations.add(annotation); } } return publicAnnotations; }
private boolean hasNoUniprotUpdateAnnotation( AnnotatedObject ao ) { for ( Annotation annot : ao.getAnnotations() ) { if( annot.getCvTopic().getShortLabel().equals( CvTopic.NON_UNIPROT ) ) { return true; } } return false; }
private boolean hasNoUniprotUpdateAnnotation( AnnotatedObject ao ) { for ( Annotation annot : ao.getAnnotations() ) { if( annot.getCvTopic().getShortLabel().equals( CvTopic.NON_UNIPROT ) ) { return true; } } return false; }
protected boolean updateCommonAttributes(T candidateObject, T objectToBeUpdated) throws PersisterException { for (Annotation annotation : candidateObject.getAnnotations()) { objectToBeUpdated.addAnnotation(annotation); } saveOrUpdateAttributes(objectToBeUpdated); return true; } }
/** * Answers the question: is that AnnotatedObject (Interaction, Experiment) annotated as negative ? * * @param annotatedObject the object we want to introspect * * @return true if the object is annotated with the 'negative' CvTopic, otherwise false. */ public boolean isNegative(AnnotatedObject annotatedObject) { boolean isNegative = false; Collection<Annotation> annotations = annotatedObject.getAnnotations(); for (Iterator<Annotation> iterator = annotations.iterator(); iterator.hasNext() && false == isNegative;) { Annotation annotation = iterator.next(); if (getNegative().equals(annotation.getCvTopic())) { isNegative = true; } } return isNegative; }
/** * Finds an Annotations with a topic that has an MI or label equal to the value provided * * @param annotatedObject The annotatedObject to find the annotation * @param miOrLabel The MI (use it when possible) or the shortLabel * @return The annotation with that CvTopic. Null if no annotation for that CV is found * @since 1.8.0 */ public static Annotation findAnnotationByTopicMiOrLabel(AnnotatedObject<?, ?> annotatedObject, String miOrLabel) { for (Annotation annotation : annotatedObject.getAnnotations()) { final CvTopic topic = annotation.getCvTopic(); if (topic != null && (miOrLabel.equals(topic.getIdentifier()) || miOrLabel.equals(topic.getShortLabel()))) { return annotation; } } return null; }
/** * Finds an Annotations with a topic that has an MI or label equal to the value provided * * @param annotatedObject The annotatedObject to find the annotation * @param miOrLabel The MI (use it when possible) or the shortLabel * @return The annotation with that CvTopic. Null if no annotation for that CV is found * @since 1.8.0 */ public static Annotation findAnnotationByTopicMiOrLabel(AnnotatedObject<?, ?> annotatedObject, String miOrLabel) { for (Annotation annotation : annotatedObject.getAnnotations()) { final CvTopic topic = annotation.getCvTopic(); if (topic != null && (miOrLabel.equals(topic.getIdentifier()) || miOrLabel.equals(topic.getShortLabel()))) { return annotation; } } return null; }
/** * Retrieves the annotations from an AnnotatedObject, initializing them if necessary. * * @param ao The annotated object instance with possibly non-initialized annotations * @return The returned annotations are ensured to be initialized * @since 2.4.0 */ public static Collection<Annotation> ensureInitializedAnnotations(AnnotatedObject ao) { Collection<Annotation> annotations; if (IntactCore.isInitialized(ao.getAnnotations())) { annotations = ao.getAnnotations(); } else { annotations = IntactContext.getCurrentInstance().getDaoFactory().getAnnotationDao().getByParentAc(ao.getClass(), ao.getAc()); } return annotations; }
/** * Retrieves the annotations from an AnnotatedObject, initializing them if necessary. * * @param ao The annotated object instance with possibly non-initialized annotations * @return The returned annotations are ensured to be initialized * @since 2.4.0 */ public static Collection<Annotation> ensureInitializedAnnotations(AnnotatedObject ao) { Collection<Annotation> annotations; if (IntactCore.isInitialized(ao.getAnnotations())) { annotations = ao.getAnnotations(); } else { annotations = IntactContext.getCurrentInstance().getDaoFactory().getAnnotationDao().getByParentAc(ao.getClass(), ao.getAc()); } return annotations; }
protected String getIdValidationRegexp(AnnotatedObject<?,?> annotatedObject) { String regexp = null; for (Annotation annotation : annotatedObject.getAnnotations()) { if (annotation.getCvTopic() != null) { CvObjectXref idXref = CvObjectUtils.getPsiMiIdentityXref(annotation.getCvTopic()); if (idXref != null && idXref.getPrimaryId().equals(CvTopic.XREF_VALIDATION_REGEXP_MI_REF)) { regexp = annotation.getAnnotationText(); } } } return regexp; } }
protected <X extends Xref, A extends Alias> void copyAnotatedObjectCommons( AnnotatedObject<X, A> source, AnnotatedObject<X, A> target ) { // if the source does not have an AC, we should not update the target shortLabel, fullName and owner // as it does not make much sense //if (source.getAc() != null) { copyProperty(source, "shortLabel", target); copyProperty(source, "fullName", target); copyProperty(source, "owner", target); //} copyXrefCollection( source.getXrefs(), target.getXrefs() ); copyAliasCollection( source.getAliases(), target.getAliases(), source, target ); copyAnnotationCollection( source.getAnnotations(), target.getAnnotations() ); }
private <T extends AnnotatedObject> void initializeCommonsIfNecessary(T ao, T managedObject) { if (IntactCore.isInitialized(ao.getXrefs())) IntactCore.initialize(managedObject.getXrefs()); if (IntactCore.isInitialized(ao.getAnnotations())) IntactCore.initialize(managedObject.getAnnotations()); if (IntactCore.isInitialized(ao.getAliases())) { IntactCore.initialize(managedObject.getAliases()); } }
/** * Initializes the AnnotatedObject collections (xrefs, aliases, annotations). * * @param ao The annotatedObject */ public static void initializeAnnotatedObject(AnnotatedObject ao) { initialize(ao.getXrefs()); initialize(ao.getAliases()); initialize(ao.getAnnotations()); }
/** * Initializes the AnnotatedObject collections (xrefs, aliases, annotations). * * @param ao The annotatedObject */ public static void initializeAnnotatedObject(AnnotatedObject ao) { initialize(ao.getXrefs()); initialize(ao.getAliases()); initialize(ao.getAnnotations()); }
private <T extends AnnotatedObject> void initializeCommonsIfNecessary(T ao, T managedObject) { if (IntactCore.isInitialized(ao.getXrefs())) IntactCore.initialize(managedObject.getXrefs()); if (IntactCore.isInitialized(ao.getAnnotations())) IntactCore.initialize(managedObject.getAnnotations()); if (IntactCore.isInitialized(ao.getAliases())) { IntactCore.initialize(managedObject.getAliases()); } }
protected <X extends Xref, A extends Alias> void copyAnotatedObjectCommons( AnnotatedObject<X, A> source, AnnotatedObject<X, A> target ) { // if the source does not have an AC, we should not update the target shortLabel, fullName and owner // as it does not make much sense //if (source.getAc() != null) { copyProperty(source, "shortLabel", target); copyProperty(source, "fullName", target); copyProperty(source, "owner", target); //} copyXrefCollection( source.getXrefs(), target.getXrefs() ); copyAliasCollection( source.getAliases(), target.getAliases(), source, target ); copyAnnotationCollection( source.getAnnotations(), target.getAnnotations() ); }
public static void populateAttributes( AnnotatedObject<?, ?> annotatedObject, AttributeContainer attributeContainer, AnnotationConverter annotationConverter ) { AnnotationConverterConfig configAnnotation = ConverterContext.getInstance().getAnnotationConfig(); Collection<Annotation> annotations; if (annotationConverter.isCheckInitializedCollections()){ annotations = IntactCore.ensureInitializedAnnotations(annotatedObject); } else { annotations = annotatedObject.getAnnotations(); } for ( Annotation annotation : annotations ) { if (!configAnnotation.isExcluded(annotation.getCvTopic())) { Attribute attribute = annotationConverter.intactToPsi( annotation ); if (!attributeContainer.getAttributes().contains( attribute )) { attributeContainer.getAttributes().add( attribute ); } } } }
protected void traverseAnnotatedObjectCommon(AnnotatedObject ao, IntactVisitor ... visitors) { traverse(ao.getAnnotations(), visitors); traverse(ao.getAliases(), visitors); traverse(ao.getXrefs(), visitors); // check if this element has been traversed already, to avoid cyclic recursion if (recursionChecker.isAlreadyTraversed(ao)) { return; } traverse(ao.getOwner(), visitors); }
protected void traverseAnnotatedObjectCommon(AnnotatedObject ao, IntactVisitor ... visitors) { traverse(ao.getAnnotations(), visitors); traverse(ao.getAliases(), visitors); traverse(ao.getXrefs(), visitors); // check if this element has been traversed already, to avoid cyclic recursion if (recursionChecker.isAlreadyTraversed(ao)) { return; } traverse(ao.getOwner(), visitors); }