use of org.finos.waltz.schema.tables.records.RatingSchemeItemRecord 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.RatingSchemeItemRecord 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.RatingSchemeItemRecord in project waltz by khartec.
the class ContextPopulatorTest method mkRatingItem.
private RatingSchemeItemRecord mkRatingItem(RatingSchemeRecord scheme, String name, String code) {
RatingSchemeItemRecord rating = dsl.newRecord(rsi);
rating.setName(mkName(name));
rating.setSchemeId(scheme.getId());
rating.setCode(code);
rating.setDescription("Desc: " + name + " / " + code);
rating.setColor("red");
rating.store();
return rating;
}
use of org.finos.waltz.schema.tables.records.RatingSchemeItemRecord in project waltz by khartec.
the class RatingSchemeDAO method saveRatingItem.
public Long saveRatingItem(long schemeId, RatingSchemeItem item) {
RatingSchemeItemRecord r = dsl.newRecord(RATING_SCHEME_ITEM);
r.setSchemeId(schemeId);
r.setName(item.name());
r.setDescription(item.description());
r.setCode(Character.toString(item.rating()));
r.setColor(item.color());
r.setPosition(item.position());
r.setUserSelectable(item.userSelectable());
return item.id().map(id -> {
r.setId(id);
r.changed(RATING_SCHEME_ITEM.ID, false);
r.store();
return id;
}).orElseGet(() -> {
r.insert();
return r.getId();
});
}
Aggregations