@Bean DataSourceInitializer hiveInitializer(final DataSource dataSource) { final String ddl = "create external table if not exists tweetdata (value STRING) LOCATION '" + input + "'"; final DataSourceInitializer dsi = new DataSourceInitializer(); dsi.setDataSource(dataSource); dsi.setDatabasePopulator(new DatabasePopulator() { @Override public void populate(Connection conn) throws SQLException, ScriptException { Statement st = conn.createStatement(); st.execute(ddl); st.close(); } }); return dsi; }
@Before public void setUp() throws SolrServerException, IOException, ScriptException, SQLException { solrJudgmentsServer.deleteByQuery("*:*"); solrJudgmentsServer.commit(); ccJudgments = testJudgmentsGenerator.generateCcJudgments(COMMON_COURT_JUDGMENTS_COUNT); scJudgments = testJudgmentsGenerator.generateScJudgments(SUPREME_COURT_JUDGMENTS_COUNT); ctJudgments = testJudgmentsGenerator.generateCtJudgments(CONSTITUTIONAL_TRIBUNAL_JUDGMENTS_COUNT); EnrichmentTag tag1 = TestInMemoryEnrichmentTagFactory.createReferencedCourtCasesTag(ccJudgments.get(0).getId(), ccJudgments.get(3), scJudgments.get(9)); EnrichmentTag tag2 = TestInMemoryEnrichmentTagFactory.createReferencedCourtCasesTag(ccJudgments.get(2).getId(), ccJudgments.get(3), ctJudgments.get(0)); EnrichmentTag tag3 = TestInMemoryEnrichmentTagFactory.createEnrichmentTag(ccJudgments.get(3).getId(), EnrichmentTagTypes.MAX_REFERENCED_MONEY, JsonNormalizer.normalizeJson("{amount:12300.45, text:'123 tys zł 45 gr'}")); EnrichmentTag tag4 = TestInMemoryEnrichmentTagFactory.createEnrichmentTag(ccJudgments.get(3).getId(), EnrichmentTagTypes.REFERENCED_REGULATIONS, JsonNormalizer.normalizeJson("[{journalTitle:'Ustawa', journalNo:162, journalYear:1998, journalEntry:1118, text:'Ustawa (art.103)'}]")); enrichmentTagRepository.save(Lists.newArrayList(tag1, tag2, tag3, tag4)); }
@RequestMapping(method = RequestMethod.GET) ModelAndView index(Map<String, Object> model) throws ScriptException, NoSuchMethodException, JsonProcessingException { List<Comment> comments = Arrays.asList(new Comment("author1", "content1"), new Comment("author2", "content2"), new Comment("author3", "content3")); String commentBox = react.renderCommentBox(comments); String data = mapper.writeValueAsString(comments); ModelAndView mav = new ModelAndView("index"); mav.addObject("content", commentBox); mav.addObject("data", data); return mav; }
@Transactional public void generateTestRawCcJudgments() throws ScriptException, SQLException { assertEquals(0, rawSourceCcJudgmentRepository.count()); ClassPathResource resource = new ClassPathResource(RAW_JUDGMENT_SQL_PATH); ScriptUtils.executeSqlScript(dataSource.getConnection(), new EncodedResource(resource, "UTF-8")); assertTrue(rawSourceCcJudgmentRepository.count()>10); entityManager.createQuery("update " + RawSourceCcJudgment.class.getName() + " set processingDate = null, processed = false, processingSkipReason = null").executeUpdate(); entityManager.flush(); }
@Before public void setUp() throws SolrServerException, IOException, ScriptException, SQLException { solrJudgmentsServer.deleteByQuery("*:*"); solrJudgmentsServer.commit(); generateCcJudgments(); generateScJudgments(); }
@Before public void setUp() throws ScriptException { jdbcTemplate = new JdbcTemplate(dataSource); try { ScriptUtils.executeSqlScript(dataSource.getConnection(), new ClassPathResource("metrics/create-schema.sql")); } catch (Exception e) { // if table exist, error is okay. } }
@PostConstruct public void postConstruct() throws ScriptException, SQLException { recreateSpringBatchTables(); }