Search in sources :

Example 6 with OrganisationalUnit

use of com.khartec.waltz.model.orgunit.OrganisationalUnit 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();
}
Also used : ImmutableEntityReference(com.khartec.waltz.model.ImmutableEntityReference) EntityReference(com.khartec.waltz.model.EntityReference) List(java.util.List) ComplexityRating(com.khartec.waltz.model.complexity.ComplexityRating) OrganisationalUnit(com.khartec.waltz.model.orgunit.OrganisationalUnit) Application(com.khartec.waltz.model.application.Application)

Example 7 with OrganisationalUnit

use of com.khartec.waltz.model.orgunit.OrganisationalUnit in project waltz by khartec.

the class AuthoritativeSourceService method logInsert.

private void logInsert(AuthoritativeSourceCreateCommand command, String username) {
    OrganisationalUnit orgUnit = organisationalUnitDao.getById(command.orgUnitId());
    DataType dataType = dataTypeDao.getById(command.dataTypeId());
    Application app = applicationDao.getById(command.applicationId());
    if (app != null && dataType != null && orgUnit != null) {
        String msg = String.format("Registered %s as an authoritative source for type: %s for org: %s", app.name(), dataType.name(), orgUnit.name());
        tripleLog(username, orgUnit, dataType, app, msg, Operation.ADD);
    }
}
Also used : DataType(com.khartec.waltz.model.datatype.DataType) OrganisationalUnit(com.khartec.waltz.model.orgunit.OrganisationalUnit) Application(com.khartec.waltz.model.application.Application)

Example 8 with OrganisationalUnit

use of com.khartec.waltz.model.orgunit.OrganisationalUnit 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);
    }
}
Also used : AuthoritativeSource(com.khartec.waltz.model.authoritativesource.AuthoritativeSource) NonAuthoritativeSource(com.khartec.waltz.model.authoritativesource.NonAuthoritativeSource) DataType(com.khartec.waltz.model.datatype.DataType) OrganisationalUnit(com.khartec.waltz.model.orgunit.OrganisationalUnit) Application(com.khartec.waltz.model.application.Application)

Example 9 with OrganisationalUnit

use of com.khartec.waltz.model.orgunit.OrganisationalUnit in project waltz by khartec.

the class LogicalFlowDecoratorRatingsServiceHarness method main.

public static void main(String[] args) throws SQLException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    AuthoritativeSourceService authoritativeSourceService = ctx.getBean(AuthoritativeSourceService.class);
    List<AuthoritativeSource> authSources = authoritativeSourceService.findAll();
    OrganisationalUnitService organisationalUnitService = ctx.getBean(OrganisationalUnitService.class);
    OrganisationalUnitDao organisationalUnitDao = ctx.getBean(OrganisationalUnitDao.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    dsl.select(ORGANISATIONAL_UNIT.fields()).from(ORGANISATIONAL_UNIT).fetch(organisationalUnitDao.TO_DOMAIN_MAPPER);
    EntityHierarchyService hierarchyService = ctx.getBean(EntityHierarchyService.class);
    List<OrganisationalUnit> allOrgUnits = organisationalUnitService.findAll();
    List<FlatNode<OrganisationalUnit, Long>> ouNodes = ListUtilities.map(allOrgUnits, ou -> new FlatNode<>(ou.id().get(), ou.parentId(), ou));
    Forest<OrganisationalUnit, Long> ouForest = HierarchyUtilities.toForest(ouNodes);
    Map<Long, Node<OrganisationalUnit, Long>> nodeMap = ouForest.getAllNodes();
}
Also used : OrganisationalUnitService(com.khartec.waltz.service.orgunit.OrganisationalUnitService) OrganisationalUnitDao(com.khartec.waltz.data.orgunit.OrganisationalUnitDao) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityHierarchyService(com.khartec.waltz.service.entity_hierarchy.EntityHierarchyService) Node(com.khartec.waltz.common.hierarchy.Node) FlatNode(com.khartec.waltz.common.hierarchy.FlatNode) AuthoritativeSource(com.khartec.waltz.model.authoritativesource.AuthoritativeSource) DSLContext(org.jooq.DSLContext) AuthoritativeSourceService(com.khartec.waltz.service.authoritative_source.AuthoritativeSourceService) OrganisationalUnit(com.khartec.waltz.model.orgunit.OrganisationalUnit) FlatNode(com.khartec.waltz.common.hierarchy.FlatNode)

Example 10 with OrganisationalUnit

use of com.khartec.waltz.model.orgunit.OrganisationalUnit in project waltz by khartec.

the class AdditiveFlowGenerator 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();
    Application referenceApplication = applicationDao.getById(APPLICATION_ID);
    List<OrganisationalUnit> orgUnits = orgUnitDao.findAll();
    Set<LogicalFlow> expectedFlows = authSources.stream().map(a -> {
        long orgUnitId = a.parentReference().id();
        if (referenceApplication.organisationalUnitId().equals(orgUnitId)) {
            return Optional.of(ImmutableLogicalFlow.builder().source(a.applicationReference()).target(referenceApplication.entityReference()).build());
        } else {
            return Optional.<LogicalFlow>empty();
        }
    }).filter(o -> o.isPresent()).map(o -> o.get()).collect(toSet());
    Set<LogicalFlow> randomTargetFlows = IntStream.range(0, rnd.nextInt(APPROX_FLOW_GENERATION_COUNT / 2)).mapToObj(i -> {
        EntityReference target = randomAppPick(apps, randomPick(orgUnits).id().get());
        return ImmutableLogicalFlow.builder().source(referenceApplication.entityReference()).target(target).build();
    }).collect(toSet());
    Set<LogicalFlow> randomSourceFlows = IntStream.range(0, rnd.nextInt(APPROX_FLOW_GENERATION_COUNT / 2)).mapToObj(i -> {
        EntityReference source = randomAppPick(apps, randomPick(orgUnits).id().get());
        return ImmutableLogicalFlow.builder().source(source).target(referenceApplication.entityReference()).build();
    }).collect(toSet());
    dsl.delete(LOGICAL_FLOW).where(LOGICAL_FLOW.SOURCE_ENTITY_ID.eq(APPLICATION_ID)).or(LOGICAL_FLOW.TARGET_ENTITY_ID.eq(APPLICATION_ID)).execute();
    Set<LogicalFlow> all = new HashSet<>();
    all.addAll(randomTargetFlows);
    all.addAll(randomSourceFlows);
    all.addAll(expectedFlows);
    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");
}
Also used : OrganisationalUnitService(com.khartec.waltz.service.orgunit.OrganisationalUnitService) Application(com.khartec.waltz.model.application.Application) IntStream(java.util.stream.IntStream) java.util(java.util) AuthoritativeSource(com.khartec.waltz.model.authoritativesource.AuthoritativeSource) SetUtilities(com.khartec.waltz.common.SetUtilities) OrganisationalUnit(com.khartec.waltz.model.orgunit.OrganisationalUnit) LogicalFlowService(com.khartec.waltz.service.logical_flow.LogicalFlowService) EntityReference(com.khartec.waltz.model.EntityReference) AuthoritativeSourceDao(com.khartec.waltz.data.authoritative_source.AuthoritativeSourceDao) LogicalFlow(com.khartec.waltz.model.logical_flow.LogicalFlow) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityKind(com.khartec.waltz.model.EntityKind) ListUtilities.randomPick(com.khartec.waltz.common.ListUtilities.randomPick) Collectors.toList(java.util.stream.Collectors.toList) ImmutableLogicalFlow(com.khartec.waltz.model.logical_flow.ImmutableLogicalFlow) DIConfiguration(com.khartec.waltz.service.DIConfiguration) OrganisationalUnitService(com.khartec.waltz.service.orgunit.OrganisationalUnitService) LogicalFlowDao(com.khartec.waltz.data.logical_flow.LogicalFlowDao) DSLContext(org.jooq.DSLContext) ApplicationService(com.khartec.waltz.service.application.ApplicationService) LogicalFlowRecord(com.khartec.waltz.schema.tables.records.LogicalFlowRecord) Collectors.toSet(java.util.stream.Collectors.toSet) LOGICAL_FLOW(com.khartec.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) LogicalFlowRecord(com.khartec.waltz.schema.tables.records.LogicalFlowRecord) LogicalFlowService(com.khartec.waltz.service.logical_flow.LogicalFlowService) AuthoritativeSourceDao(com.khartec.waltz.data.authoritative_source.AuthoritativeSourceDao) DSLContext(org.jooq.DSLContext) AuthoritativeSource(com.khartec.waltz.model.authoritativesource.AuthoritativeSource) OrganisationalUnit(com.khartec.waltz.model.orgunit.OrganisationalUnit) LogicalFlow(com.khartec.waltz.model.logical_flow.LogicalFlow) ImmutableLogicalFlow(com.khartec.waltz.model.logical_flow.ImmutableLogicalFlow) EntityReference(com.khartec.waltz.model.EntityReference) Application(com.khartec.waltz.model.application.Application) ApplicationService(com.khartec.waltz.service.application.ApplicationService)

Aggregations

OrganisationalUnit (com.khartec.waltz.model.orgunit.OrganisationalUnit)11 Application (com.khartec.waltz.model.application.Application)8 DSLContext (org.jooq.DSLContext)7 AuthoritativeSource (com.khartec.waltz.model.authoritativesource.AuthoritativeSource)5 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)5 OrganisationalUnitDao (com.khartec.waltz.data.orgunit.OrganisationalUnitDao)4 EntityReference (com.khartec.waltz.model.EntityReference)4 OrganisationalUnitService (com.khartec.waltz.service.orgunit.OrganisationalUnitService)4 List (java.util.List)4 EntityKind (com.khartec.waltz.model.EntityKind)3 DataType (com.khartec.waltz.model.datatype.DataType)3 DIConfiguration (com.khartec.waltz.service.DIConfiguration)3 ApplicationService (com.khartec.waltz.service.application.ApplicationService)3 EntityHierarchyService (com.khartec.waltz.service.entity_hierarchy.EntityHierarchyService)3 Collectors.toList (java.util.stream.Collectors.toList)3 IntStream (java.util.stream.IntStream)3 ListUtilities.randomPick (com.khartec.waltz.common.ListUtilities.randomPick)2 SetUtilities (com.khartec.waltz.common.SetUtilities)2 ApplicationDao (com.khartec.waltz.data.application.ApplicationDao)2 AuthoritativeSourceDao (com.khartec.waltz.data.authoritative_source.AuthoritativeSourceDao)2