Search in sources :

Example 11 with EntityKind

use of org.finos.waltz.model.EntityKind in project waltz by khartec.

the class ChangeLogExtractor method registerExtractUnattestedChangesForApp.

private void registerExtractUnattestedChangesForApp(String path) {
    get(path, (request, response) -> {
        EntityReference entityRef = WebUtilities.getEntityReference(request);
        EntityKind childKind = WebUtilities.getKind(request, "childKind");
        SelectJoinStep<Record4<String, String, String, Timestamp>> qry = mkUnattestedChangesQuery(entityRef, childKind);
        String filename = format("unattested-changes-%s-%d", childKind, entityRef.id());
        return writeExtract(filename, qry, request, response);
    });
}
Also used : EntityReference(org.finos.waltz.model.EntityReference) EntityKind(org.finos.waltz.model.EntityKind)

Example 12 with EntityKind

use of org.finos.waltz.model.EntityKind in project waltz by khartec.

the class ChangeLogGenerator method mkChangeLog.

private static ChangeLogRecord mkChangeLog(long appId, String email, LocalDateTime when) {
    Tuple2<String, EntityKind> messageTemplate = randomPick(messages);
    ChangeLogRecord record = new ChangeLogRecord();
    record.setMessage(messageTemplate.v1);
    record.setParentId(appId);
    record.setParentKind(EntityKind.APPLICATION.name());
    record.setChildKind(messageTemplate.v2.name());
    record.setUserId(email);
    record.setSeverity(Severity.INFORMATION.name());
    record.setCreatedAt(Timestamp.valueOf(when));
    return record;
}
Also used : ChangeLogRecord(org.finos.waltz.schema.tables.records.ChangeLogRecord) EntityKind(org.finos.waltz.model.EntityKind)

Example 13 with EntityKind

use of org.finos.waltz.model.EntityKind 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)

Example 14 with EntityKind

use of org.finos.waltz.model.EntityKind in project waltz by khartec.

the class GenericSelectorFactory method apply.

public GenericSelector apply(IdSelectionOptions selectionOptions) {
    EntityKind kind = selectionOptions.entityReference().kind();
    ImmutableGenericSelector.Builder builder = ImmutableGenericSelector.builder().kind(kind);
    if (selectionOptions.scope() == HierarchyQueryScope.EXACT) {
        Select<Record1<Long>> select = DSL.select(DSL.val(selectionOptions.entityReference().id()));
        return builder.selector(select).build();
    }
    Select<Record1<Long>> ids = applySelectorForKind(kind, selectionOptions);
    builder.selector(ids);
    return builder.build();
}
Also used : EntityKind(org.finos.waltz.model.EntityKind) Record1(org.jooq.Record1)

Example 15 with EntityKind

use of org.finos.waltz.model.EntityKind in project waltz by khartec.

the class EntityHierarchyEndpoint method buildByKindRoute.

private int buildByKindRoute(Request request, Response response) {
    requireRole(userRoleService, request, ADMIN);
    EntityKind kind = getKind(request);
    LOG.info("Building entity hierarchy for kind: {}", kind);
    return entityHierarchyService.buildFor(kind);
}
Also used : EntityKind(org.finos.waltz.model.EntityKind)

Aggregations

EntityKind (org.finos.waltz.model.EntityKind)15 EntityReference (org.finos.waltz.model.EntityReference)5 Autowired (org.springframework.beans.factory.annotation.Autowired)4 IOException (java.io.IOException)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)3 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)3 String.format (java.lang.String.format)2 Collection (java.util.Collection)2 List (java.util.List)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Collectors.toList (java.util.stream.Collectors.toList)2 Collectors.toSet (java.util.stream.Collectors.toSet)2 Stream (java.util.stream.Stream)2 ListUtilities (org.finos.waltz.common.ListUtilities)2 StringUtilities (org.finos.waltz.common.StringUtilities)2 WebUtilities (org.finos.waltz.web.WebUtilities)2 DSL (org.jooq.impl.DSL)2