use of com.khartec.waltz.model.application.Application in project waltz by khartec.
the class AuthoritativeSourceService method logRemoval.
private void logRemoval(long id, String username) {
AuthoritativeSource authSource = getById(id);
if (authSource == null) {
return;
}
OrganisationalUnit orgUnit = organisationalUnitDao.getById(authSource.parentReference().id());
DataType dataType = dataTypeDao.getByCode(authSource.dataType());
Application app = applicationDao.getById(authSource.applicationReference().id());
if (app != null && dataType != null && orgUnit != null) {
String msg = String.format("Removed %s as an authoritative source for type: %s for org: %s", app.name(), dataType.name(), orgUnit.name());
tripleLog(username, orgUnit, dataType, app, msg, Operation.REMOVE);
}
}
use of com.khartec.waltz.model.application.Application in project waltz by khartec.
the class EntityStatisticGenerator method createIntStatsFor.
private void createIntStatsFor(EntityStatisticDefinition defn, Application[] applications, EntityStatisticValueDao valueDao, int bound, BiFunction<StatisticValueState, Integer, String> outcomeFn) {
Random rnd = new Random(System.currentTimeMillis());
List<EntityStatisticValue> values = streamAppRefs(applications).map(appRef -> {
StatisticValueState state = randomPick(StatisticValueState.values());
int v = state == StatisticValueState.PROVIDED ? rnd.nextInt(bound) : 0;
// naughty
v = rnd.nextInt(bound);
return ImmutableEntityStatisticValue.builder().entity(appRef).state(state).statisticId(defn.id().get()).current(true).createdAt(LocalDateTime.now()).value(Integer.toString(v)).outcome(outcomeFn.apply(state, v)).provenance(PROVENANCE).build();
}).collect(toList());
valueDao.bulkSaveValues(values);
}
use of com.khartec.waltz.model.application.Application in project waltz by khartec.
the class FlowGenerator method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
AuthoritativeSourceDao authSourceDao = ctx.getBean(AuthoritativeSourceDao.class);
ApplicationService applicationDao = ctx.getBean(ApplicationService.class);
LogicalFlowService dataFlowDao = ctx.getBean(LogicalFlowService.class);
OrganisationalUnitService orgUnitDao = ctx.getBean(OrganisationalUnitService.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
List<AuthoritativeSource> authSources = authSourceDao.findByEntityKind(EntityKind.ORG_UNIT);
List<Application> apps = applicationDao.findAll();
List<OrganisationalUnit> orgUnits = orgUnitDao.findAll();
Set<LogicalFlow> expectedFlows = authSources.stream().flatMap(a -> {
long orgUnitId = a.parentReference().id();
return IntStream.range(0, rnd.nextInt(40)).mapToObj(i -> ImmutableLogicalFlow.builder().source(a.applicationReference()).target(randomAppPick(apps, orgUnitId)).build());
}).collect(toSet());
Set<LogicalFlow> probableFlows = authSources.stream().flatMap(a -> IntStream.range(0, rnd.nextInt(30)).mapToObj(i -> ImmutableLogicalFlow.builder().source(a.applicationReference()).target(randomAppPick(apps, randomPick(orgUnits).id().get())).build())).collect(toSet());
Set<LogicalFlow> randomFlows = apps.stream().flatMap(a -> IntStream.range(0, rnd.nextInt(5)).mapToObj(i -> {
EntityReference target = randomAppPick(apps, randomPick(orgUnits).id().get());
return ImmutableLogicalFlow.builder().source(a.entityReference()).target(target).lastUpdatedBy("admin").build();
})).collect(toSet());
dsl.deleteFrom(LOGICAL_FLOW).execute();
Set<LogicalFlow> all = new HashSet<>();
all.addAll(randomFlows);
all.addAll(expectedFlows);
all.addAll(probableFlows);
System.out.println("--- saving: " + all.size());
Set<LogicalFlowRecord> records = SetUtilities.map(all, df -> LogicalFlowDao.TO_RECORD_MAPPER.apply(df, dsl));
dsl.batchStore(records).execute();
System.out.println("--- done");
}
use of com.khartec.waltz.model.application.Application in project waltz by khartec.
the class AppGroupService method removeApplication.
public List<EntityReference> removeApplication(String userId, long groupId, long applicationId) throws InsufficientPrivelegeException {
verifyUserCanUpdateGroup(userId, groupId);
appGroupEntryDao.removeApplication(groupId, applicationId);
Application app = applicationDao.getById(applicationId);
audit(groupId, userId, String.format("Removed application %s from group", app != null ? app.name() : applicationId), EntityKind.APPLICATION, Operation.REMOVE);
return appGroupEntryDao.getEntriesForGroup(groupId);
}
use of com.khartec.waltz.model.application.Application in project waltz by khartec.
the class AppViewService method getAppView.
public AppView getAppView(long id) {
EntityReference ref = ImmutableEntityReference.builder().kind(EntityKind.APPLICATION).id(id).build();
Future<Application> application = dbExecutorPool.submit(() -> applicationService.getById(id));
Future<OrganisationalUnit> orgUnit = dbExecutorPool.submit(() -> organisationalUnitService.getByAppId(id));
Future<List<String>> tags = dbExecutorPool.submit(() -> entityTagService.findTagsForEntityReference(mkRef(EntityKind.APPLICATION, id)));
Future<List<String>> aliases = dbExecutorPool.submit(() -> entityAliasService.findAliasesForEntityReference(ref));
Future<ComplexityRating> complexity = dbExecutorPool.submit(() -> complexityRatingService.getForApp(id));
return Unchecked.supplier(() -> ImmutableAppView.builder().app(application.get()).organisationalUnit(orgUnit.get()).tags(tags.get()).aliases(aliases.get()).complexity(complexity.get()).build()).get();
}
Aggregations