Search in sources :

Example 21 with Record1

use of org.jooq.Record1 in project waltz by khartec.

the class EndUserAppIdSelectorFactory method mkForPersonReportees.

private Select<Record1<Long>> mkForPersonReportees(IdSelectionOptions options) {
    if (eucOmitted(options)) {
        return mkEmptySelect();
    }
    Select<Record1<String>> employeeId = mkEmployeeIdSelect(options.entityReference());
    SelectConditionStep<Record1<String>> reporteeIds = DSL.selectDistinct(personHierarchy.EMPLOYEE_ID).from(personHierarchy).where(personHierarchy.MANAGER_ID.eq(employeeId));
    Condition condition = involvement.ENTITY_KIND.eq(EntityKind.END_USER_APPLICATION.name()).and(involvement.EMPLOYEE_ID.eq(employeeId).or(involvement.EMPLOYEE_ID.in(reporteeIds)));
    return DSL.selectDistinct(involvement.ENTITY_ID).from(involvement).innerJoin(eua).on(eua.ID.eq(involvement.ENTITY_ID)).where(condition);
}
Also used : Condition(org.jooq.Condition) Record1(org.jooq.Record1)

Example 22 with Record1

use of org.jooq.Record1 in project waltz by khartec.

the class FlowSummaryWithTypesAndPhysicalsExport method mkAppIdSelector.

private static Select<Record1<Long>> mkAppIdSelector(ApplicationIdSelectorFactory appIdSelectorFactory) {
    EntityReference infraRef = mkRef(EntityKind.ORG_UNIT, 6811);
    EntityReference entRiskRef = mkRef(EntityKind.ORG_UNIT, 3125);
    EntityReference regCtrlRef = mkRef(EntityKind.ORG_UNIT, 2761);
    Function<EntityReference, Select<Record1<Long>>> mkOrgUnitSelector = (ref) -> DSL.select(ENTITY_HIERARCHY.ID).from(ENTITY_HIERARCHY).where(ENTITY_HIERARCHY.ANCESTOR_ID.eq(ref.id())).and(ENTITY_HIERARCHY.KIND.eq(ref.kind().name()));
    Select<Record1<Long>> ouSelector = DSL.selectFrom(mkOrgUnitSelector.apply(infraRef).unionAll(mkOrgUnitSelector.apply(entRiskRef)).unionAll(mkOrgUnitSelector.apply(regCtrlRef)).asTable());
    return DSL.select(APPLICATION.ID).from(APPLICATION).where(APPLICATION.ORGANISATIONAL_UNIT_ID.in(ouSelector)).and(APPLICATION.LIFECYCLE_PHASE.notEqual(EntityLifecycleStatus.REMOVED.name())).and(APPLICATION.IS_REMOVED.isFalse());
}
Also used : OrganisationalUnitDao(org.finos.waltz.data.orgunit.OrganisationalUnitDao) java.util(java.util) LogicalFlowDao(org.finos.waltz.data.logical_flow.LogicalFlowDao) DSL(org.jooq.impl.DSL) Tables(org.finos.waltz.schema.Tables) EntityKind(org.finos.waltz.model.EntityKind) DIConfiguration(org.finos.waltz.service.DIConfiguration) ListUtilities.newArrayList(org.finos.waltz.common.ListUtilities.newArrayList) CsvPreference(org.supercsv.prefs.CsvPreference) Function(java.util.function.Function) Condition(org.jooq.Condition) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) DataType(org.finos.waltz.model.datatype.DataType) LOGICAL_FLOW(org.finos.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW) LOGICAL_NOT_REMOVED(org.finos.waltz.data.logical_flow.LogicalFlowDao.LOGICAL_NOT_REMOVED) Record1(org.jooq.Record1) CsvListWriter(org.supercsv.io.CsvListWriter) MapUtilities.groupBy(org.finos.waltz.common.MapUtilities.groupBy) Tuple7(org.jooq.lambda.tuple.Tuple7) DSLContext(org.jooq.DSLContext) OutputStreamWriter(java.io.OutputStreamWriter) ApplicationIdSelectorFactory(org.finos.waltz.data.application.ApplicationIdSelectorFactory) Select(org.jooq.Select) StringUtilities(org.finos.waltz.common.StringUtilities) EntityLifecycleStatus(org.finos.waltz.model.EntityLifecycleStatus) OrganisationalUnit(org.finos.waltz.model.orgunit.OrganisationalUnit) Unchecked(org.jooq.lambda.Unchecked) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) Application(org.finos.waltz.model.application.Application) DataTypeDecorator(org.finos.waltz.model.datatype.DataTypeDecorator) Collections.emptyList(java.util.Collections.emptyList) IdUtilities.toIds(org.finos.waltz.model.utils.IdUtilities.toIds) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) NameProvider(org.finos.waltz.model.NameProvider) ApplicationDao(org.finos.waltz.data.application.ApplicationDao) LogicalFlowDecoratorDao(org.finos.waltz.data.datatype_decorator.LogicalFlowDecoratorDao) ExternalIdValue(org.finos.waltz.model.external_identifier.ExternalIdValue) Tuple(org.jooq.lambda.tuple.Tuple) Tuple.tuple(org.jooq.lambda.tuple.Tuple.tuple) EntityReference(org.finos.waltz.model.EntityReference) DataTypeDao(org.finos.waltz.data.data_type.DataTypeDao) IdUtilities.indexByOptId(org.finos.waltz.model.utils.IdUtilities.indexByOptId) SetUtilities.fromCollection(org.finos.waltz.common.SetUtilities.fromCollection) EntityReference(org.finos.waltz.model.EntityReference) Select(org.jooq.Select) Record1(org.jooq.Record1)

Example 23 with Record1

use of org.jooq.Record1 in project waltz by khartec.

the class FlowSummaryWithTypesAndPhysicalsExport method main.

public static void main(String[] args) throws IOException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    ApplicationIdSelectorFactory appIdSelectorFactory = new ApplicationIdSelectorFactory();
    ApplicationDao applicationDao = ctx.getBean(ApplicationDao.class);
    OrganisationalUnitDao organisationalUnitDao = ctx.getBean(OrganisationalUnitDao.class);
    LogicalFlowDao logicalFlowDao = ctx.getBean(LogicalFlowDao.class);
    LogicalFlowDecoratorDao decoratorDao = ctx.getBean(LogicalFlowDecoratorDao.class);
    DataTypeDao dataTypeDao = ctx.getBean(DataTypeDao.class);
    Select<Record1<Long>> appSelector = mkAppIdSelector(appIdSelectorFactory);
    Select<Record1<Long>> logicalFlowSelector = mkLogicalFlowSelectorFromAppSelector(appSelector);
    System.out.println("Loading apps");
    Set<Application> allApps = fromCollection(applicationDao.findAll());
    System.out.println("Loading in scope apps");
    Set<Long> inScopeAppIds = toIds(applicationDao.findByAppIdSelector(appSelector));
    System.out.println("Loading OUs");
    List<OrganisationalUnit> allOUs = organisationalUnitDao.findAll();
    System.out.println("Loading DTs");
    List<DataType> allDataTypes = dataTypeDao.findAll();
    System.out.println("Loading Logical Flows");
    List<LogicalFlow> logicalFlows = logicalFlowDao.findBySelector(logicalFlowSelector);
    System.out.println("Loading decorators");
    List<DataTypeDecorator> decorators = decoratorDao.findByAppIdSelector(appSelector);
    System.out.println("Loading phys flows");
    Map<Long, Collection<Tuple7<Long, String, String, String, String, String, String>>> physicalsByLogical = loadPhysicalsByLogical(dsl, logicalFlowSelector);
    System.out.println("Indexing");
    Map<Optional<Long>, Application> appsById = indexByOptId(allApps);
    Map<Optional<Long>, DataType> dataTypesById = indexByOptId(allDataTypes);
    Map<Optional<Long>, OrganisationalUnit> ousById = indexByOptId(allOUs);
    Map<Long, Collection<DataTypeDecorator>> decoratorsByLogicalFlowId = groupBy(DataTypeDecorator::dataFlowId, decorators);
    System.out.println("Processing");
    CsvListWriter csvWriter = setupCSVWriter();
    logicalFlows.stream().filter(lf -> lf.source().kind() == EntityKind.APPLICATION && lf.target().kind() == EntityKind.APPLICATION).map(Tuple::tuple).map(t -> t.concat(appsById.get(Optional.of(t.v1.source().id())))).map(t -> t.concat(appsById.get(Optional.of(t.v1.target().id())))).filter(t -> t.v2 != null && t.v3 != null).map(t -> t.concat(ousById.get(Optional.of(t.v2.organisationalUnitId())))).map(t -> t.concat(ousById.get(Optional.of(t.v3.organisationalUnitId())))).map(t -> t.concat(decoratorsByLogicalFlowId.getOrDefault(t.v1.id().orElse(-1L), emptyList()).stream().filter(d -> d.decoratorEntity().kind() == EntityKind.DATA_TYPE).map(d -> dataTypesById.get(Optional.of(d.decoratorEntity().id()))).sorted(Comparator.comparing(NameProvider::name)).collect(Collectors.toList()))).map(t -> t.concat(inScopeAppIds.contains(t.v2.id().get()))).map(t -> t.concat(inScopeAppIds.contains(t.v3.id().get()))).flatMap(t -> physicalsByLogical.getOrDefault(t.v1.id().orElse(-1L), newArrayList(tuple(-1L, "-", "-", "-", "-", "-", "-"))).stream().map(p -> t.concat(p.skip1()))).map(t -> newArrayList(// src
    t.v2.name(), t.v2.assetCode().map(ExternalIdValue::value).orElse(""), t.v2.applicationKind().name(), t.v2.entityLifecycleStatus().name(), // src OU
    Optional.ofNullable(t.v4).map(NameProvider::name).orElse("?"), t.v7.toString(), // trg
    t.v3.name(), t.v3.assetCode().map(ExternalIdValue::value).orElse(""), t.v3.applicationKind().name(), t.v3.entityLifecycleStatus().name(), // trg OU
    Optional.ofNullable(t.v5).map(NameProvider::name).orElse("?"), t.v8.toString(), StringUtilities.joinUsing(t.v6, NameProvider::name, ","), t.v9, t.v10, t.v11, t.v12, t.v13, t.v14)).forEach(Unchecked.consumer(csvWriter::write));
}
Also used : OrganisationalUnitDao(org.finos.waltz.data.orgunit.OrganisationalUnitDao) OrganisationalUnitDao(org.finos.waltz.data.orgunit.OrganisationalUnitDao) java.util(java.util) LogicalFlowDao(org.finos.waltz.data.logical_flow.LogicalFlowDao) DSL(org.jooq.impl.DSL) Tables(org.finos.waltz.schema.Tables) EntityKind(org.finos.waltz.model.EntityKind) DIConfiguration(org.finos.waltz.service.DIConfiguration) ListUtilities.newArrayList(org.finos.waltz.common.ListUtilities.newArrayList) CsvPreference(org.supercsv.prefs.CsvPreference) Function(java.util.function.Function) Condition(org.jooq.Condition) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) DataType(org.finos.waltz.model.datatype.DataType) LOGICAL_FLOW(org.finos.waltz.schema.tables.LogicalFlow.LOGICAL_FLOW) LOGICAL_NOT_REMOVED(org.finos.waltz.data.logical_flow.LogicalFlowDao.LOGICAL_NOT_REMOVED) Record1(org.jooq.Record1) CsvListWriter(org.supercsv.io.CsvListWriter) MapUtilities.groupBy(org.finos.waltz.common.MapUtilities.groupBy) Tuple7(org.jooq.lambda.tuple.Tuple7) DSLContext(org.jooq.DSLContext) OutputStreamWriter(java.io.OutputStreamWriter) ApplicationIdSelectorFactory(org.finos.waltz.data.application.ApplicationIdSelectorFactory) Select(org.jooq.Select) StringUtilities(org.finos.waltz.common.StringUtilities) EntityLifecycleStatus(org.finos.waltz.model.EntityLifecycleStatus) OrganisationalUnit(org.finos.waltz.model.orgunit.OrganisationalUnit) Unchecked(org.jooq.lambda.Unchecked) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) Application(org.finos.waltz.model.application.Application) DataTypeDecorator(org.finos.waltz.model.datatype.DataTypeDecorator) Collections.emptyList(java.util.Collections.emptyList) IdUtilities.toIds(org.finos.waltz.model.utils.IdUtilities.toIds) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) NameProvider(org.finos.waltz.model.NameProvider) ApplicationDao(org.finos.waltz.data.application.ApplicationDao) LogicalFlowDecoratorDao(org.finos.waltz.data.datatype_decorator.LogicalFlowDecoratorDao) ExternalIdValue(org.finos.waltz.model.external_identifier.ExternalIdValue) Tuple(org.jooq.lambda.tuple.Tuple) Tuple.tuple(org.jooq.lambda.tuple.Tuple.tuple) EntityReference(org.finos.waltz.model.EntityReference) DataTypeDao(org.finos.waltz.data.data_type.DataTypeDao) IdUtilities.indexByOptId(org.finos.waltz.model.utils.IdUtilities.indexByOptId) SetUtilities.fromCollection(org.finos.waltz.common.SetUtilities.fromCollection) DataTypeDao(org.finos.waltz.data.data_type.DataTypeDao) ApplicationDao(org.finos.waltz.data.application.ApplicationDao) OrganisationalUnit(org.finos.waltz.model.orgunit.OrganisationalUnit) LogicalFlowDao(org.finos.waltz.data.logical_flow.LogicalFlowDao) LogicalFlowDecoratorDao(org.finos.waltz.data.datatype_decorator.LogicalFlowDecoratorDao) DataType(org.finos.waltz.model.datatype.DataType) Record1(org.jooq.Record1) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) DSLContext(org.jooq.DSLContext) LogicalFlow(org.finos.waltz.model.logical_flow.LogicalFlow) DataTypeDecorator(org.finos.waltz.model.datatype.DataTypeDecorator) ApplicationIdSelectorFactory(org.finos.waltz.data.application.ApplicationIdSelectorFactory) NameProvider(org.finos.waltz.model.NameProvider) SetUtilities.fromCollection(org.finos.waltz.common.SetUtilities.fromCollection) ExternalIdValue(org.finos.waltz.model.external_identifier.ExternalIdValue) Application(org.finos.waltz.model.application.Application) CsvListWriter(org.supercsv.io.CsvListWriter)

Example 24 with Record1

use of org.jooq.Record1 in project waltz by khartec.

the class MeasurableHarness method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    MeasurableIdSelectorFactory factory = new MeasurableIdSelectorFactory();
    MeasurableService measurableService = ctx.getBean(MeasurableService.class);
    EntityReference ref = mkRef(EntityKind.PERSON, 172272);
    IdSelectionOptions options = mkOpts(ref, HierarchyQueryScope.CHILDREN);
    Select<Record1<Long>> selector = factory.apply(options);
    System.out.println("--selector");
    System.out.println(selector);
    System.out.println("---");
    List<Measurable> measurables = measurableService.findByMeasurableIdSelector(options);
    measurables.forEach(System.out::println);
    System.out.println("-----");
    measurables.stream().filter(m -> OptionalUtilities.contentsEqual(m.id(), 486L)).forEach(System.out::println);
    System.out.println(measurables.size());
}
Also used : IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) OptionalUtilities(org.finos.waltz.common.OptionalUtilities) EntityKind(org.finos.waltz.model.EntityKind) IdSelectionOptions.mkOpts(org.finos.waltz.model.IdSelectionOptions.mkOpts) DIConfiguration(org.finos.waltz.service.DIConfiguration) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) List(java.util.List) Measurable(org.finos.waltz.model.measurable.Measurable) Record1(org.jooq.Record1) MeasurableService(org.finos.waltz.service.measurable.MeasurableService) EntityReference(org.finos.waltz.model.EntityReference) MeasurableIdSelectorFactory(org.finos.waltz.data.measurable.MeasurableIdSelectorFactory) Select(org.jooq.Select) HierarchyQueryScope(org.finos.waltz.model.HierarchyQueryScope) Measurable(org.finos.waltz.model.measurable.Measurable) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MeasurableIdSelectorFactory(org.finos.waltz.data.measurable.MeasurableIdSelectorFactory) EntityReference(org.finos.waltz.model.EntityReference) MeasurableService(org.finos.waltz.service.measurable.MeasurableService) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 25 with Record1

use of org.jooq.Record1 in project waltz by khartec.

the class MeasurableRatingHarness method main.

public static void main(String[] args) throws ParseException {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    MeasurableRatingDao measurableRatingDao = ctx.getBean(MeasurableRatingDao.class);
    MeasurableIdSelectorFactory measurableIdSelectorFactory = new MeasurableIdSelectorFactory();
    EntityReference direct = mkRef(MEASURABLE, 18310);
    EntityReference indirect = mkRef(MEASURABLE, 18064);
    IdSelectionOptions directOpts = IdSelectionOptions.mkOpts(direct, CHILDREN);
    IdSelectionOptions indirectOpts = IdSelectionOptions.mkOpts(indirect, CHILDREN);
    Select<Record1<Long>> directSelector = measurableIdSelectorFactory.apply(directOpts);
    Select<Record1<Long>> indirectSelector = measurableIdSelectorFactory.apply(indirectOpts);
    List<MeasurableRatingTally> directTallies = measurableRatingDao.statsForRelatedMeasurable(directSelector);
    List<MeasurableRatingTally> indirectTallies = measurableRatingDao.statsForRelatedMeasurable(indirectSelector);
    List<Tally<Long>> tallies = measurableRatingDao.tallyByMeasurableCategoryId(1L);
    System.out.println(tallies);
}
Also used : Tally(org.finos.waltz.model.tally.Tally) MeasurableRatingTally(org.finos.waltz.model.tally.MeasurableRatingTally) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MeasurableIdSelectorFactory(org.finos.waltz.data.measurable.MeasurableIdSelectorFactory) MeasurableRatingDao(org.finos.waltz.data.measurable_rating.MeasurableRatingDao) EntityReference(org.finos.waltz.model.EntityReference) MeasurableRatingTally(org.finos.waltz.model.tally.MeasurableRatingTally) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Aggregations

Record1 (org.jooq.Record1)58 Condition (org.jooq.Condition)22 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)16 DSLContext (org.jooq.DSLContext)14 Select (org.jooq.Select)10 ApplicationIdSelectorFactory (org.finos.waltz.data.application.ApplicationIdSelectorFactory)9 EntityReference (org.finos.waltz.model.EntityReference)8 IdSelectionOptions (org.finos.waltz.model.IdSelectionOptions)8 Record (org.jooq.Record)7 IdSelectionOptions (com.khartec.waltz.model.IdSelectionOptions)5 EntityKind (org.finos.waltz.model.EntityKind)5 EntityReference (com.khartec.waltz.model.EntityReference)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 LogicalFlowDao (org.finos.waltz.data.logical_flow.LogicalFlowDao)4 EntityReference.mkRef (org.finos.waltz.model.EntityReference.mkRef)4 LogicalFlow (org.finos.waltz.model.logical_flow.LogicalFlow)4 DSL (org.jooq.impl.DSL)4 java.util (java.util)3 ArrayList (java.util.ArrayList)3