Search in sources :

Example 1 with PhysicalFlow

use of org.finos.waltz.model.physical_flow.PhysicalFlow in project waltz by khartec.

the class FlowDiagramService method makeForPhysicalSpecification.

private Long makeForPhysicalSpecification(EntityReference ref, String userId, String providedTitle) {
    PhysicalSpecification spec = physicalSpecificationDao.getById(ref.id());
    Select<Record1<Long>> logicalFlowSelector = logicalFlowIdSelectorFactory.apply(mkOpts(ref, HierarchyQueryScope.EXACT));
    List<LogicalFlow> logicalFlows = logicalFlowDao.findBySelector(logicalFlowSelector);
    List<PhysicalFlow> physicalFlows = physicalFlowDao.findBySpecificationId(ref.id());
    List<EntityReference> nodes = logicalFlows.stream().flatMap(f -> Stream.of(f.source(), f.target())).distinct().collect(toList());
    List<FlowDiagramEntity> entities = ListUtilities.concat(map(logicalFlows, d -> mkDiagramEntity(d)), map(physicalFlows, d -> mkDiagramEntity(d)), newArrayList(mkDiagramEntity(spec)), map(nodes, d -> mkDiagramEntity(d)));
    String title = isEmpty(providedTitle) ? spec.name() + " flows" : providedTitle;
    return mkNewFlowDiagram(title, userId, entities, emptyList());
}
Also used : ChangeInitiative(org.finos.waltz.model.change_initiative.ChangeInitiative) LogicalFlowDao(org.finos.waltz.data.logical_flow.LogicalFlowDao) org.finos.waltz.model(org.finos.waltz.model) Autowired(org.springframework.beans.factory.annotation.Autowired) ListUtilities.newArrayList(org.finos.waltz.common.ListUtilities.newArrayList) ImmutableChangeLog(org.finos.waltz.model.changelog.ImmutableChangeLog) PhysicalFlow(org.finos.waltz.model.physical_flow.PhysicalFlow) StringUtilities.isEmpty(org.finos.waltz.common.StringUtilities.isEmpty) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) Measurable(org.finos.waltz.model.measurable.Measurable) Record1(org.jooq.Record1) FlowDiagramDao(org.finos.waltz.data.flow_diagram.FlowDiagramDao) Select(org.jooq.Select) org.finos.waltz.model.flow_diagram(org.finos.waltz.model.flow_diagram) ChangeInitiativeDao(org.finos.waltz.data.change_initiative.ChangeInitiativeDao) MeasurableDao(org.finos.waltz.data.measurable.MeasurableDao) Collections.emptyList(java.util.Collections.emptyList) String.format(java.lang.String.format) Collectors.joining(java.util.stream.Collectors.joining) ApplicationDao(org.finos.waltz.data.application.ApplicationDao) ListUtilities.map(org.finos.waltz.common.ListUtilities.map) Stream(java.util.stream.Stream) DateTimeUtilities.nowUtc(org.finos.waltz.common.DateTimeUtilities.nowUtc) SetUtilities(org.finos.waltz.common.SetUtilities) PhysicalSpecification(org.finos.waltz.model.physical_specification.PhysicalSpecification) Actor(org.finos.waltz.model.actor.Actor) java.util(java.util) FlowDiagramAnnotationDao(org.finos.waltz.data.flow_diagram.FlowDiagramAnnotationDao) PhysicalFlowDao(org.finos.waltz.data.physical_flow.PhysicalFlowDao) EntitySearchOptions(org.finos.waltz.model.entity_search.EntitySearchOptions) DataType(org.finos.waltz.model.datatype.DataType) ChangeLog(org.finos.waltz.model.changelog.ChangeLog) Service(org.springframework.stereotype.Service) PhysicalSpecificationDao(org.finos.waltz.data.physical_specification.PhysicalSpecificationDao) DataTypeService(org.finos.waltz.service.data_type.DataTypeService) ChangeLogService(org.finos.waltz.service.changelog.ChangeLogService) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) Application(org.finos.waltz.model.application.Application) IdSelectionOptions.mkOpts(org.finos.waltz.model.IdSelectionOptions.mkOpts) FlowDiagramEntityDao(org.finos.waltz.data.flow_diagram.FlowDiagramEntityDao) FLOW_DIAGRAM(org.finos.waltz.model.EntityKind.FLOW_DIAGRAM) RandomUtilities(org.finos.waltz.common.RandomUtilities) LogicalFlowIdSelectorFactory(org.finos.waltz.data.logical_flow.LogicalFlowIdSelectorFactory) Collectors.toList(java.util.stream.Collectors.toList) Checks.checkNotNull(org.finos.waltz.common.Checks.checkNotNull) ActorDao(org.finos.waltz.data.actor.ActorDao) DateTimeUtilities(org.finos.waltz.common.DateTimeUtilities) ListUtilities(org.finos.waltz.common.ListUtilities) FlowDiagramIdSelectorFactory(org.finos.waltz.data.flow_diagram.FlowDiagramIdSelectorFactory) InvalidResultException(org.jooq.exception.InvalidResultException) PhysicalSpecification(org.finos.waltz.model.physical_specification.PhysicalSpecification) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) PhysicalFlow(org.finos.waltz.model.physical_flow.PhysicalFlow) Record1(org.jooq.Record1)

Example 2 with PhysicalFlow

use of org.finos.waltz.model.physical_flow.PhysicalFlow in project waltz by khartec.

the class ChangeLogService method writeChangeLogEntries.

public void writeChangeLogEntries(EntityReference ref, String userId, String postamble, Operation operation) {
    switch(ref.kind()) {
        case PHYSICAL_FLOW:
            PhysicalFlow physicalFlow = physicalFlowDao.getById(ref.id());
            writeChangeLogEntries(physicalFlow, userId, postamble, operation);
            break;
        case LOGICAL_DATA_FLOW:
            LogicalFlow logicalFlow = logicalFlowDao.getByFlowId(ref.id());
            writeChangeLogEntries(logicalFlow, userId, postamble, operation);
            break;
        case MEASURABLE_RATING_REPLACEMENT:
            MeasurableRatingReplacement measurableRatingReplacement = measurableRatingReplacementdao.getById(ref.id());
            writeChangeLogEntries(measurableRatingReplacement, userId, postamble, operation);
            break;
        case MEASURABLE_RATING_PLANNED_DECOMMISSION:
            MeasurableRatingPlannedDecommission measurableRatingPlannedDecommission = measurableRatingPlannedDecommissionDao.getById(ref.id());
            writeChangeLogEntries(measurableRatingPlannedDecommission, userId, postamble, operation);
        default:
    }
}
Also used : LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) MeasurableRatingReplacement(org.finos.waltz.model.measurable_rating_replacement.MeasurableRatingReplacement) MeasurableRatingPlannedDecommission(org.finos.waltz.model.measurable_rating_planned_decommission.MeasurableRatingPlannedDecommission) PhysicalFlow(org.finos.waltz.model.physical_flow.PhysicalFlow)

Example 3 with PhysicalFlow

use of org.finos.waltz.model.physical_flow.PhysicalFlow in project waltz by khartec.

the class ChangeLogService method findByParentReferenceForPhysicalFlow.

// //////////////////// PRIVATE HELPERS //////////////////////////////////////////
private List<ChangeLog> findByParentReferenceForPhysicalFlow(EntityReference ref, Optional<Date> date, Optional<Integer> limit) {
    checkNotNull(ref, "ref must not be null");
    checkTrue(ref.kind() == EntityKind.PHYSICAL_FLOW, "ref should refer to a Physical Flow");
    Future<List<ChangeLog>> flowLogsFuture = dbExecutorPool.submit(() -> changeLogDao.findByParentReference(ref, date, limit));
    Future<List<ChangeLog>> specLogsFuture = dbExecutorPool.submit(() -> {
        PhysicalFlow flow = physicalFlowDao.getById(ref.id());
        return changeLogDao.findByParentReference(mkRef(EntityKind.PHYSICAL_SPECIFICATION, flow.specificationId()), date, limit);
    });
    return Unchecked.supplier(() -> {
        List<ChangeLog> flowLogs = flowLogsFuture.get();
        List<ChangeLog> specLogs = specLogsFuture.get();
        List<ChangeLog> all = new ArrayList<>();
        all.addAll(flowLogs);
        all.addAll(specLogs);
        return CollectionUtilities.sort(all, Comparator.comparing(ChangeLog::createdAt).reversed());
    }).get();
}
Also used : PhysicalFlow(org.finos.waltz.model.physical_flow.PhysicalFlow)

Example 4 with PhysicalFlow

use of org.finos.waltz.model.physical_flow.PhysicalFlow in project waltz by khartec.

the class FlowDiagramService method makeForPhysicalFlow.

private Long makeForPhysicalFlow(EntityReference ref, String userId, String providedTitle) {
    PhysicalFlow physFlow = physicalFlowDao.getById(ref.id());
    LogicalFlow logicalFlow = logicalFlowDao.getByFlowId(physFlow.logicalFlowId());
    PhysicalSpecification spec = physicalSpecificationDao.getById(physFlow.specificationId());
    String title = isEmpty(providedTitle) ? spec.name() + " flows" : providedTitle;
    ArrayList<FlowDiagramEntity> entities = newArrayList(mkDiagramEntity(logicalFlow), mkDiagramEntity(physFlow), mkDiagramEntity(spec), mkDiagramEntity(logicalFlow.source()), mkDiagramEntity(logicalFlow.target()));
    return mkNewFlowDiagram(title, userId, entities, emptyList());
}
Also used : PhysicalSpecification(org.finos.waltz.model.physical_specification.PhysicalSpecification) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) PhysicalFlow(org.finos.waltz.model.physical_flow.PhysicalFlow)

Example 5 with PhysicalFlow

use of org.finos.waltz.model.physical_flow.PhysicalFlow in project waltz by khartec.

the class ChangeUnitGenerator method create.

@Override
public Map<String, Integer> create(ApplicationContext ctx) {
    DSLContext dsl = getDsl(ctx);
    LocalDateTime now = LocalDateTime.now();
    List<Long> changeSetIds = dsl.select(CHANGE_SET.ID).from(CHANGE_SET).fetch(CHANGE_SET.ID);
    List<PhysicalFlow> physicalFlows = dsl.select(PHYSICAL_FLOW.fields()).from(PHYSICAL_FLOW).fetch(PhysicalFlowDao.TO_DOMAIN_MAPPER);
    AtomicInteger counter = new AtomicInteger(0);
    List<ChangeUnitRecord> groupRecords = changeSetIds.stream().flatMap(id -> randomlySizedIntStream(0, 5).mapToObj(idx -> randomPick(physicalFlows)).distinct().map(flow -> {
        ChangeUnitRecord record = dsl.newRecord(CHANGE_UNIT);
        record.setChangeSetId(id);
        record.setSubjectEntityKind(EntityKind.PHYSICAL_FLOW.name());
        record.setSubjectEntityId(flow.id().get());
        record.setSubjectInitialStatus(flow.entityLifecycleStatus().name());
        record.setExecutionStatus(ExecutionStatus.PENDING.name());
        record.setLastUpdatedAt(Timestamp.valueOf(now));
        record.setLastUpdatedBy("admin");
        record.setExternalId(String.format("change-unit-ext-%s", counter.addAndGet(1)));
        record.setProvenance(SAMPLE_DATA_PROVENANCE);
        // if flow pending -> activate, activating flow, desc
        // if flow active -> retire or modify
        // if modify -> create attribute changes
        ChangeAction action = mkChangeAction(flow);
        record.setAction(action.name());
        record.setName(mkName(flow, action));
        record.setDescription("Description: " + mkName(flow, action));
        return record;
    })).collect(toList());
    dsl.batchStore(groupRecords).execute();
    List<AttributeChangeRecord> attributeChangeRecords = mkAttributeChanges(dsl, physicalFlows);
    dsl.batchStore(attributeChangeRecords).execute();
    return null;
}
Also used : LocalDateTime(java.time.LocalDateTime) ChangeUnit(org.finos.waltz.model.change_unit.ChangeUnit) ChangeUnitRecord(org.finos.waltz.schema.tables.records.ChangeUnitRecord) Tables(org.finos.waltz.schema.Tables) EntityKind(org.finos.waltz.model.EntityKind) LocalDateTime(java.time.LocalDateTime) PhysicalFlowDao(org.finos.waltz.data.physical_flow.PhysicalFlowDao) PhysicalFlow(org.finos.waltz.model.physical_flow.PhysicalFlow) DataType(org.finos.waltz.model.datatype.DataType) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) StringUtilities.joinUsing(org.finos.waltz.common.StringUtilities.joinUsing) CHANGE_SET(org.finos.waltz.schema.tables.ChangeSet.CHANGE_SET) DSLContext(org.jooq.DSLContext) ChangeUnitDao(org.finos.waltz.data.change_unit.ChangeUnitDao) AttributeChangeRecord(org.finos.waltz.schema.tables.records.AttributeChangeRecord) StringUtilities(org.finos.waltz.common.StringUtilities) EntityLifecycleStatus(org.finos.waltz.model.EntityLifecycleStatus) MapUtilities(org.finos.waltz.common.MapUtilities) Criticality(org.finos.waltz.model.Criticality) Timestamp(java.sql.Timestamp) ExecutionStatus(org.finos.waltz.model.change_unit.ExecutionStatus) CHANGE_UNIT(org.finos.waltz.schema.tables.ChangeUnit.CHANGE_UNIT) ApplicationContext(org.springframework.context.ApplicationContext) RandomUtilities(org.finos.waltz.common.RandomUtilities) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) FrequencyKind(org.finos.waltz.model.physical_flow.FrequencyKind) DateTimeUtilities(org.finos.waltz.common.DateTimeUtilities) ListUtilities(org.finos.waltz.common.ListUtilities) ChangeAction(org.finos.waltz.model.change_unit.ChangeAction) DataTypeDao(org.finos.waltz.data.data_type.DataTypeDao) ChangeAction(org.finos.waltz.model.change_unit.ChangeAction) DSLContext(org.jooq.DSLContext) AttributeChangeRecord(org.finos.waltz.schema.tables.records.AttributeChangeRecord) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PhysicalFlow(org.finos.waltz.model.physical_flow.PhysicalFlow) ChangeUnitRecord(org.finos.waltz.schema.tables.records.ChangeUnitRecord)

Aggregations

PhysicalFlow (org.finos.waltz.model.physical_flow.PhysicalFlow)12 List (java.util.List)5 ChangeUnit (org.finos.waltz.model.change_unit.ChangeUnit)5 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)5 Map (java.util.Map)4 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)4 EntityKind (org.finos.waltz.model.EntityKind)4 PhysicalSpecification (org.finos.waltz.model.physical_specification.PhysicalSpecification)4 Collectors.toList (java.util.stream.Collectors.toList)3 DateTimeUtilities (org.finos.waltz.common.DateTimeUtilities)3 ListUtilities (org.finos.waltz.common.ListUtilities)3 RandomUtilities (org.finos.waltz.common.RandomUtilities)3 PhysicalFlowDao (org.finos.waltz.data.physical_flow.PhysicalFlowDao)3 ChangeAction (org.finos.waltz.model.change_unit.ChangeAction)3 DataType (org.finos.waltz.model.datatype.DataType)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Service (org.springframework.stereotype.Service)3 Timestamp (java.sql.Timestamp)2 LocalDateTime (java.time.LocalDateTime)2 Set (java.util.Set)2