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");
}
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");
}
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());
}
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;
}
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);
}
}
Aggregations