use of com.haulmont.cuba.core.sys.jpql.model.JpqlEntityModel in project cuba by cuba-platform.
the class DomainModelBuilder method produce.
public DomainModel produce() {
Collection<MetaClass> classes = metadata.getSession().getClasses();
DomainModel result = new DomainModel(extendedEntities);
EntityBuilder builder = new EntityBuilder();
for (MetaClass aClass : classes) {
builder.startNewEntity(aClass.getName());
Collection<MetaProperty> props = aClass.getProperties();
for (MetaProperty prop : props) {
if (metadataTools.isPersistent(prop))
addProperty(builder, aClass, prop);
}
JpqlEntityModel entity = builder.produce();
result.add(entity);
}
return result;
}
use of com.haulmont.cuba.core.sys.jpql.model.JpqlEntityModel in project cuba by cuba-platform.
the class QueryTransformerAstSoftDeleteBugsTest method createDomainModel.
private DomainModel createDomainModel() {
EntityBuilder builder = new EntityBuilder();
JpqlEntityModel debtorEntity = builder.produceImmediately("dn$Debtor", "id", "id");
JpqlEntityModel agentEntity = builder.produceImmediately("dn$Agent", "id", "id");
JpqlEntityModel userEntity = builder.produceImmediately("sec$User", "active", "deleteTs");
JpqlEntityModel agentAllocation = builder.produceImmediately("dn$AgentAllocation", "agent", "debtor");
JpqlEntityModel scheduleOperation = builder.produceImmediately("dn$ScheduleOperation");
JpqlEntityModel bailiffDaySchedule = builder.produceImmediately("dn$BailiffDaySchedule", "day");
scheduleOperation.addReferenceAttribute("dn$BailiffDaySchedule", "bailiffDaySchedule", "bailiffDaySchedule", false);
scheduleOperation.addReferenceAttribute("dn$Debtor", "debtor", "debtor", false);
return new DomainModel(userEntity, agentAllocation, scheduleOperation, bailiffDaySchedule, debtorEntity);
}
use of com.haulmont.cuba.core.sys.jpql.model.JpqlEntityModel in project cuba by cuba-platform.
the class QueryParserAstBasedTest method prepareDomainModel.
private DomainModel prepareDomainModel() {
EntityBuilder builder = new EntityBuilder();
builder.startNewEntity("sec$GroupHierarchy");
builder.addReferenceAttribute("group", "sec$Group");
builder.addReferenceAttribute("as", "sec$Group");
builder.addStringAttribute("createdBy");
builder.addReferenceAttribute("parent", "sec$GroupHierarchy");
builder.addReferenceAttribute("other", "sec$GroupHierarchy");
builder.addCollectionReferenceAttribute("constraints", "sec$Constraint");
JpqlEntityModel groupHierarchy = builder.produce();
builder = new EntityBuilder();
builder.startNewEntity("sec$Constraint");
builder.addReferenceAttribute("group", "sec$GroupHierarchy");
JpqlEntityModel constraintEntity = builder.produce();
JpqlEntityModel groupEntity = builder.produceImmediately("sec$Group", "name", "group");
builder = new EntityBuilder();
builder.startNewEntity("sec$User");
builder.addStringAttribute("login");
builder.addSingleValueAttribute(Integer.class, "int1");
builder.addSingleValueAttribute(Integer.class, "int2");
builder.addReferenceAttribute("group", "sec$Group");
JpqlEntityModel userEntity = builder.produce();
return new DomainModel(groupHierarchy, constraintEntity, userEntity, groupEntity);
}
use of com.haulmont.cuba.core.sys.jpql.model.JpqlEntityModel in project cuba by cuba-platform.
the class QueryTransformerAstBasedTest method getResult_noChangesMade_withMultiFieldSelect.
@Test
public void getResult_noChangesMade_withMultiFieldSelect() throws RecognitionException {
EntityBuilder builder = new EntityBuilder();
builder.startNewEntity("Team");
builder.addStringAttribute("name");
JpqlEntityModel teamEntity = builder.produce();
builder.startNewEntity("Player");
builder.addStringAttribute("nickname");
builder.addReferenceAttribute("team", "Team");
JpqlEntityModel playerEntity = builder.produce();
DomainModel model = new DomainModel(playerEntity, teamEntity);
assertTransformsToSame(model, "SELECT p.team.name, p.nickname FROM Player p");
}
use of com.haulmont.cuba.core.sys.jpql.model.JpqlEntityModel in project cuba by cuba-platform.
the class QueryTransformerAstBasedTest method getResult_noChangesMade_withJoinAndAsAndMemberField.
@Test
public void getResult_noChangesMade_withJoinAndAsAndMemberField() throws RecognitionException {
EntityBuilder builder = new EntityBuilder();
JpqlEntityModel teamEntity = builder.produceImmediately("Team", "name");
builder.startNewEntity("Player");
builder.addReferenceAttribute("as", "Team");
builder.addReferenceAttribute("member", "Team");
JpqlEntityModel playerEntity = builder.produce();
DomainModel model = new DomainModel(playerEntity, teamEntity);
assertTransformsToSame(model, "SELECT p FROM Player p JOIN p.as t");
assertTransformsToSame(model, "SELECT p FROM Player p JOIN p.member t");
}
Aggregations