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");
});
}
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);
}
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");
}
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());
}
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);
}
Aggregations