Search in sources :

Example 1 with Transient

use of jakarta.persistence.Transient in project mycore by MyCoRe-Org.

the class MCRCategoryImpl method getLeftSiblingOrOfAncestor.

@Transient
MCRCategoryImpl getLeftSiblingOrOfAncestor() {
    int index = getPositionInParent();
    MCRCategoryImpl parent = (MCRCategoryImpl) getParent();
    if (index > 0) {
        // has left sibling
        return (MCRCategoryImpl) parent.getChildren().get(index - 1);
    }
    if (parent.getParent() != null) {
        // recursive call to get left sibling of parent
        return parent.getLeftSiblingOrOfAncestor();
    }
    // is root
    return parent;
}
Also used : UniqueConstraint(jakarta.persistence.UniqueConstraint) Transient(jakarta.persistence.Transient)

Example 2 with Transient

use of jakarta.persistence.Transient in project mycore by MyCoRe-Org.

the class MCRCategoryImpl method getPositionInParentByID.

@Transient
private int getPositionInParentByID() {
    int position = 0;
    for (MCRCategory sibling : parent.getChildren()) {
        if (getId().equals(sibling.getId())) {
            return position;
        }
        position++;
    }
    if (LOGGER.isDebugEnabled()) {
        StringBuilder sb = new StringBuilder("List of children of parent: ");
        sb.append(parent.getId()).append('\n');
        for (MCRCategory sibling : parent.getChildren()) {
            sb.append(sibling.getId()).append('\n');
        }
        LOGGER.debug(sb.toString());
    }
    throw new IndexOutOfBoundsException("Position -1 is not valid: " + getId() + " parent:" + parent.getId() + " children: " + parent.getChildren().stream().map(MCRCategory::getId).map(MCRCategoryID::getID).collect(Collectors.joining(", ")));
}
Also used : MCRCategory(org.mycore.datamodel.classifications2.MCRCategory) UniqueConstraint(jakarta.persistence.UniqueConstraint) Transient(jakarta.persistence.Transient)

Example 3 with Transient

use of jakarta.persistence.Transient in project mycore by MyCoRe-Org.

the class MCRCategoryImpl method getRightSiblingOrOfAncestor.

@Transient
MCRCategoryImpl getRightSiblingOrOfAncestor() {
    int index = getPositionInParent();
    MCRCategoryImpl parent = (MCRCategoryImpl) getParent();
    if (index + 1 < parent.getChildren().size()) {
        // has right sibling
        return (MCRCategoryImpl) parent.getChildren().get(index + 1);
    }
    if (parent.getParent() != null) {
        // recursive call to get right sibling of parent
        return parent.getRightSiblingOrOfAncestor();
    }
    // is root
    return parent;
}
Also used : UniqueConstraint(jakarta.persistence.UniqueConstraint) Transient(jakarta.persistence.Transient)

Example 4 with Transient

use of jakarta.persistence.Transient in project mycore by MyCoRe-Org.

the class MCRCategoryImpl method getLeftSiblingOrParent.

@Transient
MCRCategoryImpl getLeftSiblingOrParent() {
    int index = getPositionInParent();
    MCRCategoryImpl parent = (MCRCategoryImpl) getParent();
    if (index == 0) {
        return parent;
    }
    return (MCRCategoryImpl) parent.getChildren().get(index - 1);
}
Also used : UniqueConstraint(jakarta.persistence.UniqueConstraint) Transient(jakarta.persistence.Transient)

Example 5 with Transient

use of jakarta.persistence.Transient in project hibernate-orm by hibernate.

the class JPAXMLOverriddenAnnotationReader method initAnnotations.

/*
	 * The idea is to create annotation proxies for the xml configuration elements. Using this proxy annotations together
	 * with the {@link JPAMetadataProvider} allows to handle xml configuration the same way as annotation configuration.
	 */
private void initAnnotations() {
    if (annotations == null) {
        // We don't want the global catalog and schema here: they are applied much later,
        // when SQL gets rendered.
        XMLContext.Default defaults = xmlContext.getDefaultWithoutGlobalCatalogAndSchema(className);
        if (className != null && propertyName == null) {
            // is a class
            ManagedType managedTypeOverride = xmlContext.getManagedTypeOverride(className);
            Annotation[] annotations = getPhysicalAnnotations();
            List<Annotation> annotationList = new ArrayList<>(annotations.length + 5);
            annotationsMap = new HashMap<>(annotations.length + 5);
            for (Annotation annotation : annotations) {
                if (!annotationToXml.containsKey(annotation.annotationType())) {
                    // unknown annotations are left over
                    annotationList.add(annotation);
                }
            }
            addIfNotNull(annotationList, getEntity(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getMappedSuperclass(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getEmbeddable(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getTable(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getSecondaryTables(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getPrimaryKeyJoinColumns(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getIdClass(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getCacheable(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getInheritance(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getDiscriminatorValue(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getDiscriminatorColumn(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getSequenceGenerator(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getTableGenerator(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getNamedQueries(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getNamedNativeQueries(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getNamedStoredProcedureQueries(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getNamedEntityGraphs(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getSqlResultSetMappings(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getExcludeDefaultListeners(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getExcludeSuperclassListeners(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getAccessType(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getAttributeOverrides(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getAssociationOverrides(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getEntityListeners(managedTypeOverride, defaults));
            addIfNotNull(annotationList, getConverts(managedTypeOverride, defaults));
            this.annotations = annotationList.toArray(new Annotation[annotationList.size()]);
            for (Annotation ann : this.annotations) {
                annotationsMap.put(ann.annotationType(), ann);
            }
            checkForOrphanProperties(managedTypeOverride);
        } else if (className != null) {
            // && propertyName != null ) { //always true but less confusing
            ManagedType managedTypeOverride = xmlContext.getManagedTypeOverride(className);
            JaxbEntityListener entityListenerOverride = xmlContext.getEntityListenerOverride(className);
            Annotation[] annotations = getPhysicalAnnotations();
            List<Annotation> annotationList = new ArrayList<>(annotations.length + 5);
            annotationsMap = new HashMap<>(annotations.length + 5);
            for (Annotation annotation : annotations) {
                if (!annotationToXml.containsKey(annotation.annotationType())) {
                    // unknown annotations are left over
                    annotationList.add(annotation);
                }
            }
            preCalculateElementsForProperty(managedTypeOverride, entityListenerOverride);
            Transient transientAnn = getTransient(defaults);
            if (transientAnn != null) {
                annotationList.add(transientAnn);
            } else {
                if (defaults.canUseJavaAnnotations()) {
                    Annotation annotation = getPhysicalAnnotation(Access.class);
                    addIfNotNull(annotationList, annotation);
                }
                getId(annotationList, defaults);
                getEmbeddedId(annotationList, defaults);
                getEmbedded(annotationList, defaults);
                getBasic(annotationList, defaults);
                getVersion(annotationList, defaults);
                getManyToOne(annotationList, defaults);
                getOneToOne(annotationList, defaults);
                getOneToMany(annotationList, defaults);
                getManyToMany(annotationList, defaults);
                getAny(annotationList, defaults);
                getManyToAny(annotationList, defaults);
                getElementCollection(annotationList, defaults);
                addIfNotNull(annotationList, getSequenceGenerator(elementsForProperty, defaults));
                addIfNotNull(annotationList, getTableGenerator(elementsForProperty, defaults));
                addIfNotNull(annotationList, getConvertsForAttribute(elementsForProperty, defaults));
            }
            processEventAnnotations(annotationList, defaults);
            // FIXME use annotationsMap rather than annotationList this will be faster since the annotation type is usually known at put() time
            this.annotations = annotationList.toArray(new Annotation[annotationList.size()]);
            for (Annotation ann : this.annotations) {
                annotationsMap.put(ann.annotationType(), ann);
            }
        } else {
            this.annotations = getPhysicalAnnotations();
            annotationsMap = new HashMap<>(annotations.length + 5);
            for (Annotation ann : this.annotations) {
                annotationsMap.put(ann.annotationType(), ann);
            }
        }
    }
}
Also used : ManagedType(org.hibernate.boot.jaxb.mapping.spi.ManagedType) HashMap(java.util.HashMap) JaxbEntityListener(org.hibernate.boot.jaxb.mapping.spi.JaxbEntityListener) ArrayList(java.util.ArrayList) ClassLoaderAccess(org.hibernate.boot.spi.ClassLoaderAccess) Access(jakarta.persistence.Access) Annotation(java.lang.annotation.Annotation) ArrayList(java.util.ArrayList) List(java.util.List) JaxbTransient(org.hibernate.boot.jaxb.mapping.spi.JaxbTransient) Transient(jakarta.persistence.Transient)

Aggregations

Transient (jakarta.persistence.Transient)7 UniqueConstraint (jakarta.persistence.UniqueConstraint)5 Access (jakarta.persistence.Access)1 Annotation (java.lang.annotation.Annotation)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 HashMap (java.util.HashMap)1 List (java.util.List)1 JaxbEntityListener (org.hibernate.boot.jaxb.mapping.spi.JaxbEntityListener)1 JaxbTransient (org.hibernate.boot.jaxb.mapping.spi.JaxbTransient)1 ManagedType (org.hibernate.boot.jaxb.mapping.spi.ManagedType)1 ClassLoaderAccess (org.hibernate.boot.spi.ClassLoaderAccess)1 MCRCategory (org.mycore.datamodel.classifications2.MCRCategory)1