Search in sources :

Example 26 with Metadata

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

the class ManyToManyFetchSameEntityTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    Transaction tx = cont.persistence().createTransaction();
    try {
        EntityManager em = cont.persistence().getEntityManager();
        Metadata metadata = cont.metadata();
        same1_1 = metadata.create(Many2Many_FetchSame1.class);
        same1_1.setName("same1_1");
        em.persist(same1_1);
        same1_2 = metadata.create(Many2Many_FetchSame1.class);
        same1_2.setName("same1_2");
        em.persist(same1_2);
        same1_3 = metadata.create(Many2Many_FetchSame1.class);
        same1_3.setName("same1_3");
        em.persist(same1_3);
        same2_1 = metadata.create(Many2Many_FetchSame2.class);
        same2_1.setName("same2_1");
        em.persist(same2_1);
        same2_2 = metadata.create(Many2Many_FetchSame2.class);
        same2_2.setName("same2_2");
        em.persist(same2_2);
        same2_3 = metadata.create(Many2Many_FetchSame2.class);
        same2_3.setName("same2_3");
        same2_3.setManyToOne1(same1_3);
        em.persist(same2_3);
        same2_4 = metadata.create(Many2Many_FetchSame2.class);
        same2_4.setName("same2_4");
        same2_4.setManyToOne1(same1_3);
        em.persist(same2_4);
        same3_1 = metadata.create(Many2Many_FetchSame3.class);
        same3_1.setName("same3_1");
        same3_1 = metadata.create(Many2Many_FetchSame3.class);
        em.persist(same3_1);
        same3_2 = metadata.create(Many2Many_FetchSame3.class);
        same3_2.setName("same3_2");
        same3_2 = metadata.create(Many2Many_FetchSame3.class);
        em.persist(same3_2);
        same1_1.setMany2(Collections.singletonList(same2_1));
        same1_2.setMany2(Collections.singletonList(same2_2));
        same2_3.setMany3(same3_1);
        same2_4.setMany3(same3_2);
        tx.commit();
    } finally {
        tx.end();
    }
}
Also used : EntityManager(com.haulmont.cuba.core.EntityManager) Transaction(com.haulmont.cuba.core.Transaction) Many2Many_FetchSame1(com.haulmont.cuba.testmodel.many2many_fetchsameentity.Many2Many_FetchSame1) Many2Many_FetchSame2(com.haulmont.cuba.testmodel.many2many_fetchsameentity.Many2Many_FetchSame2) Metadata(com.haulmont.cuba.core.global.Metadata) Many2Many_FetchSame3(com.haulmont.cuba.testmodel.many2many_fetchsameentity.Many2Many_FetchSame3)

Example 27 with Metadata

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

the class EntityImportView method addLocalProperties.

public EntityImportView addLocalProperties() {
    Metadata metadata = AppBeans.get(Metadata.class);
    MetaClass metaClass = metadata.getClassNN(entityClass);
    MetadataTools metadataTools = metadata.getTools();
    metaClass.getProperties().stream().filter(property -> !property.getRange().isClass() && !metadataTools.isSystem(property) && metadataTools.isPersistent(property)).forEach(metaProperty -> addLocalProperty(metaProperty.getName()));
    return this;
}
Also used : MetadataTools(com.haulmont.cuba.core.global.MetadataTools) Collection(java.util.Collection) Map(java.util.Map) HashMap(java.util.HashMap) AppBeans(com.haulmont.cuba.core.global.AppBeans) MetaClass(com.haulmont.chile.core.model.MetaClass) Entity(com.haulmont.cuba.core.entity.Entity) Metadata(com.haulmont.cuba.core.global.Metadata) Serializable(java.io.Serializable) MetadataTools(com.haulmont.cuba.core.global.MetadataTools) MetaClass(com.haulmont.chile.core.model.MetaClass) Metadata(com.haulmont.cuba.core.global.Metadata)

Example 28 with Metadata

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

the class DynamicAttributesCache method resolveTargetMetaClass.

protected MetaClass resolveTargetMetaClass(MetaClass metaClass) {
    if (metaClass == null) {
        return null;
    }
    Metadata metadata = AppBeans.get(Metadata.NAME);
    MetaClass targetMetaClass = metadata.getExtendedEntities().getOriginalMetaClass(metaClass);
    if (targetMetaClass == null) {
        targetMetaClass = metaClass;
    }
    return targetMetaClass;
}
Also used : MetaClass(com.haulmont.chile.core.model.MetaClass) Metadata(com.haulmont.cuba.core.global.Metadata)

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