List of usage examples for org.springframework.context.annotation AnnotationConfigApplicationContext getBean
@Override public Object getBean(String name) throws BeansException
From source file:com.khartec.waltz.jobs.DatabaseHarness.java
public static void main(String[] args) throws ParseException { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); DatabaseInformationDao databaseDao = ctx.getBean(DatabaseInformationDao.class); DSLContext dsl = ctx.getBean(DSLContext.class); List<DatabaseInformation> dbs = databaseDao.findByApplicationId(801L); System.out.println(dbs.size()); SelectConditionStep<Record1<Long>> idSelector = dsl.select(APPLICATION.ID).from(APPLICATION) .where(APPLICATION.ID.in(801L, 802L, 803L)); Map<Long, List<DatabaseInformation>> moreDbs = databaseDao.findByAppSelector(idSelector); System.out.println(moreDbs.size()); System.out.println(moreDbs.values().size()); }
From source file:com.trifork.batchcopy.client.Main.java
public static void main(String[] args) throws Exception { DOMConfigurator.configure("log4j.xml"); AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext( AppConfig.class); BatchCopyClient client = applicationContext.getBean(BatchCopyClient.class); String lastToken = null;/* ww w . j a va2s .com*/ do { lastToken = client.performRequest("doseringsforslag", "dosageunit", lastToken); System.out.println("Press enter to read another record"); System.in.read(); } while (true); }
From source file:com.enitalk.configs.VelocityConfig.java
public static void main(String[] args) throws IOException { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(VelocityEngine.class); VelocityEngine engine = ctx.getBean(VelocityEngine.class); long start = System.currentTimeMillis(); Template t = engine.getTemplate("booking.vm"); VelocityContext context = new VelocityContext(); context.put("scheduledDate", new DateTime().toString()); context.put("link", "http://localhost:8080"); StringWriter writer = new StringWriter(24 * 1024); t.merge(context, writer);//from w ww . ja va 2 s. c o m FileUtils.write(new File("/home/krash/Desktop/1.html"), writer.toString(), "UTF-8"); logger.info("Took {}", System.currentTimeMillis() - start); // String templateText = FileUtils.readFileToString(new File("./templates/booking.vm"), "UTF-8"); // logger.info("Templated text {}", templateText); }
From source file:com.khartec.waltz.jobs.InvolvementHarness2.java
public static void main(String[] args) throws InterruptedException { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); DSLContext dsl = ctx.getBean(DSLContext.class); DataSource dataSource = ctx.getBean(DataSource.class); InvolvementDao dao = ctx.getBean(InvolvementDao.class); time("hmm", () -> foo(dsl, "NravvV2Is")); // time("findAllApps", () -> dao.findAllApplicationsByEmployeeId("NravvV2Is")); }
From source file:com.khartec.waltz.jobs.sample.UnknownFlowGenerator.java
public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); ApplicationService applicationDao = ctx.getBean(ApplicationService.class); DSLContext dsl = ctx.getBean(DSLContext.class); List<Application> allApps = applicationDao.findAll(); Set<DataFlowRecord> records = IntStream.range(0, 2000) .mapToObj(i -> Tuple.tuple(randomPick(allApps).id().get(), randomPick(allApps).id().get())) .map(t -> new DataFlowRecord("APPLICATION", t.v1(), "APPLICATION", t.v2(), "UNKNOWN", "UNK_TEST")) .collect(Collectors.toSet()); dsl.deleteFrom(DATA_FLOW).where(DATA_FLOW.PROVENANCE.eq("UNK_TEST")).execute(); dsl.batchInsert(records).execute();/*from ww w . ja v a 2 s. c o m*/ System.out.println("Done"); }
From source file:com.khartec.waltz.jobs.AppHarness.java
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().search(dsl, "Water & Vole"); System.out.println(jimmy);//from ww w. j ava 2 s. c om // 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)); // }
From source file:com.khartec.waltz.jobs.RatedFlowHarness.java
public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); RatedDataFlowService ratedDataFlowService = ctx.getBean(RatedDataFlowService.class); int CTO_OFFICE = 40; int CTO_ADMIN = 400; int CEO_OFFICE = 10; int MARKET_RISK = 220; int RISK = 210; int orgUnitId = RISK; tree(ratedDataFlowService, orgUnitId); }
From source file:com.khartec.waltz.jobs.sample.CapabilityGenerator.java
public static void main(String[] args) throws IOException { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); DSLContext dsl = ctx.getBean(DSLContext.class); List<String> lines = readLines(CapabilityGenerator.class.getResourceAsStream("/capabilities.csv")); System.out.println("Deleting existing Caps's"); dsl.deleteFrom(CAPABILITY).execute(); List<CapabilityRecord> records = lines.stream().skip(1).map(line -> line.split("\t")) .filter(cells -> cells.length == 4).map(cells -> { CapabilityRecord record = new CapabilityRecord(); record.setId(longVal(cells[0])); record.setParentId(longVal(cells[1])); record.setName(cells[2]); record.setDescription(cells[3]); System.out.println(record); return record; }).collect(Collectors.toList()); System.out.println("Inserting new Caps's"); dsl.batchInsert(records).execute();/* w w w . j a v a 2 s .c o m*/ System.out.println("Done"); }
From source file:com.khartec.waltz.jobs.UserHarness.java
public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); UserRoleService userRoleService = ctx.getBean(UserRoleService.class); DSLContext dsl = ctx.getBean(DSLContext.class); int rc = dsl.insertInto(USER).set(USER.USER_NAME, "kamran").set(USER.PASSWORD, "1234") .onDuplicateKeyIgnore().execute(); System.out.println(rc);/*w w w.j ava 2s.c o m*/ // // ImmutableLoginRequest loginRequest = ImmutableLoginRequest.builder() // .userName("dwatkins") // .password("wrong") // .build(); // // boolean authenticated = userService.authenticate(loginRequest); // System.out.println(authenticated); // // userRoleService.findAllUsers().forEach(System.out::println); }
From source file:com.khartec.waltz.jobs.sample.AppCapabilityGenerator.java
public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); CapabilityService capabilityDao = ctx.getBean(CapabilityService.class); ApplicationService applicationDao = ctx.getBean(ApplicationService.class); AppCapabilityService appCapabilityDao = ctx.getBean(AppCapabilityService.class); DSLContext dsl = ctx.getBean(DSLContext.class); dsl.delete(APP_CAPABILITY).execute(); List<Capability> capabilities = capabilityDao.findAll(); applicationDao.findAll().forEach(app -> { int count = rnd.nextInt(4) + 1; Set<Long> ids = IntStream.range(0, count).mapToObj(i -> randomPick(capabilities)).map(c -> c.id().get()) .collect(Collectors.toSet()); appCapabilityDao.addCapabilitiesToApp(app.id().get(), new ArrayList<>(ids)); });/*from w w w .j a v a2s . c o m*/ }