use of org.grails.datastore.mapping.model.PersistentEntity in project grails-core by grails.
the class DefaultGrailsDomainClass method getSubClasses.
/**
* Obtains a Set of subclasses
*
* @deprecated Use {@link org.grails.datastore.mapping.model.MappingContext} API instead
*/
@Deprecated
@Override
@SuppressWarnings("unchecked")
public Set getSubClasses() {
verifyContextIsInitialized();
Set<GrailsDomainClass> subClasses = new LinkedHashSet<>();
for (PersistentEntity e : mappingContext.getChildEntities(persistentEntity)) {
subClasses.add((GrailsDomainClass) grailsApplication.getArtefact(DomainClassArtefactHandler.TYPE, e.getName()));
}
return subClasses;
}
use of org.grails.datastore.mapping.model.PersistentEntity 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;
}
use of org.grails.datastore.mapping.model.PersistentEntity in project grails-core by grails.
the class DefaultGrailsDomainClass method getPersistentProperty.
public GrailsDomainClassProperty getPersistentProperty(String name) {
initializePersistentProperties();
if (propertyMap.containsKey(name)) {
return propertyMap.get(name);
}
int indexOfDot = name.indexOf('.');
if (indexOfDot > 0) {
String basePropertyName = name.substring(0, indexOfDot);
if (propertyMap.containsKey(basePropertyName)) {
verifyContextIsInitialized();
PersistentProperty prop = persistentEntity.getPropertyByName(basePropertyName);
PersistentEntity referencedEntity = prop.getOwner();
GrailsDomainClass referencedDomainClass = (GrailsDomainClass) grailsApplication.getArtefact(DomainClassArtefactHandler.TYPE, referencedEntity.getName());
if (referencedDomainClass != null) {
String restOfPropertyName = name.substring(indexOfDot + 1);
return referencedDomainClass.getPropertyByName(restOfPropertyName);
}
}
}
return null;
}
Aggregations