Search in sources :

Example 66 with EntityReference

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

the class DataTypeUsageEndpoint method saveRoute.

private List<DataTypeUsage> saveRoute(Request request, Response response) throws IOException {
    WebUtilities.requireRole(userRoleService, request, SystemRole.LOGICAL_DATA_FLOW_EDITOR);
    String user = WebUtilities.getUsername(request);
    EntityReference ref = WebUtilities.getEntityReference(request);
    Long dataTypeId = WebUtilities.getLong(request, "typeId");
    UsageInfo[] usages = WebUtilities.readBody(request, UsageInfo[].class);
    dataTypeUsageService.save(ref, dataTypeId, newArrayList(usages), user);
    return dataTypeUsageService.findForEntityAndDataType(ref, dataTypeId);
}
Also used : EntityReference(org.finos.waltz.model.EntityReference) UsageInfo(org.finos.waltz.model.usage_info.UsageInfo)

Example 67 with EntityReference

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

the class TechnologyEOLDatabaseExtractor method register.

@Override
public void register() {
    String path = WebUtilities.mkPath("data-extract", "technology-database", ":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(DATABASE_INFORMATION.DATABASE_NAME.as("Database Name"), DATABASE_INFORMATION.INSTANCE_NAME.as("Instance Name"), DATABASE_USAGE.ENVIRONMENT.as("DBMS Environment"), DATABASE_INFORMATION.DBMS_VENDOR.as("DBMS Vendor"), DATABASE_INFORMATION.DBMS_NAME.as("DBMS Name"), DATABASE_INFORMATION.END_OF_LIFE_DATE.as("End of Life date"), DATABASE_INFORMATION.LIFECYCLE_STATUS.as("Lifecycle")).from(DATABASE_INFORMATION).innerJoin(DATABASE_USAGE).on(DATABASE_USAGE.DATABASE_ID.eq(DATABASE_INFORMATION.ID)).innerJoin(APPLICATION).on(APPLICATION.ID.eq(DATABASE_USAGE.ENTITY_ID)).and(DATABASE_USAGE.ENTITY_KIND.eq(EntityKind.APPLICATION.name())).innerJoin(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 68 with EntityReference

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

the class EntityRefHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    EntityReferenceNameResolver resolver = ctx.getBean(EntityReferenceNameResolver.class);
    List<EntityReference> refs = ListUtilities.newArrayList(EntityReference.mkRef(EntityKind.MEASURABLE, 136), EntityReference.mkRef(EntityKind.MEASURABLE, 138), EntityReference.mkRef(EntityKind.MEASURABLE, -138), EntityReference.mkRef(EntityKind.CHANGE_INITIATIVE, 12));
    List<EntityReference> refs1 = ListUtilities.newArrayList(EntityReference.mkRef(EntityKind.MEASURABLE, 136));
    dump(resolver.resolve(refs));
    dump(resolver.resolve(refs1));
    System.out.println("-- done");
}
Also used : EntityReferenceNameResolver(org.finos.waltz.data.EntityReferenceNameResolver) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityReference(org.finos.waltz.model.EntityReference)

Example 69 with EntityReference

use of org.finos.waltz.model.EntityReference 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);
}
Also used : Condition(org.jooq.Condition) ACTOR(org.finos.waltz.model.EntityKind.ACTOR) LOGICAL_FLOW_DECORATOR(org.finos.waltz.schema.tables.LogicalFlowDecorator.LOGICAL_FLOW_DECORATOR) LogicalFlowDao(org.finos.waltz.data.logical_flow.LogicalFlowDao) DSL(org.jooq.impl.DSL) EntityKind(org.finos.waltz.model.EntityKind) ParseException(org.jooq.tools.json.ParseException) Collection(java.util.Collection) Set(java.util.Set) DIConfiguration(org.finos.waltz.service.DIConfiguration) Field(org.jooq.Field) CollectionUtilities.map(org.finos.waltz.common.CollectionUtilities.map) ListUtilities.newArrayList(org.finos.waltz.common.ListUtilities.newArrayList) Collectors(java.util.stream.Collectors) Condition(org.jooq.Condition) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) LOGICAL_FLOW(org.finos.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW) InlineSelectFieldFactory(org.finos.waltz.data.InlineSelectFieldFactory) MapUtilities.groupBy(org.finos.waltz.common.MapUtilities.groupBy) Map(java.util.Map) SetUtilities(org.finos.waltz.common.SetUtilities) EntityReference(org.finos.waltz.model.EntityReference) DSLContext(org.jooq.DSLContext) APPLICATION(org.finos.waltz.model.EntityKind.APPLICATION) Collection(java.util.Collection) EntityKind(org.finos.waltz.model.EntityKind)

Example 70 with EntityReference

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

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