use of com.khartec.waltz.model.authoritativesource.AuthoritativeSource 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.authoritativesource.AuthoritativeSource 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.authoritativesource.AuthoritativeSource in project waltz by khartec.
the class AuthoritativeSourceService method remove.
public int remove(long id, String username) {
logRemoval(id, username);
AuthoritativeSource authSourceToDelete = getById(id);
int deletedCount = authoritativeSourceDao.remove(id);
ratingCalculator.update(authSourceToDelete.dataType(), authSourceToDelete.parentReference());
return deletedCount;
}
use of com.khartec.waltz.model.authoritativesource.AuthoritativeSource in project waltz by khartec.
the class AuthoritativeSourceService method update.
public int update(AuthoritativeSourceUpdateCommand command, String username) {
int updateCount = authoritativeSourceDao.update(command);
AuthoritativeSource updatedAuthSource = getById(command.id().get());
ratingCalculator.update(updatedAuthSource.dataType(), updatedAuthSource.parentReference());
logUpdate(command, username);
return updateCount;
}
use of com.khartec.waltz.model.authoritativesource.AuthoritativeSource in project waltz by khartec.
the class AuthoritativeSourceService method logUpdate.
private void logUpdate(AuthoritativeSourceUpdateCommand command, String username) {
AuthoritativeSource authSource = getById(command.id().get());
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("Updated %s as an authoritative source for type: %s for org: %s", app.name(), dataType.name(), orgUnit.name());
tripleLog(username, orgUnit, dataType, app, msg, Operation.UPDATE);
}
}
Aggregations