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 <X extends Xref> X newXrefInstanceFor(Class<? extends AnnotatedObject> aoClass) { Class<X> xrefClass = (Class<X>) AnnotatedObjectUtils.getXrefClassType(aoClass); return ClassUtils.newInstance(xrefClass); }
public static <X extends Xref> X newXrefInstanceFor(Class<? extends AnnotatedObject> aoClass) { Class<X> xrefClass = (Class<X>) AnnotatedObjectUtils.getXrefClassType(aoClass); return ClassUtils.newInstance(xrefClass); }
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); }
public <X extends Xref> void populateWithPsiMi(AnnotatedObject annotatedObject, String psiMi) { this.institution = annotatedObject.getOwner(); Class<? extends Xref> xrefClass = AnnotatedObjectUtils.getXrefClassType(annotatedObject.getClass()); X xref = (X) createPsiMiXref(xrefClass, psiMi); xref.setParent(annotatedObject); if (xref instanceof CvObjectXref) { if (((CvObject)annotatedObject).getIdentifier() == null) { ((CvObjectXref)xref).prepareParentMi(); } } annotatedObject.getXrefs().add(xref); }
public AbstractAnnotatedObjectConverter(Institution institution, Class<? extends A> intactClass, Class<T> psiClass) { super(institution); this.intactClass = intactClass; this.psiClass = psiClass; Class<?> aliasClass = AnnotatedObjectUtils.getAliasClassType(intactClass); Class<?> xrefClass = AnnotatedObjectUtils.getXrefClassType(intactClass); this.annotationConverter = new AnnotationConverter(institution); this.aliasConverter = new AliasConverter(institution, aliasClass); this.xrefConverter = new XrefConverter(institution, xrefClass); }
/** * Retrieves the xrefs from an AnnotatedObject, initializing them if necessary. * * @param ao The annotated object instance with possibly non-initialized xrefs * @return The returned xrefs are ensured to be initialized * @since 2.4.0 */ public static Collection<? extends Xref> ensureInitializedXrefs(AnnotatedObject<?, ?> ao) { Collection<? extends Xref> xrefs; if (IntactCore.isInitialized(ao.getXrefs())) { xrefs = ao.getXrefs(); } else { xrefs = IntactContext.getCurrentInstance().getDaoFactory().getXrefDao(AnnotatedObjectUtils.getXrefClassType(ao.getClass())) .getByParentAc(ao.getAc()); } return xrefs; }
/** * Retrieves the xrefs from an AnnotatedObject, initializing them if necessary. * * @param ao The annotated object instance with possibly non-initialized xrefs * @return The returned xrefs are ensured to be initialized * @since 2.4.0 */ public static Collection<? extends Xref> ensureInitializedXrefs(AnnotatedObject<?, ?> ao) { Collection<? extends Xref> xrefs; if (IntactCore.isInitialized(ao.getXrefs())) { xrefs = ao.getXrefs(); } else { xrefs = IntactContext.getCurrentInstance().getDaoFactory().getXrefDao(AnnotatedObjectUtils.getXrefClassType(ao.getClass())) .getByParentAc(ao.getAc()); } return xrefs; }
public static <X extends Xref> Collection<X> getIdentityXrefs(AnnotatedObject<X, ?> annotatedObject) { Collection<X> xrefs = new ArrayList<X>(); Collection<X> allXrefs = annotatedObject.getXrefs(); if (!IntactCore.isInitialized(annotatedObject.getXrefs()) && IntactContext.currentInstanceExists()) { EntityManager entityManager = IntactContext.getCurrentInstance().getDaoFactory().getEntityManager(); // set the flush mode to manual to avoid hibernate trying to flush the session when querying the xrefs FlushModeType originalFlushMode = entityManager.getFlushMode(); entityManager.setFlushMode(FlushModeType.COMMIT); Class xrefClass = AnnotatedObjectUtils.getXrefClassType(annotatedObject.getClass()); allXrefs = IntactContext.getCurrentInstance().getDaoFactory().getXrefDao(xrefClass).getByParentAc(annotatedObject.getAc()); entityManager.setFlushMode(originalFlushMode); } for (X xref : allXrefs) { CvXrefQualifier qualifier = xref.getCvXrefQualifier(); String qualifierMi = null; if (qualifier != null && ((qualifierMi = qualifier.getIdentifier()) != null && qualifierMi.equals(CvXrefQualifier.IDENTITY_MI_REF))) { xrefs.add(xref); } } return xrefs; }
public static <X extends Xref> Collection<X> getIdentityXrefs(AnnotatedObject<X, ?> annotatedObject) { Collection<X> xrefs = new ArrayList<X>(); Collection<X> allXrefs = annotatedObject.getXrefs(); if (!IntactCore.isInitialized(annotatedObject.getXrefs()) && IntactContext.currentInstanceExists()) { EntityManager entityManager = IntactContext.getCurrentInstance().getDaoFactory().getEntityManager(); // set the flush mode to manual to avoid hibernate trying to flush the session when querying the xrefs FlushModeType originalFlushMode = entityManager.getFlushMode(); entityManager.setFlushMode(FlushModeType.COMMIT); Class xrefClass = AnnotatedObjectUtils.getXrefClassType(annotatedObject.getClass()); allXrefs = IntactContext.getCurrentInstance().getDaoFactory().getXrefDao(xrefClass).getByParentAc(annotatedObject.getAc()); entityManager.setFlushMode(originalFlushMode); } for (X xref : allXrefs) { CvXrefQualifier qualifier = xref.getCvXrefQualifier(); String qualifierMi = null; if (qualifier != null && ((qualifierMi = qualifier.getIdentifier()) != null && qualifierMi.equals(CvXrefQualifier.IDENTITY_MI_REF))) { xrefs.add(xref); } } return xrefs; }