Search in sources :

Example 1 with AssessmentDefinitionRecord

use of org.finos.waltz.schema.tables.records.AssessmentDefinitionRecord in project waltz by khartec.

the class ContextPopulatorTest method mkAssessmentDef.

private AssessmentDefinitionRecord mkAssessmentDef(String defName, RatingSchemeRecord scheme) {
    AssessmentDefinitionRecord def = dsl.newRecord(ad);
    String name = mkName(defName);
    String extId = mkName(defName, "extId");
    def.setName(name);
    def.setRatingSchemeId(scheme.getId());
    def.setEntityKind(EntityKind.APPLICATION.name());
    def.setLastUpdatedBy("admin");
    def.setProvenance("waltz");
    def.setExternalId(extId);
    def.store();
    return def;
}
Also used : AssessmentDefinitionRecord(org.finos.waltz.schema.tables.records.AssessmentDefinitionRecord)

Example 2 with AssessmentDefinitionRecord

use of org.finos.waltz.schema.tables.records.AssessmentDefinitionRecord 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");
}
Also used : RatingSchemeRecord(org.finos.waltz.schema.tables.records.RatingSchemeRecord) RatingSchemeItemRecord(org.finos.waltz.schema.tables.records.RatingSchemeItemRecord) EntityReference(org.finos.waltz.model.EntityReference) AssessmentDefinitionRecord(org.finos.waltz.schema.tables.records.AssessmentDefinitionRecord) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 3 with AssessmentDefinitionRecord

use of org.finos.waltz.schema.tables.records.AssessmentDefinitionRecord in project waltz by khartec.

the class AssessmentGenerator method createAssessmentDefinition.

private Long createAssessmentDefinition(DSLContext dsl, String name, String description, EntityKind kind, RatingScheme ratingScheme) {
    AssessmentDefinitionRecord defnRecord = dsl.newRecord(ASSESSMENT_DEFINITION);
    defnRecord.setName(name);
    defnRecord.setDescription(description);
    defnRecord.setEntityKind(kind.name());
    defnRecord.setIsReadonly(true);
    defnRecord.setLastUpdatedBy(SAMPLE_DATA_USER);
    defnRecord.setProvenance(SAMPLE_DATA_PROVENANCE);
    defnRecord.setRatingSchemeId(ratingScheme.id().orElseThrow(() -> new RuntimeException("Could not find rating scheme")));
    defnRecord.insert();
    return defnRecord.getId();
}
Also used : AssessmentDefinitionRecord(org.finos.waltz.schema.tables.records.AssessmentDefinitionRecord)

Example 4 with AssessmentDefinitionRecord

use of org.finos.waltz.schema.tables.records.AssessmentDefinitionRecord in project waltz by khartec.

the class AssessmentDefinitionDao method save.

/**
 * Saves the given assessment definition.  Either updating or inserting.
 * Returns the identifier for the record.
 * @param def the definition to save
 * @return the identifier for the record
 */
public Long save(AssessmentDefinition def) {
    AssessmentDefinitionRecord r = dsl.newRecord(ASSESSMENT_DEFINITION);
    r.setName(def.name());
    r.setEntityKind(def.entityKind().name());
    r.setRatingSchemeId(def.ratingSchemeId());
    r.setExternalId(def.externalId().orElse(null));
    r.setDescription(def.description());
    r.setVisibility(def.visibility().name());
    r.setIsReadonly(def.isReadOnly());
    r.setPermittedRole(def.permittedRole().orElse(null));
    r.setLastUpdatedAt(Timestamp.valueOf(def.lastUpdatedAt()));
    r.setLastUpdatedBy(def.lastUpdatedBy());
    r.setProvenance(StringUtilities.ifEmpty(def.provenance(), "waltz"));
    def.id().ifPresent(r::setId);
    if (r.getId() == null) {
        r.insert();
        return r.getId();
    } else {
        r.changed(ASSESSMENT_DEFINITION.ID, false);
        r.update();
        return r.getId();
    }
}
Also used : RecordMapper(org.jooq.RecordMapper) AssessmentDefinitionRecord(org.finos.waltz.schema.tables.records.AssessmentDefinitionRecord)

Aggregations

AssessmentDefinitionRecord (org.finos.waltz.schema.tables.records.AssessmentDefinitionRecord)4 BaseInMemoryIntegrationTest (org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest)1 EntityReference (org.finos.waltz.model.EntityReference)1 RatingSchemeItemRecord (org.finos.waltz.schema.tables.records.RatingSchemeItemRecord)1 RatingSchemeRecord (org.finos.waltz.schema.tables.records.RatingSchemeRecord)1 RecordMapper (org.jooq.RecordMapper)1 Test (org.junit.jupiter.api.Test)1