Search in sources :

Example 1 with DataType

use of org.finos.waltz.model.datatype.DataType in project waltz by khartec.

the class DataTypeServiceTest method getDataTypeById.

@Test
public void getDataTypeById() {
    dataTypeHelper.clearAllDataTypes();
    DataType noDataTypesAdded = dtSvc.getDataTypeById(1L);
    assertNull(noDataTypesAdded, "When no datatypes created returns null");
    dataTypeHelper.createDataType(1L, "dt1", "DT1");
    dataTypeHelper.createDataType(2L, "dt2", "DT2");
    DataType dt1 = dtSvc.getDataTypeById(1L);
    assertEquals(1L, dt1.id().get().longValue(), "returns the datatype with that id");
    assertEquals(dt1.name(), "dt1", "retrieved data type has the correct name");
    DataType dt2 = dtSvc.getDataTypeById(2L);
    assertEquals(2L, dt2.id().get().longValue(), "returns the datatype with that id");
    assertEquals("dt2", dt2.name(), "retrieved data type has the correct name");
}
Also used : DataType(org.finos.waltz.model.datatype.DataType) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 2 with DataType

use of org.finos.waltz.model.datatype.DataType in project waltz by khartec.

the class DataTypeServiceTest method getDataTypeByCode.

@Test
public void getDataTypeByCode() {
    dataTypeHelper.clearAllDataTypes();
    DataType noDataTypesAdded = dtSvc.getDataTypeByCode("DT1");
    assertNull(noDataTypesAdded, "When no datatypes created returns null");
    dataTypeHelper.createDataType(1L, "dt1", "DT1");
    DataType dt1 = dtSvc.getDataTypeByCode("DT1");
    assertEquals(1L, dt1.id().get().longValue(), "retrieved data type has the correct name");
    assertEquals("dt1", dt1.name(), "retrieved data type has the correct name");
    assertEquals("DT1", dt1.code(), "retrieved data type has the correct code");
}
Also used : DataType(org.finos.waltz.model.datatype.DataType) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 3 with DataType

use of org.finos.waltz.model.datatype.DataType in project waltz by khartec.

the class LogicalFlowDecoratorService method findFlowIdsByDataTypeForParentsAndChildren.

private Set<LogicalFlowDecoratorStat> findFlowIdsByDataTypeForParentsAndChildren(Map<DataTypeDirectionKey, List<Long>> logicalFlowIdsByDataType) {
    List<DataType> dataTypes = dataTypeDao.findAll();
    Map<Optional<Long>, DataType> dataTypesById = indexBy(IdProvider::id, dataTypes);
    return dataTypes.stream().map(dt -> {
        DataType exactDataType = dataTypesById.get(dt.id());
        Set<DataTypeDirectionKey> keysForDatatype = filterKeySetByDataTypeId(logicalFlowIdsByDataType, asSet(dt.id().get()));
        Set<DataType> parentDataTypes = getParents(exactDataType, dataTypesById);
        Set<DataTypeDirectionKey> keysForParents = filterKeySetByDataTypeId(logicalFlowIdsByDataType, getIds(parentDataTypes));
        Set<DataType> childDataTypes = getChildren(exactDataType, dataTypesById);
        Set<DataTypeDirectionKey> keysForChildren = filterKeySetByDataTypeId(logicalFlowIdsByDataType, getIds(childDataTypes));
        Set<DataTypeDirectionKey> allKeys = union(keysForDatatype, keysForParents, keysForChildren);
        Set<Long> allFlowIds = getFlowsFromKeys(logicalFlowIdsByDataType, allKeys);
        Map<FlowDirection, Integer> typeToFlowCountMap = getTypeToFlowCountMap(logicalFlowIdsByDataType, allKeys);
        return mkLogicalFlowDecoratorStat(dt, typeToFlowCountMap, allFlowIds);
    }).filter(r -> r.totalCount() > 0).collect(Collectors.toSet());
}
Also used : AuthoritativenessRatingValue(org.finos.waltz.model.rating.AuthoritativenessRatingValue) java.util(java.util) LogicalFlowDao(org.finos.waltz.data.logical_flow.LogicalFlowDao) org.finos.waltz.model(org.finos.waltz.model) Autowired(org.springframework.beans.factory.annotation.Autowired) SetUtilities.asSet(org.finos.waltz.common.SetUtilities.asSet) CollectionUtilities.map(org.finos.waltz.common.CollectionUtilities.map) ImmutableChangeLog(org.finos.waltz.model.changelog.ImmutableChangeLog) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) DataType(org.finos.waltz.model.datatype.DataType) LogicalFlowDecoratorSummaryDao(org.finos.waltz.data.data_flow_decorator.LogicalFlowDecoratorSummaryDao) ChangeLog(org.finos.waltz.model.changelog.ChangeLog) Record1(org.jooq.Record1) Service(org.springframework.stereotype.Service) LogicalFlowService(org.finos.waltz.service.logical_flow.LogicalFlowService) FlowDirection(org.finos.waltz.model.FlowDirection) IdUtilities.indexById(org.finos.waltz.model.utils.IdUtilities.indexById) DataTypeUsageService(org.finos.waltz.service.usage_info.DataTypeUsageService) ApplicationIdSelectorFactory(org.finos.waltz.data.application.ApplicationIdSelectorFactory) Select(org.jooq.Select) ChangeLogService(org.finos.waltz.service.changelog.ChangeLogService) Checks.checkNotEmpty(org.finos.waltz.common.Checks.checkNotEmpty) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) Collections.emptySet(java.util.Collections.emptySet) DataTypeDecorator(org.finos.waltz.model.datatype.DataTypeDecorator) Collections.emptyList(java.util.Collections.emptyList) ImmutableLogicalFlowMeasures(org.finos.waltz.model.logical_flow.ImmutableLogicalFlowMeasures) ImmutableDataTypeDecorator(org.finos.waltz.model.datatype.ImmutableDataTypeDecorator) Collectors(java.util.stream.Collectors) Collectors.joining(java.util.stream.Collectors.joining) MapUtilities.indexBy(org.finos.waltz.common.MapUtilities.indexBy) org.finos.waltz.model.data_flow_decorator(org.finos.waltz.model.data_flow_decorator) SetUtilities.union(org.finos.waltz.common.SetUtilities.union) Checks.checkNotNull(org.finos.waltz.common.Checks.checkNotNull) LogicalFlowDecoratorDao(org.finos.waltz.data.datatype_decorator.LogicalFlowDecoratorDao) Stream(java.util.stream.Stream) Tuple.tuple(org.jooq.lambda.tuple.Tuple.tuple) ListUtilities.asList(org.finos.waltz.common.ListUtilities.asList) ListUtilities(org.finos.waltz.common.ListUtilities) DateTimeUtilities.nowUtc(org.finos.waltz.common.DateTimeUtilities.nowUtc) SetUtilities(org.finos.waltz.common.SetUtilities) Checks(org.finos.waltz.common.Checks) DataTypeDao(org.finos.waltz.data.data_type.DataTypeDao) LogicalFlowStatsDao(org.finos.waltz.data.logical_flow.LogicalFlowStatsDao) FlowDirection(org.finos.waltz.model.FlowDirection) DataType(org.finos.waltz.model.datatype.DataType)

Example 4 with DataType

use of org.finos.waltz.model.datatype.DataType in project waltz by khartec.

the class LogicalFlowDecoratorService method getParents.

private static Set<DataType> getParents(DataType dataType, Map<Optional<Long>, DataType> dataTypesById) {
    Checks.checkNotNull(dataType, "starting datatype cannot be null");
    Set<DataType> parents = new HashSet<>(emptySet());
    DataType parent = dataTypesById.get(dataType.parentId());
    while (parent != null) {
        parents.add(parent);
        parent = dataTypesById.get(parent.parentId());
    }
    return parents;
}
Also used : DataType(org.finos.waltz.model.datatype.DataType)

Example 5 with DataType

use of org.finos.waltz.model.datatype.DataType in project waltz by khartec.

the class FlowClassificationRuleService method logRemoval.

private void logRemoval(long id, String username) {
    FlowClassificationRule rule = getById(id);
    if (rule == null) {
        return;
    }
    String parentName = getParentEntityName(rule.parentReference());
    DataType dataType = dataTypeDao.getById(rule.dataTypeId());
    Application app = applicationDao.getById(rule.applicationReference().id());
    if (app != null && dataType != null && parentName != null) {
        String msg = format("Removed the flow classification rule where %s is a source app for type: %s for %s: %s", app.name(), dataType.name(), rule.parentReference().kind().prettyName(), parentName);
        multiLog(username, id, rule.parentReference(), dataType, app, msg, Operation.REMOVE);
    }
}
Also used : DataType(org.finos.waltz.model.datatype.DataType) Application(org.finos.waltz.model.application.Application)

Aggregations

DataType (org.finos.waltz.model.datatype.DataType)16 DataTypeDao (org.finos.waltz.data.data_type.DataTypeDao)5 Application (org.finos.waltz.model.application.Application)5 DataTypeDecorator (org.finos.waltz.model.datatype.DataTypeDecorator)5 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)5 Collectors (java.util.stream.Collectors)4 BaseInMemoryIntegrationTest (org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest)4 EntityKind (org.finos.waltz.model.EntityKind)4 EntityReference (org.finos.waltz.model.EntityReference)4 Test (org.junit.jupiter.api.Test)4 java.util (java.util)3 Collections.emptyList (java.util.Collections.emptyList)3 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Collection (java.util.Collection)2 Collections.emptySet (java.util.Collections.emptySet)2 List (java.util.List)2 Collectors.toList (java.util.stream.Collectors.toList)2 ListUtilities (org.finos.waltz.common.ListUtilities)2 ListUtilities.asList (org.finos.waltz.common.ListUtilities.asList)2