use of org.jooq.DSLContext in project waltz by khartec.
the class MsSqlSearchHarness method main.
public static void main(String[] args) {
ApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
SqlServerAppSearch appSearch = new SqlServerAppSearch();
EntitySearchOptions searchOptions = ImmutableEntitySearchOptions.builder().addEntityKinds(EntityKind.APPLICATION).userId("admin").limit(50).build();
List<Application> results = appSearch.search(dsl, "sap", searchOptions);
results.stream().filter(a -> a.entityLifecycleStatus() != EntityLifecycleStatus.REMOVED).forEach(a -> System.out.println(a.name() + " - " + a.lifecyclePhase()));
}
use of org.jooq.DSLContext in project waltz by khartec.
the class PersonHarness method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
PersonDao personDao = ctx.getBean(PersonDao.class);
int c = dsl.fetchCount(PERSON, PERSON.MANAGER_EMPLOYEE_ID.eq("").or(PERSON.MANAGER_EMPLOYEE_ID.isNull()));
int c2 = dsl.fetchCount(DSL.selectDistinct(PERSON_HIERARCHY.MANAGER_ID).from(PERSON_HIERARCHY).where(PERSON_HIERARCHY.LEVEL.eq(1)));
System.out.println(c);
System.out.println(c2);
}
use of org.jooq.DSLContext in project waltz by khartec.
the class PhysicalSpecificationHarness method main.
public static void main(String[] args) throws ParseException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
PhysicalSpecificationSearchDao searcher = ctx.getBean(PhysicalSpecificationSearchDao.class);
searcher.search("sap", EntitySearchOptions.mkForEntity(EntityKind.PHYSICAL_SPECIFICATION)).forEach(ps -> System.out.println(ps.name()));
}
use of org.jooq.DSLContext in project waltz by khartec.
the class ServerComplexityHarness method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
OrganisationalUnitDao ouDao = ctx.getBean(OrganisationalUnitDao.class);
ServerComplexityService serverService = ctx.getBean(ServerComplexityService.class);
ComplexityRatingService complexityService = ctx.getBean(ComplexityRatingService.class);
// EntityReference entityReference = EntityReference.mkRef(EntityKind.PERSON, 1);
EntityReference entityReference = EntityReference.mkRef(EntityKind.PERSON, 63);
List<ComplexityRating> complexity = FunctionUtilities.time("complexity", () -> complexityService.findForAppIdSelector(IdSelectionOptions.mkOpts(entityReference, HierarchyQueryScope.CHILDREN)));
}
use of org.jooq.DSLContext in project waltz by khartec.
the class ServerHarness method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
ServerInformationService serverInfoService = ctx.getBean(ServerInformationService.class);
ServerInformationDao serverInfoDao = ctx.getBean(ServerInformationDao.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
IdSelectionOptions options = ImmutableIdSelectionOptions.builder().entityReference(ImmutableEntityReference.builder().kind(EntityKind.ORG_UNIT).id(10).build()).scope(HierarchyQueryScope.CHILDREN).build();
for (int i = 0; i < 5; i++) {
HarnessUtilities.time("stats", () -> serverInfoService.findStatsForAppSelector(options));
}
String sql = "\n" + "select \n" + " coalesce(\n" + " sum(case [server_information].[is_virtual] when 1 then 1\n" + " else 0\n" + " end), \n" + " 0) [virtual_count], \n" + " coalesce(\n" + " sum(case [server_information].[is_virtual] when 1 then 0\n" + " else 1\n" + " end), \n" + " 0) [physical_count]\n" + "from [server_information]\n" + "where [server_information].[asset_code] in (\n" + " select [application].[asset_code]\n" + " from [application]\n" + " where [application].[id] in (\n" + " select [application].[id]\n" + " from [application]\n" + " where [application].[organisational_unit_id] in (\n" + " 130, 260, 70, 200, 10, 140, 270, 80, 210, 20, 150, 280, 90, 220, 30, 160, \n" + " 290, 100, 230, 40, 170, 300, 110, 240, 50, 180, 120, 250, 60, 190\n" + " )\n" + " )\n" + ");\n";
FunctionUtilities.time("raw q", () -> {
dsl.connection(conn -> {
PreparedStatement stmt = conn.prepareStatement(sql);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
System.out.println(rs.getBigDecimal(1) + " - " + rs.getBigDecimal(2));
}
});
return null;
});
}
Aggregations