List of usage examples for org.joda.time DateTime now
public static DateTime now()
ISOChronology
in the default time zone. From source file:com.enitalk.controllers.bots.TimeZoneTestr.java
public static void main(String[] args) { Set<String> ids = DateTimeZone.getAvailableIDs(); TreeMultimap<Long, String> map = TreeMultimap.create(); for (String id : ids) { DateTimeZone dz = DateTimeZone.forID(id); int offset = dz.getOffset(DateTime.now().withZone(DateTimeZone.UTC)); map.put(TimeUnit.MILLISECONDS.toMinutes(offset), id); }//www. j av a2s .c o m ObjectMapper j = new ObjectMapper(); ArrayNode a = j.createArrayNode(); map.keySet().forEach((Long key) -> { a.addObject().set(key.toString(), j.convertValue(map.get(key), ArrayNode.class)); }); System.out.println(a); // System.out.println(map); }
From source file:com.enitalk.opentok.CheckAvailabilityRunnable.java
@Override @Scheduled(fixedDelay = 10000L)/* w w w. ja v a2 s.c o m*/ public void run() { try { Query q = Query.query(Criteria.where("video").in(2, 3).andOperator( Criteria.where("checkDate").lt(DateTime.now().toDate()), Criteria.where("video").exists(true))); List<HashMap> evs = mongo.find(q, HashMap.class, "events"); if (evs.isEmpty()) { return; } ArrayNode events = jackson.convertValue(evs, ArrayNode.class); Iterator<JsonNode> it = events.elements(); mongo.updateMulti(q, new Update().set("video", 3), "events"); while (it.hasNext()) { JsonNode en = it.next(); rabbit.send("youtube_check", MessageBuilder.withBody(jackson.writeValueAsBytes(en)).build()); } } catch (Exception e) { logger.info(ExceptionUtils.getFullStackTrace(e)); } }
From source file:com.enonic.cms.core.time.SystemTimeService.java
License:Open Source License
@Override public void afterPropertiesSet() throws Exception { this.bootTime = DateTime.now(); LOG.info("System Boot Time noted as: " + this.bootTime); }
From source file:com.enonic.cms.core.time.SystemTimeService.java
License:Open Source License
public DateTime getNowAsDateTime() { return DateTime.now(); }
From source file:com.eova.widget.upload.UploadController.java
License:Open Source License
public void file() { String filedir = getPara("filedir"); if (xx.isEmpty(filedir)) { // /*ww w . java 2s .co m*/ String today = DateTime.now().toString("yyyyMMdd"); filedir = File.separator + "upload" + File.separator + today; } upload(false, filedir); }
From source file:com.esri.geoevent.solutions.processor.geometry.QueryReportProcessor.java
License:Apache License
@Override public GeoEvent process(GeoEvent ge) throws Exception { //CreateQueryMap(); CreateQueries();/*w w w.j a 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); 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 ww . j av a 2 s. c om 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();// 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();/* w w w .ja va 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); 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; }
From source file:com.ethercis.compositionservice.CompositionService.java
License:Apache License
@QuerySetting(dialect = { @QuerySyntax(mode = I_ServiceRunMode.DialectSpace.STANDARD, httpMethod = "GET", method = "create", path = "vehr/composition", responseType = ResponseType.Json), @QuerySyntax(mode = I_ServiceRunMode.DialectSpace.EHRSCAPE, httpMethod = "POST", method = "post", path = "rest/v1/composition", responseType = ResponseType.Json) }) public Object create(I_SessionClientProperties props) throws Exception { auditSetter.handleProperties(getDataAccess(), props); String sessionId = auditSetter.getSessionId(); String templateId = props.getClientProperty(I_CompositionService.TEMPLATE_ID, (String) null); UUID ehrId = retrieveEhrId(sessionId, props); UUID committerUuid = auditSetter.getCommitterUuid(); UUID systemUuid = auditSetter.getSystemUuid(); I_CompositionService.CompositionFormat format = I_CompositionService.CompositionFormat .valueOf(props.getClientProperty(I_CompositionService.FORMAT, "XML")); if ((format == CompositionFormat.FLAT || format == CompositionFormat.ECISFLAT) && (templateId == null || templateId.length() == 0)) throw new ServiceManagerException(getGlobal(), SysErrorCode.USER_ILLEGALARGUMENT, ME, "Template Id must be specified"); //get body stuff String content = props.getClientProperty(Constants.REQUEST_CONTENT, (String) null); if (content == null) throw new ServiceManagerException(getGlobal(), SysErrorCode.USER_ILLEGALARGUMENT, ME, "Content cannot be empty for a new composition"); Integer contentLength = (Integer) props.getClientProperty(Constants.REQUEST_CONTENT_LENGTH, (Integer) 0); if (content.length() != contentLength) throw new ServiceManagerException(getGlobal(), SysErrorCode.USER_ILLEGALARGUMENT, ME, "Content may be altered found length =" + content.length() + " expected:" + contentLength); // String contentType = props.getClientProperty(Constants.REQUEST_CONTENT_TYPE, ""); UUID compositionId;/*from ww w . j a v a 2 s. c o m*/ switch (format) { case XML: CanonicalHandler canonicalHandler = new CanonicalHandler(knowledgeCache.getKnowledgeCache(), templateId, null); Composition composition = canonicalHandler.build(getGlobal(), content); templateId = composition.getArchetypeDetails().getTemplateId().getValue(); I_CompositionAccess compositionAccess = I_CompositionAccess.getNewInstance(getDataAccess(), composition, DateTime.now(), ehrId); I_EntryAccess entryAccess = I_EntryAccess.getNewInstance(getDataAccess(), templateId, 0, compositionAccess.getId(), composition); compositionAccess.addContent(entryAccess); compositionId = compositionAccess.commit(committerUuid, systemUuid, auditSetter.getDescription()); //create an XML response Document document = DocumentHelper.createDocument(); Element root = document.addElement("compositionCreateRestResponseData"); root.addElement("action").addText("CREATE"); root.addElement("compositionUid").addText(encodeUuid(compositionId, 1)); root.addElement("meta").addElement("href") .addText(Constants.URI_TAG + "?" + encodeURI(null, compositionId, 1, null)); global.getProperty().set(MethodName.RETURN_TYPE_PROPERTY, "" + MethodName.RETURN_XML); return document; case ECISFLAT: PvCompoHandler pvCompoHandler = new PvCompoHandler(this.getDataAccess(), templateId, null); Map<String, String> kvPairs = FlatJsonUtil .inputStream2Map(new StringReader(new String(content.getBytes()))); compositionId = pvCompoHandler.storeComposition(ehrId, kvPairs, auditSetter.getCommitterUuid(), auditSetter.getSystemUuid(), auditSetter.getDescription()); //create json response global.getProperty().set(MethodName.RETURN_TYPE_PROPERTY, "" + MethodName.RETURN_JSON); Map<String, Object> retmap = new HashMap<>(); retmap.put("action", "CREATE"); retmap.put(COMPOSITION_UID, encodeUuid(compositionId, 1)); Map<String, Map<String, String>> metaref = MetaBuilder.add2MetaMap(null, "href", Constants.URI_TAG + "?" + encodeURI(null, compositionId, 1, null)); retmap.putAll(metaref); return retmap; case FLAT: I_FlatJsonCompositionConverter flatJsonCompositionConverter = FlatJsonCompositionConverter .getInstance(getDataAccess().getKnowledgeManager()); Map flatMap = FlatJsonUtil.inputStream2Map(new StringReader(new String(content.getBytes()))); Composition newComposition = flatJsonCompositionConverter.toComposition(templateId, flatMap); I_CompositionAccess access = I_CompositionAccess.getNewInstance(getDataAccess(), newComposition, DateTime.now(), ehrId); I_EntryAccess entry = I_EntryAccess.getNewInstance(getDataAccess(), templateId, 0, access.getId(), newComposition); access.addContent(entry); compositionId = access.commit(committerUuid, systemUuid, auditSetter.getDescription()); //create json response global.getProperty().set(MethodName.RETURN_TYPE_PROPERTY, "" + MethodName.RETURN_JSON); retmap = new HashMap<>(); retmap.put("action", "CREATE"); retmap.put(COMPOSITION_UID, encodeUuid(compositionId, 1)); metaref = MetaBuilder.add2MetaMap(null, "href", Constants.URI_TAG + "?" + encodeURI(null, compositionId, 1, null)); retmap.putAll(metaref); return retmap; default: throw new ServiceManagerException(getGlobal(), SysErrorCode.USER_ILLEGALARGUMENT, ME, "This format is not supported:" + format); } }