use of org.finos.waltz.schema.tables.records.RatingSchemeRecord in project waltz by khartec.
the class ContextPopulatorTest method fooTest.
@Test
public void fooTest() {
EntityReference a1 = appHelper.createNewApp(mkName("a1"), ouIds.a);
EntityReference a2 = appHelper.createNewApp(mkName("a2"), ouIds.a);
EntityReference a3 = appHelper.createNewApp(mkName("a3"), ouIds.a);
RatingSchemeRecord scheme = dsl.newRecord(rs);
scheme.setName(mkName("scheme"));
scheme.setDescription("desc");
scheme.store();
RatingSchemeItemRecord ratingItem1 = mkRatingItem(scheme, "ratingItem1", "X");
RatingSchemeItemRecord ratingItem2 = mkRatingItem(scheme, "ratingItem2", "Y");
AssessmentDefinitionRecord def1 = mkAssessmentDef("def1", scheme);
AssessmentDefinitionRecord def2 = mkAssessmentDef("anotherDef", scheme);
mkRating(a1, def1, ratingItem1);
mkRating(a2, def1, ratingItem2);
mkRating(a1, def2, ratingItem2);
Set<ContextVariableDeclaration> declarations = SetUtilities.asSet(ImmutableContextVariableDeclaration.builder().name("def1Var").ref(mkVarRef(EntityKind.ASSESSMENT_DEFINITION, def1.getExternalId())).build(), ImmutableContextVariableDeclaration.builder().name("def1VarDupe").ref(mkVarRef(EntityKind.ASSESSMENT_DEFINITION, def1.getExternalId())).build(), ImmutableContextVariableDeclaration.builder().name("def2Var").ref(mkVarRef(EntityKind.ASSESSMENT_DEFINITION, def2.getExternalId())).build());
Set<ContextVariable<? extends ContextValue>> vars = populator.populateContext(declarations, selector);
assertVar(vars, a1, "def1Var", mkAssessmentCodeCheck("X"), "A1");
assertVar(vars, a1, "def2Var", mkAssessmentCodeCheck("Y"), "A1");
assertVar(vars, a1, "def1VarDupe", mkAssessmentCodeCheck("X"), "A1");
assertVar(vars, a2, "def1Var", mkAssessmentCodeCheck("Y"), "A2");
assertVar(vars, a2, "def1VarDupe", mkAssessmentCodeCheck("Y"), "A2");
}
use of org.finos.waltz.schema.tables.records.RatingSchemeRecord in project waltz by khartec.
the class AssessmentGenerator method createRatingScheme.
private Long createRatingScheme(DSLContext dsl, String name, Tuple3<String, String, String>... options) {
// create
RatingSchemeRecord ratingSchemeRecord = dsl.newRecord(RATING_SCHEME);
ratingSchemeRecord.setName(name);
ratingSchemeRecord.setDescription(name + " ratings");
ratingSchemeRecord.insert();
System.out.println("Inserted scheme " + ratingSchemeRecord.getId());
List<RatingSchemeItemRecord> ratingRecords = Stream.of(options).map(t -> {
RatingSchemeItemRecord itemR = dsl.newRecord(RATING_SCHEME_ITEM);
itemR.setCode(t.v1);
itemR.setName(t.v2);
itemR.setColor(t.v3);
itemR.setDescription(t.v2);
itemR.setSchemeId(ratingSchemeRecord.getId());
itemR.setUserSelectable(true);
return itemR;
}).collect(toList());
dsl.batchInsert(ratingRecords).execute();
return ratingSchemeRecord.getId();
}
use of org.finos.waltz.schema.tables.records.RatingSchemeRecord in project waltz by khartec.
the class RatingSchemeDAO method save.
public Boolean save(RatingScheme scheme) {
RatingSchemeRecord r = dsl.newRecord(RATING_SCHEME);
r.setName(scheme.name());
r.setDescription(scheme.description());
return scheme.id().map(id -> {
r.setId(id);
r.changed(RATING_SCHEME.ID, false);
return r.update() == 1;
}).orElseGet(() -> r.insert() == 1);
}
use of org.finos.waltz.schema.tables.records.RatingSchemeRecord in project waltz by khartec.
the class RatingSchemeHelper method createEmptyRatingScheme.
public long createEmptyRatingScheme(String name) {
return dsl.select(RATING_SCHEME.ID).from(RATING_SCHEME).where(RATING_SCHEME.NAME.eq(name)).fetchOptional(RATING_SCHEME.ID).orElseGet(() -> {
RatingSchemeRecord record = dsl.newRecord(RATING_SCHEME);
record.setName(name);
record.setDescription(name);
record.store();
return record.getId();
});
}
Aggregations