List of usage examples for javax.xml.datatype XMLGregorianCalendar getSecond
public abstract int getSecond();
From source file:com.microsoft.exchange.integration.TimeZoneIntegrationTest.java
@Test public void createGetDeleteCalendarItem() throws DatatypeConfigurationException { TimeZone utcTimeZone = TimeZone.getTimeZone(RequestServerTimeZoneInterceptor.FALLBACK_TIMEZONE_ID); TimeZone.setDefault(utcTimeZone); ApplicationContext context = new ClassPathXmlApplicationContext( "classpath:test-contexts/exchangeContext.xml"); RequestServerTimeZoneInterceptor timeZoneInterceptor = context .getBean(RequestServerTimeZoneInterceptor.class); ExchangeWebServices ews = context.getBean(ExchangeWebServices.class); BaseExchangeCalendarDataDao exchangeCalendarDao = context.getBean(BaseExchangeCalendarDataDao.class); exchangeCalendarDao.setWebServices(ews); assertEquals(TimeZone.getDefault(), utcTimeZone); //XMLGregorianCalendar is sortof backed by a gregorian calendar, date/times should reflect default jvm timezone XMLGregorianCalendar xmlStart = DateHelp.getXMLGregorianCalendarNow(); CalendarItemType calendarItem = new CalendarItemType(); calendarItem.setStart(xmlStart);/*from w ww . j av a 2 s . co m*/ ItemIdType itemId = exchangeCalendarDao.createCalendarItem(upn, calendarItem); assertNotNull(itemId); Set<ItemIdType> itemIds = Collections.singleton(itemId); Set<CalendarItemType> calendarItems = exchangeCalendarDao.getCalendarItems(upn, itemIds); assertNotNull(calendarItems); CalendarItemType createdCalendarItem = DataAccessUtils.singleResult(calendarItems); assertNotNull(createdCalendarItem); XMLGregorianCalendar createdCalendarItemStart = createdCalendarItem.getStart(); assertNotNull(createdCalendarItemStart); assertEquals(xmlStart.getTimezone(), createdCalendarItemStart.getTimezone()); //nope! tzDisplayName = createdCalendarItem.getTimeZone() //assertEquals(RequestServerTimeZoneInterceptor.FALLBACK_TIMEZONE_ID, createdCalendarItem.getTimeZone()); assertEquals(xmlStart.getEon(), createdCalendarItemStart.getEon()); assertEquals(xmlStart.getEonAndYear(), createdCalendarItemStart.getEonAndYear()); assertEquals(xmlStart.getYear(), createdCalendarItemStart.getYear()); assertEquals(xmlStart.getMonth(), createdCalendarItemStart.getMonth()); assertEquals(xmlStart.getDay(), createdCalendarItemStart.getDay()); assertEquals(xmlStart.getHour(), createdCalendarItemStart.getHour()); assertEquals(xmlStart.getMinute(), createdCalendarItemStart.getMinute()); assertEquals(xmlStart.getSecond(), createdCalendarItemStart.getSecond()); //nope! always seems to be a slight variation //assertEquals(xmlStart.toGregorianCalendar().getTimeInMillis(), createdCalendarItemStart.toGregorianCalendar().getTimeInMillis()); //assertEquals(xmlStart.getMillisecond(), createdCalendarItemStart.getMillisecond()); //assertEquals(xmlStart.getFractionalSecond(), createdCalendarItemStart.getFractionalSecond()); assertTrue(DateHelp.withinOneSecond(xmlStart, createdCalendarItemStart)); assertTrue(exchangeCalendarDao.deleteCalendarItems(upn, itemIds)); }
From source file:edu.harvard.i2b2.previousquery.ui.PreviousQueryPanel.java
@SuppressWarnings("unchecked") public String loadPreviousQueries(String user) { System.out.println("Loading previous queries for: " + System.getProperty("user")); String xmlStr = writeContentQueryXML(user); // System.out.println(xmlStr); String responseStr = null;/* w ww .j a va 2 s . c om*/ if (System.getProperty("webServiceMethod").equals("SOAP")) { responseStr = QueryListNamesClient.sendQueryRequestSOAP(xmlStr); } else { responseStr = QueryListNamesClient.sendQueryRequestREST(xmlStr); } if (responseStr.equalsIgnoreCase("CellDown")) { cellStatus = new String("CellDown"); return "CellDown"; } try { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.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")); if (queryMasterType.getMasterTypeCd() != null) { tmpData.queryType(queryMasterType.getMasterTypeCd()); } previousQueries.add(tmpData); } return ""; } catch (Exception e) { e.printStackTrace(); return "error"; } }
From source file:edu.harvard.i2b2.previousquery.ui.PreviousQueryPanel.java
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. j a v a2 s . c om 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 = PreviousQueryJAXBUtil.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; } 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.previousquery.ui.PreviousQueryPanel.java
private void jBackwardButtonActionPerformed(java.awt.event.ActionEvent evt) { /*LoginHelper pms = new LoginHelper(); try {/* w ww . j a v a2s . c o m*/ 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 = PreviousQueryJAXBUtil.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; } 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:edu.harvard.i2b2.patientSet.ui.PatientSetJPanel.java
@SuppressWarnings("unchecked") public String loadPreviousQueries(boolean getAllInGroup) { System.out.println("Loading previous queries for: " + System.getProperty("user")); //String xmlStr = writeContentQueryXML(getAllInGroup); String xmlStr = writeFindQueryXML("all users", "Patient Set", 1, 1); // System.out.println(xmlStr); String responseStr = null;/*from w w w .j ava 2 s . com*/ 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); } return ""; } catch (Exception e) { e.printStackTrace(); return "error"; } }
From source file:edu.harvard.i2b2.patientSet.ui.PatientSetJPanel.java
public String loadPreviousQueries(String user) { System.out.println("Loading previous queries for: " + System.getProperty("user")); String xmlStr = writeFindQueryXML(user, "Patient Set", 1, 1);//writeFindQueryXML(user); // System.out.println(xmlStr); String responseStr = null;// ww w.ja va 2 s . c o m 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")); if (queryMasterType.getMasterTypeCd() != null) { tmpData.queryType(queryMasterType.getMasterTypeCd()); } previousQueries.add(tmpData); } return ""; } catch (Exception e) { e.printStackTrace(); return "error"; } }
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;/* w w w . j ava2 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 ww.ja va 2s . 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:edu.harvard.i2b2.patientMapping.ui.MainComposite.java
public void processQueryData(QueryMasterData ndata) { ArrayList<QueryModel> nodeXmls = new ArrayList<QueryModel>(); try {/*from w w w .j av a2 s . c om*/ JAXBUtil jaxbUtil = PatientMappingJAXBUtil.getJAXBUtil(); String xmlcontent = null; String xmlrequest = null; xmlrequest = ndata.writeDefinitionQueryXML(); lastRequestMessage(xmlrequest); if (System.getProperty("webServiceMethod").equals("SOAP")) { xmlcontent = PatientMappingQueryClient.sendPDQQueryRequestSOAP(xmlrequest); } else { xmlcontent = PatientMappingQueryClient.sendPDQQueryRequestREST(xmlrequest); } lastResponseMessage(xmlcontent); if (xmlcontent == null) { return; } else { log.debug("Query content response: " + xmlcontent); ndata.xmlContent(xmlcontent); } JAXBElement jaxbElement = jaxbUtil.unMashallFromString(ndata.xmlContent()); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); BodyType bt = messageType.getMessageBody(); MasterResponseType masterResponseType = (MasterResponseType) new JAXBUnWrapHelper() .getObjectByClass(bt.getAny(), MasterResponseType.class); RequestXmlType requestXmlType = masterResponseType.getQueryMaster().get(0).getRequestXml(); org.w3c.dom.Element element = (org.w3c.dom.Element) requestXmlType.getContent().get(0); if (element != null) { log.debug("query definition not null"); } else { log.error("query definition is null"); } String domString = edu.harvard.i2b2.common.util.xml.XMLUtil.convertDOMElementToString(element); log.debug("string output" + domString); JAXBContext jc1 = JAXBContext .newInstance(edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.ObjectFactory.class); Unmarshaller unMarshaller = jc1.createUnmarshaller(); JAXBElement queryDefinitionJaxbElement = (JAXBElement) unMarshaller .unmarshal(new StringReader(domString)); QueryDefinitionType queryDefinitionType = (QueryDefinitionType) queryDefinitionJaxbElement.getValue(); int numOfPanels = queryDefinitionType.getPanel().size(); int conceptCount = 0; for (int i = 0; i < numOfPanels; i++) { PanelType panelType = queryDefinitionType.getPanel().get(i); for (int j = 0; j < panelType.getItem().size(); j++) { ItemType itemType = panelType.getItem().get(j); /////////////////////////////////////////////// QueryModel nodedata = null; ConstrainByModifier md = itemType.getConstrainByModifier(); if (md != null) { nodedata = new ModifierData(); nodedata.isModifier(true); ((ModifierData) nodedata).modifier_key(md.getModifierKey()); ((ModifierData) nodedata).applied_path(md.getAppliedPath()); ((ModifierData) nodedata).modifier_name(md.getModifierName()); ((ModifierData) nodedata).setModifierValueConstraint(md.getConstrainByValue()); } else { nodedata = new QueryModel(); } nodedata.name(itemType.getItemName()); nodedata.visualAttribute("FA"); nodedata.tooltip(itemType.getTooltip()); nodedata.fullname(itemType.getItemKey()); nodedata.hlevel(new Integer(itemType.getHlevel()).toString()); if (itemType.getItemShape() != null) { nodedata.tableRow().height = new String(itemType.getItemShape()); nodedata.tableRow().color = ((ConceptTableModel) table.getModel()) .getColor(itemType.getItemColor()); // nodedata.tableRow().rowNumber = // Integer // .parseInt(itemType // .getItemRowNumber()); nodedata.tableRow().rowNumber = conceptCount + 1; } else { nodedata.tableRow().height = "Medium"; nodedata.tableRow().color = new RGB(0, 0, 128); nodedata.tableRow().rowNumber = conceptCount + 1; } nodedata.constrainByValue(itemType.getConstrainByValue()); if (itemType.getConstrainByValue().size() > 0) { nodedata.setValueConstrains(itemType.getConstrainByValue()); if (itemType.getConstrainByValue().size() > 0) { nodedata.setValueConstrains(itemType.getConstrainByValue()); if (nodedata.valueModel().hasEnumValue()) { if (nodedata.valueModel().useTextValue()) { ArrayList<String> results = new ArrayList<String>(); results.toArray(nodedata.valueModel().value().split(",")); nodedata.valueModel().selectedValues = results; } } } } // Handle Constrain By Dates for (int u = 0; u < itemType.getConstrainByDate().size(); u++) { nodedata.setTimeConstrain(itemType.getConstrainByDate().get(u).getDateFrom(), itemType.getConstrainByDate().get(u).getDateTo()); } nodedata.updateNodeMetaDataXML(); //if (status.equalsIgnoreCase("error")) { // MessageBox mBox = new // MessageBox(table // .getShell(), // SWT.ICON_INFORMATION | SWT.OK); // mBox.setText("Please Note ..."); // mBox.setMessage("Response delivered from the remote server could not be understood,\n" // + // "you may wish to retry your last action."); // mBox.open(); // event.detail = DND.DROP_NONE; //continue; //} else { nodeXmls.add(nodedata); conceptCount++; //} } } if (nodeXmls.size() == 0) { return; } populateTable(nodeXmls); // get query instance String xmlRequest = ndata.writeContentQueryXML(); lastRequestMessage(xmlRequest); String xmlResponse = PatientMappingQueryClient.sendPDQQueryRequestREST(xmlRequest); lastResponseMessage(xmlResponse); jaxbElement = jaxbUtil.unMashallFromString(xmlResponse); messageType = (ResponseMessageType) jaxbElement.getValue(); bt = messageType.getMessageBody(); InstanceResponseType instanceResponseType = (InstanceResponseType) new JAXBUnWrapHelper() .getObjectByClass(bt.getAny(), InstanceResponseType.class); QueryInstanceData instanceData = null; XMLGregorianCalendar startDate = null; for (QueryInstanceType queryInstanceType : instanceResponseType.getQueryInstance()) { QueryInstanceData runData = new QueryInstanceData(); runData.visualAttribute("FA"); runData.tooltip("The results of the query run"); runData.id(new Integer(queryInstanceType.getQueryInstanceId()).toString()); XMLGregorianCalendar cldr = queryInstanceType.getStartDate(); runData.name("Results of " + "[" + cldr.getMonth() + "-" + cldr.getDay() + "-" + cldr.getYear() + " " + cldr.getHour() + ":" + cldr.getMinute() + ":" + cldr.getSecond() + "]"); if (instanceData == null) { startDate = cldr; instanceData = runData; } else { if (cldr.toGregorianCalendar().compareTo(startDate.toGregorianCalendar()) > 0) { startDate = cldr; instanceData = runData; } } } // get patient set if (instanceData == null) { // event.detail = DND.DROP_NONE; return; } log.debug("Got query instance: " + instanceData.name()); xmlRequest = instanceData.writeContentQueryXML(); lastRequestMessage(xmlRequest); xmlResponse = PatientMappingQueryClient.sendPDQQueryRequestREST(xmlRequest); lastResponseMessage(xmlResponse); jaxbElement = jaxbUtil.unMashallFromString(xmlResponse); messageType = (ResponseMessageType) jaxbElement.getValue(); bt = messageType.getMessageBody(); ResultResponseType resultResponseType = (ResultResponseType) new JAXBUnWrapHelper() .getObjectByClass(bt.getAny(), ResultResponseType.class); for (QueryResultInstanceType queryResultInstanceType : resultResponseType.getQueryResultInstance()) { if (!(queryResultInstanceType.getQueryResultType().getName().equalsIgnoreCase("PATIENTSET"))) { continue; } String status = queryResultInstanceType.getQueryStatusType().getName(); if (status.equalsIgnoreCase("FINISHED")) { String setId = new Integer(queryResultInstanceType.getResultInstanceId()).toString(); String setSize = new Integer(queryResultInstanceType.getSetSize()).toString(); String description = queryResultInstanceType.getDescription(); if (description != null) { patientSetText.setText(description); } else { patientSetText.setText("Patient Set: " + setSize + " patients"); } patientRefId = new String(setId); patientMinNumText.setText("1"); leftArrowButton.setEnabled(false); int maxPatientNum = new Integer(patientMaxNumText.getText()).intValue(); patientSetSize = queryResultInstanceType.getSetSize(); if (patientSetSize > maxPatientNum) { rightArrowButton.setEnabled(true); patientMaxNumText.setText("10"); } else { rightArrowButton.setEnabled(false); if (patientSetSize > 0) { patientMaxNumText.setText(setSize); } } log.debug("Dropped set of: " + setSize + " patients"/* * strs[0 * ] */ + " with refId: " + setId/* * strs[ 1 ] */); } else { // message } } } catch (Exception e) { e.printStackTrace(); return; } }
From source file:edu.harvard.i2b2.explorer.ui.MainComposite.java
public void processQueryData(QueryMasterData ndata) { ArrayList<QueryModel> nodeXmls = new ArrayList<QueryModel>(); try {// w ww . j a v a 2 s .c om JAXBUtil jaxbUtil = ExplorerJAXBUtil.getJAXBUtil(); String xmlcontent = null; String xmlrequest = null; xmlrequest = ndata.writeDefinitionQueryXML(); lastRequestMessage(xmlrequest); if (System.getProperty("webServiceMethod").equals("SOAP")) xmlcontent = PDOQueryClient.sendPDQQueryRequestSOAP(xmlrequest); else xmlcontent = PDOQueryClient.sendPDQQueryRequestREST(xmlrequest); lastResponseMessage(xmlcontent); if (xmlcontent == null) return; else { log.debug("Query content response: " + xmlcontent); ndata.xmlContent(xmlcontent); } JAXBElement jaxbElement = jaxbUtil.unMashallFromString(ndata.xmlContent()); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); BodyType bt = messageType.getMessageBody(); MasterResponseType masterResponseType = (MasterResponseType) new JAXBUnWrapHelper() .getObjectByClass(bt.getAny(), MasterResponseType.class); RequestXmlType requestXmlType = masterResponseType.getQueryMaster().get(0).getRequestXml(); org.w3c.dom.Element element = (org.w3c.dom.Element) requestXmlType.getContent().get(0); if (element != null) log.debug("query definition not null"); else log.error("query definition is null"); String domString = edu.harvard.i2b2.common.util.xml.XMLUtil.convertDOMElementToString(element); log.debug("string output" + domString); JAXBContext jc1 = JAXBContext .newInstance(edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.ObjectFactory.class); Unmarshaller unMarshaller = jc1.createUnmarshaller(); JAXBElement queryDefinitionJaxbElement = (JAXBElement) unMarshaller .unmarshal(new StringReader(domString)); QueryDefinitionType queryDefinitionType = (QueryDefinitionType) queryDefinitionJaxbElement.getValue(); int numOfPanels = queryDefinitionType.getPanel().size(); int conceptCount = 0; if (queryDefinitionType.getSubquery().size() == 0) // it's a normal query conceptCount = addQueryModel(queryDefinitionType, nodeXmls, conceptCount); // add concepts to nodeXmls, increment conceptCount else if (queryDefinitionType.getSubquery().size() > 0) // temporal queries have subqueries { conceptCount = addQueryModel(queryDefinitionType, nodeXmls, conceptCount); List<QueryDefinitionType> subqueries = queryDefinitionType.getSubquery(); for (QueryDefinitionType subQuery : subqueries) conceptCount = addQueryModel(subQuery, nodeXmls, conceptCount); // for each subquery, add concepts to nodeXmls, increment conceptCount } if (nodeXmls.size() == 0) return; populateTable(nodeXmls); // get query instance String xmlRequest = ndata.writeContentQueryXML(); lastRequestMessage(xmlRequest); String xmlResponse = PDOQueryClient.sendPDQQueryRequestREST(xmlRequest); lastResponseMessage(xmlResponse); jaxbElement = jaxbUtil.unMashallFromString(xmlResponse); messageType = (ResponseMessageType) jaxbElement.getValue(); bt = messageType.getMessageBody(); InstanceResponseType instanceResponseType = (InstanceResponseType) new JAXBUnWrapHelper() .getObjectByClass(bt.getAny(), InstanceResponseType.class); QueryInstanceData instanceData = null; XMLGregorianCalendar startDate = null; for (QueryInstanceType queryInstanceType : instanceResponseType.getQueryInstance()) { QueryInstanceData runData = new QueryInstanceData(); runData.visualAttribute("FA"); runData.tooltip("The results of the query run"); runData.id(new Integer(queryInstanceType.getQueryInstanceId()).toString()); XMLGregorianCalendar cldr = queryInstanceType.getStartDate(); runData.name("Results of " + "[" + cldr.getMonth() + "-" + cldr.getDay() + "-" + cldr.getYear() + " " + cldr.getHour() + ":" + cldr.getMinute() + ":" + cldr.getSecond() + "]"); if (instanceData == null) { startDate = cldr; instanceData = runData; } else { if (cldr.toGregorianCalendar().compareTo(startDate.toGregorianCalendar()) > 0) { startDate = cldr; instanceData = runData; } } } // get patient set if (instanceData == null) return; log.debug("Got query instance: " + instanceData.name()); xmlRequest = instanceData.writeContentQueryXML(); lastRequestMessage(xmlRequest); xmlResponse = PDOQueryClient.sendPDQQueryRequestREST(xmlRequest); lastResponseMessage(xmlResponse); jaxbElement = jaxbUtil.unMashallFromString(xmlResponse); messageType = (ResponseMessageType) jaxbElement.getValue(); bt = messageType.getMessageBody(); ResultResponseType resultResponseType = (ResultResponseType) new JAXBUnWrapHelper() .getObjectByClass(bt.getAny(), ResultResponseType.class); for (QueryResultInstanceType queryResultInstanceType : resultResponseType.getQueryResultInstance()) { if (!(queryResultInstanceType.getQueryResultType().getName().equalsIgnoreCase("PATIENTSET"))) continue; String status = queryResultInstanceType.getQueryStatusType().getName(); if (status.equalsIgnoreCase("FINISHED")) { String setId = new Integer(queryResultInstanceType.getResultInstanceId()).toString(); final String setSize = new Integer(queryResultInstanceType.getSetSize()).toString(); final String description = queryResultInstanceType.getDescription(); patientRefId = new String(setId); patientSetSize = queryResultInstanceType.getSetSize(); Display.getDefault().asyncExec(new Runnable() { public void run() { if (description != null) patientSetText.setText(description); else patientSetText.setText("Patient Set: " + setSize + " patients"); patientMinNumText.setText("1"); leftArrowButton.setEnabled(false); int maxPatientNum = new Integer(patientMaxNumText.getText()).intValue(); if (patientSetSize > maxPatientNum) { rightArrowButton.setEnabled(true); patientMaxNumText.setText("10"); } else { rightArrowButton.setEnabled(false); if (patientSetSize > 0) patientMaxNumText.setText(setSize); } } }); log.debug("Dropped set of: " + setSize + " patients" + " with refId: " + setId); } else { // message } } } catch (Exception e) { e.printStackTrace(); return; } }