Search in sources :

Example 6 with OrganisationalUnit

use of org.finos.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);
    FlowClassificationRuleService authoritativeSourceService = ctx.getBean(FlowClassificationRuleService.class);
    List<FlowClassificationRule> 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(org.finos.waltz.service.orgunit.OrganisationalUnitService) OrganisationalUnitDao(org.finos.waltz.data.orgunit.OrganisationalUnitDao) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityHierarchyService(org.finos.waltz.service.entity_hierarchy.EntityHierarchyService) Node(org.finos.waltz.common.hierarchy.Node) FlatNode(org.finos.waltz.common.hierarchy.FlatNode) DSLContext(org.jooq.DSLContext) OrganisationalUnit(org.finos.waltz.model.orgunit.OrganisationalUnit) FlowClassificationRule(org.finos.waltz.model.flow_classification_rule.FlowClassificationRule) FlowClassificationRuleService(org.finos.waltz.service.flow_classification_rule.FlowClassificationRuleService) FlatNode(org.finos.waltz.common.hierarchy.FlatNode)

Example 7 with OrganisationalUnit

use of org.finos.waltz.model.orgunit.OrganisationalUnit in project waltz by khartec.

the class AppGenerator method create.

@Override
public Map<String, Integer> create(ApplicationContext ctx) {
    DSLContext dsl = getDsl(ctx);
    ApplicationService applicationDao = ctx.getBean(ApplicationService.class);
    OrganisationalUnitService ouDao = ctx.getBean(OrganisationalUnitService.class);
    List<String> animals = Unchecked.supplier(() -> readLines(getClass().getResourceAsStream("/app-names.txt"))).get();
    OrganisationalUnit[] organisationalUnits = ouDao.findAll().toArray(new OrganisationalUnit[0]);
    List<AppRegistrationRequest> registrationRequests = new ArrayList<>();
    for (int i = 0; i < NUM_APPS; i++) {
        String animal = randomPick(animals.toArray(new String[0])) + " - " + i;
        OrganisationalUnit organisationalUnit = randomPick(organisationalUnits);
        LifecyclePhase phase = rnd.nextInt(10) > 7 ? randomPick(LifecyclePhase.values()) : LifecyclePhase.PRODUCTION;
        Criticality businessCriticality = rnd.nextInt(10) > 7 ? randomPick(Criticality.values()) : Criticality.HIGH;
        AppRegistrationRequest app = ImmutableAppRegistrationRequest.builder().name(animal).assetCode("wltz-0" + i).description("All about " + animal).applicationKind(randomPick(ApplicationKind.values())).lifecyclePhase(phase).overallRating(randomPick(RagRating.R, RagRating.A, RagRating.A, RagRating.G, RagRating.G)).organisationalUnitId(organisationalUnit.id().get()).businessCriticality(businessCriticality).build();
        registrationRequests.add(app);
    }
    registrationRequests.forEach(a -> applicationDao.registerApp(a, "admin"));
    return null;
}
Also used : OrganisationalUnitService(org.finos.waltz.service.orgunit.OrganisationalUnitService) ArrayList(java.util.ArrayList) DSLContext(org.jooq.DSLContext) OrganisationalUnit(org.finos.waltz.model.orgunit.OrganisationalUnit) LifecyclePhase(org.finos.waltz.model.application.LifecyclePhase) ImmutableAppRegistrationRequest(org.finos.waltz.model.application.ImmutableAppRegistrationRequest) AppRegistrationRequest(org.finos.waltz.model.application.AppRegistrationRequest) ApplicationService(org.finos.waltz.service.application.ApplicationService) Criticality(org.finos.waltz.model.Criticality)

Example 8 with OrganisationalUnit

use of org.finos.waltz.model.orgunit.OrganisationalUnit in project waltz by khartec.

the class AppGroupService method addOrganisationalUnit.

public List<AppGroupEntry> addOrganisationalUnit(String userId, long groupId, long orgUnitId) throws InsufficientPrivelegeException {
    verifyUserCanUpdateGroup(userId, groupId);
    OrganisationalUnit orgUnit = organisationalUnitDao.getById(orgUnitId);
    if (orgUnit != null) {
        appGroupOrganisationalUnitDao.addOrgUnit(groupId, orgUnitId);
        audit(groupId, userId, format("Added application %s to group", orgUnit.name()), EntityKind.ORG_UNIT, Operation.ADD);
    }
    return appGroupOrganisationalUnitDao.getEntriesForGroup(groupId);
}
Also used : OrganisationalUnit(org.finos.waltz.model.orgunit.OrganisationalUnit)

Example 9 with OrganisationalUnit

use of org.finos.waltz.model.orgunit.OrganisationalUnit in project waltz by khartec.

the class OrgUnitTest method ouCanBeRetrievedById.

@Test
public void ouCanBeRetrievedById() {
    OrganisationalUnit rootOU = dao.getById(ouIds.root);
    assertNotNull(rootOU);
}
Also used : OrganisationalUnit(org.finos.waltz.model.orgunit.OrganisationalUnit) BaseInMemoryIntegrationTest(org.finos.waltz.integration_test.inmem.BaseInMemoryIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

OrganisationalUnit (org.finos.waltz.model.orgunit.OrganisationalUnit)9 DSLContext (org.jooq.DSLContext)5 OrganisationalUnitDao (org.finos.waltz.data.orgunit.OrganisationalUnitDao)3 Application (org.finos.waltz.model.application.Application)3 java.util (java.util)2 ArrayList (java.util.ArrayList)2 ApplicationDao (org.finos.waltz.data.application.ApplicationDao)2 LogicalFlowDao (org.finos.waltz.data.logical_flow.LogicalFlowDao)2 EntityKind (org.finos.waltz.model.EntityKind)2 EntityReference (org.finos.waltz.model.EntityReference)2 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)2 LOGICAL_FLOW (org.finos.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW)2 OrganisationalUnitService (org.finos.waltz.service.orgunit.OrganisationalUnitService)2 Condition (org.jooq.Condition)2 Tuple (org.jooq.lambda.tuple.Tuple)2 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1 LocalDateTime (java.time.LocalDateTime)1 Collections.emptyList (java.util.Collections.emptyList)1