Search in sources :

Example 71 with EntityReference

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

the class PeopleExtractor method registerExtractForApp.

private void registerExtractForApp(String path) {
    post(path, (request, response) -> {
        EntityReference entityRef = WebUtilities.getEntityReference(request);
        IdSelectionOptions selectionOptions = mkOpts(entityRef, HierarchyQueryScope.determineUpwardsScopeForKind(entityRef.kind()));
        GenericSelector selector = genericSelectorFactory.apply(selectionOptions);
        SelectSeekStep1<Record5<String, String, String, String, String>, String> qry = dsl.select(PERSON.DISPLAY_NAME.as("Name"), PERSON.TITLE.as("Title"), PERSON.OFFICE_PHONE.as("Telephone"), PERSON.EMAIL.as("Email"), INVOLVEMENT_KIND.NAME.as("Role")).from(PERSON).innerJoin(INVOLVEMENT).on(INVOLVEMENT.EMPLOYEE_ID.eq(PERSON.EMPLOYEE_ID)).innerJoin(INVOLVEMENT_KIND).on(INVOLVEMENT_KIND.ID.eq(INVOLVEMENT.KIND_ID)).where(INVOLVEMENT.ENTITY_ID.in(selector.selector()).and(INVOLVEMENT.ENTITY_KIND.eq(selector.kind().name()))).orderBy(PERSON.DISPLAY_NAME);
        return writeExtract("involved_people", qry, request, response);
    });
}
Also used : EntityReference(org.finos.waltz.model.EntityReference) WebUtilities.getEntityReference(org.finos.waltz.web.WebUtilities.getEntityReference) GenericSelector(org.finos.waltz.data.GenericSelector) Record5(org.jooq.Record5) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions)

Example 72 with EntityReference

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

the class PhysicalFlowExtractor method register.

@Override
public void register() {
    post(WebUtilities.mkPath("data-extract", "physical-flows", "all", ":kind", ":id"), (request, response) -> {
        EntityReference ref = WebUtilities.getEntityReference(request);
        String fileName = "physical-flows-all-" + ref.id();
        return writeReportResults(response, preparePhysicalFlows(prepareAllFlowsQuery(ref), parseExtractFormat(request), fileName, getTagsMap()));
    });
    post(WebUtilities.mkPath("data-extract", "physical-flows", "produces", ":kind", ":id"), (request, response) -> {
        EntityReference ref = WebUtilities.getEntityReference(request);
        String fileName = "physical-flows-produces-" + ref.id();
        return writeReportResults(response, preparePhysicalFlows(prepareProducesQuery(ref), parseExtractFormat(request), fileName, getTagsMap()));
    });
    post(WebUtilities.mkPath("data-extract", "physical-flows", "consumes", ":kind", ":id"), (request, response) -> {
        EntityReference ref = WebUtilities.getEntityReference(request);
        String fileName = "physical-flows-consumes-" + ref.id();
        SelectConditionStep<Record> qry = prepareConsumesQuery(ref);
        Map<Long, List<String>> tags = getTagsMap();
        return writeReportResults(response, preparePhysicalFlows(qry, parseExtractFormat(request), fileName, tags));
    });
    post(WebUtilities.mkPath("data-extract", "physical-flows", "by-selector"), (request, response) -> {
        IdSelectionOptions idSelectionOptions = WebUtilities.readIdSelectionOptionsFromBody(request);
        Select<Record1<Long>> idSelector = physicalFlowIdSelectorFactory.apply(idSelectionOptions);
        Condition condition = PhysicalFlow.PHYSICAL_FLOW.ID.in(idSelector).and(physicalFlowIdSelectorFactory.getLifecycleCondition(idSelectionOptions));
        SelectConditionStep<Record> qry = getQuery(condition);
        Map<Long, List<String>> tags = getTagsMap();
        String fileName = String.format("physical-flows-for-%s-%s", idSelectionOptions.entityReference().kind().name().toLowerCase(), idSelectionOptions.entityReference().id());
        return writeReportResults(response, preparePhysicalFlows(qry, parseExtractFormat(request), fileName, tags));
    });
}
Also used : EntityReference(org.finos.waltz.model.EntityReference) ListUtilities.newArrayList(org.finos.waltz.common.ListUtilities.newArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions)

Example 73 with EntityReference

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

the class TechnologyEOLServerExtractor method register.

@Override
public void register() {
    String path = WebUtilities.mkPath("data-extract", "technology-server", ":kind", ":id");
    get(path, (request, response) -> {
        EntityReference ref = getReference(request);
        Select<Record1<Long>> appIdSelector = applicationIdSelectorFactory.apply(mkOpts(ref));
        SelectConditionStep<Record> qry = dsl.selectDistinct(ORGANISATIONAL_UNIT.NAME.as("Org Unit")).select(APPLICATION.NAME.as("Application Name"), APPLICATION.ASSET_CODE.as("Asset Code")).select(SERVER_INFORMATION.HOSTNAME.as("Host Name"), SERVER_USAGE.ENVIRONMENT.as("Environment"), SERVER_INFORMATION.COUNTRY.as("Country"), SERVER_INFORMATION.LOCATION.as("Location"), SERVER_INFORMATION.OPERATING_SYSTEM.as("Operating System"), SERVER_INFORMATION.OS_END_OF_LIFE_DATE.as("Operating System EOL"), SERVER_INFORMATION.HW_END_OF_LIFE_DATE.as("Hardware EOL"), SERVER_INFORMATION.LIFECYCLE_STATUS.as("Lifecycle")).from(SERVER_INFORMATION).join(SERVER_USAGE).on(SERVER_USAGE.SERVER_ID.eq(SERVER_INFORMATION.ID)).join(APPLICATION).on(APPLICATION.ID.eq(SERVER_USAGE.ENTITY_ID)).join(ORGANISATIONAL_UNIT).on(ORGANISATIONAL_UNIT.ID.eq(APPLICATION.ORGANISATIONAL_UNIT_ID)).where(APPLICATION.ID.in(appIdSelector)).and(APPLICATION.LIFECYCLE_PHASE.notEqual("RETIRED"));
        return writeExtract(mkFilename(ref), qry, request, response);
    });
}
Also used : EntityReference(org.finos.waltz.model.EntityReference) WebUtilities.getEntityReference(org.finos.waltz.web.WebUtilities.getEntityReference)

Example 74 with EntityReference

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

the class SurveyRunExtractor method register.

@Override
public void register() {
    String surveysForEntityPath = WebUtilities.mkPath("data-extract", "surveys", "entity", ":kind", ":id");
    String surveyRunPath = WebUtilities.mkPath("data-extract", "survey-run", ":id");
    String surveyInstanceResponsesPath = WebUtilities.mkPath("data-extract", "survey-run-response", "instance", ":id");
    String surveyRunResponsesPath = WebUtilities.mkPath("data-extract", "survey-run-response", ":id");
    get(surveyRunPath, (request, response) -> {
        long runId = WebUtilities.getId(request);
        LOG.info("Survey run has been exported successfully");
        return writeExtract(mkFilename(getSurveyRunNameById(runId)), getSurveyRunInstances(runId), request, response);
    });
    get(surveyInstanceResponsesPath, (request, response) -> {
        long instanceId = WebUtilities.getId(request);
        LOG.info("Survey instance with responses has been exported successfully");
        return writeExtract(mkFilename(getSurveyRunNameByInstanceId(instanceId)), getSurveyInstanceResponses(instanceId), request, response);
    });
    get(surveyRunResponsesPath, (request, response) -> {
        long runId = WebUtilities.getId(request);
        LOG.info("Survey run with responses has been exported successfully");
        return writeExtract(mkFilename(getSurveyRunNameById(runId)), getSurveyRunWithResponses(runId), request, response);
    });
    get(surveysForEntityPath, (request, response) -> {
        EntityReference ref = WebUtilities.getEntityReference(request);
        LOG.info("Survey information for entity has been exported successfully");
        return writeExtract(mkFilename(format("%s-%d", ref.kind().name().toLowerCase(), ref.id())), getSurveysForEntity(ref), request, response);
    });
}
Also used : EntityReference(org.finos.waltz.model.EntityReference)

Example 75 with EntityReference

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

the class ChangeUnitIdSelectorFactory method mkForFlowEndpoint.

private Select<Record1<Long>> mkForFlowEndpoint(IdSelectionOptions options) {
    SelectorUtilities.ensureScopeIsExact(options);
    EntityReference ref = options.entityReference();
    Condition sourceRef = LOGICAL_FLOW.SOURCE_ENTITY_KIND.eq(ref.kind().name()).and(LOGICAL_FLOW.SOURCE_ENTITY_ID.eq(ref.id()));
    Condition targetRef = LOGICAL_FLOW.TARGET_ENTITY_KIND.eq(ref.kind().name()).and(LOGICAL_FLOW.TARGET_ENTITY_ID.eq(ref.id()));
    return DSL.select(CHANGE_UNIT.ID).from(CHANGE_UNIT).innerJoin(PHYSICAL_FLOW).on(PHYSICAL_FLOW.ID.eq(CHANGE_UNIT.SUBJECT_ENTITY_ID).and(CHANGE_UNIT.SUBJECT_ENTITY_KIND.eq(EntityKind.PHYSICAL_FLOW.name()))).innerJoin(LOGICAL_FLOW).on(LOGICAL_FLOW.ID.eq(PHYSICAL_FLOW.LOGICAL_FLOW_ID)).where(sourceRef.or(targetRef));
}
Also used : Condition(org.jooq.Condition) EntityReference(org.finos.waltz.model.EntityReference)

Aggregations

EntityReference (org.finos.waltz.model.EntityReference)114 BaseInMemoryIntegrationTest (org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest)55 Test (org.junit.jupiter.api.Test)55 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)40 EntityKind (org.finos.waltz.model.EntityKind)23 List (java.util.List)21 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)19 Autowired (org.springframework.beans.factory.annotation.Autowired)17 DataTypeDecorator (org.finos.waltz.model.datatype.DataTypeDecorator)16 Set (java.util.Set)14 Collection (java.util.Collection)13 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)13 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)10 IdSelectionOptions.mkOpts (org.finos.waltz.model.IdSelectionOptions.mkOpts)9 DateTimeUtilities (org.finos.waltz.common.DateTimeUtilities)8 ListUtilities.newArrayList (org.finos.waltz.common.ListUtilities.newArrayList)8 Bookmark (org.finos.waltz.model.bookmark.Bookmark)8 Collections.emptyList (java.util.Collections.emptyList)7 Collectors (java.util.stream.Collectors)7 CollectionUtilities.first (org.finos.waltz.common.CollectionUtilities.first)7