Search in sources :

Example 11 with Application

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

the class EntityStatisticGenerator method create.

public Map<String, Integer> create(ApplicationContext context) {
    DSLContext dsl = context.getBean(DSLContext.class);
    ApplicationDao applicationDao = context.getBean(ApplicationDao.class);
    OrganisationalUnitDao organisationalUnitDao = context.getBean(OrganisationalUnitDao.class);
    EntityStatisticValueDao valueDao = context.getBean(EntityStatisticValueDao.class);
    EntityStatisticDefinitionDao definitionDao = context.getBean(EntityStatisticDefinitionDao.class);
    EntityHierarchyService entityHierarchyService = context.getBean(EntityHierarchyService.class);
    Application[] applications = applicationDao.findAll().toArray(new Application[0]);
    OrganisationalUnit[] orgUnits = organisationalUnitDao.findAll().toArray(new OrganisationalUnit[0]);
    dsl.deleteFrom(ENTITY_STATISTIC_DEFINITION).where(ENTITY_STATISTIC_DEFINITION.PROVENANCE.eq("DEMO")).execute();
    log("deleted existing statistics (provenance: '" + SAMPLE_DATA_PROVENANCE + "')");
    dsl.update(ENTITY_STATISTIC_VALUE).set(ENTITY_STATISTIC_VALUE.CURRENT, false).where(ENTITY_STATISTIC_VALUE.PROVENANCE.eq("DEMO")).execute();
    log("marked existing statistic values as non-current (provenance: '" + SAMPLE_DATA_PROVENANCE + "')");
    definitionDao.insert(SDLC);
    definitionDao.insert(SDLC_TECH);
    definitionDao.insert(SDLC_PROCESS);
    definitionDao.insert(SDLC_JIRA);
    definitionDao.insert(SDLC_SVN);
    definitionDao.insert(SDLC_WIKI);
    definitionDao.insert(AUDIT);
    definitionDao.insert(SERVER_COUNT);
    definitionDao.insert(PRE_COMPUTED);
    createAdoptionStatsFor(SDLC_TECH, applications, valueDao);
    createAdoptionStatsFor(SDLC_PROCESS, applications, valueDao);
    createAdoptionStatsFor(SDLC_JIRA, applications, valueDao);
    createAdoptionStatsFor(SDLC_SVN, applications, valueDao);
    createAdoptionStatsFor(SDLC_WIKI, applications, valueDao);
    createIntStatsFor(AUDIT, applications, valueDao, 20, failIfPositiveFn);
    createIntStatsFor(SDLC, applications, valueDao, 20, failIfPositiveFn);
    createIntStatsFor(SERVER_COUNT, applications, valueDao, 20, (x, y) -> "VIRTUAL");
    createIntStatsFor(SERVER_COUNT, applications, valueDao, 20, (x, y) -> "BARE_METAL");
    createPreComputedStatsFor(PRE_COMPUTED, orgUnits, valueDao);
    entityHierarchyService.buildFor(EntityKind.ENTITY_STATISTIC);
    log("Rebuilt entity hierarchy");
    return null;
}
Also used : OrganisationalUnitDao(org.finos.waltz.data.orgunit.OrganisationalUnitDao) EntityStatisticDefinitionDao(org.finos.waltz.data.entity_statistic.EntityStatisticDefinitionDao) EntityStatisticValueDao(org.finos.waltz.data.entity_statistic.EntityStatisticValueDao) EntityHierarchyService(org.finos.waltz.service.entity_hierarchy.EntityHierarchyService) DSLContext(org.jooq.DSLContext) ApplicationDao(org.finos.waltz.data.application.ApplicationDao) OrganisationalUnit(org.finos.waltz.model.orgunit.OrganisationalUnit) Application(org.finos.waltz.model.application.Application)

Example 12 with Application

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

the class LogicalFlowGenerator method create.

@Override
public Map<String, Integer> create(ApplicationContext ctx) {
    FlowClassificationRuleDao flowClassificationRuleDao = ctx.getBean(FlowClassificationRuleDao.class);
    ApplicationService applicationDao = ctx.getBean(ApplicationService.class);
    OrganisationalUnitService orgUnitDao = ctx.getBean(OrganisationalUnitService.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    List<FlowClassificationRule> flowClassificationRules = flowClassificationRuleDao.findByEntityKind(EntityKind.ORG_UNIT);
    List<Application> apps = applicationDao.findAll();
    List<OrganisationalUnit> orgUnits = orgUnitDao.findAll();
    LocalDateTime now = LocalDateTime.now();
    Set<LogicalFlow> expectedFlows = flowClassificationRules.stream().flatMap(a -> {
        long orgUnitId = a.parentReference().id();
        return randomlySizedIntStream(0, 40).mapToObj(i -> randomAppPick(apps, orgUnitId).map(target -> ImmutableLogicalFlow.builder().source(a.applicationReference()).target(target).lastUpdatedBy("admin").provenance(SAMPLE_DATA_PROVENANCE).lastUpdatedAt(now).build()).orElse(null));
    }).filter(Objects::nonNull).collect(toSet());
    Set<LogicalFlow> probableFlows = flowClassificationRules.stream().flatMap(a -> randomlySizedIntStream(0, 30).mapToObj(i -> randomAppPick(apps, randomPick(orgUnits).id().get()).map(target -> ImmutableLogicalFlow.builder().source(a.applicationReference()).target(target).lastUpdatedBy("admin").provenance(SAMPLE_DATA_PROVENANCE).lastUpdatedAt(now).build()).orElse(null))).filter(Objects::nonNull).collect(toSet());
    Set<LogicalFlow> randomFlows = apps.stream().flatMap(a -> randomlySizedIntStream(0, 5).mapToObj(i -> randomAppPick(apps, randomPick(orgUnits).id().get()).map(target -> ImmutableLogicalFlow.builder().source(a.entityReference()).target(target).lastUpdatedBy("admin").provenance(SAMPLE_DATA_PROVENANCE).lastUpdatedAt(now).build()).orElse(null))).filter(Objects::nonNull).collect(toSet());
    Set<LogicalFlow> all = new HashSet<>();
    all.addAll(randomFlows);
    all.addAll(expectedFlows);
    all.addAll(probableFlows);
    Set<LogicalFlow> deduped = uniqBy(all, x -> Tuple.tuple(x.source(), x.target()));
    log("--- saving: " + deduped.size());
    Set<LogicalFlowRecord> records = SetUtilities.map(deduped, df -> LogicalFlowDao.TO_RECORD_MAPPER.apply(df, dsl));
    dsl.batchStore(records).execute();
    log("--- done");
    return null;
}
Also used : OrganisationalUnitService(org.finos.waltz.service.orgunit.OrganisationalUnitService) LocalDateTime(java.time.LocalDateTime) java.util(java.util) LogicalFlowDao(org.finos.waltz.data.logical_flow.LogicalFlowDao) ApplicationService(org.finos.waltz.service.application.ApplicationService) EntityKind(org.finos.waltz.model.EntityKind) SetUtilities.uniqBy(org.finos.waltz.common.SetUtilities.uniqBy) LocalDateTime(java.time.LocalDateTime) LogicalFlowRecord(org.finos.waltz.schema.tables.records.LogicalFlowRecord) LOGICAL_FLOW(org.finos.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW) FlowClassificationRuleDao(org.finos.waltz.data.flow_classification_rule.FlowClassificationRuleDao) FlowClassificationRule(org.finos.waltz.model.flow_classification_rule.FlowClassificationRule) DSLContext(org.jooq.DSLContext) Collectors.toSet(java.util.stream.Collectors.toSet) OrganisationalUnit(org.finos.waltz.model.orgunit.OrganisationalUnit) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) Application(org.finos.waltz.model.application.Application) ImmutableLogicalFlow(org.finos.waltz.model.logical_flow.ImmutableLogicalFlow) OrganisationalUnitService(org.finos.waltz.service.orgunit.OrganisationalUnitService) ApplicationContext(org.springframework.context.ApplicationContext) Collectors.toList(java.util.stream.Collectors.toList) Tuple(org.jooq.lambda.tuple.Tuple) ListUtilities(org.finos.waltz.common.ListUtilities) RandomUtilities.randomPick(org.finos.waltz.common.RandomUtilities.randomPick) SetUtilities(org.finos.waltz.common.SetUtilities) RandomUtilities.randomlySizedIntStream(org.finos.waltz.common.RandomUtilities.randomlySizedIntStream) EntityReference(org.finos.waltz.model.EntityReference) LogicalFlowRecord(org.finos.waltz.schema.tables.records.LogicalFlowRecord) FlowClassificationRuleDao(org.finos.waltz.data.flow_classification_rule.FlowClassificationRuleDao) DSLContext(org.jooq.DSLContext) OrganisationalUnit(org.finos.waltz.model.orgunit.OrganisationalUnit) FlowClassificationRule(org.finos.waltz.model.flow_classification_rule.FlowClassificationRule) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) ImmutableLogicalFlow(org.finos.waltz.model.logical_flow.ImmutableLogicalFlow) Application(org.finos.waltz.model.application.Application) ApplicationService(org.finos.waltz.service.application.ApplicationService)

Example 13 with Application

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

the class AppGroupService method removeApplication.

public List<AppGroupEntry> removeApplication(String userId, long groupId, long applicationId) throws InsufficientPrivelegeException {
    verifyUserCanUpdateGroup(userId, groupId);
    appGroupEntryDao.removeApplication(groupId, applicationId);
    Application app = applicationDao.getById(applicationId);
    audit(groupId, userId, format("Removed application %s from group", app != null ? app.name() : applicationId), EntityKind.APPLICATION, Operation.REMOVE);
    return appGroupEntryDao.findEntriesForGroup(groupId);
}
Also used : Application(org.finos.waltz.model.application.Application)

Example 14 with Application

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

the class AppGroupService method addApplication.

public List<AppGroupEntry> addApplication(String userId, long groupId, long applicationId) throws InsufficientPrivelegeException {
    verifyUserCanUpdateGroup(userId, groupId);
    Application app = applicationDao.getById(applicationId);
    if (app != null) {
        appGroupEntryDao.addApplication(groupId, applicationId);
        audit(groupId, userId, format("Added application %s to group", app.name()), EntityKind.APPLICATION, Operation.ADD);
    }
    return appGroupEntryDao.findEntriesForGroup(groupId);
}
Also used : Application(org.finos.waltz.model.application.Application)

Example 15 with Application

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

the class ApplicationService method findRelated.

public Map<AssetCodeRelationshipKind, List<Application>> findRelated(long appId) {
    List<Application> related = applicationDao.findRelatedByApplicationId(appId);
    Optional<Application> foundApp = related.stream().filter(app -> app.id().equals(Optional.of(appId))).findFirst();
    if (foundApp.isPresent()) {
        Application app = foundApp.get();
        Function<Application, AssetCodeRelationshipKind> classifier = relatedApp -> {
            boolean sameParent = relatedApp.parentAssetCode().equals(app.parentAssetCode());
            boolean sameCode = relatedApp.assetCode().equals(app.assetCode());
            boolean isParent = relatedApp.assetCode().equals(app.parentAssetCode());
            boolean isChild = relatedApp.parentAssetCode().equals(app.assetCode());
            if (sameCode) {
                return AssetCodeRelationshipKind.SHARING;
            } else if (isParent) {
                return AssetCodeRelationshipKind.PARENT;
            } else if (isChild) {
                return AssetCodeRelationshipKind.CHILD;
            } else if (sameParent && app.parentAssetCode().isPresent()) {
                return AssetCodeRelationshipKind.SIBLING;
            } else {
                return AssetCodeRelationshipKind.NONE;
            }
        };
        return related.stream().filter(// can do simple ref check here
        relatedApp -> relatedApp != app).collect(Collectors.groupingBy(classifier));
    } else {
        return emptyMap();
    }
}
Also used : IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) EntityKind(org.finos.waltz.model.EntityKind) ImmutableEntityReference(org.finos.waltz.model.ImmutableEntityReference) AssetCodeRelationshipKind(org.finos.waltz.model.application.AssetCodeRelationshipKind) Tally(org.finos.waltz.model.tally.Tally) Autowired(org.springframework.beans.factory.annotation.Autowired) Function(java.util.function.Function) EntitySearchOptions(org.finos.waltz.model.entity_search.EntitySearchOptions) StringUtilities.isEmpty(org.finos.waltz.common.StringUtilities.isEmpty) Record1(org.jooq.Record1) Service(org.springframework.stereotype.Service) Map(java.util.Map) EntityAliasDao(org.finos.waltz.data.entity_alias.EntityAliasDao) ApplicationIdSelectorFactory(org.finos.waltz.data.application.ApplicationIdSelectorFactory) Select(org.jooq.Select) Collections.emptyMap(java.util.Collections.emptyMap) Checks.checkNotEmpty(org.finos.waltz.common.Checks.checkNotEmpty) AppRegistrationResponse(org.finos.waltz.model.application.AppRegistrationResponse) Application(org.finos.waltz.model.application.Application) Collections.emptyList(java.util.Collections.emptyList) Collection(java.util.Collection) TagService(org.finos.waltz.service.tag.TagService) ApplicationSearchDao(org.finos.waltz.data.application.search.ApplicationSearchDao) Collectors(java.util.stream.Collectors) ApplicationDao(org.finos.waltz.data.application.ApplicationDao) List(java.util.List) Checks.checkNotNull(org.finos.waltz.common.Checks.checkNotNull) ExternalIdValue(org.finos.waltz.model.external_identifier.ExternalIdValue) EntityReference(org.finos.waltz.model.EntityReference) Optional(java.util.Optional) AppRegistrationRequest(org.finos.waltz.model.application.AppRegistrationRequest) AssetCodeRelationshipKind(org.finos.waltz.model.application.AssetCodeRelationshipKind) 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