Search in sources :

Example 1 with AssessmentRatingRecord

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

the class ContextPopulatorTest method mkRating.

private AssessmentRatingRecord mkRating(EntityReference appRef, AssessmentDefinitionRecord defRecord, RatingSchemeItemRecord ratingRecord) {
    AssessmentRatingRecord record = dsl.newRecord(ar);
    record.setEntityKind(appRef.kind().name());
    record.setEntityId(appRef.id());
    record.setAssessmentDefinitionId(defRecord.getId());
    record.setRatingId(ratingRecord.getId());
    record.setLastUpdatedBy("admin");
    record.setProvenance("prov");
    record.store();
    return record;
}
Also used : AssessmentRatingRecord(org.finos.waltz.schema.tables.records.AssessmentRatingRecord)

Example 2 with AssessmentRatingRecord

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

the class AssessmentRatingDao method store.

public boolean store(SaveAssessmentRatingCommand command) {
    checkNotNull(command, "command cannot be null");
    AssessmentRatingRecord record = TO_RECORD_MAPPER.apply(command);
    EntityReference ref = command.entityReference();
    boolean isUpdate = dsl.fetchExists(dsl.select(ASSESSMENT_RATING.fields()).from(ASSESSMENT_RATING).where(ASSESSMENT_RATING.ENTITY_KIND.eq(ref.kind().name())).and(ASSESSMENT_RATING.ENTITY_ID.eq(ref.id())).and(ASSESSMENT_RATING.ASSESSMENT_DEFINITION_ID.eq(command.assessmentDefinitionId())));
    return isUpdate ? dsl.executeUpdate(record) == 1 : dsl.executeInsert(record) == 1;
}
Also used : ImmutableEntityReference(org.finos.waltz.model.ImmutableEntityReference) EntityReference(org.finos.waltz.model.EntityReference) AssessmentRatingRecord(org.finos.waltz.schema.tables.records.AssessmentRatingRecord)

Example 3 with AssessmentRatingRecord

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

the class AssessmentRatingBulkImport method mkAssessmentRatingRecord.

private AssessmentRatingRecord mkAssessmentRatingRecord(Long defnId, AssessmentRatingEntry r, String updateUser) {
    AssessmentRatingRecord record = dsl.newRecord(ASSESSMENT_RATING);
    record.setAssessmentDefinitionId(defnId);
    record.setEntityId(r.entity().id());
    record.setEntityKind(r.entity().kind().name());
    record.setRatingId(r.ratingId());
    record.setLastUpdatedAt(DateTimeUtilities.nowUtcTimestamp());
    record.setLastUpdatedBy(updateUser);
    record.setDescription(r.description());
    record.setProvenance(PROVENANCE);
    return record;
}
Also used : AssessmentRatingRecord(org.finos.waltz.schema.tables.records.AssessmentRatingRecord)

Example 4 with AssessmentRatingRecord

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

the class AssessmentGenerator method createAssessmentRecords.

private void createAssessmentRecords(DSLContext dsl, RatingScheme ratingScheme, Long assessmentDefnId, EntityKind targetKind, TableField<? extends Record, Long> targetIdField, double density) {
    List<Long> targetIds = loadAllIds(dsl, targetIdField);
    List<AssessmentRatingRecord> records = targetIds.stream().filter(d -> RandomUtilities.getRandom().nextDouble() < density).map(id -> tuple(id, randomPick(ratingScheme.ratings()))).filter(t -> t.v2.id().isPresent()).map(t -> {
        AssessmentRatingRecord record = new AssessmentRatingRecord();
        record.setAssessmentDefinitionId(assessmentDefnId);
        record.setRatingId(t.v2.id().get());
        record.setEntityKind(targetKind.name());
        record.setEntityId(t.v1);
        record.setLastUpdatedBy(SAMPLE_DATA_USER);
        record.setProvenance(SAMPLE_DATA_PROVENANCE);
        record.setDescription("sample data");
        return record;
    }).collect(toList());
    log("About to store %d assessments for kind: %s", records.size(), targetIdField.getTable().getName());
    dsl.batchInsert(records).execute();
}
Also used : DSL(org.jooq.impl.DSL) Tables(org.finos.waltz.schema.Tables) EntityKind(org.finos.waltz.model.EntityKind) RatingScheme(org.finos.waltz.model.rating.RatingScheme) RatingSchemeItemRecord(org.finos.waltz.schema.tables.records.RatingSchemeItemRecord) RatingSchemeService(org.finos.waltz.service.rating_scheme.RatingSchemeService) ApplicationContext(org.springframework.context.ApplicationContext) ColorUtilities(org.finos.waltz.common.ColorUtilities) AssessmentDefinitionRecord(org.finos.waltz.schema.tables.records.AssessmentDefinitionRecord) RandomUtilities(org.finos.waltz.common.RandomUtilities) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Tuple3(org.jooq.lambda.tuple.Tuple3) Stream(java.util.stream.Stream) Tuple.tuple(org.jooq.lambda.tuple.Tuple.tuple) ListUtilities(org.finos.waltz.common.ListUtilities) org.jooq(org.jooq) Map(java.util.Map) RandomUtilities.randomPick(org.finos.waltz.common.RandomUtilities.randomPick) AssessmentRatingRecord(org.finos.waltz.schema.tables.records.AssessmentRatingRecord) RatingSchemeRecord(org.finos.waltz.schema.tables.records.RatingSchemeRecord) AssessmentRatingRecord(org.finos.waltz.schema.tables.records.AssessmentRatingRecord)

Aggregations

AssessmentRatingRecord (org.finos.waltz.schema.tables.records.AssessmentRatingRecord)4 List (java.util.List)1 Map (java.util.Map)1 Collectors.toList (java.util.stream.Collectors.toList)1 Stream (java.util.stream.Stream)1 ColorUtilities (org.finos.waltz.common.ColorUtilities)1 ListUtilities (org.finos.waltz.common.ListUtilities)1 RandomUtilities (org.finos.waltz.common.RandomUtilities)1 RandomUtilities.randomPick (org.finos.waltz.common.RandomUtilities.randomPick)1 EntityKind (org.finos.waltz.model.EntityKind)1 EntityReference (org.finos.waltz.model.EntityReference)1 ImmutableEntityReference (org.finos.waltz.model.ImmutableEntityReference)1 RatingScheme (org.finos.waltz.model.rating.RatingScheme)1 Tables (org.finos.waltz.schema.Tables)1 AssessmentDefinitionRecord (org.finos.waltz.schema.tables.records.AssessmentDefinitionRecord)1 RatingSchemeItemRecord (org.finos.waltz.schema.tables.records.RatingSchemeItemRecord)1 RatingSchemeRecord (org.finos.waltz.schema.tables.records.RatingSchemeRecord)1 RatingSchemeService (org.finos.waltz.service.rating_scheme.RatingSchemeService)1 org.jooq (org.jooq)1 DSL (org.jooq.impl.DSL)1