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();
}
}
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;
}
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;
}
Aggregations