Example usage for javax.xml.datatype DatatypeFactory newInstance

List of usage examples for javax.xml.datatype DatatypeFactory newInstance

Introduction

In this page you can find the example usage for javax.xml.datatype DatatypeFactory newInstance.

Prototype

public static DatatypeFactory newInstance() throws DatatypeConfigurationException 

Source Link

Document

Obtain a new instance of a DatatypeFactory .

Usage

From source file:org.socraticgrid.displayalert.DisplayAlertMessages.java

/**
 * Create one of the responses to be returned by getMessages
 * //from w  ww  . j av a 2 s .  c  o m
 * 
 * @param ticket AlertTicket
 * @param contact AlertContact record corresponding to ticket
 * @param isArch is the ticket archived or not
 * @param location location passed in request
 * @return response object to be added to return
 * @throws DatatypeConfigurationException 
 */
private GetMessageResponse createAlertResponse(AlertTicket ticket, AlertContact contact, boolean isArch,
        String location) throws DatatypeConfigurationException {
    GetMessagesResponseType.GetMessageResponse response = new GetMessagesResponseType.GetMessageResponse();

    response.setMessageType("Alert");

    //--------------------------
    // Set ARCHIVED attribute
    //--------------------------
    if (isArch) {
        response.setLocation("Archive");
    } else {
        response.setLocation(location);
    }

    //--------------------------
    // Set READ/UNREAD attribute
    //--------------------------
    if (checkRead(ticket, contact.getUserId())) {
        response.setMessageStatus("Read");
    } else {
        response.setMessageStatus("Unread");
    }

    //        System.out.println("===> TICKET ID: " + ticket.getTicketId()
    //                          +"     DESC: " + ticket.getDescription());

    //--------------------------
    response.setDescription(ticket.getDescription());
    response.setFrom(contact.getUserName());
    response.setTitle(ticket.getDescription());
    //--------------------------
    // Temporarily setting task % from DSA in ptFMPSSN column
    //--------------------------
    if (!CommonUtil.strNullorEmpty(ticket.getPtFMPSSN())) {
        try {
            response.setTasksComplete(Integer.parseInt(ticket.getPtFMPSSN()));
        } catch (NumberFormatException nfe) {
            response.setTasksComplete(0);
        }
    }

    //--------------------------
    // Set MSG DATE
    //--------------------------
    GregorianCalendar gc = new GregorianCalendar();
    gc.setTime(ticket.getAlertTimestamp());
    XMLGregorianCalendar xgcDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
    response.setMessageDate(xgcDate);

    //--------------------------
    String msgId = ticket.getTicketId().toString();
    response.setMessageId(msgId);

    //--------------------------
    // Check the starred/flagged label in the status table
    //--------------------------
    for (AlertStatus status : ticket.getStatus()) {
        if (!CommonUtil.strNullorEmpty(contact.getUserId())) {
            if (contact.getUserId().equals(status.getUserId()) && status.isFlagged()) {
                response.getLabels().add("Starred");
            }
        }
    }
    //--------------------------
    response.setPriority(ticket.getPriority());
    response.setSuccessStatus(true);
    response.setFrom(ticket.getAlertOriginator());
    //response.setTasksComplete(ticket.getActionHistory().size());
    response.setTasksCount(ticket.getActionHistory().size());

    return response;
}

From source file:org.socraticgrid.displaymaildata.DisplayMailDataHandler.java

/**
 * Retrieve mail for user.//from   w w w.ja  v  a  2 s  .c o  m
 *
 * @param userType = "P" if logged in user is a provider
 *                   "T" if logged in user is a patient
 * @param userId = unique id of logged in user.
 * @param login = email server user name of logged in user.
 * @param pswd  = password of logged in user.
 * @param folderName = 
 * @param displayName = full name
 * @param onlyNew =
 *
 * @return
 * @throws java.lang.Exception
 */
//private  //DBG ONLY - REMOVE COMMENT MARKS
public List<SummaryData> retrieveMail(String userType, String userId, String patientId, String login,
        String pswd, String folderName, String patientName, boolean onlyNew, String mailHost, String mailUrl)
        throws Exception, DatatypeConfigurationException {
    List<SummaryData> dataList = new LinkedList<SummaryData>();
    IMAPSSLStore sslStore = null;
    IMAPFolder currentFolder = null;
    String folderToOpen = folderName;

    System.out.println("===> retrieveMail Incoming params:");
    System.out.println("===>     mailHost=" + mailHost);
    System.out.println("===>      mailUrl=" + mailUrl);
    System.out.println("===>    maillogin=" + login);
    System.out.println("===>   folderName=" + folderName);
    try {
        //Get session
        Session session = Session.getInstance(new Properties());
        URLName urlName = new URLName(mailUrl);
        //Get the sslStore
        sslStore = new IMAPSSLStore(session, urlName);
        sslStore.connect(mailHost, login, pswd);

        folderToOpen = this.mapKmrLocationToImapFolder(folderName, this.host);

        currentFolder = (IMAPFolder) sslStore.getFolder(folderToOpen);
        currentFolder.open(Folder.READ_ONLY);

        Message[] allMessages = currentFolder.getMessages();

        GregorianCalendar cal = new GregorianCalendar();

        System.out.println("====> FILTER PARAMS for Emails:");
        System.out.println("====>     folder = " + folderToOpen);
        System.out.println("====>     User   = " + login);
        //            System.out.println("====>     from   = "+ patientName +"/"+ patientEmail);
        //            System.out.println("====>     ptid   = "+ patientId);
        System.out.println("====> Total Emails found = " + allMessages.length);
        System.out.println();

        // TMN - CHECK SLOW PERFORMANCE ISSUE HERE:

        //Loop through each email and find ONLY the ones required for return.
        for (Message msg : allMessages) {
            if (msg == null) {
                continue;
            }

            // Keep this in case we want to search entire message
            //
            //                OutputStream os = new ByteArrayOutputStream();
            //                msg.writeTo(os);
            //                String msgContent = os.toString();

            SummaryData summaryData = new SummaryData();
            summaryData.setDataSource(DATA_SOURCE);

            String from = "";
            Address[] fromAddr = msg.getFrom();

            if (fromAddr != null && fromAddr.length > 0) {

                String fromFull = fromAddr[0].toString();
                from = getContactIdFromEmail(extractEmailAddressFromSender(fromFull));

                //System.out.println("retrieveMail: FROM=" + fromFull + " ldap.cn=" + from);

            }

            //------------------------------------------------------
            //FILTERING: Check to exclude email if
            //     0) patientId is passed in as a param
            // AND 1) email does NOT contain PATIENTID=<patientId>
            // AND 2) email FROM field <> patientName
            // AND 3) email FROM field <> patientEmail.
            //
            // because must becoming from EMR inbox and looking for emails
            // addressed to userId BUT only ABOUT or FROM patientId.
            //------------------------------------------------------

            summaryData.setFrom(from);
            summaryData.setAuthor(summaryData.getFrom());
            cal.setTime(msg.getReceivedDate());
            summaryData.setDateCreated(DatatypeFactory.newInstance().newXMLGregorianCalendar(cal));

            summaryData.setDescription(msg.getSubject());

            summaryData.setItemId(userType + userId + ITEM_ID_SEPARATER + msg.getFolder().getName()
                    + ITEM_ID_SEPARATER + msg.getHeader("Message-ID")[0]);

            //this.printMsgIdSubject(msg); //DBG printout

            boolean msgRead = msg.isSet(Flags.Flag.SEEN);
            addNameValue(summaryData.getItemValues(), ITEM_READ, String.valueOf(msgRead));

            boolean msgStar = msg.isSet(Flags.Flag.FLAGGED);
            if (msgStar) {
                addNameValue(summaryData.getItemValues(), ITEM_STARRED, "Starred");
            }

            addNameValue(summaryData.getItemValues(), ITEM_REPLIED,
                    String.valueOf(msg.isSet(Flags.Flag.ANSWERED)));
            addNameValue(summaryData.getItemValues(), "MESSAGE_TYPE", msg.getFolder().getName());
            if (onlyNew) {
                if (!msg.isSet(Flags.Flag.SEEN)) {
                    dataList.add(summaryData);
                }
            } else {
                dataList.add(summaryData);
            }
        }

    } catch (MessagingException me) {
        log.error("Error in processing email");
        me.printStackTrace();
    } finally {
        // Close connections

        if (currentFolder != null) {
            try {
                currentFolder.close(false);
            } catch (Exception e) {
            }
        }

        if (sslStore != null) {
            try {
                sslStore.close();
            } catch (Exception e) {
            }
        }
    }

    return dataList;
}

From source file:org.socraticgrid.docmgr.DocumentManagerImpl.java

/**
 * Parse metadata query result for getMessages() return.
 *
 * @param msgType/*ww w  .  j a v  a2s  .c  om*/
 * @param metadata result
 * @return
 */
private GetMessagesResponseType parseMetadataMessageResponse(String userId, String msgType, String location,
        oasis.names.tc.ebxml_regrep.xsd.query._3.AdhocQueryResponse result) {

    GetMessagesResponseType response = new GetMessagesResponseType();

    try {
        GetMessageResponse msgResponse;

        //Check for errors
        if (result.getRegistryErrorList() != null) {
            msgResponse = new GetMessageResponse();
            List<RegistryError> errorList = result.getRegistryErrorList().getRegistryError();
            for (RegistryError error : errorList) {
                msgResponse.setStatusMessage(error.getValue());
                break;
            }
            msgResponse.setSuccessStatus(false);
            response.getGetMessageResponse().add(msgResponse);
        }
        List<JAXBElement<? extends IdentifiableType>> objectList = result.getRegistryObjectList()
                .getIdentifiable();
        log.debug("Found metadata for documents: " + objectList.size());
        for (JAXBElement<? extends IdentifiableType> object : objectList) {
            IdentifiableType identifiableType = object.getValue();
            if (identifiableType instanceof ExtrinsicObjectType) {
                msgResponse = new GetMessageResponse();
                msgResponse.setSuccessStatus(true);

                //Poplulate summary data object
                GregorianCalendar cal = new GregorianCalendar();
                String author = null;
                String institution = null;
                msgResponse.setMessageType(msgType);
                msgResponse.setMessageStatus(KMR_INBOX_UNREAD);
                ExtrinsicObjectType extrinsic = (ExtrinsicObjectType) identifiableType;
                try {
                    msgResponse
                            .setDescription(extrinsic.getDescription().getLocalizedString().get(0).getValue());
                } catch (Exception e) {
                    msgResponse.setDescription("");
                }
                msgResponse.setTitle(extrinsic.getName().getLocalizedString().get(0).getValue());
                for (SlotType1 metaSlot : extrinsic.getSlot()) {
                    //Set only if not already set, we use the creation date if special kmr
                    //  metadata tag is not found.
                    if (XDS_CREATION_TIME.equals(metaSlot.getName())
                            && (msgResponse.getMessageDate() == null)) {
                        try {
                            cal.setTime(parseXDSDate(metaSlot.getValueList().getValue().get(0)));
                            if (msgResponse.getMessageDate() == null)
                                msgResponse.setMessageDate(
                                        DatatypeFactory.newInstance().newXMLGregorianCalendar(cal));
                        } catch (Exception pe) {
                            String msg = "Error parsing: " + XDS_CREATION_TIME;
                            log.error(msg, pe);

                            msgResponse.setStatusMessage(msg + ". " + pe.getMessage());
                            msgResponse.setSuccessStatus(false);
                        }
                    } else if ((XDS_KMR_READ + ":" + userId).equals(metaSlot.getName())) {
                        try {
                            if (Boolean.TRUE
                                    .equals(Boolean.valueOf(metaSlot.getValueList().getValue().get(0)))) {
                                msgResponse.setMessageStatus(KMR_INBOX_READ);
                            } else {
                                msgResponse.setMessageStatus(KMR_INBOX_UNREAD);
                            }
                        } catch (Exception e) {
                            String msg = "Error parsing: " + XDS_KMR_READ + ":" + userId;
                            log.error(msg, e);

                            msgResponse.setStatusMessage(msg + ". " + e.getMessage());
                            msgResponse.setSuccessStatus(false);
                        }
                    } else if ((XDS_KMR_STARRED + ":" + userId).equals(metaSlot.getName())) {
                        try {
                            if (Boolean.TRUE
                                    .equals(Boolean.valueOf(metaSlot.getValueList().getValue().get(0)))) {
                                msgResponse.getLabels().add(KMR_INBOX_STARRED);
                            }
                        } catch (Exception e) {
                            String msg = "Error parsing: " + XDS_KMR_STARRED + ":" + userId;
                            log.error(msg, e);

                            msgResponse.setStatusMessage(msg + ". " + e.getMessage());
                            msgResponse.setSuccessStatus(false);
                        }
                    } else if ((XDS_KMR_ARCHIVE + ":" + userId).equals(metaSlot.getName())) {
                        try {
                            if (Boolean.TRUE
                                    .equals(Boolean.valueOf(metaSlot.getValueList().getValue().get(0)))) {
                                //Set archive if location value not already set (trash)
                                if ((msgResponse.getLocation() == null)
                                        || msgResponse.getLocation().isEmpty()) {
                                    msgResponse.setLocation(KMR_INBOX_ARCHIVE);
                                }
                            }
                        } catch (Exception e) {
                            String msg = "Error parsing: " + XDS_KMR_ARCHIVE + ":" + userId;
                            log.error(msg, e);

                            msgResponse.setStatusMessage(msg + ". " + e.getMessage());
                            msgResponse.setSuccessStatus(false);
                        }
                    } else if ((XDS_KMR_DELETE + ":" + userId).equals(metaSlot.getName())) {
                        try {
                            if (Boolean.TRUE
                                    .equals(Boolean.valueOf(metaSlot.getValueList().getValue().get(0)))) {
                                msgResponse.setLocation(KMR_INBOX_USERTRASH);
                            }
                        } catch (Exception e) {
                            String msg = "Error parsing: " + XDS_KMR_DELETE + ":" + userId;
                            log.error(msg, e);

                            msgResponse.setStatusMessage(msg + ". " + e.getMessage());
                            msgResponse.setSuccessStatus(false);
                        }
                    } else if ((XDS_KMR_STOREDATE).equals(metaSlot.getName())) {
                        try {
                            cal.setTime(parseXDSDate(metaSlot.getValueList().getValue().get(0)));
                            msgResponse
                                    .setMessageDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(cal));
                        } catch (Exception pe) {
                            String msg = "Error parsing: " + XDS_KMR_STOREDATE;
                            log.error(msg, pe);

                            msgResponse.setStatusMessage(msg + ". " + pe.getMessage());
                            msgResponse.setSuccessStatus(false);
                        }
                    }
                } //end for meta slots
                for (ExternalIdentifierType identifier : extrinsic.getExternalIdentifier()) {
                    if (XDS_DOC_ID.equals(identifier.getName().getLocalizedString().get(0).getValue())) {
                        msgResponse.setMessageId(identifier.getValue());
                    }
                }
                for (ClassificationType classification : extrinsic.getClassification()) {
                    if (XDS_CLASS_AUTHOR.equals(classification.getClassificationScheme())) {
                        for (SlotType1 authorSlot : classification.getSlot()) {
                            if (XDS_SLOT_AUTHOR.equals(authorSlot.getName())) {
                                author = authorSlot.getValueList().getValue().get(0);
                            }
                        }
                        for (SlotType1 authorSlot : classification.getSlot()) {
                            if (XDS_SLOT_INSTITUTION.equals(authorSlot.getName())) {
                                institution = authorSlot.getValueList().getValue().get(0);
                            }
                        }
                    }
                }

                //Set From field as combo of author and institution
                if ((institution != null) && !institution.isEmpty()) {
                    msgResponse.setFrom(institution + " - " + author);
                } else {
                    msgResponse.setFrom(author);
                }

                msgResponse.setPriority("");
                msgResponse.setTasksComplete(0);
                msgResponse.setTasksCount(0);

                //Filter documents not in requested location
                if ((location == null) || location.isEmpty() || KMR_INBOX.equalsIgnoreCase(location)) {
                    //If we're here, we want inbox only items,
                    //  which means an empty location value
                    if ((msgResponse.getLocation() != null) && !msgResponse.getLocation().isEmpty()) {
                        continue;
                    }
                } else {
                    //A location has been specified that is not Inbox,
                    //  so, make sure location mathces
                    if (!location.equalsIgnoreCase(msgResponse.getLocation())) {
                        continue;
                    }
                }

                //Add the document to the response
                response.getGetMessageResponse().add(msgResponse);
            } //end if extrinisc object
        } //end for result object list
    } catch (Exception e) {
        log.error("Error parsing metadata result.", e);

        GetMessageResponse msgResponse = new GetMessageResponse();
        msgResponse.setStatusMessage(e.getMessage());
        msgResponse.setSuccessStatus(false);
        response.getGetMessageResponse().add(msgResponse);
    }

    return response;
}

From source file:org.socraticgrid.docmgr.DocumentManagerImpl.java

/**
 * KMR Inbox request for cross-gateway NHIN documents.
 *
 * @param request/*from www  .  jav  a 2  s . com*/
 * @return
 */
public org.socraticgrid.common.docmgr.GetNHINDocumentsResponseType getNHINDocuments(
        org.socraticgrid.common.docmgr.GetNHINDocumentsRequestType request) {
    GetNHINDocumentsResponseType response = new GetNHINDocumentsResponseType();

    //Assign default response
    response.setProcessState(XDSProcessConstants.PROCESS_STATE_AVAILABLE);
    response.setSuccessStatus(true);

    //Check if there is an existing query.
    XDSService xdsService = new XDSService();
    ProcessQueryParams query = new ProcessQueryParams();
    query.setPatientId(request.getPatientId());
    List<XDSProcess> processes = xdsService.getProcessesByParams(query);

    //If query exists and is stale, delete
    Iterator<XDSProcess> procIter = processes.iterator();
    while (procIter.hasNext()) {
        XDSProcess process = procIter.next();
        GregorianCalendar now = new GregorianCalendar();
        GregorianCalendar staleTime = new GregorianCalendar();
        staleTime.setTime(process.getStartTime());
        staleTime.add(Calendar.MINUTE, XDS_QUERY_DURATION);
        if (now.after(staleTime)) {
            log.info("Removing stale process for patient: " + process.getPatientId() + ", ticket: "
                    + process.getTicket());
            xdsService.deleteProcess(process);
            procIter.remove();
        }
    }

    //Check if there is an existing query that is still valid
    if (!processes.isEmpty()) {
        XDSProcess process = processes.get(0);
        response.setProcessState(XDSProcessConstants.PROCESS_STATE_IN_PROGRESS);
        response.setStatusMessage("Current query in progress for patient: " + process.getPatientId()
                + ", by user: " + process.getUserId() + ", started at: " + process.getStartTime());
    }

    //Check action value if we don't have an existing query
    if (processes.isEmpty() && (request.getAction() != null) && request.getAction().equals(XDS_INBOX_ACTION)) {

        StartNHINQueryAndDownloadResponseType startResponse = null;

        try {
            log.debug("Starting NHIN query for patient: " + request.getPatientId());

            //Start new query
            StartNHINQueryAndDownloadRequestType startRequest = new StartNHINQueryAndDownloadRequestType();
            startRequest.setPatientUnitNumber(request.getPatientId());
            startRequest.setPatientDOB(request.getPatientDOB());
            startRequest.setPatientFirstName(request.getPatientFirstName());
            startRequest.setPatientMiddleName(request.getPatientMiddleName());
            startRequest.setPatientLastName(request.getPatientLastName());
            startRequest.setUsername(request.getUserId());
            startRequest.setProviderFirstName(request.getUserFirstName());
            startRequest.setProviderMiddleName(request.getUserMiddleName());
            startRequest.setProviderLastName(request.getUserLastName());
            startRequest.setHomeCommunityId(
                    PropertyAccessor.getProperty(REPOSITORY_PROPERTY_FILE, DEFAULT_HOME_COMMUNITY_ID));
            GregorianCalendar queryDate = new GregorianCalendar();
            queryDate.add(Calendar.YEAR, -5);
            startRequest.setQueryFromDate(DatatypeFactory.newInstance().newXMLGregorianCalendar(queryDate));
            startRequest.setCallbackURL(
                    PropertyAccessor.getProperty(REPOSITORY_PROPERTY_FILE, XDS_PROCESS_ENDPOINT_PROP));
            startResponse = startNHINQueryAndDownload(startRequest);
        } catch (Exception e) {
            log.error("Error handling getDocuments for patient: " + request.getPatientId(), e);
        }

        //Create new process record
        if ((startResponse != null) && !startResponse.getTicket().equals(JOB_FAILURE_ID)) {
            XDSProcess newProcess = new XDSProcess();
            newProcess.setTicket(startResponse.getTicket());
            newProcess.setPatientId(request.getPatientId());
            newProcess.setUserId(request.getUserId());
            newProcess.setStartTime(new Date());
            newProcess.setDownloadCount(-1L);
            newProcess.setExistedCount(-1L);
            newProcess.setResultCount(-1L);
            xdsService.saveProcess(newProcess);

            response.setProcessState(XDSProcessConstants.PROCESS_STATE_IN_PROGRESS);
            response.setStatusMessage("Process started.");
        } else {
            response.setProcessState(XDSProcessConstants.PROCESS_STATE_AVAILABLE);
            response.setStatusMessage("Process start failed.");
        }
    }

    return response;
}

From source file:org.socraticgrid.docmgr.NHINQueryProcessor.java

/**
 * Parse metadata query result for summary return.
 *
 * @param result summary info//w  w w.  jav  a 2  s .  co  m
 * @return
 */
private DocumentInfoType parseMetadata(ExtrinsicObjectType docMeta) {
    GregorianCalendar cal = new GregorianCalendar();

    //Poplulate summary data object
    DocumentInfoType summaryData = new DocumentInfoType();
    summaryData.setDataSource(DATA_SOURCE);
    String desc = "NHIN Document";
    try {
        //So many possible nulls, this try catch seems to be the best
        //  way to make sure we get the data.
        desc = docMeta.getDescription().getLocalizedString().get(0).getValue();
    } catch (Exception e1) {
        try {
            desc = docMeta.getName().getLocalizedString().get(0).getValue();
        } catch (Exception e2) {
            //do nothing
        }
    }
    summaryData.setDescription(desc);
    addNameValue(summaryData.getItemValues(), ITEM_DOCUMENT_NAME,
            docMeta.getName().getLocalizedString().get(0).getValue());
    addNameValue(summaryData.getItemValues(), ITEM_MIME_TYPE, docMeta.getMimeType());
    addNameValue(summaryData.getItemValues(), ITEM_HOME_COMMUNITY_ID, docMeta.getHome());
    for (SlotType1 metaSlot : docMeta.getSlot()) {
        if (XDS_CREATION_TIME.equals(metaSlot.getName())) {
            try {
                cal.setTime(parseXDSDate(metaSlot.getValueList().getValue().get(0)));
                summaryData.setDateCreated(DatatypeFactory.newInstance().newXMLGregorianCalendar(cal));
            } catch (Exception pe) {
                String msg = "Error parsing: " + XDS_CREATION_TIME;
                log.error(msg, pe);
            }
        }
        if (XDS_PATIENT_INFO.equals(metaSlot.getName())) {
            //Find patient name
            for (String ptVal : metaSlot.getValueList().getValue()) {
                //Patient name is PID-5
                if (ptVal.startsWith(XDS_PATIENT_NAME)) {
                    summaryData.setPatient(ptVal.substring(XDS_PATIENT_NAME.length()));
                }
            }
        }
        if (XDS_DOC_SIZE.equals(metaSlot.getName())) {
            addNameValue(summaryData.getItemValues(), ITEM_DOCUMENT_SIZE,
                    metaSlot.getValueList().getValue().get(0));
        }
        if (XDS_REPOSITORY_ID.equals(metaSlot.getName())) {
            addNameValue(summaryData.getItemValues(), ITEM_REPOSITORY_ID,
                    metaSlot.getValueList().getValue().get(0));
        }
    } //end for meta slots
    for (ExternalIdentifierType identifier : docMeta.getExternalIdentifier()) {
        if (XDS_DOC_ID.equals(identifier.getName().getLocalizedString().get(0).getValue())) {
            summaryData.setItemId(identifier.getValue());
        }
    }
    for (ClassificationType classification : docMeta.getClassification()) {
        if (XDS_CLASS_AUTHOR.equals(classification.getClassificationScheme())) {
            for (SlotType1 authorSlot : classification.getSlot()) {
                if (XDS_SLOT_AUTHOR.equals(authorSlot.getName())) {
                    summaryData.setAuthor(authorSlot.getValueList().getValue().get(0));
                }
            }
            for (SlotType1 authorSlot : classification.getSlot()) {
                if (XDS_SLOT_INSTITUTION.equals(authorSlot.getName())) {
                    addNameValue(summaryData.getItemValues(), ITEM_INSTITUTION,
                            authorSlot.getValueList().getValue().get(0));
                }
            }
        }
    }

    return summaryData;
}

From source file:org.sofun.platform.opta.parser.bb.BB1Parser.java

/**
 * Returns a date given date and time./*w  w  w .  j a va 2 s  .co m*/
 * 
 * Expecting date in UTC.
 * 
 * @param dateStr: date in format yyyyMMdd HH:mm:ss as a {@link String}
 * @param: tz: Timezone (Europe/London)
 * @return a {@link Date} instance
 * @throws DatatypeConfigurationException
 * @throws ParseException
 */
private Date getDateTZ(String dateStr, String tz) throws Exception {
    return DatatypeFactory.newInstance().newXMLGregorianCalendar(dateStr).toGregorianCalendar().getTime();
}

From source file:org.talend.components.netsuite.client.model.search.SearchDateFieldAdapter.java

public SearchDateFieldAdapter(BasicMetaData metaData, SearchFieldType fieldType, Class<T> fieldClass) {
    super(metaData, fieldType, fieldClass);

    try {//  w  w  w  .  j av a 2s  . c om
        datatypeFactory = DatatypeFactory.newInstance();
    } catch (DatatypeConfigurationException e) {
        throw new NetSuiteException("Failed to create XML data type factory", e);
    }
}

From source file:org.techytax.util.DateHelper.java

public static XMLGregorianCalendar getDate(String date_str) throws Exception {
    XMLGregorianCalendar calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar();
    Date date = stringToDate(date_str);
    calendar.setDay(getDay(date));/*from w ww.j  av  a  2  s  .co  m*/
    calendar.setMonth(getMonth(date) + 1);
    calendar.setYear(getYear(date));
    return calendar;
}

From source file:org.techytax.util.DateHelper.java

public static XMLGregorianCalendar getDateForXml(Date date) {
    XMLGregorianCalendar calendar = null;
    try {/*from w w w.j  a  va2 s.  c om*/
        calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar();
    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
    }
    calendar.setDay(getDay(date));
    calendar.setMonth(getMonth(date) + 1);
    calendar.setYear(getYear(date));
    calendar.setHour(0);
    calendar.setMinute(0);
    calendar.setSecond(0);
    return calendar;
}

From source file:org.tolven.app.bean.DataExtractBean.java

public void streamResultsXML(Writer out, DataQueryResults dq) {
    Long totalCount = null;//from  ww w  .ja v  a2 s.c o  m
    if (dq.isReturnTotalCount()) {
        getMDQueryResults(dq, true);
        totalCount = (Long) dq.getIterator().next();
    }

    if (dq.getLimit() != 0) {
        getMDQueryResults(dq, false);
    }
    try {
        XMLStreamWriter xmlStreamWriter = null;
        try {
            XMLOutputFactory factory = XMLOutputFactory.newInstance();
            xmlStreamWriter = factory.createXMLStreamWriter(out);
            xmlStreamWriter.writeStartDocument("UTF-8", "1.0");
            xmlStreamWriter.writeStartElement("results");
            xmlStreamWriter.writeAttribute("path", dq.getPath());
            xmlStreamWriter.writeAttribute("account", String.valueOf(dq.getAccount().getId()));
            xmlStreamWriter.writeAttribute("database",
                    getTolvenPropertiesBean().getProperty("tolven.repository.oid"));
            GregorianCalendar nowCal = new GregorianCalendar();
            nowCal.setTime(dq.getNow());
            DatatypeFactory xmlFactory = DatatypeFactory.newInstance();
            XMLGregorianCalendar ts = xmlFactory.newXMLGregorianCalendar(nowCal);
            xmlStreamWriter.writeAttribute("timestamp", ts.toXMLFormat());
            if (!dq.isItemQuery()) {
                xmlStreamWriter.writeAttribute("offset", Long.toString(dq.getOffset()));
                xmlStreamWriter.writeAttribute("limit", Long.toString(dq.getLimit()));
                xmlStreamWriter.writeAttribute("count", Long.toString(dq.getCount()));
            }
            if (!dq.isItemQuery() && totalCount != null) {
                xmlStreamWriter.writeAttribute("totalCount", totalCount.toString());
            }
            addExtendedFields(dq);
            //addPlaceholderIds(dq);
            if (MenuStructure.PLACEHOLDER.equals(dq.getMenuStructure().getRole())) {
                addParentFields(dq);
            }
            addSimpleXMLColumnHeadings(dq, xmlStreamWriter);
            if (dq.getLimit() != 0) {
                addXMLRows(dq, xmlStreamWriter);
            }
            xmlStreamWriter.writeEndElement();
            xmlStreamWriter.writeEndDocument();
        } finally {
            if (xmlStreamWriter != null) {
                xmlStreamWriter.close();
            }
        }
    } catch (Exception ex) {
        throw new RuntimeException("Could not obtain XML results for menupath: " + dq.getPath()
                + " in account: " + dq.getAccount().getId(), ex);
    }
}