List of usage examples for org.joda.time DateTime getDayOfMonth
public int getDayOfMonth()
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(); }/* w w w. j ava 2 s . c o m*/ return result; }
From source file:com.core.meka.Util.java
public static String fechaYhora(Date d) { DateTime n = new DateTime(d); return n.getDayOfMonth() + "/" + n.getMonthOfYear() + "/" + n.getYear() + " " + (n.getHourOfDay() < 10 ? "0" + n.getHourOfDay() : n.getHourOfDay()) + ":" + (n.getMinuteOfHour() < 10 ? "0" + n.getMinuteOfHour() : n.getMinuteOfHour()); }
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 w w w . ja v a 2 s.c o m */ 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/*from w w w . ja va 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.edoli.calendarlms.CalendarAdapter.java
License:Apache License
@SuppressWarnings("deprecation") @Override/* w w w .j a va 2 s . c o m*/ public View getView(int position, View convertView, ViewGroup parent) { Context context = parent.getContext(); RelativeLayout view = new RelativeLayout(context); DateTime date = mDate.plusDays(position); AbsListView.LayoutParams layoutParams = null; int gHeight = mGridView.getMeasuredHeight(); int cHeight = gHeight / 6; int gWidth = mGridView.getMeasuredWidth(); int cWidth = gWidth / 7; int row = position / 7; int column = position % 7; layoutParams = new AbsListView.LayoutParams(cWidth, cHeight); if (column == 6) { layoutParams.width = gWidth - cWidth * 6; } if (row == 5) { layoutParams.height = gHeight - cHeight * 5; } view.setLayoutParams(layoutParams); int day = date.getDayOfMonth(); TextView dayView = new TextView(context); RelativeLayout.LayoutParams dayParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); dayParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); dayParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); dayView.setLayoutParams(dayParams); dayView.setText(day + ""); dayView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20); if (column == 0) { dayView.setTextColor(Color.RED); } // Set Background of cell int fillColor = 0; int strokeColor = 0; if (date.getMonthOfYear() != mMonth) { fillColor = Color.argb(51, 0, 0, 0); strokeColor = Color.GRAY; dayView.setTextColor(Color.GRAY); } else { fillColor = Color.argb(51, 238, 238, 230); strokeColor = Color.GRAY; } // Set different color or event cell if (mCalendarEvents != null) { for (CalendarEvent event : mCalendarEvents) { DateTime eventDate = event.getDate(); if (eventDate.getDayOfYear() == date.getDayOfYear()) { fillColor = Color.argb(51, 205, 92, 92); } } } ShapeDrawable drawable = new CellShapeDrawable(fillColor, strokeColor, row, column); view.setBackgroundDrawable(drawable); view.addView(dayView); return view; }
From source file:com.ehdev.chronos.lib.types.holders.PayPeriodHolder.java
License:Open Source License
/** * Will do the calculations for the start and end of the process */// w w w .j a v a 2 s .c o m public void generate() { //Get the start and end of pay period DateTime startOfPP = gJob.getStartOfPayPeriod(); gDuration = gJob.getDuration(); DateTime endOfPP = DateTime.now(); //Today long duration = endOfPP.getMillis() - startOfPP.getMillis(); DateTimeZone startZone = startOfPP.getZone(); DateTimeZone endZone = endOfPP.getZone(); long offset = endZone.getOffset(endOfPP) - startZone.getOffset(startOfPP); int weeks = (int) ((duration + offset) / 1000 / 60 / 60 / 24 / 7); /* System.out.println("end of pp: " + endOfPP); System.out.println("start of pp: " + startOfPP); System.out.println("dur: " + duration); System.out.println("weeks diff: " + weeks); */ switch (gDuration) { case ONE_WEEK: //weeks = weeks; startOfPP = startOfPP.plusWeeks(weeks); endOfPP = startOfPP.plusWeeks(1); break; case TWO_WEEKS: weeks = weeks / 2; startOfPP = startOfPP.plusWeeks(weeks * 2); endOfPP = startOfPP.plusWeeks(2); break; case THREE_WEEKS: weeks = weeks / 3; startOfPP = startOfPP.plusWeeks(weeks * 3); endOfPP = startOfPP.plusWeeks(3); break; case FOUR_WEEKS: weeks = weeks / 4; startOfPP = startOfPP.plusWeeks(weeks * 4); endOfPP = startOfPP.plusWeeks(4); break; case FULL_MONTH: //in this case, endOfPP is equal to now startOfPP = DateMidnight.now().toDateTime().withDayOfMonth(1); endOfPP = startOfPP.plusMonths(1); break; case FIRST_FIFTEENTH: DateTime now = DateTime.now(); if (now.getDayOfMonth() >= 15) { startOfPP = now.withDayOfMonth(15); endOfPP = startOfPP.plusDays(20).withDayOfMonth(1); } else { startOfPP = now.withDayOfMonth(1); endOfPP = now.withDayOfMonth(15); } break; default: break; } if (startOfPP.isAfter(DateTime.now())) { startOfPP = startOfPP.minusWeeks(getDays() / 7); endOfPP = endOfPP.minusWeeks(getDays() / 7); } gStartOfPP = startOfPP; gEndOfPP = endOfPP; }
From source file:com.enitalk.configs.DateCache.java
public NavigableSet<DateTime> days(JsonNode tree, String tz, JsonNode teacherNode) { ConcurrentSkipListSet<DateTime> dates = new ConcurrentSkipListSet<>(); Iterator<JsonNode> els = tree.elements(); DateTimeZone dz = DateTimeZone.forID(tz); DateTimeFormatter hour = DateTimeFormat.forPattern("HH:mm").withZone(dz); DateTime today = DateTime.now().millisOfDay().setCopy(0); while (els.hasNext()) { JsonNode el = els.next();//from w w w . ja va 2 s.com String day = el.path("day").asText(); boolean plus = today.getDayOfWeek() > days.get(day); if (el.has("start") && el.has("end")) { DateTime start = hour.parseDateTime(el.path("start").asText()).dayOfMonth() .setCopy(today.getDayOfMonth()).monthOfYear().setCopy(today.getMonthOfYear()).year() .setCopy(today.getYear()).withDayOfWeek(days.get(day)).plusWeeks(plus ? 1 : 0); DateTime end = hour.parseDateTime(el.path("end").asText()).dayOfMonth() .setCopy(today.getDayOfMonth()).monthOfYear().setCopy(today.getMonthOfYear()).year() .setCopy(today.getYear()).withDayOfWeek(days.get(day)).plusWeeks(plus ? 1 : 0); Hours hours = Hours.hoursBetween(start, end); int hh = hours.getHours() + 1; while (hh-- > 0) { dates.add(start.plusHours(hh).toDateTime(DateTimeZone.UTC)); } } else { List<String> datesAv = jackson.convertValue(el.path("times"), List.class); logger.info("Array of dates {} {}", datesAv, day); datesAv.forEach((String dd) -> { DateTime date = hour.parseDateTime(dd).dayOfMonth().setCopy(today.getDayOfMonth()).monthOfYear() .setCopy(today.getMonthOfYear()).year().setCopy(today.getYear()) .withDayOfWeek(days.get(day)).plusWeeks(plus ? 1 : 0); dates.add(date.toDateTime(DateTimeZone.UTC)); }); } } final TreeSet<DateTime> addWeek = new TreeSet<>(); for (int i = 1; i < 2; i++) { for (DateTime e : dates) { addWeek.add(e.plusWeeks(i)); } } dates.addAll(addWeek); DateTime nowUtc = DateTime.now().toDateTime(DateTimeZone.UTC); nowUtc = nowUtc.plusHours(teacherNode.path("notice").asInt(2)); NavigableSet<DateTime> ss = dates.tailSet(nowUtc, true); return ss; }
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 {/*from w w w . jav a2 s . co 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();//from w w w .j av a 2 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); 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 {//from w w w. j av a 2 s. co 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(); } }