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;
}
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;
}
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;
}
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();
}
Aggregations