List of usage examples for javax.xml.datatype XMLGregorianCalendar getDay
public abstract int getDay();
From source file:ca.phon.session.io.xml.v12.XMLSessionReader_v12.java
/** * Read session in from given xml {@link SessionType} object. * /* w ww .j a v a 2s . c om*/ * @param sessionType * * @return session */ private Session readSessionType(SessionType sessionType) { final SessionFactory factory = SessionFactory.newFactory(); final Session retVal = factory.createSession(); // copy header info retVal.setName(sessionType.getId()); retVal.setCorpus(sessionType.getCorpus()); final HeaderType headerData = sessionType.getHeader(); if (headerData != null) { if (headerData.getMedia() != null && headerData.getMedia().length() > 0) { retVal.setMediaLocation(headerData.getMedia()); } if (headerData.getDate() != null) { final XMLGregorianCalendar xmlDate = headerData.getDate(); final LocalDate dateTime = LocalDate.of(xmlDate.getYear(), xmlDate.getMonth(), xmlDate.getDay()); retVal.setDate(dateTime); } if (headerData.getLanguage().size() > 0) { String langs = ""; for (String lang : headerData.getLanguage()) { langs += (langs.length() > 0 ? " " : "") + lang; } retVal.setLanguage(langs); } } // copy participant information final ParticipantsType participants = sessionType.getParticipants(); if (participants != null) { for (ParticipantType pt : participants.getParticipant()) { final Participant p = copyParticipant(factory, pt, retVal.getDate()); retVal.addParticipant(p); } } // copy transcriber information final TranscribersType transcribers = sessionType.getTranscribers(); if (transcribers != null) { for (TranscriberType tt : transcribers.getTranscriber()) { final Transcriber t = copyTranscriber(factory, tt); retVal.addTranscriber(t); } } // copy tier information final UserTiersType userTiers = sessionType.getUserTiers(); if (userTiers != null) { for (UserTierType utt : userTiers.getUserTier()) { final TierDescription td = copyTierDescription(factory, utt); retVal.addUserTier(td); } } final List<TierViewItem> tierOrder = new ArrayList<TierViewItem>(); for (TvType tot : sessionType.getTierOrder().getTier()) { final TierViewItem toi = copyTierViewItem(factory, tot); tierOrder.add(toi); } retVal.setTierView(tierOrder); // copy transcript data final List<Comment> recordComments = new ArrayList<Comment>(); boolean foundFirstRecord = false; if (sessionType.getTranscript() != null) { for (Object uOrComment : sessionType.getTranscript().getUOrComment()) { if (uOrComment instanceof CommentType) { final CommentType ct = (CommentType) uOrComment; final Comment comment = copyComment(factory, ct); recordComments.add(comment); } else { if (!foundFirstRecord && recordComments.size() > 0) { // add record comments to session metadata for (Comment c : recordComments) { retVal.getMetadata().addComment(c); } recordComments.clear(); } final RecordType rt = (RecordType) uOrComment; Record record = null; try { record = new LazyRecord(factory, retVal, rt); } catch (Exception e) { LOGGER.info(rt.getId()); LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); } retVal.addRecord(record); for (Comment comment : recordComments) { record.addComment(comment); } recordComments.clear(); foundFirstRecord = true; } } } return retVal; }
From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.java
public String loadPreviousQueries(boolean getAllInGroup) { System.out.println("Loading previous queries for: " + System.getProperty("user")); String xmlStr = writeContentQueryXML(getAllInGroup); lastRequestMessage = xmlStr;/* w ww. j a va2s . c o m*/ //System.out.println(xmlStr); String responseStr = QueryListNamesClient.sendQueryRequestREST(xmlStr); if (responseStr.equalsIgnoreCase("CellDown")) { cellStatus = new String("CellDown"); return "CellDown"; } lastResponseMessage = responseStr; 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); 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.tooltip("A query run by " + queryMasterType.getUserId());//System.getProperty("user")); tmpData.visualAttribute("CA"); tmpData.xmlContent(null); tmpData.id(new Integer(queryMasterType.getQueryMasterId()).toString()); tmpData.userId(queryMasterType.getUserId()); //System.getProperty("user")); previousQueries.add(tmpData); } return ""; } catch (Exception e) { e.printStackTrace(); return "error"; } }
From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.java
private void populateChildNodes(DefaultMutableTreeNode node) { if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryMasterData")) { QueryMasterData data = (QueryMasterData) node.getUserObject(); try {/*from ww w .j a va 2s . co m*/ String xmlRequest = data.writeContentQueryXML(); lastRequestMessage = xmlRequest; //System.out.println(xmlRequest); String xmlResponse = QueryListNamesClient.sendQueryRequestREST(xmlRequest); if (xmlResponse.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; } lastResponseMessage = xmlResponse; try { JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(xmlResponse); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); BodyType bt = messageType.getMessageBody(); InstanceResponseType instanceResponseType = (InstanceResponseType) new JAXBUnWrapHelper() .getObjectByClass(bt.getAny(), InstanceResponseType.class); for (QueryInstanceType queryInstanceType : instanceResponseType.getQueryInstance()) { //change later for working with new xml schema //RunQuery runQuery = queryInstanceType.getResult().get(i).getRunQuery().get(0); QueryInstanceData runData = new QueryInstanceData(); runData.visualAttribute("FA"); runData.tooltip("The results of the query run"); runData.id(new Integer(queryInstanceType.getQueryInstanceId()).toString()); //runData.patientRefId(new Integer(queryInstanceType.getRefId()).toString()); //runData.patientCount(new Long(queryInstanceType.getCount()).toString()); XMLGregorianCalendar cldr = queryInstanceType.getStartDate(); runData.name("Results of " + "[" + addZero(cldr.getMonth()) + "-" + addZero(cldr.getDay()) + "-" + addZero(cldr.getYear()) + " " + addZero(cldr.getHour()) + ":" + addZero(cldr.getMinute()) + ":" + addZero(cldr.getSecond()) + "]"); data.runs.add(runData); addNode(runData, node); } } catch (Exception e) { e.printStackTrace(); } jTree1.scrollPathToVisible(new TreePath(node.getPath())); } catch (Exception e) { e.printStackTrace(); } } else if (node.getUserObject().getClass().getSimpleName().equalsIgnoreCase("QueryInstanceData")) { QueryInstanceData data = (QueryInstanceData) node.getUserObject(); try { String xmlRequest = data.writeContentQueryXML(); lastRequestMessage = xmlRequest; //System.out.println(xmlRequest); String xmlResponse = QueryListNamesClient.sendQueryRequestREST(xmlRequest); if (xmlResponse.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; } lastResponseMessage = xmlResponse; JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(xmlResponse); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); BodyType bt = messageType.getMessageBody(); ResultResponseType resultResponseType = (ResultResponseType) new JAXBUnWrapHelper() .getObjectByClass(bt.getAny(), ResultResponseType.class); for (QueryResultInstanceType queryResultInstanceType : resultResponseType .getQueryResultInstance()) { String status = queryResultInstanceType.getQueryStatusType().getName(); QueryResultData resultData = new QueryResultData(); resultData.visualAttribute("LAO"); resultData.tooltip("A patient set of the query run"); //resultData.queryId(data.queryId()); resultData.patientRefId(new Integer(queryResultInstanceType.getResultInstanceId()).toString());//data.patientRefId()); resultData.patientCount(new Integer(queryResultInstanceType.getSetSize()).toString());//data.patientCount()); if (status.equalsIgnoreCase("FINISHED")) { resultData.name("Patient Set - " + resultData.patientCount() + " Patients"); } else { resultData.name("Patient Set - " + status); } resultData.xmlContent(xmlResponse); addNode(resultData, node); } jTree1.scrollPathToVisible(new TreePath(node.getPath())); } catch (Exception e) { e.printStackTrace(); } } //implement for other type of nodes later!!! }
From source file:org.apache.cxf.cwiki.SiteExporter.java
public String breadcrumbs(BlogEntrySummary page) { StringBuffer buffer = new StringBuffer(); if (breadCrumbRoot != null) { buffer.append("<a href=\""); buffer.append("../../../index.html"); buffer.append("\">"); buffer.append(breadCrumbRoot);/*from www. j a v a 2s . co m*/ buffer.append("</a>"); buffer.append(SEPARATOR); } else { buffer.append("<a href=\"../../../index.html\">Index</a>"); buffer.append(SEPARATOR); } XMLGregorianCalendar published = page.getPublished(); buffer.append(String.valueOf(published.getYear())); buffer.append(SEPARATOR); if (published.getMonth() < 10) { buffer.append("0"); } buffer.append(String.valueOf(published.getMonth())); buffer.append(SEPARATOR); if (published.getDay() < 10) { buffer.append("0"); } buffer.append(String.valueOf(published.getDay())); buffer.append(SEPARATOR); buffer.append("<a href=\""); buffer.append(page.createFileName()); buffer.append("\">"); buffer.append(page.getTitle()); buffer.append("</a>"); return buffer.toString(); }
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);//ww w .j a v a 2 s.c o 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.QueryPreviousRunsPanel.java
public String loadPreviousQueries(boolean getAllInGroup) { System.out.println("Loading previous queries for: " + System.getProperty("user")); String xmlStr = writeContentQueryXML(getAllInGroup); // System.out.println(xmlStr); String responseStr = null;//w w w .j a va 2s.c o m 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.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.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 av a 2s .co m*/ 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 jFindButtonActionPerformed(java.awt.event.ActionEvent evt) { System.out.println("Loading previous queries for: " + System.getProperty("user")); cellStatus = ""; String searchStr = this.jSearchStringTextField.getText(); int category = this.jCategoryComboBox.getSelectedIndex(); int strategy = this.jContainComboBox.getSelectedIndex(); String xmlStr = writeFindQueryXML(searchStr, category, strategy); // System.out.println(xmlStr); String responseStr = null;//from ww w . j av a 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 = 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.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 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 a2s.co 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 = 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 w w .j a 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 = 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; } }