use of org.finos.waltz.model.EntityKind in project waltz by khartec.
the class EntityCostExtractor method registerCostsForSelector.
private void registerCostsForSelector(String costsForSelectorPath) {
post(costsForSelectorPath, (request, response) -> {
IdSelectionOptions idSelectionOptions = WebUtilities.readIdSelectionOptionsFromBody(request);
EntityKind targetKind = WebUtilities.getKind(request);
GenericSelector genericSelector = genericSelectorFactory.applyForKind(targetKind, idSelectionOptions);
SelectJoinStep<Record1<Integer>> latestYear = DSL.select(DSL.max(COST.YEAR)).from(COST);
SelectSeekStep2<Record, String, Long> qry = dsl.select(COST.ENTITY_ID.as("Entity ID"), COST.ENTITY_KIND.as("Entity Kind")).select(ENTITY_NAME_FIELD.as("Name")).select(COST_KIND.NAME.as("Kind"), COST_KIND.DESCRIPTION.as("Kind Description")).select(COST.YEAR.as("Year"), COST.AMOUNT.as("Amount"), COST.PROVENANCE.as("Provenance")).from(COST).innerJoin(COST_KIND).on(COST.COST_KIND_ID.eq(COST_KIND.ID)).where(COST.ENTITY_ID.in(genericSelector.selector()).and(COST.ENTITY_KIND.eq(genericSelector.kind().name()))).and(COST.YEAR.eq(latestYear)).orderBy(ENTITY_NAME_FIELD.as("Name"), COST.COST_KIND_ID);
return writeExtract(mkFilename(idSelectionOptions.entityReference()), qry, request, response);
});
}
use of org.finos.waltz.model.EntityKind in project waltz by khartec.
the class FlowLineageHarness method findIncomingByRefs.
private static void findIncomingByRefs(DSLContext dsl, Set<EntityReference> entityReferences) {
Map<EntityKind, Collection<EntityReference>> refsByKind = groupBy(ref -> ref.kind(), entityReferences);
Condition anyTargetMatches = refsByKind.entrySet().stream().map(entry -> LOGICAL_FLOW.TARGET_ENTITY_KIND.eq(entry.getKey().name()).and(LOGICAL_FLOW.TARGET_ENTITY_ID.in(map(entry.getValue(), ref -> ref.id())))).collect(Collectors.reducing(DSL.falseCondition(), (acc, c) -> acc.or(c)));
System.out.println(anyTargetMatches);
Field<String> SOURCE_NAME_FIELD = InlineSelectFieldFactory.mkNameField(LOGICAL_FLOW.SOURCE_ENTITY_ID, LOGICAL_FLOW.SOURCE_ENTITY_KIND, newArrayList(EntityKind.APPLICATION, EntityKind.ACTOR));
dsl.select(LOGICAL_FLOW.fields()).select(SOURCE_NAME_FIELD).from(LOGICAL_FLOW).where(anyTargetMatches.and(LogicalFlowDao.LOGICAL_NOT_REMOVED)).forEach(System.out::println);
dsl.select().from(LOGICAL_FLOW_DECORATOR).innerJoin(LOGICAL_FLOW).on(LOGICAL_FLOW.ID.eq(LOGICAL_FLOW_DECORATOR.LOGICAL_FLOW_ID)).where(anyTargetMatches).forEach(System.out::println);
}
use of org.finos.waltz.model.EntityKind in project waltz by khartec.
the class AttestationInstanceEndpoint method register.
@Override
public void register() {
String attestInstancePath = mkPath(BASE_URL, "attest", ":id");
String attestEntityForUserPath = mkPath(BASE_URL, "attest-entity");
String findByEntityRefPath = mkPath(BASE_URL, "entity", ":kind", ":id");
String findByRunIdPath = mkPath(BASE_URL, "run", ":id");
String findUnattestedByUserPath = mkPath(BASE_URL, "unattested", "user");
String findAllByUserPath = mkPath(BASE_URL, "all", "user");
String findHistoricalForPendingByUserPath = mkPath(BASE_URL, "historical", "user");
String findPersonsByInstancePath = mkPath(BASE_URL, ":id", "person");
String findBySelectorPath = mkPath(BASE_URL, "selector");
String findLatestMeasurableAttestationsPath = mkPath(BASE_URL, "latest", "measurable-category", "entity", ":kind", ":id");
String findApplicationAttestationInstancesForKindAndSelectorPath = mkPath(BASE_URL, "applications", "attested-entity", ":kind", ":id");
String findApplicationAttestationSummaryForSelectorPath = mkPath(BASE_URL, "app-summary");
String cleanupOrphansPath = mkPath(BASE_URL, "cleanup-orphans");
String reassignRecipientsPath = mkPath(BASE_URL, "reassign-recipients");
String getCountsOfRecipientsToReassignPath = mkPath(BASE_URL, "reassign-counts");
DatumRoute<Boolean> attestInstanceRoute = (req, res) -> attestationInstanceService.attestInstance(getId(req), getUsername(req));
ListRoute<AttestationInstance> findByEntityRefRoute = (req, res) -> attestationInstanceService.findByEntityReference(getEntityReference(req));
ListRoute<AttestationInstance> findUnattestedByRecipientRoute = (req, res) -> attestationInstanceService.findByRecipient(getUsername(req), true);
ListRoute<AttestationInstance> findAllByRecipientRoute = (req, res) -> attestationInstanceService.findByRecipient(getUsername(req), false);
ListRoute<AttestationInstance> findHistoricalForPendingByRecipientRoute = (req, res) -> attestationInstanceService.findHistoricalForPendingByUserId(getUsername(req));
ListRoute<AttestationInstance> findByRunIdRoute = (req, res) -> attestationInstanceService.findByRunId(getId(req));
ListRoute<Person> findPersonsByInstanceRoute = (request, response) -> {
long id = Long.valueOf(request.params("id"));
return attestationInstanceService.findPersonsByInstanceId(id);
};
ListRoute<AttestationInstance> findBySelectorRoute = ((request, response) -> attestationInstanceService.findByIdSelector(readIdSelectionOptionsFromBody(request)));
ListRoute<LatestMeasurableAttestationInfo> findLatestMeasurableAttestationsRoute = ((request, response) -> attestationInstanceService.findLatestMeasurableAttestations(getEntityReference(request)));
ListRoute<ApplicationAttestationInstanceSummary> findApplicationAttestationInstancesForKindAndSelectorRoute = ((request, response) -> {
EntityKind attestedKind = getKind(request);
Long attestedId = StringUtilities.parseLong(request.params("id"), null);
ApplicationAttestationInstanceInfo applicationAttestationInstanceInfo = readBody(request, ApplicationAttestationInstanceInfo.class);
return attestationInstanceService.findApplicationAttestationInstancesForKindAndSelector(attestedKind, attestedId, applicationAttestationInstanceInfo);
});
ListRoute<ApplicationAttestationSummaryCounts> findApplicationAttestationSummaryForSelectorRoute = ((request, response) -> attestationInstanceService.findAttestationInstanceSummaryForSelector(readBody(request, ApplicationAttestationInstanceInfo.class)));
DatumRoute<Boolean> attestEntityForUserRoute = (req, res) -> attestationInstanceService.attestForEntity(getUsername(req), readCreateCommand(req));
postForDatum(attestInstancePath, attestInstanceRoute);
postForDatum(attestEntityForUserPath, attestEntityForUserRoute);
getForList(findByEntityRefPath, findByEntityRefRoute);
getForList(findUnattestedByUserPath, findUnattestedByRecipientRoute);
getForList(findAllByUserPath, findAllByRecipientRoute);
getForList(findHistoricalForPendingByUserPath, findHistoricalForPendingByRecipientRoute);
getForList(findByRunIdPath, findByRunIdRoute);
getForList(findPersonsByInstancePath, findPersonsByInstanceRoute);
getForList(findLatestMeasurableAttestationsPath, findLatestMeasurableAttestationsRoute);
postForList(findBySelectorPath, findBySelectorRoute);
postForList(findApplicationAttestationInstancesForKindAndSelectorPath, findApplicationAttestationInstancesForKindAndSelectorRoute);
postForList(findApplicationAttestationSummaryForSelectorPath, findApplicationAttestationSummaryForSelectorRoute);
getForDatum(cleanupOrphansPath, this::cleanupOrphansRoute);
postForDatum(reassignRecipientsPath, this::reassignRecipientsRoute);
getForDatum(getCountsOfRecipientsToReassignPath, this::getCountsOfRecipientsToReassign);
}
use of org.finos.waltz.model.EntityKind in project waltz by khartec.
the class ReportGridExtractor method prepareReportRows.
private List<Tuple2<Application, ArrayList<Object>>> prepareReportRows(Set<Tuple2<ReportGridColumnDefinition, Boolean>> colsWithCommentRequirement, ReportGridInstance reportGridInstance) {
Set<ReportGridCell> tableData = reportGridInstance.cellData();
Map<Long, Application> applicationsById = indexById(reportGridInstance.applications());
Map<Long, RatingSchemeItem> ratingsById = indexById(reportGridInstance.ratingSchemeItems());
Map<Long, Collection<ReportGridCell>> tableDataByAppId = groupBy(tableData, ReportGridCell::applicationId);
boolean allowCostsExport = settingsService.getValue(SettingsService.ALLOW_COST_EXPORTS_KEY).map(r -> StringUtilities.isEmpty(r) || Boolean.parseBoolean(r)).orElse(true);
return tableDataByAppId.entrySet().stream().map(r -> {
Long appId = r.getKey();
Application app = applicationsById.getOrDefault(appId, null);
ArrayList<Object> reportRow = new ArrayList<>();
Collection<ReportGridCell> cells = r.getValue();
Map<Tuple3<Long, EntityKind, Long>, ReportGridCell> cellValuesByColumnRefForApp = indexBy(cells, k -> tuple(k.columnEntityId(), k.columnEntityKind(), k.entityFieldReferenceId()));
// find data for columns
colsWithCommentRequirement.forEach(t -> {
ReportGridColumnDefinition colDef = t.v1;
Boolean needsComment = t.v2;
boolean isCostColumn = colDef.columnEntityKind().equals(EntityKind.COST_KIND);
if (!allowCostsExport && isCostColumn) {
reportRow.add("REDACTED");
} else {
ReportGridCell cell = cellValuesByColumnRefForApp.getOrDefault(tuple(colDef.columnEntityId(), colDef.columnEntityKind(), getIdOrDefault(colDef.entityFieldReference(), null)), null);
reportRow.add(getValueFromReportCell(ratingsById, cell));
if (needsComment) {
reportRow.add(getCommentFromCell(cell));
}
}
});
return tuple(app, reportRow);
}).sorted(Comparator.comparing(t -> t.v1.name())).collect(toList());
}
use of org.finos.waltz.model.EntityKind in project waltz by khartec.
the class ComplexityExtractor method register.
@Override
public void register() {
String findBySelectorPath = WebUtilities.mkPath("data-extract", "complexity", "target-kind", ":kind", "selector");
post(findBySelectorPath, (request, response) -> {
IdSelectionOptions idSelectionOptions = WebUtilities.readIdSelectionOptionsFromBody(request);
EntityKind targetKind = WebUtilities.getKind(request);
GenericSelector genericSelector = genericSelectorFactory.applyForKind(targetKind, idSelectionOptions);
SelectConditionStep<Record> qry = dsl.select(ENTITY_NAME_FIELD.as("Entity Name")).select(COMPLEXITY.ENTITY_ID).select(COMPLEXITY_KIND.NAME.as("Complexity Kind")).select(COMPLEXITY.SCORE.as("Score")).select(COMPLEXITY.PROVENANCE).from(COMPLEXITY).innerJoin(COMPLEXITY_KIND).on(COMPLEXITY.COMPLEXITY_KIND_ID.eq(COMPLEXITY_KIND.ID)).where(COMPLEXITY.ENTITY_ID.in(genericSelector.selector()).and(COMPLEXITY.ENTITY_KIND.eq(genericSelector.kind().name())));
return writeExtract(mkFilename(idSelectionOptions), qry, request, response);
});
}
Aggregations