List of usage examples for java.util GregorianCalendar setTime
public final void setTime(Date date)
Date
. From source file:org.openmrs.api.PatientServiceTest.java
/** * @see PatientService#mergePatients(Patient,Patient) * @verifies audit prior date of birth// www .ja v a 2s . co m */ @Test public void mergePatients_shouldAuditPriorDateOfBirth() throws Exception { //retrieve preferred patient and set a date of birth GregorianCalendar cDate = new GregorianCalendar(); cDate.setTime(new Date()); //milliseconds are not serialized into the database. they will be ignored in the test cDate.set(Calendar.MILLISECOND, 0); Patient preferred = patientService.getPatient(999); preferred.setBirthdate(cDate.getTime()); preferred.addName(new PersonName("givenName", "middleName", "familyName")); patientService.savePatient(preferred); Patient notPreferred = patientService.getPatient(7); voidOrders(Collections.singleton(notPreferred)); PersonMergeLog audit = mergeAndRetrieveAudit(preferred, notPreferred); Assert.assertEquals("prior date of birth was not audited", cDate.getTime(), audit.getPersonMergeLogData().getPriorDateOfBirth()); }
From source file:org.openmrs.api.PatientServiceTest.java
/** * @see PatientService#mergePatients(Patient,Patient) * @verifies audit prior date of death/*from w w w.java2 s. co m*/ */ @Test public void mergePatients_shouldAuditPriorDateOfDeath() throws Exception { //retrieve preferred patient and set a date of birth GregorianCalendar cDate = new GregorianCalendar(); cDate.setTime(new Date()); //milliseconds are not serialized into the database. they will be ignored in the test cDate.set(Calendar.MILLISECOND, 0); Patient preferred = patientService.getPatient(999); preferred.setDeathDate(cDate.getTime()); preferred.setDead(true); preferred.setCauseOfDeath(Context.getConceptService().getConcept(3)); preferred.addName(new PersonName("givenName", "middleName", "familyName")); patientService.savePatient(preferred); Patient notPreferred = patientService.getPatient(7); voidOrders(Collections.singleton(notPreferred)); PersonMergeLog audit = mergeAndRetrieveAudit(preferred, notPreferred); Assert.assertEquals("prior date of death was not audited", cDate.getTime(), audit.getPersonMergeLogData().getPriorDateOfDeath()); }
From source file:org.apache.lens.server.metastore.TestMetastoreService.java
private XBaseCube createTestCube(String cubeName) throws Exception { GregorianCalendar c = new GregorianCalendar(); c.setTime(new Date()); final XMLGregorianCalendar startDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); c.add(GregorianCalendar.DAY_OF_MONTH, 7); final XMLGregorianCalendar endDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); XBaseCube cube = cubeObjectFactory.createXBaseCube(); cube.setName(cubeName);/* ww w . j a v a 2 s . c o m*/ cube.setDimAttributes(new XDimAttributes()); cube.setExpressions(new XExpressions()); cube.setMeasures(new XMeasures()); cube.setJoinChains(new XJoinChains()); cube.setProperties(new XProperties()); XDimAttribute xd1 = cubeObjectFactory.createXDimAttribute(); xd1.setName("dim1"); xd1.setType("STRING"); xd1.setDescription("first dimension"); xd1.setDisplayString("Dimension1"); // Don't set endtime on this dim to validate null handling on server side xd1.setStartTime(startDate); xd1.setNumDistinctValues(2000L); XDimAttribute xd2 = cubeObjectFactory.createXDimAttribute(); xd2.setName("dim2"); xd2.setType("INT"); xd2.setDescription("second dimension"); xd2.setDisplayString("Dimension2"); // Don't set start time on this dim to validate null handling on server side xd2.setEndTime(endDate); XDimAttribute xd3 = cubeObjectFactory.createXDimAttribute(); xd3.setName("testdim2col2"); xd3.setType("STRING"); xd3.setDescription("ref chained dimension"); xd3.setDisplayString("Chained Dimension"); XChainColumn xcc = new XChainColumn(); xcc.setChainName("chain1"); xcc.setRefCol("col2"); xd3.getChainRefColumn().add(xcc); xd3.setNumDistinctValues(1000L); // add attribute with complex type XDimAttribute xd4 = cubeObjectFactory.createXDimAttribute(); xd4.setName("dim4"); xd4.setType("struct<a:INT,b:array<string>,c:map<int,array<struct<x:int,y:array<int>>>"); xd4.setDescription("complex attribute"); xd4.setDisplayString("Complex Attribute"); cube.getDimAttributes().getDimAttribute().add(xd1); cube.getDimAttributes().getDimAttribute().add(xd2); cube.getDimAttributes().getDimAttribute().add(xd3); cube.getDimAttributes().getDimAttribute().add(xd4); XMeasure xm1 = new XMeasure(); xm1.setName("msr1"); xm1.setType(XMeasureType.DOUBLE); xm1.setDescription("first measure"); xm1.setDisplayString("Measure1"); // Don't set start time and end time to validate null handling on server side. //xm1.setStarttime(startDate); //xm1.setEndtime(endDate); xm1.setDefaultAggr("sum"); XMeasure xm2 = new XMeasure(); xm2.setName("msr2"); xm2.setType(XMeasureType.INT); xm2.setDescription("second measure"); xm2.setDisplayString("Measure2"); xm2.setStartTime(startDate); xm2.setEndTime(endDate); xm2.setDefaultAggr("max"); cube.getMeasures().getMeasure().add(xm1); cube.getMeasures().getMeasure().add(xm2); XJoinChain xj1 = new XJoinChain(); xj1.setName("chain1"); xj1.setDescription("first chain"); xj1.setDisplayString("Chain-1"); xj1.setPaths(new XJoinPaths()); XJoinPath path1 = cubeObjectFactory.createXJoinPath(); path1.setEdges(new XJoinEdges()); XTableReference link1 = new XTableReference(); link1.setTable(cubeName); link1.setColumn("col1"); XTableReference link2 = new XTableReference(); link2.setTable("testdim"); link2.setColumn("col1"); link2.setMapsToMany(true); XJoinEdge edge1 = cubeObjectFactory.createXJoinEdge(); edge1.setFrom(link1); edge1.setTo(link2); path1.getEdges().getEdge().add(edge1); xj1.getPaths().getPath().add(path1); cube.getJoinChains().getJoinChain().add(xj1); XJoinChain xj2 = new XJoinChain(); xj2.setName("dim2chain"); xj2.setDescription("testdim2 chain"); xj2.setDisplayString("Chain-2"); xj2.setPaths(new XJoinPaths()); XJoinPath path = cubeObjectFactory.createXJoinPath(); path.setEdges(new XJoinEdges()); path.getEdges().getEdge().add(edge1); XJoinEdge edge2 = cubeObjectFactory.createXJoinEdge(); XTableReference link3 = new XTableReference(); link3.setTable("testdim"); link3.setColumn("col2"); XTableReference link4 = new XTableReference(); link4.setTable("testdim2"); link4.setColumn("col1"); edge2.setFrom(link3); edge2.setTo(link4); path.getEdges().getEdge().add(edge2); xj2.getPaths().getPath().add(path); cube.getJoinChains().getJoinChain().add(xj2); XExprColumn xe1 = new XExprColumn(); xe1.setName("expr1"); xe1.setType("DOUBLE"); xe1.setDescription("first expression"); xe1.setDisplayString("Expression1"); XExprSpec es = new XExprSpec(); es.setExpr("msr1/1000"); xe1.getExprSpec().add(es); XExprColumn xe2 = new XExprColumn(); xe2.setName("expr2"); xe2.setType("float"); xe2.setDescription("multi expression"); xe2.setDisplayString("Expression2"); XExprSpec es1 = new XExprSpec(); es1.setExpr("msr1/1000"); xe2.getExprSpec().add(es1); XExprSpec es2 = new XExprSpec(); es2.setExpr("(msr1/1000) + 0.01"); es2.setStartTime(startDate); xe2.getExprSpec().add(es2); XExprSpec es3 = new XExprSpec(); es3.setExpr("(msr1/1000) + 0.03"); es3.setEndTime(endDate); xe2.getExprSpec().add(es3); XExprSpec es4 = new XExprSpec(); es4.setExpr("(msr1/1000) - 0.01"); es4.setStartTime(startDate); es4.setEndTime(endDate); xe2.getExprSpec().add(es4); cube.getExpressions().getExpression().add(xe1); cube.getExpressions().getExpression().add(xe2); XProperty xp1 = cubeObjectFactory.createXProperty(); xp1.setName("foo"); xp1.setValue("bar"); cube.getProperties().getProperty().add(xp1); return cube; }
From source file:org.alfresco.opencmis.CMISConnector.java
private String convertAspectPropertyValue(Object value) { if (value instanceof Date) { GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT")); cal.setTime((Date) value); value = cal;/*from ww w . jav a 2 s . co m*/ } if (value instanceof GregorianCalendar) { DatatypeFactory df; try { df = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException e) { throw new IllegalArgumentException("Aspect conversation exception: " + e.getMessage(), e); } return df.newXMLGregorianCalendar((GregorianCalendar) value).toXMLFormat(); } // MNT-12496 MNT-15044 // Filter for AtomPub and Web services bindings only. Browser/json binding already encodes. if (AlfrescoCmisServiceCall.get() != null && (CallContext.BINDING_ATOMPUB.equals(AlfrescoCmisServiceCall.get().getBinding()) || CallContext.BINDING_WEBSERVICES.equals(AlfrescoCmisServiceCall.get().getBinding()))) { return filterXmlRestrictedCharacters(value.toString()); } else { return value.toString(); } }
From source file:org.ramadda.geodata.cdmdata.PointDatabaseTypeHandler.java
/** * _more_/*from w ww. j a v a 2 s. c o m*/ * * @param request _more_ * @param entry _more_ * @param columnsToUse _more_ * @param list _more_ * * @return _more_ * * @throws Exception _more_ */ private Result makeSearchResultsChart(Request request, Entry entry, List<PointDataMetadata> columnsToUse, List<PointData> list) throws Exception { StringBuffer sb = new StringBuffer(); getHtmlHeader(request, sb, entry, list); if (list.size() == 0) { sb.append(msg("No results found")); return new Result("Point Search Results", sb); } getPageHandler().addGoogleJSImport(request, sb); sb.append( "<script type=\"text/javascript\">\ngoogle.load('visualization', '1', {'packages':['motionchart']});\ngoogle.setOnLoadCallback(drawChart);\nfunction drawChart() {\n var data = new google.visualization.DataTable();\n"); sb.append("data.addRows(" + list.size() + ");\n"); sb.append("data.addColumn('string', 'Location');\n"); sb.append("data.addColumn('date', 'Date');\n"); int baseCnt = 2; String entityCol = null; boolean useTimeForName = request.get(ARG_POINT_CHART_USETIMEFORNAME, false); String dateFormat = "yyyy/MM/dd HH:mm:ss"; SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); for (PointDataMetadata pdm : columnsToUse) { String pdmName = pdm.shortName.toLowerCase(); if (pdm.getColumnName().equals(COL_ID)) { continue; } if (entityCol == null) { if ((pdmName.indexOf("station") >= 0) || pdmName.equals("region") || pdmName.equals("id") || pdmName.equals("idn")) { entityCol = pdm.getColumnName(); continue; } } if (pdmName.indexOf("name") >= 0) { entityCol = pdm.getColumnName(); break; } } // System.err.println ("entityCol:" + entityCol); for (PointDataMetadata pdm : columnsToUse) { if ((entityCol != null) && pdm.isColumn(entityCol)) { continue; } String varName = pdm.formatName(); varName = varName.replace("'", "\\'"); if (pdm.isString()) { sb.append("data.addColumn('string', '" + varName + "');\n"); } else if (pdm.isDate()) { //For now skip the date // sb.append("data.addColumn('string', '" + varName+"');\n"); } else { sb.append("data.addColumn('number', '" + varName + "');\n"); } } GregorianCalendar cal = new GregorianCalendar(RepositoryUtil.TIMEZONE_DEFAULT); int row = -1; sb.append("var theDate;\n"); for (PointData pointData : list) { row++; cal.setTime(pointData.date); String entityName; if (useTimeForName) { entityName = sdf.format(pointData.date); } else if (entityCol != null) { entityName = pointData.getValue(entityCol).toString().trim(); } else { entityName = "latlon_" + pointData.lat + "/" + pointData.lon; } entityName = entityName.replace("'", "\\'"); sb.append("theDate = new Date(" + cal.get(cal.YEAR) + "," + cal.get(cal.MONTH) + "," + cal.get(cal.DAY_OF_MONTH) + ");\n"); sb.append("theDate.setHours(" + cal.get(cal.HOUR) + "," + cal.get(cal.MINUTE) + "," + cal.get(cal.SECOND) + "," + cal.get(cal.MILLISECOND) + ");\n"); sb.append("data.setValue(" + row + ", 0, '" + entityName + "');\n"); sb.append("data.setValue(" + row + ", 1, theDate);\n"); int cnt = -1; for (PointDataMetadata pdm : columnsToUse) { //Already did the entity if ((entityCol != null) && pdm.isColumn(entityCol)) { continue; } Object value = pointData.getValue(pdm); if (row == 0) { sb.append("//" + pdm.shortName + "\n"); } if (pdm.isString()) { cnt++; String tmp = value.toString().trim(); tmp = tmp.replace("'", "\\'"); sb.append("data.setValue(" + row + ", " + (cnt + baseCnt) + ", '" + tmp + "');\n"); } else if (pdm.isDate()) { // sb.append("data.setValue(" +row+", " + (cnt+baseCnt) +", " +value +");\n"); } else { cnt++; sb.append("data.setValue(" + row + ", " + (cnt + baseCnt) + ", " + value + ");\n"); } } } sb.append("var chart = new google.visualization.MotionChart(document.getElementById('chart_div'));\n"); sb.append("chart.draw(data, {width: 800, height:500});\n"); sb.append("}\n"); sb.append("</script>\n"); sb.append("<div id=\"chart_div\" style=\"width: 800px; height: 500px;\"></div>\n"); return new Result("Point Search Results", sb); }
From source file:edu.harvard.i2b2.patientSet.ui.PatientSetJPanel.java
@SuppressWarnings("rawtypes") private void jForwardButtonActionPerformed(java.awt.event.ActionEvent evt) { System.out.println("Loading previous queries for: " + System.getProperty("user")); cellStatus = ""; //String searchStr = jSearchStringTextField.getText(); int category = jCategoryComboBox.getSelectedIndex(); int strategy = jContainComboBox.getSelectedIndex(); curCreationDate = previousQueries.get(previousQueries.size() - 1).creationTime(); //////////////////////////////////////////////// SimpleDateFormat df = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");//.getDateInstance(); Date date = null;/*from ww w . ja v a2 s . c o m*/ try { date = df.parse(this.jStartTimeTextField.getText()); } catch (Exception e) { e.printStackTrace(); } DTOFactory dtoFactory = new DTOFactory(); TimeZone tz = Calendar.getInstance().getTimeZone(); GregorianCalendar cal = new GregorianCalendar(tz); cal.setTime(date); //cal.get(Calendar.ZONE_OFFSET); int zt_offset = (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / 60000; //log.info("Timezone: "+tz.getID()+" : "+zt_offset); //if (startTime() != -1) { ConstrainDateType constraindateType = new ConstrainDateType(); XMLGregorianCalendar xmlC = dtoFactory.getXMLGregorianCalendarDate(cal.get(GregorianCalendar.YEAR), cal.get(GregorianCalendar.MONTH) + 1, cal.get(GregorianCalendar.DAY_OF_MONTH)); xmlC.setTimezone(zt_offset);//0);//-5*60); xmlC.setHour(cal.get(GregorianCalendar.HOUR_OF_DAY)); xmlC.setMinute(cal.get(GregorianCalendar.MINUTE)); xmlC.setSecond(cal.get(GregorianCalendar.SECOND)); constraindateType.setValue(xmlC); //timeConstrain.setDateFrom(constraindateType); //} //////////////////////////////////////////////// String xmlStr = writePagingQueryXML("", category, strategy, false, xmlC);//curCreationDate); // System.out.println(xmlStr); String responseStr = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { responseStr = QueryListNamesClient.sendQueryRequestSOAP(xmlStr); } else { responseStr = QueryListNamesClient.sendFindQueryRequestREST(xmlStr); } if (responseStr.equalsIgnoreCase("CellDown")) { cellStatus = new String("CellDown"); return; //"CellDown"; } try { JAXBUtil jaxbUtil = PatientSetJAXBUtil.getJAXBUtil(); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(responseStr); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); BodyType bt = messageType.getMessageBody(); MasterResponseType masterResponseType = (MasterResponseType) new JAXBUnWrapHelper().getObjectByClass( bt.getAny(), edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.MasterResponseType.class); for (Condition status : masterResponseType.getStatus().getCondition()) { if (status.getType().equals("ERROR")) cellStatus = new String("CellDown"); } previousQueries = new ArrayList<QueryMasterData>(); for (QueryMasterType queryMasterType : masterResponseType.getQueryMaster()) { QueryMasterData tmpData; tmpData = new QueryMasterData(); XMLGregorianCalendar cldr = queryMasterType.getCreateDate(); tmpData.name( queryMasterType.getName() + " [" + addZero(cldr.getMonth()) + "-" + addZero(cldr.getDay()) + "-" + addZero(cldr.getYear()) + " ]" + " [" + queryMasterType.getUserId() + "]"); tmpData.creationTime(cldr);//.clone()); tmpData.creationTimeStr( addZero(cldr.getMonth()) + "-" + addZero(cldr.getDay()) + "-" + addZero(cldr.getYear()) + " " + cldr.getHour() + ":" + cldr.getMinute() + ":" + cldr.getSecond()); tmpData.tooltip("A query run by " + queryMasterType.getUserId()); // System. // getProperty // ("user")); tmpData.visualAttribute("CA"); tmpData.xmlContent(null); tmpData.id(queryMasterType.getQueryMasterId()); tmpData.userId(queryMasterType.getUserId()); // System.getProperty // ("user")); previousQueries.add(tmpData); } if (previousQueries.size() == 0) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "No results were found.", "Not Found", JOptionPane.INFORMATION_MESSAGE); } }); return; } loadPatientSets(); if (cellStatus.equalsIgnoreCase("")) { reset(200, false, false); } else if (cellStatus.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); } return; } catch (Exception e) { e.printStackTrace(); return; } }
From source file:edu.harvard.i2b2.patientSet.ui.PatientSetJPanel.java
@SuppressWarnings("rawtypes") private void jBackwardButtonActionPerformed(java.awt.event.ActionEvent evt) { /*LoginHelper pms = new LoginHelper(); try {/*from w w w .ja v a 2 s . com*/ PasswordType ptype = new PasswordType(); ptype.setIsToken(UserInfoBean.getInstance().getUserPasswordIsToken()); ptype.setTokenMsTimeout(UserInfoBean.getInstance() .getUserPasswordTimeout()); ptype.setValue(UserInfoBean.getInstance().getUserPassword()); String response = pms.getUserInfo(UserInfoBean.getInstance().getUserName(), ptype, UserInfoBean.getInstance().getSelectedProjectUrl(), UserInfoBean.getInstance().getUserDomain(), false, UserInfoBean.getInstance().getProjectId()); } catch(Exception e) { e.printStackTrace(); }*/ System.out.println("Loading previous queries for: " + System.getProperty("user")); cellStatus = ""; //String searchStr = jSearchStringTextField.getText(); int category = jCategoryComboBox.getSelectedIndex(); int strategy = jContainComboBox.getSelectedIndex(); curCreationDate = previousQueries.get(0).creationTime(); //////////////////////////////////////////////// SimpleDateFormat df = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");//.getDateInstance(); Date date = null; try { date = df.parse(this.jStartTimeTextField.getText()); } catch (Exception e) { e.printStackTrace(); } DTOFactory dtoFactory = new DTOFactory(); TimeZone tz = Calendar.getInstance().getTimeZone(); GregorianCalendar cal = new GregorianCalendar(tz); cal.setTime(date); //cal.get(Calendar.ZONE_OFFSET); int zt_offset = (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / 60000; //log.info("Timezone: "+tz.getID()+" : "+zt_offset); //if (startTime() != -1) { ConstrainDateType constraindateType = new ConstrainDateType(); XMLGregorianCalendar xmlC = dtoFactory.getXMLGregorianCalendarDate(cal.get(GregorianCalendar.YEAR), cal.get(GregorianCalendar.MONTH) + 1, cal.get(GregorianCalendar.DAY_OF_MONTH)); xmlC.setTimezone(zt_offset);//0);//-5*60); xmlC.setHour(cal.get(GregorianCalendar.HOUR_OF_DAY)); xmlC.setMinute(cal.get(GregorianCalendar.MINUTE)); xmlC.setSecond(cal.get(GregorianCalendar.SECOND)); constraindateType.setValue(xmlC); //timeConstrain.setDateFrom(constraindateType); //} //////////////////////////////////////////////// String xmlStr = writePagingQueryXML("", category, strategy, true, xmlC);//curCreationDate); // System.out.println(xmlStr); String responseStr = null; if (System.getProperty("webServiceMethod").equals("SOAP")) { responseStr = QueryListNamesClient.sendQueryRequestSOAP(xmlStr); } else { responseStr = QueryListNamesClient.sendFindQueryRequestREST(xmlStr); } if (responseStr.equalsIgnoreCase("CellDown")) { cellStatus = new String("CellDown"); return; //"CellDown"; } try { JAXBUtil jaxbUtil = PatientSetJAXBUtil.getJAXBUtil(); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(responseStr); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); BodyType bt = messageType.getMessageBody(); MasterResponseType masterResponseType = (MasterResponseType) new JAXBUnWrapHelper().getObjectByClass( bt.getAny(), edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.MasterResponseType.class); for (Condition status : masterResponseType.getStatus().getCondition()) { if (status.getType().equals("ERROR")) cellStatus = new String("CellDown"); } previousQueries = new ArrayList<QueryMasterData>(); for (QueryMasterType queryMasterType : masterResponseType.getQueryMaster()) { QueryMasterData tmpData; tmpData = new QueryMasterData(); XMLGregorianCalendar cldr = queryMasterType.getCreateDate(); tmpData.name( queryMasterType.getName() + " [" + addZero(cldr.getMonth()) + "-" + addZero(cldr.getDay()) + "-" + addZero(cldr.getYear()) + " ]" + " [" + queryMasterType.getUserId() + "]"); tmpData.creationTime(cldr);//.clone()); tmpData.creationTimeStr( addZero(cldr.getMonth()) + "-" + addZero(cldr.getDay()) + "-" + addZero(cldr.getYear()) + " " + cldr.getHour() + ":" + cldr.getMinute() + ":" + cldr.getSecond()); tmpData.tooltip("A query run by " + queryMasterType.getUserId()); // System. // getProperty // ("user")); tmpData.visualAttribute("CA"); tmpData.xmlContent(null); tmpData.id(queryMasterType.getQueryMasterId()); tmpData.userId(queryMasterType.getUserId()); // System.getProperty // ("user")); previousQueries.add(tmpData); } if (previousQueries.size() == 0) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "No results were found.", "Not Found", JOptionPane.INFORMATION_MESSAGE); } }); return; } loadPatientSets(); if (cellStatus.equalsIgnoreCase("")) { reset(200, false, true); } else if (cellStatus.equalsIgnoreCase("CellDown")) { final JPanel parent = this; java.awt.EventQueue.invokeLater(new Runnable() { public void run() { JOptionPane.showMessageDialog(parent, "Trouble with connection to the remote server, " + "this is often a network error, please try again", "Network Error", JOptionPane.INFORMATION_MESSAGE); } }); } return; } catch (Exception e) { e.printStackTrace(); return; } }
From source file:fr.paris.lutece.plugins.plu.web.PluJspBean.java
/** * Apply a Plu and return to the Plu manage * @param request the Http request//from ww w. j ava 2 s . co m * @throws ParseException ParseException * @return HTML */ public String doApplicablePlu(HttpServletRequest request) throws ParseException { int nIdPlu = Integer.parseInt(request.getParameter(PARAMETER_PLU_ID)); Plu plu = _pluServices.findByPrimaryKey(nIdPlu); Date dateApplicationPlu = stringToDate(request.getParameter(PARAMETER_DATE_APPLICATION), "dd/MM/yyyy"); Etat etat = _etatServices.findByPrimaryKey(1); plu.setEtat(etat); plu.setDa(dateApplicationPlu); _pluServices.update(plu); // Set the date application of the VA in state 1 List<Version> versionState1 = _versionServices.findVersionState(1, nIdPlu); for (Version version : versionState1) { version.setD2(dateApplicationPlu); _versionServices.update(version); } GregorianCalendar dayBeforeApplication = new GregorianCalendar(); dayBeforeApplication.setTime(dateApplicationPlu); dayBeforeApplication.add(Calendar.DATE, -1); // Set the date archive of the VA in state 3 List<Version> versionState3 = _versionServices.selectArchive(); for (Version version : versionState3) { version.setD4(dayBeforeApplication.getTime()); version.setArchive('N'); _versionServices.update(version); } Plu plu2 = new Plu(); _pluServices.create(plu2); plu2 = _pluServices.findPluWork(); //all the folder of the previous working PLU : call this PLUAPP List<Folder> folderList = _folderServices.findByPluId(nIdPlu); Map<Integer, Integer> mapIdOldIdNew = new Hashtable<Integer, Integer>(); for (Folder folder : folderList) { Folder folder2 = new Folder(); //for each folder of PLUAPP, clone this in folder2 folder2.setPlu(plu2.getId()); if (mapIdOldIdNew.containsKey(folder.getParentFolder())) { folder2.setParentFolder(mapIdOldIdNew.get(folder.getParentFolder())); } else { folder2.setParentFolder(folder.getParentFolder()); } folder2.setTitle(folder.getTitle()); folder2.setDescription(folder.getDescription()); folder2.setNomImage(folder.getNomImage()); folder2.setImg(folder.getImg()); folder2.setHtml(folder.getHtml()); folder2.setHtmlImpression(folder.getHtmlImpression()); _folderServices.create(folder2); folder2 = _folderServices.findLastFolder(); mapIdOldIdNew.put(folder.getId(), folder2.getId()); List<FolderVersion> folderVersionList = _folderVersionServices.findByFolder(folder); for (FolderVersion folderVersion : folderVersionList) { FolderVersion folderVersion2 = new FolderVersion(); folderVersion2.setVersion(folderVersion.getVersion()); folderVersion2.setFolder(folder2); _folderVersionServices.create(folderVersion2); } } return JSP_REDIRECT_TO_MANAGE_PLU; }
From source file:edu.wisc.ssec.mcidasv.data.cyclone.AtcfStormDataSource.java
/** * _more_/* www .j ava2 s . co m*/ * * @param stormInfo * _more_ * @param tracks * _more_ * @param trackFile * _more_ * @param waysToUse * _more_ * @param throwError * _more_ * * * @return _more_ * @throws Exception * _more_ */ private boolean readTracks(StormInfo stormInfo, StormTrackCollection tracks, String trackFile, Hashtable<String, Boolean> waysToUse, boolean throwError) throws Exception { long t1 = System.currentTimeMillis(); byte[] bytes = readFile(trackFile, true); long t2 = System.currentTimeMillis(); // System.err.println("read time:" + (t2 - t1)); boolean isZip = trackFile.endsWith(".gz"); if ((bytes == null) && isZip) { String withoutGZ = trackFile.substring(0, trackFile.length() - 3); bytes = readFile(withoutGZ, true); isZip = false; } if (bytes == null) { if (throwError) { throw new BadDataException("Unable to read track file:" + trackFile); } return false; } if (isZip) { GZIPInputStream zin = new GZIPInputStream(new ByteArrayInputStream(bytes)); bytes = IOUtil.readBytes(zin); zin.close(); } GregorianCalendar convertCal = new GregorianCalendar(DateUtil.TIMEZONE_GMT); convertCal.clear(); String trackData = new String(bytes); List lines = StringUtil.split(trackData, "\n", true, true); SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddHH"); fmt.setTimeZone(TimeZone.getTimeZone("UTC")); Hashtable trackMap = new Hashtable(); Real altReal = new Real(RealType.Altitude, 0); // System.err.println("obs:" + lines.size()); /* * Hashtable okWays = new Hashtable(); okWays.put(WAY_CARQ, ""); * okWays.put(WAY_WRNG, ""); okWays.put(WAY_BEST, ""); okWays.put("ETA", * ""); okWays.put("NGX", ""); okWays.put("BAMS", ""); */ Hashtable seenDate = new Hashtable(); initParams(); int xcnt = 0; for (int i = 0; i < lines.size(); i++) { String line = (String) lines.get(i); if (i == 0) { // System.err.println(line); } List toks = StringUtil.split(line, ",", true); /* * System.err.println(toks.size() + " " + BASEIDX); * if(toks.size()<BASEIDX-1) { System.err.println("bad line:" + * line); continue; } else { System.err.println("good line:" + * line); } */ // BASIN,CY,YYYYMMDDHH,TECHNUM,TECH,TAU,LatN/S,LonE/W,VMAX,MSLP,TY,RAD,WINDCODE,RAD1,RAD2,RAD3,RAD4,RADP,RRP,MRD,GUSTS,EYE,SUBREGION,MAXSEAS,INITIALS,DIR,SPEED,STORMNAME,DEPTH,SEAS,SEASCODE,SEAS1,SEAS2,SEAS3,SEAS4 // AL, 01, 2007050612, , BEST, 0, 355N, 740W, 35, 1012, EX, 34, NEQ, // 0, 0, 0, 120, // AL, 01, 2007050812, 01, CARQ, -24, 316N, 723W, 55, 0, DB, 34, // AAA, 0, 0, 0, 0, String dateString = (String) toks.get(IDX_YYYYMMDDHH); String wayString = (String) toks.get(IDX_TECH); // if (okWays.get(wayString) == null) { // continue; // } boolean isBest = wayString.equals(WAY_BEST); boolean isWarning = wayString.equals(WAY_WRNG); boolean isCarq = wayString.equals(WAY_CARQ); int category = ((IDX_TY < toks.size()) ? getCategory((String) toks.get(IDX_TY)) : CATEGORY_XX); if (category != CATEGORY_XX) { // System.err.println("cat:" + category); } String fhour = (String) toks.get(IDX_TAU); int forecastHour = new Integer(fhour).intValue(); // A hack - we've seen some atfc files that have a 5 character // forecast hour // right padded with "00", eg., 01200 if ((fhour.length() == 5) && (forecastHour > 100)) { forecastHour = forecastHour / 100; } if (isWarning || isCarq) { forecastHour = -forecastHour; } // Check for unique dates for this way String dttmkey = wayString + "_" + dateString + "_" + forecastHour; if (seenDate.get(dttmkey) != null) { continue; } seenDate.put(dttmkey, dttmkey); Date dttm = fmt.parse(dateString); convertCal.setTime(dttm); String key; Way way = getWay(wayString, null); if (!isBest && (waysToUse != null) && (waysToUse.size() > 0) && (waysToUse.get(wayString) == null)) { continue; } if (isBest) { key = wayString; } else { key = wayString + "_" + dateString; convertCal.add(Calendar.HOUR_OF_DAY, forecastHour); } dttm = convertCal.getTime(); StormTrack track = (StormTrack) trackMap.get(key); if (track == null) { way = (isBest ? Way.OBSERVATION : way); track = new StormTrack(stormInfo, addWay(way), new DateTime(dttm), obsParams); trackMap.put(key, track); tracks.addTrack(track); } String latString = (String) toks.get(IDX_LAT); String lonString = (String) toks.get(IDX_LON); String t = latString + " " + lonString; boolean south = latString.endsWith("S"); boolean west = lonString.endsWith("W"); double latitude = Double.parseDouble(latString.substring(0, latString.length() - 1)) / 10.0; double longitude = Double.parseDouble(lonString.substring(0, lonString.length() - 1)) / 10.0; if (south) { latitude = -latitude; } if (west) { longitude = -longitude; } EarthLocation elt = new EarthLocationLite(new Real(RealType.Latitude, latitude), new Real(RealType.Longitude, longitude), altReal); List<Real> attributes = new ArrayList<Real>(); double windspeed = ((IDX_VMAX < toks.size()) ? getDouble((String) toks.get(IDX_VMAX)) : Double.NaN); double pressure = ((IDX_MSLP < toks.size()) ? getDouble((String) toks.get(IDX_MSLP)) : Double.NaN); attributes.add(PARAM_STORMCATEGORY.getReal((double) category)); attributes.add(PARAM_MINPRESSURE.getReal(pressure)); attributes.add(PARAM_MAXWINDSPEED_KTS.getReal(windspeed)); StormTrackPoint stp = new StormTrackPoint(elt, new DateTime(dttm), forecastHour, attributes); track.addPoint(stp); } return true; }
From source file:com.ext.portlet.epsos.EpsosHelperService.java
private String xmlEncodeDate(Date date) { if (date == null) return ""; try {//from ww w.ja v a 2 s. com GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance(); cal.setTime(date); XMLGregorianCalendar xmlCal = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal); return xmlCal.toXMLFormat(); } catch (Exception e) { return date.toString(); } }