Search in sources :

Example 41 with EntityReference

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

the class FlowLineageHarness method main.

public static void main(String[] args) throws ParseException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    LogicalFlowDao flowDao = ctx.getBean(LogicalFlowDao.class);
    EntityReference ref1 = mkRef(APPLICATION, 25662);
    EntityReference ref2 = mkRef(ACTOR, 10);
    EntityReference ref3 = mkRef(APPLICATION, 25612);
    findIncomingByRefs(dsl, SetUtilities.fromArray(ref1, ref2, ref3));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityReference(org.finos.waltz.model.EntityReference) DSLContext(org.jooq.DSLContext) LogicalFlowDao(org.finos.waltz.data.logical_flow.LogicalFlowDao)

Example 42 with EntityReference

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

the class ChangeLogHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIBaseConfiguration.class);
    ChangeLogSummariesDao dao = ctx.getBean(ChangeLogSummariesDao.class);
    EntityReference ref = mkRef(EntityKind.APPLICATION, 1234L);
    // FunctionUtilities.time("findUnattestedChanges", () -> dao.findUnattestedChanges(ref));
    // FunctionUtilities.time("findUnattestedChanges", () -> dao.findUnattestedChanges(ref));
    // FunctionUtilities.time("findUnattestedChanges", () -> dao.findUnattestedChanges(ref));
    // List<ChangeLog> changes = FunctionUtilities.time("findUnattestedChanges", () -> dao.findUnattestedChanges(ref));
    // System.out.println(changes);
    GenericSelectorFactory factory = new GenericSelectorFactory();
    IdSelectionOptions idSelectionOptions = mkOpts(mkRef(EntityKind.APP_GROUP, 11874), HierarchyQueryScope.EXACT);
    FunctionUtilities.time("test", () -> dao.findCountByParentAndChildKindForDateBySelector(factory.applyForKind(EntityKind.APPLICATION, idSelectionOptions), DateTimeUtilities.toSqlDate(DateTimeUtilities.today()), Optional.of(10)));
    System.out.println("done");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ChangeLogSummariesDao(org.finos.waltz.data.changelog.ChangeLogSummariesDao) EntityReference(org.finos.waltz.model.EntityReference) GenericSelectorFactory(org.finos.waltz.data.GenericSelectorFactory) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions)

Example 43 with EntityReference

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

the class DataFlowHarness method main.

public static void main(String[] args) throws ParseException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    LogicalFlowService service = ctx.getBean(LogicalFlowService.class);
    LogicalFlowDao dao = ctx.getBean(LogicalFlowDao.class);
    LogicalFlowIdSelectorFactory factory = new LogicalFlowIdSelectorFactory();
    IdSelectionOptions options = IdSelectionOptions.mkOpts(EntityReference.mkRef(EntityKind.ORG_UNIT, 5000), HierarchyQueryScope.CHILDREN);
    Select<Record1<Long>> selector = factory.apply(options);
    System.out.println(selector);
    List<LogicalFlow> flows = dao.findBySelector(selector);
    flows.forEach(System.out::println);
    // by data type
    EntityReference dataType = EntityReference.mkRef(EntityKind.DATA_TYPE, 6000);
    IdSelectionOptions dataTypeOptions = IdSelectionOptions.mkOpts(dataType, HierarchyQueryScope.CHILDREN);
    List<LogicalFlow> byDataTypeFlows = service.findBySelector(dataTypeOptions);
    byDataTypeFlows.forEach(System.out::println);
    System.out.println(byDataTypeFlows.size());
}
Also used : LogicalFlowIdSelectorFactory(org.finos.waltz.data.logical_flow.LogicalFlowIdSelectorFactory) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) LogicalFlowService(org.finos.waltz.service.logical_flow.LogicalFlowService) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) EntityReference(org.finos.waltz.model.EntityReference) DSLContext(org.jooq.DSLContext) LogicalFlowDao(org.finos.waltz.data.logical_flow.LogicalFlowDao) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 44 with EntityReference

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

the class EntityRelationshipHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    EntityRelationshipDao dao = ctx.getBean(EntityRelationshipDao.class);
    EntityReference ref = EntityReference.mkRef(EntityKind.MEASURABLE, 613);
    Collection<EntityRelationship> rels = dao.findRelationshipsInvolving(ref);
    rels.forEach(r -> System.out.println(r.a().name()));
    System.out.println("----");
    System.out.println(dao.tallyRelationshipsInvolving(ref));
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityRelationshipDao(org.finos.waltz.data.entity_relationship.EntityRelationshipDao) EntityReference(org.finos.waltz.model.EntityReference) EntityRelationship(org.finos.waltz.model.entity_relationship.EntityRelationship) DSLContext(org.jooq.DSLContext)

Example 45 with EntityReference

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

the class PhysicalSpecificationServiceTest method findBySelector.

@Test
public void findBySelector() {
    assertThrows(IllegalArgumentException.class, () -> psSvc.findBySelector(null), "Options cannot be null");
    EntityReference a = appHelper.createNewApp("a", ouIds.a);
    Long specId = psHelper.createPhysicalSpec(a, "findByEntityReference");
    IdSelectionOptions specOpts = mkOpts(mkRef(EntityKind.PHYSICAL_SPECIFICATION, specId));
    Collection<PhysicalSpecification> specs = psSvc.findBySelector(specOpts);
    assertEquals(1, specs.size(), "When selector is a spec only returns one result");
    assertEquals(specId, first(specs).id().get(), "Returns spec when using spec selector");
    EntityReference b = appHelper.createNewApp("b", ouIds.a1);
    LogicalFlow flow = lfHelper.createLogicalFlow(a, b);
    Long specId2 = psHelper.createPhysicalSpec(b, "findByEntityReference");
    PhysicalFlowCreateCommandResponse physFlow = pfHelper.createPhysicalFlow(flow.entityReference().id(), specId, mkName("findBySelector"));
    PhysicalFlowCreateCommandResponse physFlow2 = pfHelper.createPhysicalFlow(flow.entityReference().id(), specId2, mkName("findBySelector"));
    IdSelectionOptions appOpts = mkOpts(mkRef(EntityKind.APPLICATION, b.id()));
    assertThrows(UnsupportedOperationException.class, () -> psSvc.findBySelector(appOpts), "Throws exception  for unsupported entity kinds");
    IdSelectionOptions flowOpts = mkOpts(mkRef(EntityKind.LOGICAL_DATA_FLOW, flow.entityReference().id()));
    Collection<PhysicalSpecification> specsForFlow = psSvc.findBySelector(flowOpts);
    assertEquals(2, specsForFlow.size(), "Returns all specs linked to a flow");
    assertEquals(asSet(specId, specId2), map(specsForFlow, d -> d.entityReference().id()), "Returns all specs linked to a flow");
    pfHelper.deletePhysicalFlow(physFlow2.entityReference().id());
    psHelper.removeSpec(specId2);
    Collection<PhysicalSpecification> activeSpecsForFlow = psSvc.findBySelector(flowOpts);
    assertEquals(1, activeSpecsForFlow.size(), "Returns all specs linked to a flow");
    assertEquals(asSet(specId), map(activeSpecsForFlow, d -> d.entityReference().id()), "Returns only active specs linked to a flow");
}
Also used : PhysicalFlowCreateCommandResponse(org.finos.waltz.model.physical_flow.PhysicalFlowCreateCommandResponse) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) CommandOutcome(org.finos.waltz.model.command.CommandOutcome) PhysicalSpecificationService(org.finos.waltz.service.physical_specification.PhysicalSpecificationService) EntityKind(org.finos.waltz.model.EntityKind) Autowired(org.springframework.beans.factory.annotation.Autowired) SetUtilities.asSet(org.finos.waltz.common.SetUtilities.asSet) DataTypeDecoratorService(org.finos.waltz.service.data_type.DataTypeDecoratorService) EntitySearchOptions.mkForEntity(org.finos.waltz.model.entity_search.EntitySearchOptions.mkForEntity) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) org.finos.waltz.model.physical_specification(org.finos.waltz.model.physical_specification) SetUtilities.map(org.finos.waltz.common.SetUtilities.map) NameHelper.mkName(org.finos.waltz.integration_test.inmem.helpers.NameHelper.mkName) LogicalFlowService(org.finos.waltz.service.logical_flow.LogicalFlowService) org.finos.waltz.integration_test.inmem.helpers(org.finos.waltz.integration_test.inmem.helpers) CommandResponse(org.finos.waltz.model.command.CommandResponse) PhysicalFlowCreateCommandResponse(org.finos.waltz.model.physical_flow.PhysicalFlowCreateCommandResponse) CollectionUtilities.first(org.finos.waltz.common.CollectionUtilities.first) PhysicalFlowService(org.finos.waltz.service.physical_flow.PhysicalFlowService) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) Collections.emptySet(java.util.Collections.emptySet) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) DataTypeDecorator(org.finos.waltz.model.datatype.DataTypeDecorator) Collections.emptyList(java.util.Collections.emptyList) Collection(java.util.Collection) IdSelectionOptions.mkOpts(org.finos.waltz.model.IdSelectionOptions.mkOpts) Set(java.util.Set) UserTimestamp(org.finos.waltz.model.UserTimestamp) Test(org.junit.jupiter.api.Test) List(java.util.List) DateTimeUtilities(org.finos.waltz.common.DateTimeUtilities) PhysicalSpecDefinitionService(org.finos.waltz.service.physical_specification_definition.PhysicalSpecDefinitionService) ListUtilities.asList(org.finos.waltz.common.ListUtilities.asList) Assertions(org.junit.jupiter.api.Assertions) EntityReference(org.finos.waltz.model.EntityReference) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) EntityReference(org.finos.waltz.model.EntityReference) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

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