Search in sources :

Example 26 with EntityReference

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

the class PhysicalFlowUploadService method validateCommand.

// //////////////////// PRIVATE //////////////////////
// ///////////////////////////////////////////////////
private PhysicalFlowUploadCommandResponse validateCommand(Map<String, Actor> actorsByName, Map<String, Application> applicationsByAssetCode, Map<String, DataType> dataTypeMap, Aliases<TransportKindValue> transportAliases, PhysicalFlowUploadCommand cmd) {
    checkNotNull(cmd, "cmd cannot be null");
    Map<String, String> errors = new HashMap<>();
    // resolve entity refs - source, target, owner
    EntityReference source = getNodeRefByString(actorsByName, applicationsByAssetCode, cmd.source());
    EntityReference target = getNodeRefByString(actorsByName, applicationsByAssetCode, cmd.target());
    EntityReference owner = getNodeRefByString(actorsByName, applicationsByAssetCode, cmd.owner());
    EntityReference dataType = getDataTypeByString(dataTypeMap, cmd.dataType());
    if (source == null) {
        errors.put("source", String.format("%s not found", cmd.source()));
    }
    if (target == null) {
        errors.put("target", String.format("%s not found", cmd.target()));
    }
    if (owner == null) {
        errors.put("owner", String.format("%s not found", cmd.owner()));
    }
    if (dataType == null) {
        errors.put("dataType", String.format("%s not found", cmd.dataType()));
    }
    // resolve enums - format, frequency, transport, criticality
    DataFormatKind format = DataFormatKind.parse(cmd.format(), (s) -> null);
    if (format == null) {
        errors.put("format", String.format("%s is not a recognised value", cmd.format()));
    }
    FrequencyKind frequency = FrequencyKind.parse(cmd.frequency(), (s) -> null);
    if (frequency == null) {
        errors.put("frequency", String.format("%s is not a recognised value", cmd.frequency()));
    }
    TransportKindValue transport = transportAliases.lookup(cmd.transport()).orElseGet(() -> {
        errors.put("transport", String.format("%s is not a recognised value", cmd.transport()));
        return null;
    });
    Criticality criticality = Criticality.parse(cmd.criticality(), (s) -> null);
    if (criticality == null) {
        errors.put("criticality", String.format("%s is not a recognised value", cmd.criticality()));
    }
    // check for nulls or duplicates in other fields
    if (isEmpty(cmd.name())) {
        errors.put("name", "name not provided");
    }
    Integer basisOffset = parseBasisOffset(cmd.basisOffset());
    if (basisOffset == null) {
        errors.put("basisOffset", String.format("%s is not a recognised value, expect this to be a number", cmd.basisOffset()));
    }
    ImmutablePhysicalFlowParsed parsedFlow = ImmutablePhysicalFlowParsed.builder().source(source).target(target).owner(owner).name(cmd.name()).format(format).specDescription(cmd.specDescription()).specExternalId(cmd.specExternalId()).frequency(frequency).transport(transport).criticality(criticality).description(cmd.description()).externalId(cmd.externalId()).basisOffset(basisOffset).dataType(dataType).build();
    return ImmutablePhysicalFlowUploadCommandResponse.builder().parsedFlow(parsedFlow).errors(errors).originalCommand(cmd).outcome(errors.size() > 0 ? CommandOutcome.FAILURE : CommandOutcome.SUCCESS).build();
}
Also used : HashMap(java.util.HashMap) DataFormatKind(org.finos.waltz.model.physical_specification.DataFormatKind) EntityReference(org.finos.waltz.model.EntityReference) Criticality(org.finos.waltz.model.Criticality)

Example 27 with EntityReference

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

the class LogicalFlowDecoratorRatingsCalculator method lookupFlowClassificationRule.

private Optional<Long> lookupFlowClassificationRule(Map<Long, DataType> typesById, Map<Long, LogicalFlow> flowsById, Map<Long, Application> targetAppsById, FlowClassificationRuleResolver resolver, DataTypeDecorator decorator) {
    LogicalFlow flow = flowsById.get(decorator.dataFlowId());
    EntityReference vantagePoint = lookupVantagePoint(targetAppsById, flow);
    EntityReference source = flow.source();
    Optional<FlowClassificationRuleVantagePoint> flowClassificationRuleVantagePoint = resolver.resolveAuthSource(vantagePoint, source, decorator.dataTypeId());
    return flowClassificationRuleVantagePoint.map(FlowClassificationRuleVantagePoint::ruleId);
}
Also used : FlowClassificationRuleVantagePoint(org.finos.waltz.model.flow_classification_rule.FlowClassificationRuleVantagePoint) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) EntityReference(org.finos.waltz.model.EntityReference)

Example 28 with EntityReference

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

the class LogicalFlowDecoratorRatingsCalculator method lookupRating.

private AuthoritativenessRatingValue lookupRating(Map<Long, LogicalFlow> flowsById, Map<Long, Application> targetAppsById, FlowClassificationRuleResolver resolver, DataTypeDecorator decorator) {
    LogicalFlow flow = flowsById.get(decorator.dataFlowId());
    EntityReference vantagePoint = lookupVantagePoint(targetAppsById, flow);
    EntityReference source = flow.source();
    return resolver.resolve(vantagePoint, source, decorator.decoratorEntity().id());
}
Also used : LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) EntityReference(org.finos.waltz.model.EntityReference)

Example 29 with EntityReference

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

the class LogicalFlowDecoratorSummaryDao method summarizeForCondition.

private List<DecoratorRatingSummary> summarizeForCondition(Condition condition) {
    // this is intentionally TARGET only as we use to calculate auth source stats
    Condition dataFlowJoinCondition = LOGICAL_FLOW.ID.eq(LOGICAL_FLOW_DECORATOR.LOGICAL_FLOW_ID);
    Collection<Field<?>> groupingFields = newArrayList(LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_KIND, LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_ID, LOGICAL_FLOW_DECORATOR.RATING);
    Field<Integer> countField = DSL.count(LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_ID).as("count");
    return dsl.select(groupingFields).select(countField).from(LOGICAL_FLOW_DECORATOR).innerJoin(LOGICAL_FLOW).on(dsl.renderInlined(dataFlowJoinCondition)).where(dsl.renderInlined(condition)).groupBy(groupingFields).fetch(r -> {
        EntityKind decoratorEntityKind = EntityKind.valueOf(r.getValue(LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_KIND));
        long decoratorEntityId = r.getValue(LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_ID);
        EntityReference decoratorRef = EntityReference.mkRef(decoratorEntityKind, decoratorEntityId);
        AuthoritativenessRatingValue rating = AuthoritativenessRatingValue.of(r.getValue(LOGICAL_FLOW_DECORATOR.RATING));
        Integer count = r.getValue(countField);
        return ImmutableDecoratorRatingSummary.builder().decoratorEntityReference(decoratorRef).rating(rating).count(count).build();
    });
}
Also used : AuthoritativenessRatingValue(org.finos.waltz.model.rating.AuthoritativenessRatingValue) EntityReference(org.finos.waltz.model.EntityReference) EntityKind(org.finos.waltz.model.EntityKind)

Example 30 with EntityReference

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

the class ChangeUnitIdSelectorFactory method mkForDirectEntity.

private Select<Record1<Long>> mkForDirectEntity(IdSelectionOptions options) {
    SelectorUtilities.ensureScopeIsExact(options);
    EntityReference ref = options.entityReference();
    return DSL.select(CHANGE_UNIT.ID).from(CHANGE_UNIT).where(CHANGE_UNIT.SUBJECT_ENTITY_ID.eq(ref.id())).and(CHANGE_UNIT.SUBJECT_ENTITY_KIND.eq(ref.kind().name()));
}
Also used : EntityReference(org.finos.waltz.model.EntityReference)

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