Example usage for javax.xml.datatype XMLGregorianCalendar getYear

List of usage examples for javax.xml.datatype XMLGregorianCalendar getYear

Introduction

In this page you can find the example usage for javax.xml.datatype XMLGregorianCalendar getYear.

Prototype

public abstract int getYear();

Source Link

Document

Returns the low order component for XML Schema 1.0 dateTime datatype field for year or DatatypeConstants#FIELD_UNDEFINED .

Usage

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;//from  w  w w .  jav a 2  s .  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;/*from   w w  w  .  ja  va2s  .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 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   w  w w  .  ja v  a2  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 w w  w  .  ja v  a2s. 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 {/*from w  w  w.  j a va 2 s .co  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  ww .j a  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"));
            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;/*from ww w .  ja v  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 = 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 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("all users", searchStr, category, strategy);
    // System.out.println(xmlStr);

    String responseStr = null;//from  w  w w. j av  a2s  . c  om
    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.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 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 www  .j  av  a2 s.com
    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  . co  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 = 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;
    }
}