List of usage examples for org.joda.time DateTime getSecondOfMinute
public int getSecondOfMinute()
From source file:com.collective.celos.Util.java
License:Apache License
public static boolean isFullMinute(DateTime dt) { return isFullSecond(dt) && dt.getSecondOfMinute() == 0; }
From source file:com.core.meka.Util.java
public static String fechaLarga(Date fecha) { String result = "Sin especificar"; if (fecha != null) { DateTime d = new DateTime(fecha); result = d.getDayOfMonth() + "/" + d.getMonthOfYear() + "/" + d.getYear() + " " + (d.getHourOfDay() < 10 ? "0" : "") + d.getHourOfDay() + ":" + (d.getMinuteOfHour() < 10 ? "0" : "") + d.getMinuteOfHour() + ":" + (d.getSecondOfMinute() < 10 ? "0" : "") + d.getSecondOfMinute(); }/*from w w w .j a va2s.c o m*/ return result; }
From source file:com.cronutils.model.time.ExecutionTime.java
License:Apache License
/** * If date is not match, will return next closest match. * If date is match, will return this date. * @param date - reference DateTime instance - never null; * @return DateTime instance, never null. Value obeys logic specified above. * @throws NoSuchValueException/*from ww w . j av a 2 s . c om*/ */ DateTime nextClosestMatch(DateTime date) throws NoSuchValueException { List<Integer> year = yearsValueGenerator.generateCandidates(date.getYear(), date.getYear()); TimeNode days = null; int lowestMonth = months.getValues().get(0); int lowestHour = hours.getValues().get(0); int lowestMinute = minutes.getValues().get(0); int lowestSecond = seconds.getValues().get(0); NearestValue nearestValue; DateTime newDate; if (year.isEmpty()) { int newYear = yearsValueGenerator.generateNextValue(date.getYear()); days = generateDays(cronDefinition, new DateTime(newYear, lowestMonth, 1, 0, 0)); return initDateTime(yearsValueGenerator.generateNextValue(date.getYear()), lowestMonth, days.getValues().get(0), lowestHour, lowestMinute, lowestSecond, date.getZone()); } if (!months.getValues().contains(date.getMonthOfYear())) { nearestValue = months.getNextValue(date.getMonthOfYear(), 0); int nextMonths = nearestValue.getValue(); if (nearestValue.getShifts() > 0) { newDate = new DateTime(date.getYear(), 1, 1, 0, 0, 0, date.getZone()) .plusYears(nearestValue.getShifts()); return nextClosestMatch(newDate); } if (nearestValue.getValue() < date.getMonthOfYear()) { date = date.plusYears(1); } days = generateDays(cronDefinition, new DateTime(date.getYear(), nextMonths, 1, 0, 0)); return initDateTime(date.getYear(), nextMonths, days.getValues().get(0), lowestHour, lowestMinute, lowestSecond, date.getZone()); } days = generateDays(cronDefinition, date); if (!days.getValues().contains(date.getDayOfMonth())) { nearestValue = days.getNextValue(date.getDayOfMonth(), 0); if (nearestValue.getShifts() > 0) { newDate = new DateTime(date.getYear(), date.getMonthOfYear(), 1, 0, 0, 0, date.getZone()) .plusMonths(nearestValue.getShifts()); return nextClosestMatch(newDate); } if (nearestValue.getValue() < date.getDayOfMonth()) { date = date.plusMonths(1); } return initDateTime(date.getYear(), date.getMonthOfYear(), nearestValue.getValue(), lowestHour, lowestMinute, lowestSecond, date.getZone()); } if (!hours.getValues().contains(date.getHourOfDay())) { nearestValue = hours.getNextValue(date.getHourOfDay(), 0); int nextHours = nearestValue.getValue(); if (nearestValue.getShifts() > 0) { newDate = new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), 0, 0, 0, date.getZone()).plusDays(nearestValue.getShifts()); return nextClosestMatch(newDate); } if (nearestValue.getValue() < date.getHourOfDay()) { date = date.plusDays(1); } return initDateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), nextHours, lowestMinute, lowestSecond, date.getZone()); } if (!minutes.getValues().contains(date.getMinuteOfHour())) { nearestValue = minutes.getNextValue(date.getMinuteOfHour(), 0); int nextMinutes = nearestValue.getValue(); if (nearestValue.getShifts() > 0) { newDate = new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), date.getHourOfDay(), 0, 0, date.getZone()).plusHours(nearestValue.getShifts()); return nextClosestMatch(newDate); } if (nearestValue.getValue() < date.getMinuteOfHour()) { date = date.plusHours(1); } return initDateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), date.getHourOfDay(), nextMinutes, lowestSecond, date.getZone()); } if (!seconds.getValues().contains(date.getSecondOfMinute())) { nearestValue = seconds.getNextValue(date.getSecondOfMinute(), 0); int nextSeconds = nearestValue.getValue(); if (nearestValue.getShifts() > 0) { newDate = new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), date.getHourOfDay(), date.getMinuteOfHour(), 0, date.getZone()) .plusMinutes(nearestValue.getShifts()); return nextClosestMatch(newDate); } if (nearestValue.getValue() < date.getSecondOfMinute()) { date = date.plusMinutes(1); } return initDateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), date.getHourOfDay(), date.getMinuteOfHour(), nextSeconds, date.getZone()); } return date; }
From source file:com.cronutils.model.time.ExecutionTime.java
License:Apache License
/** * If date is not match, will return previous closest match. * If date is match, will return this date. * @param date - reference DateTime instance - never null; * @return DateTime instance, never null. Value obeys logic specified above. * @throws NoSuchValueException/* w w w .j a v a 2s . c o m*/ */ DateTime previousClosestMatch(DateTime date) throws NoSuchValueException { List<Integer> year = yearsValueGenerator.generateCandidates(date.getYear(), date.getYear()); TimeNode days = generateDays(cronDefinition, date); int highestMonth = months.getValues().get(months.getValues().size() - 1); int highestDay = days.getValues().get(days.getValues().size() - 1); int highestHour = hours.getValues().get(hours.getValues().size() - 1); int highestMinute = minutes.getValues().get(minutes.getValues().size() - 1); int highestSecond = seconds.getValues().get(seconds.getValues().size() - 1); NearestValue nearestValue; DateTime newDate; if (year.isEmpty()) { int previousYear = yearsValueGenerator.generatePreviousValue(date.getYear()); if (highestDay > 28) { int highestDayOfMonth = new DateTime(previousYear, highestMonth, 1, 0, 0).dayOfMonth() .getMaximumValue(); if (highestDay > highestDayOfMonth) { nearestValue = days.getPreviousValue(highestDay, 1); if (nearestValue.getShifts() > 0) { newDate = new DateTime(previousYear, highestMonth, 1, 23, 59, 59) .minusMonths(nearestValue.getShifts()).dayOfMonth().withMaximumValue(); return previousClosestMatch(newDate); } else { highestDay = nearestValue.getValue(); } } } return initDateTime(previousYear, highestMonth, highestDay, highestHour, highestMinute, highestSecond, date.getZone()); } if (!months.getValues().contains(date.getMonthOfYear())) { nearestValue = months.getPreviousValue(date.getMonthOfYear(), 0); int previousMonths = nearestValue.getValue(); if (nearestValue.getShifts() > 0) { newDate = new DateTime(date.getYear(), 12, 31, 23, 59, 59).minusYears(nearestValue.getShifts()); return previousClosestMatch(newDate); } return initDateTime(date.getYear(), previousMonths, highestDay, highestHour, highestMinute, highestSecond, date.getZone()); } if (!days.getValues().contains(date.getDayOfMonth())) { nearestValue = days.getPreviousValue(date.getDayOfMonth(), 0); if (nearestValue.getShifts() > 0) { newDate = new DateTime(date.getYear(), date.getMonthOfYear(), 1, 23, 59, 59) .minusMonths(nearestValue.getShifts()).dayOfMonth().withMaximumValue(); return previousClosestMatch(newDate); } return initDateTime(date.getYear(), date.getMonthOfYear(), nearestValue.getValue(), highestHour, highestMinute, highestSecond, date.getZone()); } if (!hours.getValues().contains(date.getHourOfDay())) { nearestValue = hours.getPreviousValue(date.getHourOfDay(), 0); if (nearestValue.getShifts() > 0) { newDate = new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), 23, 59, 59) .minusDays(nearestValue.getShifts()); return previousClosestMatch(newDate); } return initDateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), nearestValue.getValue(), highestMinute, highestSecond, date.getZone()); } if (!minutes.getValues().contains(date.getMinuteOfHour())) { nearestValue = minutes.getPreviousValue(date.getMinuteOfHour(), 0); if (nearestValue.getShifts() > 0) { newDate = new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), date.getHourOfDay(), 59, 59).minusHours(nearestValue.getShifts()); return previousClosestMatch(newDate); } return initDateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), date.getHourOfDay(), nearestValue.getValue(), highestSecond, date.getZone()); } if (!seconds.getValues().contains(date.getSecondOfMinute())) { nearestValue = seconds.getPreviousValue(date.getSecondOfMinute(), 0); int previousSeconds = nearestValue.getValue(); if (nearestValue.getShifts() > 0) { newDate = new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), date.getHourOfDay(), date.getMinuteOfHour(), 59).minusMinutes(nearestValue.getShifts()); return previousClosestMatch(newDate); } return initDateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), date.getHourOfDay(), date.getMinuteOfHour(), previousSeconds, date.getZone()); } return date; }
From source file:com.ecofactor.qa.automation.util.DateUtil.java
License:Open Source License
/** * Convert time to utc calendar./*from w ww . j a v a 2 s .c o m*/ * @param date the date * @return the calendar */ public static Calendar convertTimeToUTCCalendar(DateTime date) { Calendar utcCalendar = getUTCCalendar(); StringBuilder startDate = new StringBuilder(); startDate.append(utcCalendar.get(Calendar.YEAR)).append("-").append(utcCalendar.get(Calendar.MONTH) + 1) .append("-").append(utcCalendar.get(Calendar.DATE)).toString(); int hours = date.getHourOfDay(); int mins = date.getMinuteOfHour(); int secs = date.getSecondOfMinute(); startDate.append(" " + hours + ":" + mins + ":" + secs); Calendar changedCalendar = parseToUTCCalendar(startDate.toString(), DATE_FMT); System.out.println(changedCalendar); return changedCalendar; }
From source file:com.ephesoft.dcma.nsi.NsiExporter.java
License:Open Source License
private void transformXmlAndExportFiles(String batchInstanceID, String exportFolder, String xmlTagStyle, boolean isZipSwitchOn, String baseDocsFolder, InputStream xslStream) throws TransformerFactoryConfigurationError, DCMAApplicationException { String batchXmlName = batchInstanceID + ICommonConstants.UNDERSCORE_BATCH_XML; String sourceXMLPath = baseDocsFolder + File.separator + batchInstanceID + ICommonConstants.UNDERSCORE_BATCH_XML; String targetXmlPath = exportFolder + File.separator + batchInstanceID + xmlTagStyle; LOGGER.debug("Transforming XML " + sourceXMLPath + " to " + targetXmlPath); try {// ww w. j a v a 2 s . c o m TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = null; try { // NOTE, this needs to be fixed to use the InputStream xslStream object, not a hardcoded path to the file. transformer = tFactory.newTransformer(new StreamSource(xslStream)); } finally { if (xslStream != null) { try { xslStream.close(); } catch (IOException e) { LOGGER.info("Error closing input stream for :" + xslResource.toString()); } } } if (transformer != null) { DateTimeZone zone = DateTimeZone.forID(NSIExportConstant.TIME_ZONE_ID); DateTime dateTime = new DateTime(zone); String date = Integer.toString(dateTime.getYear()) + NSIExportConstant.HYPEN + Integer.toString(dateTime.getMonthOfYear()) + NSIExportConstant.HYPEN + Integer.toString(dateTime.getDayOfMonth()); String time = Integer.toString(dateTime.getHourOfDay()) + NSIExportConstant.COLON + Integer.toString(dateTime.getMinuteOfHour()) + NSIExportConstant.COLON + Integer.toString(dateTime.getSecondOfMinute()); transformer.setParameter(NSIExportConstant.DATE, date); transformer.setParameter(NSIExportConstant.HOURS, time); transformer.setParameter(NSIExportConstant.BASE_DOC_FOLDER_PATH, baseDocsFolder + File.separator); transformer.setParameter(NSIExportConstant.EXPORT_FOLDER_PATH, exportFolder + File.separator); File file = new File(exportFolder); boolean isFileCreated = false; if (!file.exists()) { isFileCreated = file.mkdir(); } else { isFileCreated = true; } if (isFileCreated) { String imageFolderPath = exportFolder + File.separator + NSIExportConstant.IMAGE_FOLDER_NAME; File imageFolder = new File(imageFolderPath); boolean isImageFolderCreated = false; if (!imageFolder.exists()) { isImageFolderCreated = imageFolder.mkdir(); } else { isImageFolderCreated = true; } if (isImageFolderCreated) { LOGGER.info(exportFolder + " folder created"); Batch batch = batchSchemaService.getBatch(batchInstanceID); List<Document> documentList = batch.getDocuments().getDocument(); transformXML(isZipSwitchOn, batchXmlName, sourceXMLPath, targetXmlPath, transformer); File baseDocFolder = new File(baseDocsFolder); for (Document document : documentList) { if (document != null && document.getMultiPageTiffFile() != null && !document.getMultiPageTiffFile().isEmpty()) { String multipageTiffName = document.getMultiPageTiffFile(); String filePath = baseDocFolder.getAbsolutePath() + File.separator + multipageTiffName; String exportFileName = multipageTiffName.replace( NSIExportConstant.TIF_WITH_DOT_EXTENSION, NSIExportConstant.DAT_WITH_DOT_EXTENSION); String exportFilePath = imageFolderPath + File.separator + exportFileName; File oldFile = new File(filePath); File newFile = new File(exportFilePath); try { FileUtils.copyFile(oldFile, newFile); } catch (Exception e) { LOGGER.error("Error creating in file: " + newFile + "is" + e.getMessage(), e); } } } } } else { LOGGER.error("Access is denied for creating: " + file.getName()); } } else { LOGGER.error("Transformer is null due to Invalid xsl file."); } } catch (FileNotFoundException e1) { LOGGER.error("Could not find NSITransform.xsl file : " + e1.getMessage(), e1); throw new DCMAApplicationException("Could not find nsiTransform.xsl file : " + e1.getMessage(), e1); } catch (TransformerException e1) { LOGGER.error( "Problem occurred in transforming " + sourceXMLPath + " to " + targetXmlPath + e1.getMessage(), e1); throw new DCMAApplicationException("Could not find nsiTransform.xsl file : ", e1); } catch (IOException ioe) { LOGGER.error( "Problem occurred in transforming " + sourceXMLPath + " to " + targetXmlPath + ioe.getMessage(), ioe); throw new DCMAApplicationException("Could not transform ibmCMTransform.xsl file : " + ioe.getMessage(), ioe); } }
From source file:com.esri.geoevent.solutions.processor.geometry.QueryReportProcessor.java
License:Apache License
@Override public GeoEvent process(GeoEvent ge) throws Exception { //CreateQueryMap(); CreateQueries();// ww w . j ava 2 s. c om double radius = (Double) properties.get("radius").getValue(); String units = properties.get("units").getValue().toString(); int inwkid = (Integer) properties.get("wkidin").getValue(); int outwkid = (Integer) properties.get("wkidout").getValue(); int bufferwkid = (Integer) properties.get("wkidbuffer").getValue(); srIn = SpatialReference.create(inwkid); srBuffer = SpatialReference.create(bufferwkid); srOut = SpatialReference.create(outwkid); com.esri.ges.spatial.Geometry geo = ge.getGeometry(); com.esri.ges.spatial.Geometry inGeo = null; if (properties.get("geosrc").getValueAsString().equals("Buffer")) { inGeometry = constructGeometry(geo); Unit u = queryUnit(units); inGeo = constructBuffer(geo, radius, u); } else if (properties.get("geosrc").getValueAsString().equals("Event Definition")) { String eventfld = properties.get("geoeventdef").getValue().toString(); String[] arr = eventfld.split(":"); String geostr = (String) ge.getField(arr[1]); com.esri.ges.spatial.Geometry g = constructGeometryFromString(geostr); com.esri.core.geometry.Geometry polyGeo = constructGeometry(g); Envelope env = new Envelope(); polyGeo.queryEnvelope(env); inGeometry = env.getCenter(); com.esri.core.geometry.Geometry projGeo = GeometryEngine.project(polyGeo, srBuffer, srOut); String json = GeometryEngine.geometryToJson(srOut, projGeo); inGeo = spatial.fromJson(json); } else { com.esri.core.geometry.Geometry polyGeo = constructGeometry(geo); Envelope env = new Envelope(); polyGeo.queryEnvelope(env); inGeometry = env.getCenter(); com.esri.core.geometry.Geometry projGeo = GeometryEngine.project(polyGeo, srBuffer, srOut); String json = GeometryEngine.geometryToJson(srOut, projGeo); inGeo = spatial.fromJson(json); } String jsonGeo = inGeo.toJson(); String geotype = GeometryUtility.parseGeometryType(inGeo.getType()); ExecuteRestQueries(jsonGeo, geotype); String timestamp = ""; if ((Boolean) properties.get("usetimestamp").getValue()) { String eventfld = properties.get("timestamp").getValueAsString(); String[] arr = eventfld.split(":"); timestamp = ge.getField(arr[1]).toString(); } DateTime dt = DateTime.now(); String ts = ((Integer) dt.getYear()).toString() + ((Integer) dt.getMonthOfYear()).toString() + ((Integer) dt.getDayOfMonth()).toString() + ((Integer) dt.getHourOfDay()).toString() + ((Integer) dt.getMinuteOfHour()).toString() + ((Integer) dt.getSecondOfMinute()).toString(); String file = properties.get("filename").getValueAsString() + ts + ".html"; ParseResponses(timestamp, file); String host = properties.get("host").getValueAsString(); if (host.contains("http://")) { host.replace("http://", ""); } String url = "http://" + host + ":6180/geoevent/assets/reports/" + file; GeoEventDefinition geoDef = ge.getGeoEventDefinition(); String outDefName = geoDef.getName() + "_out"; GeoEventDefinition edOut; if ((edOut = manager.searchGeoEventDefinition(outDefName, getId())) == null) { List<FieldDefinition> fds = Arrays .asList(((FieldDefinition) new DefaultFieldDefinition("url", FieldType.String))); edOut = geoDef.augment(fds); edOut.setOwner(getId()); edOut.setName(outDefName); manager.addGeoEventDefinition(edOut); } GeoEventCreator geoEventCreator = messaging.createGeoEventCreator(); GeoEvent geOut = geoEventCreator.create(edOut.getGuid(), new Object[] { ge.getAllFields(), url }); geOut.setProperty(GeoEventPropertyName.TYPE, "message"); geOut.setProperty(GeoEventPropertyName.OWNER_ID, getId()); geOut.setProperty(GeoEventPropertyName.OWNER_ID, definition.getUri()); for (Map.Entry<GeoEventPropertyName, Object> property : ge.getProperties()) if (!geOut.hasProperty(property.getKey())) geOut.setProperty(property.getKey(), property.getValue()); queries.clear(); responseMap.clear(); return geOut; }
From source file:com.esri.geoevent.solutions.processor.queryreport.QueryReportProcessor.java
License:Apache License
@Override public void afterPropertiesSet() { radius = (Double) properties.get("radius").getValue(); units = properties.get("units").getValue().toString(); //inwkid = (Integer) properties.get("wkidin").getValue(); outwkid = (Integer) properties.get("wkidout").getValue(); bufferwkid = (Integer) properties.get("wkidbuffer").getValue(); geoSrc = properties.get("geosrc").getValueAsString(); useCentroid = (Boolean) properties.get("usecentroid").getValue(); eventfld = properties.get("geoeventdef").getValue().toString(); useTimeStamp = (Boolean) properties.get("usetimestamp").getValue(); DateTime dt = DateTime.now(); ts = ((Integer) dt.getYear()).toString() + ((Integer) dt.getMonthOfYear()).toString() + ((Integer) dt.getDayOfMonth()).toString() + ((Integer) dt.getHourOfDay()).toString() + ((Integer) dt.getMinuteOfHour()).toString() + ((Integer) dt.getSecondOfMinute()).toString(); time = ((Integer) dt.getYear()).toString() + "/" + ((Integer) dt.getMonthOfYear()).toString() + "/" + ((Integer) dt.getDayOfMonth()).toString() + " " + ((Integer) dt.getHourOfDay()).toString() + ":" + ((Integer) dt.getMinuteOfHour()).toString() + ":" + ((Integer) dt.getSecondOfMinute()).toString(); file = properties.get("filename").getValueAsString() + ts + ".html"; host = properties.get("host").getValueAsString(); outDefName = properties.get("gedname").getValueAsString(); connName = properties.get("connection").getValueAsString(); folder = properties.get("folder").getValueAsString(); service = properties.get("service").getValueAsString(); lyrName = properties.get("layer").getValueAsString(); try {/* w ww. ja va2s . c o m*/ conn = connectionManager.getArcGISServerConnection(connName); } catch (Exception e) { LOG.error(e.getMessage()); ValidationException ve = new ValidationException("Unable to make connection to ArcGIS Server"); LOG.error(ve.getMessage()); try { throw ve; } catch (ValidationException e1) { e1.printStackTrace(); } } layer = conn.getLayer(folder, service, lyrName, ArcGISServerType.FeatureServer); layerId = ((Integer) layer.getId()).toString(); field = properties.get("field").getValueAsString(); sortField = properties.get("sortfield").getValueAsString(); if (!properties.get("endpoint").getValueAsString().isEmpty()) { endpoint = properties.get("endpoint").getValueAsString(); } try { token = conn.getDecryptedToken(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } //fields = conn.getFields(folder, service, layer.getId(), ArcGISServerType.FeatureServer); calcDist = (Boolean) properties.get("calcDistance").getValue(); wc = properties.get("wc").getValueAsString(); lyrHeaderCfg = properties.get("lyrheader").getValueAsString(); sortByDist = false; if (calcDist) { sortByDist = (Boolean) properties.get("sortdist").getValue(); distToken = "${distance.value}"; distUnits = properties.get("dist_units").getValueAsString(); } //token = properties.get("field-token").getValueAsString(); itemConfig = properties.get("item-config").getValueAsString(); title = properties.get("title").getValueAsString(); Object objHeader = properties.get("header"); header = null; if (objHeader != null) { header = properties.get("header").getValueAsString(); } }
From source file:com.esri.ges.solutions.processor.geometry.QueryProcessor.java
License:Apache License
@Override public GeoEvent process(GeoEvent ge) throws Exception { CreateQueryMap();//from w ww.j a va 2 s. com double radius = (Double) properties.get("radius").getValue(); String units = properties.get("units").getValue().toString(); int inwkid = (Integer) properties.get("wkidin").getValue(); int outwkid = (Integer) properties.get("wkidout").getValue(); int bufferwkid = (Integer) properties.get("wkidbuffer").getValue(); srIn = SpatialReference.create(inwkid); srBuffer = SpatialReference.create(bufferwkid); srOut = SpatialReference.create(outwkid); com.esri.ges.spatial.Point eventGeo = (com.esri.ges.spatial.Point) ge.getGeometry(); double x = eventGeo.getX(); double y = eventGeo.getY(); com.esri.ges.spatial.Geometry buffer = constructBuffer(x, y, radius, units); String jsonGeo = buffer.toJson(); String geotype = GeometryUtility.parseGeometryType(buffer.getType()); ExecuteRestQueries(jsonGeo, geotype); String timestamp = ""; if ((Boolean) properties.get("usetimestamp").getValue()) { String eventfld = properties.get("timestamp").getValueAsString(); String[] arr = eventfld.split(":"); timestamp = ge.getField(arr[1]).toString(); } DateTime dt = DateTime.now(); String ts = ((Integer) dt.getYear()).toString() + ((Integer) dt.getMonthOfYear()).toString() + ((Integer) dt.getDayOfMonth()).toString() + ((Integer) dt.getHourOfDay()).toString() + ((Integer) dt.getMinuteOfHour()).toString() + ((Integer) dt.getSecondOfMinute()).toString(); String file = properties.get("filename").getValueAsString() + ts + ".html"; ParseResponses(timestamp, file); String host = properties.get("host").getValueAsString(); String url = "http://" + host + ":6180/geoevent/assets/reports/" + file; GeoEventDefinition geoDef = ge.getGeoEventDefinition(); List<FieldDefinition> fds = Arrays .asList(((FieldDefinition) new DefaultFieldDefinition("url", FieldType.String))); GeoEventDefinition edOut = geoDef.augment(fds); edOut.setOwner(getId()); manager.addTemporaryGeoEventDefinition(edOut, true); GeoEventCreator geoEventCreator = messaging.createGeoEventCreator(); GeoEvent geOut = geoEventCreator.create(edOut.getGuid(), new Object[] { ge.getAllFields(), url }); geOut.setProperty(GeoEventPropertyName.TYPE, "message"); geOut.setProperty(GeoEventPropertyName.OWNER_ID, getId()); geOut.setProperty(GeoEventPropertyName.OWNER_ID, definition.getUri()); for (Map.Entry<GeoEventPropertyName, Object> property : ge.getProperties()) if (!geOut.hasProperty(property.getKey())) geOut.setProperty(property.getKey(), property.getValue()); queries.clear(); responseMap.clear(); return geOut; }
From source file:com.esri.ges.solutions.processor.geometry.QueryReportProcessor.java
License:Apache License
@Override public GeoEvent process(GeoEvent ge) throws Exception { CreateQueryMap();/*from w w w . ja va2 s.c o m*/ double radius = (Double) properties.get("radius").getValue(); String units = properties.get("units").getValue().toString(); int inwkid = (Integer) properties.get("wkidin").getValue(); int outwkid = (Integer) properties.get("wkidout").getValue(); int bufferwkid = (Integer) properties.get("wkidbuffer").getValue(); srIn = SpatialReference.create(inwkid); srBuffer = SpatialReference.create(bufferwkid); srOut = SpatialReference.create(outwkid); Geometry geo = ge.getGeometry(); Geometry inGeo = null; if (properties.get("geosrc").getValueAsString().equals("Buffer")) { inGeo = constructBuffer(geo, radius, units); } else if (properties.get("geosrc").getValueAsString().equals("Event Definition")) { String eventfld = properties.get("geoeventdef").getValue().toString(); String[] arr = eventfld.split(":"); String geostr = (String) ge.getField(arr[1]); inGeo = constructGeometryFromString(geostr); } else { inGeo = geo; } String jsonGeo = inGeo.toJson(); String geotype = GeometryUtility.parseGeometryType(inGeo.getType()); ExecuteRestQueries(jsonGeo, geotype); String timestamp = ""; if ((Boolean) properties.get("usetimestamp").getValue()) { String eventfld = properties.get("timestamp").getValueAsString(); String[] arr = eventfld.split(":"); timestamp = ge.getField(arr[1]).toString(); } DateTime dt = DateTime.now(); String ts = ((Integer) dt.getYear()).toString() + ((Integer) dt.getMonthOfYear()).toString() + ((Integer) dt.getDayOfMonth()).toString() + ((Integer) dt.getHourOfDay()).toString() + ((Integer) dt.getMinuteOfHour()).toString() + ((Integer) dt.getSecondOfMinute()).toString(); String file = properties.get("filename").getValueAsString() + ts + ".html"; ParseResponses(timestamp, file); String host = properties.get("host").getValueAsString(); String url = "http://" + host + ":6180/geoevent/assets/reports/" + file; GeoEventDefinition geoDef = ge.getGeoEventDefinition(); List<FieldDefinition> fds = Arrays .asList(((FieldDefinition) new DefaultFieldDefinition("url", FieldType.String))); GeoEventDefinition edOut = geoDef.augment(fds); edOut.setOwner(getId()); manager.addTemporaryGeoEventDefinition(edOut, true); GeoEventCreator geoEventCreator = messaging.createGeoEventCreator(); GeoEvent geOut = geoEventCreator.create(edOut.getGuid(), new Object[] { ge.getAllFields(), url }); geOut.setProperty(GeoEventPropertyName.TYPE, "message"); geOut.setProperty(GeoEventPropertyName.OWNER_ID, getId()); geOut.setProperty(GeoEventPropertyName.OWNER_ID, definition.getUri()); for (Map.Entry<GeoEventPropertyName, Object> property : ge.getProperties()) if (!geOut.hasProperty(property.getKey())) geOut.setProperty(property.getKey(), property.getValue()); queries.clear(); responseMap.clear(); return geOut; }