Search in sources :

Example 1 with Metadata

use of com.haulmont.cuba.core.global.Metadata in project cuba by cuba-platform.

the class SuggestionPickerFieldLoader method loadMetaClass.

protected void loadMetaClass(SuggestionPickerField suggestionField, Element element) {
    String metaClass = element.attributeValue("metaClass");
    if (!StringUtils.isEmpty(metaClass)) {
        Metadata metadata = AppBeans.get(Metadata.NAME);
        suggestionField.setMetaClass(metadata.getSession().getClass(metaClass));
    }
}
Also used : Metadata(com.haulmont.cuba.core.global.Metadata)

Example 2 with Metadata

use of com.haulmont.cuba.core.global.Metadata in project cuba by cuba-platform.

the class WebTokenList method isInversePropertyAssignableFromDsClass.

protected boolean isInversePropertyAssignableFromDsClass(MetaProperty inverseProp) {
    Metadata metadata = AppBeans.get(Metadata.NAME);
    ExtendedEntities extendedEntities = metadata.getExtendedEntities();
    Class inversePropClass = extendedEntities.getEffectiveClass(inverseProp.getDomain());
    Class dsClass = extendedEntities.getEffectiveClass(datasource.getMetaClass());
    // noinspection unchecked
    return inversePropClass.isAssignableFrom(dsClass);
}
Also used : ExtendedEntities(com.haulmont.cuba.core.global.ExtendedEntities) Metadata(com.haulmont.cuba.core.global.Metadata)

Example 3 with Metadata

use of com.haulmont.cuba.core.global.Metadata in project cuba by cuba-platform.

the class EntitySerializationExceptionHandler method isEntityClass.

private boolean isEntityClass(String className) {
    Metadata metadata = AppBeans.get(Metadata.NAME);
    try {
        Class entityClass = ReflectionHelper.loadClass(className);
        MetaClass metaClass = metadata.getClass(entityClass);
        return metaClass != null;
    } catch (ClassNotFoundException e) {
        return false;
    }
}
Also used : MetaClass(com.haulmont.chile.core.model.MetaClass) Metadata(com.haulmont.cuba.core.global.Metadata) MetaClass(com.haulmont.chile.core.model.MetaClass)

Example 4 with Metadata

use of com.haulmont.cuba.core.global.Metadata in project cuba by cuba-platform.

the class FakeFilterSupport method createFakeFilterEntity.

public FilterEntity createFakeFilterEntity(String xml) {
    if (filterEntity != null) {
        return filterEntity;
    }
    Metadata metadata = AppBeans.get(Metadata.NAME);
    FilterEntity fakeFilterEntity = metadata.create(FilterEntity.class);
    fakeFilterEntity.setXml(xml);
    return fakeFilterEntity;
}
Also used : FilterEntity(com.haulmont.cuba.security.entity.FilterEntity) Metadata(com.haulmont.cuba.core.global.Metadata)

Example 5 with Metadata

use of com.haulmont.cuba.core.global.Metadata in project cuba by cuba-platform.

the class EntityChangedEvent method getResolvableType.

/**
 * INTERNAL.
 */
@Override
public ResolvableType getResolvableType() {
    Metadata metadata = AppBeans.get(Metadata.NAME);
    ExtendedEntities extendedEntities = metadata.getExtendedEntities();
    MetaClass metaClass = extendedEntities.getOriginalOrThisMetaClass(metadata.getClassNN(entityId.getEntityClass()));
    MetaProperty pkProperty = metadata.getTools().getPrimaryKeyProperty(metaClass);
    if (pkProperty == null) {
        throw new IllegalStateException("Unable to send EntityChangedEvent for " + metaClass + " because it has no primary key");
    }
    if (BaseDbGeneratedIdEntity.class.isAssignableFrom(metaClass.getJavaClass())) {
        return ResolvableType.forClassWithGenerics(getClass(), ResolvableType.forClass(metaClass.getJavaClass()), ResolvableType.forClassWithGenerics(IdProxy.class, ResolvableType.forClass(pkProperty.getJavaType())));
    } else {
        return ResolvableType.forClassWithGenerics(getClass(), ResolvableType.forClass(metaClass.getJavaClass()), ResolvableType.forClass(pkProperty.getJavaType()));
    }
}
Also used : ExtendedEntities(com.haulmont.cuba.core.global.ExtendedEntities) MetaClass(com.haulmont.chile.core.model.MetaClass) Metadata(com.haulmont.cuba.core.global.Metadata) IdProxy(com.haulmont.cuba.core.entity.IdProxy) MetaProperty(com.haulmont.chile.core.model.MetaProperty)

Aggregations

Metadata (com.haulmont.cuba.core.global.Metadata)28 MetaClass (com.haulmont.chile.core.model.MetaClass)12 ExtendedEntities (com.haulmont.cuba.core.global.ExtendedEntities)4 PostConstruct (javax.annotation.PostConstruct)4 MetaPropertyPath (com.haulmont.chile.core.model.MetaPropertyPath)2 EntityManager (com.haulmont.cuba.core.EntityManager)2 Transaction (com.haulmont.cuba.core.Transaction)2 Entity (com.haulmont.cuba.core.entity.Entity)2 ReferenceToEntity (com.haulmont.cuba.core.entity.ReferenceToEntity)2 AppBeans (com.haulmont.cuba.core.global.AppBeans)2 Messages (com.haulmont.cuba.core.global.Messages)2 MetadataTools (com.haulmont.cuba.core.global.MetadataTools)2 Collection (java.util.Collection)2 MetaProperty (com.haulmont.chile.core.annotations.MetaProperty)1 MetaProperty (com.haulmont.chile.core.model.MetaProperty)1 CategoryAttribute (com.haulmont.cuba.core.entity.CategoryAttribute)1 Config (com.haulmont.cuba.core.entity.Config)1 IdProxy (com.haulmont.cuba.core.entity.IdProxy)1 Lookup (com.haulmont.cuba.core.entity.annotation.Lookup)1 Scripting (com.haulmont.cuba.core.global.Scripting)1