use of org.finos.waltz.schema.tables.EntityHierarchy in project waltz by khartec.
the class QuestionAppPredicateNamespace method dataTypeUsages.
public Set<String> dataTypeUsages(String name) {
DataTypeUsage dtu = DATA_TYPE_USAGE.as("dtu");
DataType dt = DATA_TYPE.as("dt");
EntityHierarchy eh = ENTITY_HIERARCHY.as("eh");
Condition dtNameMatches = dt.CODE.eq(name).or(dt.NAME.eq(name));
Condition subjectMatches = dtu.ENTITY_ID.eq(subjectRef.id()).and(dtu.ENTITY_KIND.eq(subjectRef.kind().name()));
return dsl.select(dtu.USAGE_KIND).from(dt).innerJoin(eh).on(eh.ANCESTOR_ID.eq(dt.ID).and(eh.KIND.eq(EntityKind.DATA_TYPE.name()))).innerJoin(dtu).on(dtu.DATA_TYPE_ID.eq(eh.ID)).where(dtNameMatches).and(subjectMatches).fetchSet(dtu.USAGE_KIND);
}
use of org.finos.waltz.schema.tables.EntityHierarchy in project waltz by khartec.
the class QuestionEntityPredicateNamespace method belongsToOrgUnit.
// --- HELPER ---
protected boolean belongsToOrgUnit(String name, Table<?> subjectTable, Field<Long> subjectId, Field<Long> subjectOu) {
EntityHierarchy eh = ENTITY_HIERARCHY.as("eh");
OrganisationalUnit ou = OrganisationalUnit.ORGANISATIONAL_UNIT.as("ou");
SelectConditionStep<Record1<Long>> targetOrgUnitId = DSL.select(ou.ID).from(ou).where(ou.NAME.eq(name)).or(ou.EXTERNAL_ID.eq(name));
Condition subjectInTargetOuTree = subjectOu.in(DSL.selectDistinct(eh.ID).from(eh).where(eh.ANCESTOR_ID.eq(targetOrgUnitId)));
Condition subjectEntitiesMatch = subjectId.eq(subjectRef.id());
SelectConditionStep<Record1<Long>> qry = DSL.select(subjectId).from(subjectTable).where(subjectEntitiesMatch).and(subjectInTargetOuTree);
return dsl.fetchExists(qry);
}
Aggregations