Search in sources :

Example 21 with Application

use of org.finos.waltz.model.application.Application in project waltz by finos.

the class InvolvementImporter method main.

public static void main(String[] args) throws IOException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    ApplicationService applicationService = ctx.getBean(ApplicationService.class);
    PersonService personService = ctx.getBean(PersonService.class);
    Map<String, Application> appsByExtId = indexBy(a -> ExternalIdValue.orElse(a.assetCode(), null), applicationService.findAll());
    Map<String, Person> peopleByName = indexBy(p -> toSurnameFirstname(p.displayName()).toLowerCase(), personService.all());
    Siphon<String[]> incorrectSizeSiphon = mkSiphon(arr -> arr.length != 3);
    Siphon<Tuple2<String, ?>> unknownAppSiphon = mkSiphon(t -> !appsByExtId.containsKey(t.v1));
    Siphon<Tuple2<?, String>> unknownPersonSiphon = mkSiphon(t -> !peopleByName.containsKey(t.v2.toLowerCase()));
    Siphon<Tuple2<Application, ?>> retiredAppSiphon = mkSiphon(t -> t.v1.lifecyclePhase() == LifecyclePhase.RETIRED);
    List<Tuple2<Application, Person>> r = IOUtilities.streamLines(classLoader.getResourceAsStream(fileName)).map(line -> line.split("\t")).filter(d -> incorrectSizeSiphon.test(d)).map(arr -> Tuple.tuple(arr[1], arr[0])).filter(t -> unknownAppSiphon.test(t)).map(t -> t.map1(extId -> appsByExtId.get(extId))).filter(t -> retiredAppSiphon.test(t)).filter(t -> unknownPersonSiphon.test(t)).map(t -> t.map2(n -> peopleByName.get(n.toLowerCase()))).collect(Collectors.toList());
    Set<Application> distinctApps = r.stream().map(t -> t.v1).distinct().collect(Collectors.toSet());
    Set<Person> distinctPeople = r.stream().map(t -> t.v2).distinct().collect(Collectors.toSet());
    System.out.println("----");
    System.out.println("Wrong size count: " + incorrectSizeSiphon.getResults().size());
    System.out.println("Apps not found count: " + unknownAppSiphon.getResults().size());
    System.out.println("Retired app count: " + retiredAppSiphon.getResults().size());
    System.out.println("Person not found count: " + unknownPersonSiphon.getResults().size());
    System.out.println("----");
    System.out.println("Good record count: " + r.size());
    System.out.println("Distinct App count: " + distinctApps.size());
    System.out.println("Distinct People count: " + distinctPeople.size());
    Map<String, Long> unknownPersonCounts = countBy(Tuple2::v2, unknownPersonSiphon.getResults());
    DebugUtilities.dump(unknownPersonCounts);
}
Also used : LifecyclePhase(org.finos.waltz.model.application.LifecyclePhase) ApplicationService(org.finos.waltz.service.application.ApplicationService) Application(org.finos.waltz.model.application.Application) ArrayUtilities(org.finos.waltz.common.ArrayUtilities) Set(java.util.Set) StreamUtilities.mkSiphon(org.finos.waltz.common.StreamUtilities.mkSiphon) DIConfiguration(org.finos.waltz.service.DIConfiguration) IOException(java.io.IOException) PersonService(org.finos.waltz.service.person.PersonService) MapUtilities.countBy(org.finos.waltz.common.MapUtilities.countBy) Collectors(java.util.stream.Collectors) IOUtilities(org.finos.waltz.common.IOUtilities) Person(org.finos.waltz.model.person.Person) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MapUtilities.indexBy(org.finos.waltz.common.MapUtilities.indexBy) Tuple2(org.jooq.lambda.tuple.Tuple2) List(java.util.List) DebugUtilities(org.finos.waltz.common.DebugUtilities) ExternalIdValue(org.finos.waltz.model.external_identifier.ExternalIdValue) Tuple(org.jooq.lambda.tuple.Tuple) Map(java.util.Map) Siphon(org.finos.waltz.common.StreamUtilities.Siphon) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) PersonService(org.finos.waltz.service.person.PersonService) Tuple2(org.jooq.lambda.tuple.Tuple2) Application(org.finos.waltz.model.application.Application) Person(org.finos.waltz.model.person.Person) ApplicationService(org.finos.waltz.service.application.ApplicationService)

Example 22 with Application

use of org.finos.waltz.model.application.Application in project waltz by finos.

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);
}
Also used : Application(org.finos.waltz.model.application.Application)

Example 23 with Application

use of org.finos.waltz.model.application.Application in project waltz by finos.

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);
}
Also used : Application(org.finos.waltz.model.application.Application)

Example 24 with Application

use of org.finos.waltz.model.application.Application in project waltz by finos.

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;
}
Also used : OrganisationalUnitDao(org.finos.waltz.data.orgunit.OrganisationalUnitDao) EntityStatisticDefinitionDao(org.finos.waltz.data.entity_statistic.EntityStatisticDefinitionDao) EntityStatisticValueDao(org.finos.waltz.data.entity_statistic.EntityStatisticValueDao) EntityHierarchyService(org.finos.waltz.service.entity_hierarchy.EntityHierarchyService) DSLContext(org.jooq.DSLContext) ApplicationDao(org.finos.waltz.data.application.ApplicationDao) OrganisationalUnit(org.finos.waltz.model.orgunit.OrganisationalUnit) Application(org.finos.waltz.model.application.Application)

Example 25 with Application

use of org.finos.waltz.model.application.Application in project waltz by finos.

the class AppHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    // Water & Vole
    // P&S Blotter
    // P & S Gorilla
    List<Application> jimmy = new SqlServerAppSearch().searchFullText(dsl, EntitySearchOptions.mkForEntity(EntityKind.APPLICATION, "Water & Vole"));
    System.out.println(jimmy);
// ApplicationService applicationService = ctx.getBean(ApplicationService.class);
// DSLContext dsl = ctx.getBean(DSLContext.class);
// 
// List<String> tagList = applicationService.findAllTags();
// 
// tagList.forEach(System.out::println);
// 
// System.out.println("---------------");
// 
// applicationService.findByTag("not-good-at-flying").forEach(a -> System.out.println(a.name()));
// 
// System.out.println(applicationService.findTagsForApplication(521L));
// 
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) SqlServerAppSearch(org.finos.waltz.data.application.search.SqlServerAppSearch) DSLContext(org.jooq.DSLContext) Application(org.finos.waltz.model.application.Application)

Aggregations

Application (org.finos.waltz.model.application.Application)54 DSLContext (org.jooq.DSLContext)24 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)24 EntityKind (org.finos.waltz.model.EntityKind)22 Collectors (java.util.stream.Collectors)20 ApplicationDao (org.finos.waltz.data.application.ApplicationDao)18 EntityReference (org.finos.waltz.model.EntityReference)18 DIConfiguration (org.finos.waltz.service.DIConfiguration)18 ExternalIdValue (org.finos.waltz.model.external_identifier.ExternalIdValue)16 List (java.util.List)14 IOException (java.io.IOException)12 java.util (java.util)12 Map (java.util.Map)12 DataType (org.finos.waltz.model.datatype.DataType)12 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)12 ApplicationService (org.finos.waltz.service.application.ApplicationService)12 Tuple (org.jooq.lambda.tuple.Tuple)12 LogicalFlowDao (org.finos.waltz.data.logical_flow.LogicalFlowDao)10 CsvPreference (org.supercsv.prefs.CsvPreference)10 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)8