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;
}
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;
}
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);
}
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);
}
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();
}
}
Aggregations