List of usage examples for java.sql Date Date
public Date(long date)
From source file:org.apache.carbondata.sdk.file.CarbonReaderTest.java
@Test public void testTimeStampAndBadRecord() throws IOException, InterruptedException { String timestampFormat = carbonProperties.getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT); String badRecordAction = carbonProperties.getProperty(CarbonCommonConstants.CARBON_BAD_RECORDS_ACTION, CarbonCommonConstants.CARBON_BAD_RECORDS_ACTION_DEFAULT); String badRecordLoc = carbonProperties.getProperty(CarbonCommonConstants.CARBON_BADRECORDS_LOC, CarbonCommonConstants.CARBON_BADRECORDS_LOC_DEFAULT_VAL); String rootPath = new File(this.getClass().getResource("/").getPath() + "../../").getCanonicalPath(); String storeLocation = rootPath + "/target/"; carbonProperties.addProperty(CarbonCommonConstants.CARBON_BADRECORDS_LOC, storeLocation) .addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, "yyyy-MM-dd hh:mm:ss") .addProperty(CarbonCommonConstants.CARBON_BAD_RECORDS_ACTION, "REDIRECT"); String path = "./testWriteFiles"; FileUtils.deleteDirectory(new File(path)); Field[] fields = new Field[9]; fields[0] = new Field("stringField", DataTypes.STRING); fields[1] = new Field("intField", DataTypes.INT); fields[2] = new Field("shortField", DataTypes.SHORT); fields[3] = new Field("longField", DataTypes.LONG); fields[4] = new Field("doubleField", DataTypes.DOUBLE); fields[5] = new Field("boolField", DataTypes.BOOLEAN); fields[6] = new Field("dateField", DataTypes.DATE); fields[7] = new Field("timeField", DataTypes.TIMESTAMP); fields[8] = new Field("decimalField", DataTypes.createDecimalType(8, 2)); try {//from www . ja va 2s .c om CarbonWriterBuilder builder = CarbonWriter.builder().outputPath(path); CarbonWriter writer = builder.withCsvInput(new Schema(fields)).writtenBy("CarbonReaderTest").build(); for (int i = 0; i < 100; i++) { String[] row = new String[] { "robot" + (i % 10), String.valueOf(i), String.valueOf(i), String.valueOf(Long.MAX_VALUE - i), String.valueOf((double) i / 2), String.valueOf(true), "2018-05-12", "2018-05-12", "12.345" }; writer.write(row); String[] row2 = new String[] { "robot" + (i % 10), String.valueOf(i), String.valueOf(i), String.valueOf(Long.MAX_VALUE - i), String.valueOf((double) i / 2), String.valueOf(true), "2019-03-02", "2019-02-12 03:03:34", "12.345" }; writer.write(row2); } writer.close(); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } File folder = new File(path); Assert.assertTrue(folder.exists()); File[] dataFiles = folder.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { return pathname.getName().endsWith(CarbonCommonConstants.FACT_FILE_EXT); } }); Assert.assertNotNull(dataFiles); Assert.assertTrue(dataFiles.length > 0); CarbonReader reader = CarbonReader.builder(path, "_temp") .projection(new String[] { "stringField", "shortField", "intField", "longField", "doubleField", "boolField", "dateField", "timeField", "decimalField" }) .build(); int i = 0; while (reader.hasNext()) { Object[] row = (Object[]) reader.readNextRow(); int id = (int) row[2]; Assert.assertEquals("robot" + (id % 10), row[0]); Assert.assertEquals(Short.parseShort(String.valueOf(id)), row[1]); Assert.assertEquals(Long.MAX_VALUE - id, row[3]); Assert.assertEquals((double) id / 2, row[4]); Assert.assertEquals(true, (boolean) row[5]); long day = 24L * 3600 * 1000; Assert.assertEquals("2019-03-02", new Date((day * ((int) row[6]))).toString()); Assert.assertEquals("2019-02-12 03:03:34.0", new Timestamp((long) row[7] / 1000).toString()); i++; } Assert.assertEquals(i, 100); reader.close(); FileUtils.deleteDirectory(new File(path)); carbonProperties.addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, timestampFormat); carbonProperties.addProperty(CarbonCommonConstants.CARBON_BAD_RECORDS_ACTION, badRecordAction); carbonProperties.addProperty(CarbonCommonConstants.CARBON_BADRECORDS_LOC, badRecordLoc); }
From source file:org.kuali.coeus.common.budget.framework.core.Budget.java
public Date createDateFromString(String budgetFiscalYearStart) { if (budgetFiscalYearStart == null) { return null; }// w w w . ja v a 2 s. c om String[] dateParts = budgetFiscalYearStart.split("/"); // mm/dd/yyyy // using Calendar her because org.kuali.core.util.DateUtils.newdate(...) has hour value in time fields (UT?) Calendar calendar = Calendar.getInstance(); calendar.set(Integer.valueOf(dateParts[2]), Integer.valueOf(dateParts[0]) - 1, Integer.valueOf(dateParts[1]), 0, 0, 0); return new Date(calendar.getTimeInMillis()); }
From source file:com.taobao.android.tools.TPatchTool.java
/** * create manifest for patch file//from w ww . j a va2 s .c o m * * @return */ private Manifest createManifest() { Manifest manifest = new Manifest(); Attributes main = manifest.getMainAttributes(); main.putValue("Manifest-Version", "1.0"); main.putValue("Created-By", "1.0 (DexPatch)"); main.putValue("Created-Time", new Date(System.currentTimeMillis()).toGMTString()); return manifest; }
From source file:fr.certu.chouette.exchange.gtfs.importer.NeptuneConverter.java
private Period clonePeriodAfterMidnight(Period source) { Period result = new Period(); result.setStartDate(new Date(source.getStartDate().getTime() + dayOffest)); result.setEndDate(new Date(source.getEndDate().getTime() + dayOffest)); return result; }
From source file:fr.certu.chouette.exchange.gtfs.importer.NeptuneConverter.java
private Date cloneDateAfterMidnight(Date source) { return new Date(source.getTime() + dayOffest); }
From source file:edu.ku.kuali.kra.award.web.struts.action.AwardActionsAction.java
/** * BU KC/SAP Integration: Transmission to SAP logic. Cycle through the award list and only pass on those that have been * marked as approved for transmission then create a record with sending data before calling the web service. * * @param mapping// w w w.j a v a2 s . c o m * - The ActionMapping used to select this instance * @param form * - The optional ActionForm bean for this request (if any) * @param request * - The HTTP request we are processing * @param response * - The HTTP response we are creating * @return an ActionForward instance describing where and how control should be forwarded, or null if the response has already been completed. * @throws Exception * - if an exception occurs */ public ActionForward transmitAward(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { BusinessObjectService boService = KcServiceLocator.getService(BusinessObjectService.class); SapIntegrationService integrationService = KcServiceLocator.getService(SapIntegrationService.class); // call the transmit() method on SAPIntegrationService AwardForm awardForm = (AwardForm) form; Award primaryAward = awardForm.getAwardHierarchyBean().getRootNode().getAward(); // cycle through the award list and only pass on those that have been // marked as approved for transmission ArrayList<Award> awardsList = new ArrayList<Award>(); checkAwardChildrenForTransmission(awardForm.getAwardHierarchyBean().getRootNode(), awardsList, request); if (((AwardExtension) primaryAward.getExtension()).getLastTransmissionDate() == null && awardsList.isEmpty()) { GlobalVariables.getMessageMap().putErrorForSectionId("awardTransmission", "error.award.sapintegration.no.validated.child.awards"); return mapping.findForward(Constants.MAPPING_AWARD_ACTIONS_PAGE); } SapTransmission transmission = new SapTransmission(primaryAward, awardsList); // create transmission record with sending data SapTransmissionResponse transmissionResponse = integrationService.transmit(transmission); // SapTransmissionResponse transmissionResponse= new SapTransmissionResponse(Status.SUCCESS, null, null, null, null, null, null); Map<Long, String> sponsoredProgramIds = transmissionResponse.getSponsoredProgramIds(); // BU Customization ID: N/A 20130306 20140317 - Handle SAP Walker number Map<Long, String> walkerIds = transmissionResponse.getWalkerIds(); // add to transmission record with response data and timestamp // mark all award as transmitted Calendar cl = Calendar.getInstance(); Date transmissionDate = new Date(cl.getTime().getTime()); if (transmissionResponse != null) { if (transmissionResponse.isSuccess()) { // set last transmission date on root award ((AwardExtension) primaryAward.getExtension()).setLastTransmissionDate(transmissionDate); if (sponsoredProgramIds.containsKey(primaryAward.getAwardId())) { String sponsoredProgramId = sponsoredProgramIds.get(primaryAward.getAwardId()); LOG.info("Found a generated sponsored program id '" + sponsoredProgramId + "' from SAP service for parent award with id: " + primaryAward.getAwardId() + ". Updating award cost share source destination."); for (AwardCostShare awardCostShare : primaryAward.getAwardCostShares()) { awardCostShare.setDestination(sponsoredProgramId); } } generateGrantNumber(primaryAward); boService.save(primaryAward); // set last transmission date on all awards for (Award award : awardsList) { // Integer lastBudgetVersionNumber = // getAwardBudgetService().getLastBudgetVersion(award.getAwardDocument()).getBudgetVersionNumber(); List<AwardBudgetExt> budgetDocumentVersions = getAwardBudgetService() .getAllBudgetsForAward(award); // iterate through versions and post the highest one that is // "to be posted" for (AwardBudgetExt budgetDocumentVersion : budgetDocumentVersions) { AwardBudgetExt awardBudgetVersionOverviewExt = budgetDocumentVersion; // lastBudgetVersionNumber == // budgetDocumentVersion.getBudgetVersionOverview().getBudgetVersionNumber() // && if (awardBudgetVersionOverviewExt != null && Constants.BUDGET_STATUS_CODE_TO_BE_POSTED .equals(awardBudgetVersionOverviewExt.getAwardBudgetStatusCode())) { Document document = getDocumentService() .getByDocumentHeaderId(budgetDocumentVersion.getDocumentNumber()); LOG.info("About to attempt to post an AwardBudgetDocument. Type: " + document.getDocumentNumber()); if (document instanceof AwardBudgetDocument) { AwardBudgetDocument awardBudgetDocument = (AwardBudgetDocument) getDocumentService() .getByDocumentHeaderId(budgetDocumentVersion.getDocumentNumber()); getAwardBudgetService().post(awardBudgetDocument); } } } // TODO - TEMP FIX, needs to be removed!!! if (!"Group".equalsIgnoreCase(((AwardExtension) award.getExtension()).getChildType())) { ((AwardExtension) award.getExtension()).setLastTransmissionDate(transmissionDate); } if (sponsoredProgramIds.containsKey(award.getAwardId())) { String sponsoredProgramId = sponsoredProgramIds.get(award.getAwardId()); LOG.info("Found a generated sponsored program id '" + sponsoredProgramId + "' from SAP service for award with id: " + award.getAwardId() + ". Updating award account number."); award.setAccountNumber(sponsoredProgramId); } // BU Customization ID: N/A 20130306 20140317 - Handle SAP Walker number if (walkerIds.containsKey(award.getAwardId())) { String walkerId = walkerIds.get(award.getAwardId()); LOG.info("Found a generated walker id '" + walkerIds + "' from SAP service for award with id: " + award.getAwardId() + ". Updating award walker number."); ((AwardExtension) award.getExtension()).setWalkerSourceNumber(walkerId); } generateGrantNumber(award); boService.save(award); } } else { // display error GlobalVariables.getMessageMap().putErrorForSectionId("awardTransmission", Constants.GRANTS_GOV_GENERIC_ERROR_KEY, transmissionResponse.getMessage()); } // BU Customization ID: N/A 20130429 - Issue 55 - KC_SAP Interface to display warning List<String> warningMessages = transmissionResponse.getWarningMessages(); if (warningMessages.size() > 0) { for (String warning : warningMessages) { GlobalVariables.getMessageMap().putWarning("awardTransmission", "warning.award.sapintegration.warning.message", warning); LOG.info("Found a warning message : " + warning); } } // add transmission record AwardTransmission newAwardTransmission = new AwardTransmission(); Long awardId = awardForm.getAwardHierarchyBean().getRootNode().getAward().getAwardId(); newAwardTransmission.setAwardId(awardId); newAwardTransmission.setInitiatorId(GlobalVariables.getUserSession().getPrincipalId()); newAwardTransmission.setTransmitterId(GlobalVariables.getUserSession().getPrincipalId()); newAwardTransmission.setSentData(transmissionResponse.getSentData()); newAwardTransmission.setReturnedData(transmissionResponse.getReceivedData()); newAwardTransmission.setTransmissionDate(transmissionDate); newAwardTransmission.setSuccessIndicator(transmissionResponse.isSuccess() ? "Y" : "N"); newAwardTransmission.setBasisOfPaymentCode(primaryAward.getBasisOfPaymentCode()); newAwardTransmission.setAccountTypeCode(primaryAward.getAccountTypeCode()); newAwardTransmission.setSponsorCode(primaryAward.getSponsorCode()); newAwardTransmission.setMethodOfPaymentCode(primaryAward.getMethodOfPaymentCode()); newAwardTransmission.setDocumentNumber(primaryAward.getAwardDocument().getDocumentNumber()); for (Award award : awardsList) { // add child award transmission for each AwardTransmissionChild transmissionChild = new AwardTransmissionChild(); transmissionChild.setAwardId(award.getAwardId()); transmissionChild.setParentDocumentNumber(primaryAward.getAwardDocument().getDocumentNumber()); transmissionChild.setChildDocumentNumber(award.getAwardDocument().getDocumentNumber()); transmissionChild.setLeadUnitNumber(award.getLeadUnitNumber()); transmissionChild.setChildType(((AwardExtension) award.getExtension()).getChildType()); transmissionChild.setAwardNumber(award.getAwardNumber()); String overheadKey = (String) GlobalVariables.getUserSession() .retrieveObject("overheadKey-".concat(award.getAwardNumber())); GlobalVariables.getUserSession().removeObject("overheadKey-".concat(award.getAwardNumber())); transmissionChild.setOverheadKey(overheadKey); String baseCode = (String) GlobalVariables.getUserSession() .retrieveObject("baseCode-".concat(award.getAwardNumber())); GlobalVariables.getUserSession().removeObject("baseCode-".concat(award.getAwardNumber())); transmissionChild.setBaseCode(baseCode); String offCampus = (String) GlobalVariables.getUserSession() .retrieveObject("offCampus-".concat(award.getAwardNumber())); GlobalVariables.getUserSession().removeObject("offCampus-".concat(award.getAwardNumber())); transmissionChild.setOffCampus(offCampus); newAwardTransmission.getTransmissionChildren().add(transmissionChild); } boService.save(newAwardTransmission); ((AwardExtension) awardForm.getAwardHierarchyBean().getRootNode().getAward().getExtension()) .getAwardTransmissions().add(newAwardTransmission); } else { GlobalVariables.getMessageMap().putErrorForSectionId("awardTransmission", "error.award.sapintegration.empty.transmission.response"); } return mapping.findForward(Constants.MAPPING_AWARD_ACTIONS_PAGE); }
From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java
@Override public void insertPanden(final List<Pand> panden) throws DAOException { try {//w w w . j a va 2 s . c o m jdbcTemplate.batchUpdate("insert into bag_pand (" + "bag_pand_id," + "aanduiding_record_inactief," + "aanduiding_record_correctie," + "officieel," + "pand_geometrie," + "bouwjaar," + "pand_status," + "begindatum_tijdvak_geldigheid," + "einddatum_tijdvak_geldigheid," + "in_onderzoek," + "bron_documentdatum," + "bron_documentnummer" + ") values (?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { ps.setLong(1, panden.get(i).getIdentificatie()); ps.setInt(2, panden.get(i).getAanduidingRecordInactief().ordinal()); ps.setLong(3, panden.get(i).getAanduidingRecordCorrectie()); ps.setInt(4, panden.get(i).getOfficieel().ordinal()); ps.setString(5, panden.get(i).getPandGeometrie()); ps.setInt(6, panden.get(i).getBouwjaar()); ps.setString(7, panden.get(i).getPandStatus()); ps.setTimestamp(8, new Timestamp(panden.get(i).getBegindatumTijdvakGeldigheid().getTime())); if (panden.get(i).getEinddatumTijdvakGeldigheid() == null) ps.setNull(9, Types.TIMESTAMP); else ps.setTimestamp(9, new Timestamp(panden.get(i).getEinddatumTijdvakGeldigheid().getTime())); ps.setInt(10, panden.get(i).getInOnderzoek().ordinal()); ps.setDate(11, new Date(panden.get(i).getDocumentdatum().getTime())); ps.setString(12, panden.get(i).getDocumentnummer()); } @Override public int getBatchSize() { return panden.size(); } }); } catch (DataAccessException e) { throw new DAOException("Error inserting panden", e); } }
From source file:eionet.meta.service.RDFVocabularyImportServiceTest.java
/** * In this test, four concepts RDF is imported. Concepts are derived from base RDF. Labels are are updated. Labels with working * language tested./* www. j av a 2 s . c o m*/ * * @throws Exception */ @Test @Rollback public void testIfConceptsAddedWithCorrectLabelsAfterPurge() throws Exception { // get vocabulary folder VocabularyFolder vocabularyFolder = vocabularyService.getVocabularyFolder(TEST_VALID_VOCABULARY_ID); // get reader for RDF file Reader reader = getReaderFromResource("rdf_import/rdf_import_test_9.rdf"); // import RDF into database vocabularyImportService.importRdfIntoVocabulary(reader, vocabularyFolder, true, false); Assert.assertFalse("Transaction rolled back (unexpected)", transactionManager.getTransaction(null).isRollbackOnly()); // get updated values of concepts with attributes List<VocabularyConcept> updatedConcepts = getVocabularyConceptsWithAttributes(vocabularyFolder); Assert.assertEquals("Updated Concepts does not include 3 vocabulary concepts", updatedConcepts.size(), 3); // manually compare updated objects values // Concept 1 VocabularyConcept concept = findVocabularyConceptByIdentifier(updatedConcepts, "rdf_test_concept_1"); concept.setStatus(StandardGenericStatus.VALID); concept.setAcceptedDate(new Date(System.currentTimeMillis())); concept.setStatusModified(new Date(System.currentTimeMillis())); Assert.assertEquals("Label does not match for concept.", "en_rdf_test_concept_1", concept.getLabel()); Assert.assertEquals("skos:prefLabel should have 3 elements for concept.", 3, VocabularyImportBaseHandler .getDataElementValuesByName("skos:prefLabel", concept.getElementAttributes()).size()); // Concept 2 concept = findVocabularyConceptByIdentifier(updatedConcepts, "rdf_test_concept_2"); concept.setStatus(StandardGenericStatus.VALID); concept.setAcceptedDate(new Date(System.currentTimeMillis())); concept.setStatusModified(new Date(System.currentTimeMillis())); Assert.assertEquals("Label does not match for concept.", "rdf_test_concept_label_2", concept.getLabel()); Assert.assertEquals("Definition does not match for concept.", "rdf_test_concept_def_2", concept.getDefinition()); Assert.assertEquals("skos:prefLabel should have 2 elements for concept.", 2, VocabularyImportBaseHandler .getDataElementValuesByName("skos:prefLabel", concept.getElementAttributes()).size()); Assert.assertEquals("skos:definition should have 1 elements for concept.", 1, VocabularyImportBaseHandler .getDataElementValuesByName("skos:definition", concept.getElementAttributes()).size()); // Concept 3 concept = findVocabularyConceptByIdentifier(updatedConcepts, "rdf_test_concept_3"); concept.setStatus(StandardGenericStatus.VALID); concept.setAcceptedDate(new Date(System.currentTimeMillis())); concept.setStatusModified(new Date(System.currentTimeMillis())); Assert.assertEquals("Label does not match for concept.", "bg_rdf_test_concept_3", concept.getLabel()); Assert.assertEquals("Definition does not match for concept.", "en_rdf_test_concept_3", concept.getDefinition()); Assert.assertEquals("skos:prefLabel should have 2 elements for concept.", 2, VocabularyImportBaseHandler .getDataElementValuesByName("skos:prefLabel", concept.getElementAttributes()).size()); Assert.assertEquals("skos:definition should have 2 elements for concept.", 2, VocabularyImportBaseHandler .getDataElementValuesByName("skos:definition", concept.getElementAttributes()).size()); }
From source file:org.apache.carbondata.sdk.file.CarbonReaderTest.java
@Test public void testReadSchemaInDataFileAndSort() throws IOException, InterruptedException { String timestampFormat = carbonProperties.getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT); String badRecordAction = carbonProperties.getProperty(CarbonCommonConstants.CARBON_BAD_RECORDS_ACTION, CarbonCommonConstants.CARBON_BAD_RECORDS_ACTION_DEFAULT); String badRecordLoc = carbonProperties.getProperty(CarbonCommonConstants.CARBON_BADRECORDS_LOC, CarbonCommonConstants.CARBON_BADRECORDS_LOC_DEFAULT_VAL); String rootPath = new File(this.getClass().getResource("/").getPath() + "../../").getCanonicalPath(); String storeLocation = rootPath + "/target/"; carbonProperties.addProperty(CarbonCommonConstants.CARBON_BADRECORDS_LOC, storeLocation) .addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, "yyyy-MM-dd hh:mm:ss") .addProperty(CarbonCommonConstants.CARBON_BAD_RECORDS_ACTION, "REDIRECT"); String path = "./testWriteFiles"; FileUtils.deleteDirectory(new File(path)); Field[] fields = new Field[9]; fields[0] = new Field("stringField", DataTypes.STRING); fields[1] = new Field("shortField", DataTypes.SHORT); fields[2] = new Field("intField", DataTypes.INT); fields[3] = new Field("longField", DataTypes.LONG); fields[4] = new Field("doubleField", DataTypes.DOUBLE); fields[5] = new Field("boolField", DataTypes.BOOLEAN); fields[6] = new Field("dateField", DataTypes.DATE); fields[7] = new Field("timeField", DataTypes.TIMESTAMP); fields[8] = new Field("decimalField", DataTypes.createDecimalType(8, 2)); try {//from w w w . j a v a2 s . co m CarbonWriterBuilder builder = CarbonWriter.builder().outputPath(path); CarbonWriter writer = builder.withCsvInput(new Schema(fields)).writtenBy("CarbonReaderTest").build(); for (int i = 0; i < 100; i++) { String[] row2 = new String[] { "robot" + (i % 10), String.valueOf(i), String.valueOf(i), String.valueOf(Long.MAX_VALUE - i), String.valueOf((double) i / 2), String.valueOf(true), "2019-03-02", "2019-02-12 03:03:34", "12.345" }; writer.write(row2); } writer.close(); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } File[] dataFiles2 = new File(path).listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.endsWith("carbondata"); } }); Schema schema = CarbonSchemaReader.readSchema(dataFiles2[0].getAbsolutePath()); // sort the schema Arrays.sort(schema.getFields(), new Comparator<Field>() { @Override public int compare(Field o1, Field o2) { return Integer.compare(o1.getSchemaOrdinal(), o2.getSchemaOrdinal()); } }); // Transform the schema String[] strings = new String[schema.getFields().length]; for (int i = 0; i < schema.getFields().length; i++) { strings[i] = (schema.getFields())[i].getFieldName(); } File folder = new File(path); Assert.assertTrue(folder.exists()); CarbonReader reader = CarbonReader.builder(path, "_temp").projection(strings).build(); int i = 0; while (reader.hasNext()) { Object[] row = (Object[]) reader.readNextRow(); int id = (int) row[2]; Assert.assertEquals("robot" + (id % 10), row[0]); Assert.assertEquals(Short.parseShort(String.valueOf(id)), row[1]); Assert.assertEquals(Long.MAX_VALUE - id, row[3]); Assert.assertEquals((double) id / 2, row[4]); Assert.assertEquals(true, (boolean) row[5]); long day = 24L * 3600 * 1000; Assert.assertEquals("2019-03-02", new Date((day * ((int) row[6]))).toString()); Assert.assertEquals("2019-02-12 03:03:34.0", new Timestamp((long) row[7] / 1000).toString()); i++; } Assert.assertEquals(i, 100); reader.close(); FileUtils.deleteDirectory(new File(path)); carbonProperties.addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, timestampFormat); carbonProperties.addProperty(CarbonCommonConstants.CARBON_BAD_RECORDS_ACTION, badRecordAction); carbonProperties.addProperty(CarbonCommonConstants.CARBON_BADRECORDS_LOC, badRecordLoc); }
From source file:nl.ordina.bag.etl.dao.AbstractBAGDAO.java
@Override public void insertVerblijfsobjecten(final List<Verblijfsobject> verblijfsobjecten) throws DAOException { try {//from w ww . j a v a 2s . c o m transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { jdbcTemplate.batchUpdate("insert into bag_verblijfsobject (" + "bag_verblijfsobject_id," + "aanduiding_record_inactief," + "aanduiding_record_correctie," + "officieel," + "verblijfsobject_geometrie," + "oppervlakte_verblijfsobject," + "verblijfsobject_status," + "begindatum_tijdvak_geldigheid," + "einddatum_tijdvak_geldigheid," + "in_onderzoek," + "bron_documentdatum," + "bron_documentnummer," + "bag_nummeraanduiding_id" + ") values (?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { ps.setLong(1, verblijfsobjecten.get(i).getIdentificatie()); ps.setInt(2, verblijfsobjecten.get(i).getAanduidingRecordInactief().ordinal()); ps.setLong(3, verblijfsobjecten.get(i).getAanduidingRecordCorrectie()); ps.setInt(4, verblijfsobjecten.get(i).getOfficieel().ordinal()); ps.setString(5, verblijfsobjecten.get(i).getVerblijfsobjectGeometrie()); ps.setInt(6, verblijfsobjecten.get(i).getOppervlakteVerblijfsobject()); ps.setInt(7, verblijfsobjecten.get(i).getVerblijfsobjectStatus().ordinal()); ps.setTimestamp(8, new Timestamp( verblijfsobjecten.get(i).getBegindatumTijdvakGeldigheid().getTime())); if (verblijfsobjecten.get(i).getEinddatumTijdvakGeldigheid() == null) ps.setNull(9, Types.TIMESTAMP); else ps.setTimestamp(9, new Timestamp(verblijfsobjecten.get(i) .getEinddatumTijdvakGeldigheid().getTime())); ps.setInt(10, verblijfsobjecten.get(i).getInOnderzoek().ordinal()); ps.setDate(11, new Date(verblijfsobjecten.get(i).getDocumentdatum().getTime())); ps.setString(12, verblijfsobjecten.get(i).getDocumentnummer()); ps.setLong(13, verblijfsobjecten.get(i).getHoofdAdres()); } @Override public int getBatchSize() { return verblijfsobjecten.size(); } }); insertGebruikersdoelen(verblijfsobjecten); insertNevenadressen(TypeAdresseerbaarObject.VERBLIJFSOBJECT, verblijfsobjecten); insertGerelateerdePanden(verblijfsobjecten); } }); } catch (DataAccessException e) { throw new DAOException("Error inserting verblijfsobjecten", e); } }