Search in sources :

Example 46 with Record1

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

the class RemoveTaxonomy method main.

public static void main(String[] args) {
    final String categoryExtId = "FUNCTION_3_1";
    LOG.debug("Starting removal process for taxonomy {}", categoryExtId);
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    ctx.getBean(DSLContext.class).transaction(tx -> {
        DSLContext dsl = DSL.using(tx);
        Long categoryId = dsl.select(MEASURABLE_CATEGORY.ID).from(MEASURABLE_CATEGORY).where(MEASURABLE_CATEGORY.EXTERNAL_ID.eq(categoryExtId)).fetchOne(MEASURABLE_CATEGORY.ID);
        if (categoryId == null) {
            LOG.error("Could not find taxonomy with external id: {}", categoryExtId);
            return;
        }
        MeasurableIdSelectorFactory selectorFactory = new MeasurableIdSelectorFactory();
        Select<Record1<Long>> measurableIdSelector = selectorFactory.apply(mkOpts(mkRef(EntityKind.MEASURABLE_CATEGORY, categoryId), HierarchyQueryScope.EXACT));
        removeAssociatedRatings(dsl, measurableIdSelector);
        removeBookmarks(dsl, measurableIdSelector);
        removeEntityRelationships(dsl, measurableIdSelector);
        removeFlowDiagramLinks(dsl, measurableIdSelector);
        removeEntitySvgDiagram(dsl, measurableIdSelector);
        removeInvolvements(dsl, measurableIdSelector);
        removeRatingScheme(dsl, categoryId);
        removeMeasurables(dsl, measurableIdSelector);
        removeCategory(dsl, categoryId);
        throw new IllegalArgumentException("Aborting, comment this line if you really mean to execute this removal");
    });
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MeasurableIdSelectorFactory(org.finos.waltz.data.measurable.MeasurableIdSelectorFactory) DSLContext(org.jooq.DSLContext) Record1(org.jooq.Record1)

Example 47 with Record1

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

the class AppGroupFromOrgUnitImporter method main.

public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
    DSLContext dsl = ctx.getBean(DSLContext.class);
    LOG.debug("Fetching app groups...");
    Result<Record1<Long>> appGroupOrgEntries = fetchAppGroupOUEntries(dsl);
    LOG.debug("Finding applications...");
    Set<Tuple2<Long, Long>> appGroupWithAppId = findAssociatedApplications(dsl, appGroupOrgEntries);
    LOG.debug("Fetching existing app group entry records...");
    Set<Tuple2<Long, Long>> existingAppGroupEntries = findExistingAppGroupEntryRecords(dsl, appGroupOrgEntries);
    LOG.debug("Finding new records...");
    Set<Tuple2<Long, Long>> newRecords = minus(appGroupWithAppId, existingAppGroupEntries);
    LOG.debug("Finding records to remove...");
    Set<Tuple2<Long, Long>> recordsToRemove = minus(existingAppGroupEntries, appGroupWithAppId);
    LOG.debug("Deleting records...");
    int removedRecordCount = dsl.batchDelete(mkRecords(recordsToRemove)).execute().length;
    LOG.debug("Deleted record count: " + removedRecordCount);
    LOG.debug("Inserting records...");
    int insertedRecordCount = dsl.batchInsert(mkRecords(newRecords)).execute().length;
    LOG.debug("Inserted record count: " + insertedRecordCount);
// System.exit(-1);
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Tuple2(org.jooq.lambda.tuple.Tuple2) DSLContext(org.jooq.DSLContext) Record1(org.jooq.Record1)

Example 48 with Record1

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

the class ServerHarness method main.

public static void main(String[] args) {
    System.out.println("start");
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIBaseConfiguration.class);
    ServerInformationDao serverInfoDao = ctx.getBean(ServerInformationDao.class);
    IdSelectionOptions mOpts = mkOpts(mkRef(EntityKind.MEASURABLE, 1), HierarchyQueryScope.CHILDREN);
    IdSelectionOptions pOpts = mkOpts(mkRef(EntityKind.PERSON, 2), HierarchyQueryScope.CHILDREN);
    IdSelectionOptions ouOpts = mkOpts(mkRef(EntityKind.ORG_UNIT, 3), HierarchyQueryScope.CHILDREN);
    IdSelectionOptions agOpts = mkOpts(mkRef(EntityKind.APP_GROUP, 4), HierarchyQueryScope.EXACT);
    System.out.println("start timer");
    ListUtilities.asList(mOpts, pOpts, ouOpts, agOpts).forEach(opts -> {
        FunctionUtilities.time("stats: " + opts.entityReference(), () -> {
            Select<Record1<Long>> selector = new ApplicationIdSelectorFactory().apply(opts);
            return serverInfoDao.calculateStatsForAppSelector(selector);
        });
    });
    System.out.println("end");
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ServerInformationDao(org.finos.waltz.data.server_information.ServerInformationDao) ApplicationIdSelectorFactory(org.finos.waltz.data.application.ApplicationIdSelectorFactory) IdSelectionOptions(org.finos.waltz.model.IdSelectionOptions) Record1(org.jooq.Record1)

Example 49 with Record1

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

the class UnionHarness method measurableIdSelectorFactory_mkForFlowDiagram.

private static void measurableIdSelectorFactory_mkForFlowDiagram(ApplicationContext ctx) {
    Select<Record1<Long>> selector = new MeasurableIdSelectorFactory().apply(mkOpts(mkRef(EntityKind.FLOW_DIAGRAM, 12L)));
    List<Measurable> measurables = ctx.getBean(MeasurableDao.class).findByMeasurableIdSelector(selector);
    System.out.println(measurables.size());
}
Also used : Measurable(org.finos.waltz.model.measurable.Measurable) MeasurableIdSelectorFactory(org.finos.waltz.data.measurable.MeasurableIdSelectorFactory) MeasurableDao(org.finos.waltz.data.measurable.MeasurableDao) Record1(org.jooq.Record1)

Example 50 with Record1

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

the class LogicalFlowIdSelectorFactory method mkForDataType.

private Select<Record1<Long>> mkForDataType(IdSelectionOptions options) {
    Select<Record1<Long>> dataTypeSelector = dataTypeIdSelectorFactory.apply(options);
    Condition supplierNotRemoved = SUPPLIER_APP.IS_REMOVED.isFalse();
    Condition consumerNotRemoved = CONSUMER_APP.IS_REMOVED.isFalse();
    Condition appKindFilterConditions = options.filters().omitApplicationKinds().isEmpty() ? DSL.trueCondition() : SUPPLIER_APP.KIND.notIn(options.filters().omitApplicationKinds()).or(CONSUMER_APP.KIND.notIn(options.filters().omitApplicationKinds()));
    return DSL.select(LOGICAL_FLOW_DECORATOR.LOGICAL_FLOW_ID).from(LOGICAL_FLOW_DECORATOR).innerJoin(LOGICAL_FLOW).on(LOGICAL_FLOW.ID.eq(LOGICAL_FLOW_DECORATOR.LOGICAL_FLOW_ID)).innerJoin(SUPPLIER_APP).on(LOGICAL_FLOW.SOURCE_ENTITY_ID.eq(SUPPLIER_APP.ID).and(LOGICAL_FLOW.SOURCE_ENTITY_KIND.eq(EntityKind.APPLICATION.name()))).innerJoin(CONSUMER_APP).on(LOGICAL_FLOW.TARGET_ENTITY_ID.eq(CONSUMER_APP.ID).and(LOGICAL_FLOW.TARGET_ENTITY_KIND.eq(EntityKind.APPLICATION.name()))).where(LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_ID.in(dataTypeSelector).and(LOGICAL_FLOW_DECORATOR.DECORATOR_ENTITY_KIND.eq(EntityKind.DATA_TYPE.name()))).and(LOGICAL_NOT_REMOVED).and(supplierNotRemoved).and(consumerNotRemoved).and(appKindFilterConditions);
}
Also used : Condition(org.jooq.Condition) 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