private static void logPersistence(AnnotatedObject<?,?> ao) { if (log.isDebugEnabled()) { log.debug("\t\t\tPersisted with AC: " + ao.getAc()); if (!ao.getXrefs().isEmpty()) { log.debug("\t\t\tXrefs: " + ao.getXrefs().size()); for (Xref xref : ao.getXrefs()) { log.debug("\t\t\t\t"+xref); } } if (!ao.getAliases().isEmpty()) { log.debug("\t\t\tAliases: " + ao.getAliases().size()); for (Alias alias: ao.getAliases()) { log.debug("\t\t\t\t"+alias); } } if (!ao.getAnnotations().isEmpty()) { log.debug("\t\t\tAnnotations: " + ao.getAnnotations().size()); for (Annotation annot: ao.getAnnotations()) { log.debug("\t\t\t\t"+annot); } } } }
/** * Prints the label, ac, and the counts of some attributes (xrefs, aliases and annotations) of an AnnotatedObject * @param ao Annotated object to prints * * @since 1.8.0 */ public static String annotatedObjectToString(AnnotatedObject ao, boolean showAttributesCount) { Class clazz = CgLibUtil.removeCglibEnhanced(ao.getClass()); StringBuilder sb = new StringBuilder(); sb.append(clazz.getSimpleName()).append("{label=").append(ao.getShortLabel()).append(", ac=").append(ao.getAc()); if (showAttributesCount) { String xrefsCount = "[not initialized]"; String aliasCount = "[not initialized]"; String annotationsCount = "[not initialized]"; if (IntactCore.isInitialized(ao.getXrefs())) { xrefsCount = String.valueOf(ao.getXrefs().size()); } if (IntactCore.isInitialized(ao.getAliases())) { aliasCount = String.valueOf(ao.getAliases().size()); } if (IntactCore.isInitialized(ao.getAnnotations())) { annotationsCount = String.valueOf(ao.getAnnotations().size()); } sb.append(", xrefCount=").append(xrefsCount).append(", aliasCount=").append(aliasCount).append(", annotationsCount=").append(annotationsCount); } sb.append("}"); return sb.toString(); }
public static Collection<Alias> getAliasByType(AnnotatedObject<?, ?> annotatedObject, String miOrLabel) { Collection<Alias> matchingAliases = new ArrayList<Alias>(); for (Alias alias : annotatedObject.getAliases()) { if (alias.getCvAliasType() != null && ( alias.getCvAliasType().getIdentifier().equals(miOrLabel) || alias.getCvAliasType().getShortLabel().equals(miOrLabel)) ) { matchingAliases.add(alias); } } return matchingAliases; }
/** * Prints the label, ac, and the counts of some attributes (xrefs, aliases and annotations) of an AnnotatedObject * @param ao Annotated object to prints * * @since 1.8.0 */ public static String annotatedObjectToString(AnnotatedObject ao, boolean showAttributesCount) { Class clazz = CgLibUtil.removeCglibEnhanced(ao.getClass()); StringBuilder sb = new StringBuilder(); sb.append(clazz.getSimpleName()).append("{label=").append(ao.getShortLabel()).append(", ac=").append(ao.getAc()); if (showAttributesCount) { String xrefsCount = "[not initialized]"; String aliasCount = "[not initialized]"; String annotationsCount = "[not initialized]"; if (IntactCore.isInitialized(ao.getXrefs())) { xrefsCount = String.valueOf(ao.getXrefs().size()); } if (IntactCore.isInitialized(ao.getAliases())) { aliasCount = String.valueOf(ao.getAliases().size()); } if (IntactCore.isInitialized(ao.getAnnotations())) { annotationsCount = String.valueOf(ao.getAnnotations().size()); } sb.append(", xrefCount=").append(xrefsCount).append(", aliasCount=").append(aliasCount).append(", annotationsCount=").append(annotationsCount); } sb.append("}"); return sb.toString(); }
public static Collection<Alias> getAliasByType(AnnotatedObject<?, ?> annotatedObject, String miOrLabel) { Collection<Alias> matchingAliases = new ArrayList<Alias>(); for (Alias alias : annotatedObject.getAliases()) { if (alias.getCvAliasType() != null && ( alias.getCvAliasType().getIdentifier().equals(miOrLabel) || alias.getCvAliasType().getShortLabel().equals(miOrLabel)) ) { matchingAliases.add(alias); } } return matchingAliases; }
/** * Retrieves the aliases from an AnnotatedObject, initializing them if necessary. * * @param ao The annotated object instance with possibly non-initialized aliases * @return The returned aliases are ensured to be initialized * @since 2.4.0 */ public static Collection<? extends Alias> ensureInitializedAliases(AnnotatedObject<?, ?> ao) { Collection<? extends Alias> aliases; if (IntactCore.isInitialized(ao.getAliases())) { aliases = ao.getAliases(); } else { aliases = IntactContext.getCurrentInstance().getDaoFactory().getAliasDao(AnnotatedObjectUtils.getAliasClassType(ao.getClass())) .getByParentAc(ao.getAc()); } return aliases; }
/** * Retrieves the aliases from an AnnotatedObject, initializing them if necessary. * * @param ao The annotated object instance with possibly non-initialized aliases * @return The returned aliases are ensured to be initialized * @since 2.4.0 */ public static Collection<? extends Alias> ensureInitializedAliases(AnnotatedObject<?, ?> ao) { Collection<? extends Alias> aliases; if (IntactCore.isInitialized(ao.getAliases())) { aliases = ao.getAliases(); } else { aliases = IntactContext.getCurrentInstance().getDaoFactory().getAliasDao(AnnotatedObjectUtils.getAliasClassType(ao.getClass())) .getByParentAc(ao.getAc()); } return aliases; }
if (IntactCore.isInitializedAndDirty(ao.getAliases())) { for ( Alias alias : ao.getAliases() ) { synchedAliases.add( synchronizeAlias( alias, ao ) ); ao.getAliases().clear(); ao.getAliases().addAll(synchedAliases); } else { synchedAliases = ao.getAliases();
private static List<SearchItem> searchItemsForAnnotatedObject( AnnotatedObject<? extends Xref, ? extends Alias> ao, boolean includeAliases ) { List<SearchItem> searchItems = new ArrayList<SearchItem>(); searchItems.add( new SearchItem( ao.getAc(), ao.getAc(), ao.getClass().getName(), "ac" ) ); searchItems.add( new SearchItem( ao.getAc(), ao.getShortLabel(), ao.getClass().getName(), "shortlabel" ) ); if ( ao.getFullName() != null ) { searchItems.add( new SearchItem( ao.getAc(), ao.getFullName(), ao.getClass().getName(), "fullname" ) ); } if ( includeAliases ) { for ( Alias alias : ao.getAliases() ) { if ( alias.getCvAliasType() != null ) { searchItems.add( new SearchItem( ao.getAc(), alias.getName(), ao.getClass().getName(), alias.getCvAliasType().getShortLabel() ) ); } else { log.warn( "Couldn't insert SearchItem for Alias, as it cvAliasType is null: " + alias.getName() ); } } } return searchItems; }
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() ); }
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); }
return IntactCore.isInitialized(parent.getAnnotations()); } else if (child instanceof Alias) { return IntactCore.isInitialized(parent.getAliases()); } else { throw new IllegalArgumentException("Unexpected combination parent/child - Parent: " +
public static void populateNames( AnnotatedObject<?, ?> annotatedObject, NamesContainer namesContainer, AliasConverter aliasConverter ) { Names names = namesContainer.getNames(); if ( names == null ) { names = new Names(); } String shortLabel = annotatedObject.getShortLabel(); String fullName = annotatedObject.getFullName(); names.setShortLabel( shortLabel ); names.setFullName( fullName ); if ( !ConverterContext.getInstance().getInteractorConfig().isExcludeInteractorAliases() ) { Collection<? extends Alias> aliases; if (aliasConverter.isCheckInitializedCollections()){ aliases = IntactCore.ensureInitializedAliases(annotatedObject); } else { aliases = annotatedObject.getAliases(); } for ( Alias alias : aliases) { names.getAliases().add( aliasConverter.intactToPsi( alias ) ); } } namesContainer.setNames( names ); }
@Override protected void saveOrUpdateAttributes( T intactObject ) throws PersisterException { if ( intactObject == null ) { throw new NullPointerException( "intactObject" ); } InstitutionPersister institutionPersister = InstitutionPersister.getInstance(); institutionPersister.saveOrUpdate( intactObject.getOwner() ); CvObjectPersister cvPersister = CvObjectPersister.getInstance(); for ( Xref xref : intactObject.getXrefs() ) { cvPersister.saveOrUpdate( xref.getCvDatabase() ); if ( xref.getCvXrefQualifier() != null ) { cvPersister.saveOrUpdate( xref.getCvXrefQualifier() ); } institutionPersister.saveOrUpdate( xref.getOwner() ); } for ( Alias alias : intactObject.getAliases() ) { if ( alias.getCvAliasType() != null ) { cvPersister.saveOrUpdate( alias.getCvAliasType() ); } institutionPersister.saveOrUpdate( alias.getOwner() ); } for ( Annotation annotation : intactObject.getAnnotations() ) { if ( annotation.getCvTopic() != null ) { cvPersister.saveOrUpdate( annotation.getCvTopic() ); } institutionPersister.saveOrUpdate( annotation.getOwner() ); } }