Search in sources :

Example 1 with Association

use of org.grails.datastore.mapping.model.types.Association in project grails-core by grails.

the class DefaultGrailsDomainClass method getAssociations.

/**
     * Retrieves a list of associations
     *
     * @deprecated Use {@link org.grails.datastore.mapping.model.MappingContext} API instead
     */
@Deprecated
public List<GrailsDomainClassProperty> getAssociations() {
    verifyContextIsInitialized();
    List<GrailsDomainClassProperty> associations = new ArrayList<>();
    List<String> associationNames = new ArrayList<>();
    for (Association a : persistentEntity.getAssociations()) {
        associationNames.add(a.getName());
    }
    for (GrailsDomainClassProperty p : persistentProperties) {
        if (associationNames.contains(p.getName())) {
            associations.add(p);
        }
    }
    return associations;
}
Also used : Association(org.grails.datastore.mapping.model.types.Association) GrailsDomainClassProperty(grails.core.GrailsDomainClassProperty)

Example 2 with Association

use of org.grails.datastore.mapping.model.types.Association in project grails-core by grails.

the class DefaultGrailsDomainClass method getComponents.

/**
     * Retrieves a list of embedded components
     *
     * @deprecated Use {@link org.grails.datastore.mapping.model.MappingContext} API instead
     */
@Deprecated
public List<GrailsDomainClass> getComponents() {
    verifyContextIsInitialized();
    List<GrailsDomainClass> components = new ArrayList<>();
    for (Association a : persistentEntity.getAssociations()) {
        if (a.isEmbedded()) {
            components.add((GrailsDomainClass) grailsApplication.getArtefact(DomainClassArtefactHandler.TYPE, a.getAssociatedEntity().getName()));
        }
    }
    return components;
}
Also used : Association(org.grails.datastore.mapping.model.types.Association) GrailsDomainClass(grails.core.GrailsDomainClass)

Example 3 with Association

use of org.grails.datastore.mapping.model.types.Association in project grails-core by grails.

the class DefaultGrailsDomainClass method getMergedConfigurationMap.

@SuppressWarnings("unchecked")
private Map getMergedConfigurationMap() {
    verifyContextIsInitialized();
    Map configurationMap = new HashMap();
    PersistentEntity currentEntity = this.persistentEntity;
    while (currentEntity != null) {
        List<Association> associations = currentEntity.getAssociations();
        for (Association association : associations) {
            PersistentEntity associatedEntity = association.getAssociatedEntity();
            if (associatedEntity != null) {
                configurationMap.put(association.getName(), associatedEntity.getJavaClass());
            }
        }
        currentEntity = currentEntity.getParentEntity();
    }
    return configurationMap;
}
Also used : Association(org.grails.datastore.mapping.model.types.Association) PersistentEntity(org.grails.datastore.mapping.model.PersistentEntity)

Aggregations

Association (org.grails.datastore.mapping.model.types.Association)3 GrailsDomainClass (grails.core.GrailsDomainClass)1 GrailsDomainClassProperty (grails.core.GrailsDomainClassProperty)1 PersistentEntity (org.grails.datastore.mapping.model.PersistentEntity)1