Search in sources :

Example 31 with Application

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

the class ReportGridExtractor method prepareReportRows.

private List<Tuple2<Application, ArrayList<Object>>> prepareReportRows(Set<Tuple2<ReportGridColumnDefinition, Boolean>> colsWithCommentRequirement, ReportGridInstance reportGridInstance) {
    Set<ReportGridCell> tableData = reportGridInstance.cellData();
    Map<Long, Application> applicationsById = indexById(reportGridInstance.applications());
    Map<Long, RatingSchemeItem> ratingsById = indexById(reportGridInstance.ratingSchemeItems());
    Map<Long, Collection<ReportGridCell>> tableDataByAppId = groupBy(tableData, ReportGridCell::applicationId);
    boolean allowCostsExport = settingsService.getValue(SettingsService.ALLOW_COST_EXPORTS_KEY).map(r -> StringUtilities.isEmpty(r) || Boolean.parseBoolean(r)).orElse(true);
    return tableDataByAppId.entrySet().stream().map(r -> {
        Long appId = r.getKey();
        Application app = applicationsById.getOrDefault(appId, null);
        ArrayList<Object> reportRow = new ArrayList<>();
        Collection<ReportGridCell> cells = r.getValue();
        Map<Tuple3<Long, EntityKind, Long>, ReportGridCell> cellValuesByColumnRefForApp = indexBy(cells, k -> tuple(k.columnEntityId(), k.columnEntityKind(), k.entityFieldReferenceId()));
        // find data for columns
        colsWithCommentRequirement.forEach(t -> {
            ReportGridColumnDefinition colDef = t.v1;
            Boolean needsComment = t.v2;
            boolean isCostColumn = colDef.columnEntityKind().equals(EntityKind.COST_KIND);
            if (!allowCostsExport && isCostColumn) {
                reportRow.add("REDACTED");
            } else {
                ReportGridCell cell = cellValuesByColumnRefForApp.getOrDefault(tuple(colDef.columnEntityId(), colDef.columnEntityKind(), getIdOrDefault(colDef.entityFieldReference(), null)), null);
                reportRow.add(getValueFromReportCell(ratingsById, cell));
                if (needsComment) {
                    reportRow.add(getCommentFromCell(cell));
                }
            }
        });
        return tuple(app, reportRow);
    }).sorted(Comparator.comparing(t -> t.v1.name())).collect(toList());
}
Also used : CellType(org.apache.poi.ss.usermodel.CellType) LifecyclePhase(org.finos.waltz.model.application.LifecyclePhase) java.util(java.util) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IdUtilities.getIdOrDefault(org.finos.waltz.model.utils.IdUtilities.getIdOrDefault) EntityKind(org.finos.waltz.model.EntityKind) ReportGridService(org.finos.waltz.service.report_grid.ReportGridService) org.finos.waltz.model.report_grid(org.finos.waltz.model.report_grid) SurveyQuestionService(org.finos.waltz.service.survey.SurveyQuestionService) Autowired(org.springframework.beans.factory.annotation.Autowired) Spark.post(spark.Spark.post) CollectionUtilities(org.finos.waltz.common.CollectionUtilities) CsvPreference(org.supercsv.prefs.CsvPreference) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) SXSSFWorkbook(org.apache.poi.xssf.streaming.SXSSFWorkbook) Tuple2(org.jooq.lambda.tuple.Tuple2) Tuple3(org.jooq.lambda.tuple.Tuple3) RatingSchemeItem(org.finos.waltz.model.rating.RatingSchemeItem) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Service(org.springframework.stereotype.Service) CsvListWriter(org.supercsv.io.CsvListWriter) Cell(org.apache.poi.ss.usermodel.Cell) SXSSFSheet(org.apache.poi.xssf.streaming.SXSSFSheet) IdUtilities.indexById(org.finos.waltz.model.utils.IdUtilities.indexById) Collectors.toSet(java.util.stream.Collectors.toSet) StringUtilities(org.finos.waltz.common.StringUtilities) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) SurveyQuestion(org.finos.waltz.model.survey.SurveyQuestion) MapUtilities(org.finos.waltz.common.MapUtilities) Application(org.finos.waltz.model.application.Application) StringWriter(java.io.StringWriter) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) NameProvider(org.finos.waltz.model.NameProvider) SettingsService(org.finos.waltz.service.settings.SettingsService) Collectors.toList(java.util.stream.Collectors.toList) ExternalIdValue(org.finos.waltz.model.external_identifier.ExternalIdValue) Stream(java.util.stream.Stream) CheckedConsumer.unchecked(org.jooq.lambda.fi.util.function.CheckedConsumer.unchecked) Tuple.tuple(org.jooq.lambda.tuple.Tuple.tuple) ListUtilities(org.finos.waltz.common.ListUtilities) WebUtilities(org.finos.waltz.web.WebUtilities) Row(org.apache.poi.ss.usermodel.Row) EntityReference(org.finos.waltz.model.EntityReference) IdUtilities(org.finos.waltz.model.utils.IdUtilities) EntityFieldReference(org.finos.waltz.model.entity_field_reference.EntityFieldReference) RatingSchemeItem(org.finos.waltz.model.rating.RatingSchemeItem) Tuple3(org.jooq.lambda.tuple.Tuple3) Application(org.finos.waltz.model.application.Application)

Example 32 with Application

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

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 33 with Application

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

the class FlowDiagramService method makeForApplication.

private Long makeForApplication(EntityReference ref, String userId, String providedTitle) {
    Application app = applicationDao.getById(ref.id());
    String title = isEmpty(providedTitle) ? app.name() + " flows" : providedTitle;
    ArrayList<FlowDiagramEntity> entities = newArrayList(mkDiagramEntity(app));
    ArrayList<FlowDiagramAnnotation> annotations = newArrayList(mkDiagramAnnotation(app.entityReference(), title));
    return mkNewFlowDiagram(title, userId, entities, annotations);
}
Also used : Application(org.finos.waltz.model.application.Application)

Example 34 with Application

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

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)

Example 35 with Application

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

the class FlowClassificationRuleService method logInsert.

private void logInsert(Long ruleId, FlowClassificationRuleCreateCommand command, String username) {
    String parentName = getParentEntityName(command.parentReference());
    DataType dataType = dataTypeDao.getById(command.dataTypeId());
    Application app = applicationDao.getById(command.applicationId());
    if (app != null && dataType != null && parentName != null) {
        String msg = format("Registered the flow classification rule with %s as the source app for type: %s for %s: %s", app.name(), dataType.name(), command.parentReference().kind().prettyName(), parentName);
        multiLog(username, ruleId, command.parentReference(), dataType, app, msg, Operation.ADD);
    }
}
Also used : DataType(org.finos.waltz.model.datatype.DataType) Application(org.finos.waltz.model.application.Application)

Aggregations

Application (org.finos.waltz.model.application.Application)54 DSLContext (org.jooq.DSLContext)24 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)24 EntityKind (org.finos.waltz.model.EntityKind)22 Collectors (java.util.stream.Collectors)20 ApplicationDao (org.finos.waltz.data.application.ApplicationDao)18 EntityReference (org.finos.waltz.model.EntityReference)18 DIConfiguration (org.finos.waltz.service.DIConfiguration)18 ExternalIdValue (org.finos.waltz.model.external_identifier.ExternalIdValue)16 List (java.util.List)14 IOException (java.io.IOException)12 java.util (java.util)12 Map (java.util.Map)12 DataType (org.finos.waltz.model.datatype.DataType)12 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)12 ApplicationService (org.finos.waltz.service.application.ApplicationService)12 Tuple (org.jooq.lambda.tuple.Tuple)12 LogicalFlowDao (org.finos.waltz.data.logical_flow.LogicalFlowDao)10 CsvPreference (org.supercsv.prefs.CsvPreference)10 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)8