Search in sources :

Example 26 with Application

use of org.finos.waltz.model.application.Application in project waltz by khartec.

the class LogicalFlowDecoratorRatingsCalculator method calculate.

public Collection<DataTypeDecorator> calculate(Collection<DataTypeDecorator> decorators) {
    List<LogicalFlow> appToAppFlows = filter(IS_APP_TO_APP_FLOW, loadFlows(decorators));
    if (isEmpty(appToAppFlows))
        return Collections.emptyList();
    List<Application> targetApps = loadTargetApplications(appToAppFlows);
    List<DataType> dataTypes = dataTypeDao.findAll();
    Set<FlowClassification> flowClassifications = flowClassificationDao.findAll();
    Map<Long, DataType> typesById = indexById(dataTypes);
    Map<Long, LogicalFlow> flowsById = indexById(appToAppFlows);
    Map<Long, Application> targetAppsById = indexById(targetApps);
    FlowClassificationRuleResolver resolver = createResolver(targetApps);
    return decorators.stream().filter(d -> flowsById.containsKey(d.dataFlowId())).map(decorator -> {
        try {
            if (decorator.decoratorEntity().kind() != EntityKind.DATA_TYPE) {
                return decorator;
            } else {
                AuthoritativenessRatingValue rating = lookupRating(flowsById, targetAppsById, resolver, decorator);
                Optional<Long> ruleId = lookupFlowClassificationRule(typesById, flowsById, targetAppsById, resolver, decorator);
                return ImmutableDataTypeDecorator.copyOf(decorator).withRating(rating).withFlowClassificationRuleId(ruleId);
            }
        } catch (Exception e) {
            LOG.warn("Failed to calculate rating for decorator: {}, reason: {}", decorator, e.getMessage());
            return null;
        }
    }).filter(Objects::nonNull).collect(Collectors.toSet());
}
Also used : AuthoritativenessRatingValue(org.finos.waltz.model.rating.AuthoritativenessRatingValue) java.util(java.util) LogicalFlowDao(org.finos.waltz.data.logical_flow.LogicalFlowDao) FlowClassification(org.finos.waltz.model.flow_classification.FlowClassification) ApplicationService(org.finos.waltz.service.application.ApplicationService) EntityKind(org.finos.waltz.model.EntityKind) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) FlowClassificationDao(org.finos.waltz.data.flow_classification_rule.FlowClassificationDao) DataType(org.finos.waltz.model.datatype.DataType) SetUtilities.map(org.finos.waltz.common.SetUtilities.map) FlowClassificationRuleVantagePoint(org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint) FlowClassificationRuleDao(org.finos.waltz.data.flow_classification_rule.FlowClassificationRuleDao) Service(org.springframework.stereotype.Service) IdUtilities.indexById(org.finos.waltz.model.utils.IdUtilities.indexById) Logger(org.slf4j.Logger) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) Application(org.finos.waltz.model.application.Application) DataTypeDecorator(org.finos.waltz.model.datatype.DataTypeDecorator) Predicate(java.util.function.Predicate) ListUtilities.isEmpty(org.finos.waltz.common.ListUtilities.isEmpty) ImmutableDataTypeDecorator(org.finos.waltz.model.datatype.ImmutableDataTypeDecorator) Collectors(java.util.stream.Collectors) FlowClassificationRuleResolver(org.finos.waltz.service.flow_classification_rule.FlowClassificationRuleResolver) Checks.checkNotNull(org.finos.waltz.common.Checks.checkNotNull) ListUtilities.filter(org.finos.waltz.common.ListUtilities.filter) EntityReference(org.finos.waltz.model.EntityReference) DataTypeDao(org.finos.waltz.data.data_type.DataTypeDao) FlowClassification(org.finos.waltz.model.flow_classification.FlowClassification) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) AuthoritativenessRatingValue(org.finos.waltz.model.rating.AuthoritativenessRatingValue) DataType(org.finos.waltz.model.datatype.DataType) Application(org.finos.waltz.model.application.Application) FlowClassificationRuleResolver(org.finos.waltz.service.flow_classification_rule.FlowClassificationRuleResolver)

Example 27 with Application

use of org.finos.waltz.model.application.Application in project waltz by khartec.

the class LogicalFlowDecoratorRatingsCalculator method lookupVantagePoint.

private EntityReference lookupVantagePoint(Map<Long, Application> targetAppsById, LogicalFlow flow) {
    Application targetApp = targetAppsById.get(flow.target().id());
    long targetOrgUnitId = targetApp.organisationalUnitId();
    return EntityReference.mkRef(EntityKind.ORG_UNIT, targetOrgUnitId);
}
Also used : Application(org.finos.waltz.model.application.Application)

Example 28 with Application

use of org.finos.waltz.model.application.Application in project waltz by khartec.

the class FlowClassificationRuleService method logUpdate.

private void logUpdate(FlowClassificationRuleUpdateCommand command, String username) {
    FlowClassificationRule rule = getById(command.id().get());
    if (rule == null) {
        return;
    }
    String parentName = getParentEntityName(rule.parentReference());
    DataType dataType = dataTypeDao.getById(rule.dataTypeId());
    Application app = applicationDao.getById(rule.applicationReference().id());
    FlowClassification classification = flowClassificationDao.getById(command.classificationId());
    if (app != null && dataType != null && parentName != null) {
        String msg = format("Updated flow classification rule: %s as the source application with rating: %s, for type: %s, for %s: %s", app.name(), classification.name(), dataType.name(), rule.parentReference().kind().prettyName(), parentName);
        multiLog(username, rule.id().get(), rule.parentReference(), dataType, app, msg, Operation.UPDATE);
    }
}
Also used : FlowClassification(org.finos.waltz.model.flow_classification.FlowClassification) DataType(org.finos.waltz.model.datatype.DataType) Application(org.finos.waltz.model.application.Application)

Aggregations

Application (org.finos.waltz.model.application.Application)28 EntityKind (org.finos.waltz.model.EntityKind)12 DSLContext (org.jooq.DSLContext)12 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)12 Collectors (java.util.stream.Collectors)11 EntityReference (org.finos.waltz.model.EntityReference)10 ApplicationDao (org.finos.waltz.data.application.ApplicationDao)9 ExternalIdValue (org.finos.waltz.model.external_identifier.ExternalIdValue)9 DIConfiguration (org.finos.waltz.service.DIConfiguration)9 IOException (java.io.IOException)7 java.util (java.util)7 List (java.util.List)7 Map (java.util.Map)6 DataType (org.finos.waltz.model.datatype.DataType)6 ApplicationService (org.finos.waltz.service.application.ApplicationService)6 CsvPreference (org.supercsv.prefs.CsvPreference)6 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)5 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)5 OrganisationalUnit (org.finos.waltz.model.orgunit.OrganisationalUnit)5 LogicalFlowDao (org.finos.waltz.data.logical_flow.LogicalFlowDao)4