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:org.oscarehr.hospitalReportManager.HRMReport.java

public List<Integer> getDateOfBirth() {
    List<Integer> dateOfBirthList = new ArrayList<Integer>();
    XMLGregorianCalendar fullDate = dateFP(demographics.getDateOfBirth());
    dateOfBirthList.add(fullDate.getYear());
    dateOfBirthList.add(fullDate.getMonth());
    dateOfBirthList.add(fullDate.getDay());

    return dateOfBirthList;
}

From source file:org.oscarehr.integration.mchcv.OnlineHCValidator.java

@Override
public HCValidationResult validate(String healthCardNumber, String versionCode) {
    Requests requests = new Requests();
    HcvRequest request = new HcvRequest();
    request.setHealthNumber(healthCardNumber);
    request.setVersionCode(versionCode);
    requests.getHcvRequest().add(request);
    HcvResults results = null;//from  w w w  .j a v  a  2 s. com
    try {
        results = validation.validate(requests, "en");
    } catch (Faultexception ex) {
        throw new RuntimeException(ex.getMessage());
    }

    List persons = results.getResults();
    Person person = (Person) persons.get(0);

    HCValidationResult result = new HCValidationResult();
    result.setResponseCode(person.getResponseCode());
    result.setResponseDescription(person.getResponseDescription());
    result.setResponseAction(person.getResponseAction());
    result.setFirstName(person.getFirstName());
    result.setLastName(person.getLastName());
    result.setGender(person.getGender());

    String birthDate = null;
    XMLGregorianCalendar xmlBirthDate = person.getDateOfBirth();
    if (xmlBirthDate != null) {
        birthDate = makeDate(xmlBirthDate.getYear(), xmlBirthDate.getMonth(), xmlBirthDate.getDay());
    }
    result.setBirthDate(birthDate);

    String expiryDate = null;
    XMLGregorianCalendar xmlExpiryDate = person.getExpiryDate();
    if (xmlExpiryDate != null) {
        expiryDate = makeDate(xmlExpiryDate.getYear(), xmlExpiryDate.getMonth(), xmlExpiryDate.getDay());
    }
    result.setExpiryDate(expiryDate);
    return result;
}

From source file:org.ow2.aspirerfid.demos.warehouse.management.beg.CaptureReport.java

private void handleReports(ECReports reports) throws IOException, JAXBException {
    log.debug("**********************Handling incomming reports****************************");

    // get the current time and set the eventTime
    XMLGregorianCalendar now = null;
    try {//from  w ww. j  a va 2  s.co m
        DatatypeFactory dataFactory = DatatypeFactory.newInstance();
        now = dataFactory.newXMLGregorianCalendar(new GregorianCalendar());

        log.debug("Event Time:" + now.getHour() + ":" + now.getMinute() + ":" + ":" + now.getSecond() + "\n");

    } catch (DatatypeConfigurationException e) {
        e.printStackTrace();
    }

    List<ECReport> theReports = reports.getReports().getReport();
    // collect all the tags
    List<EPC> epcs = new LinkedList<EPC>();
    if (theReports != null) {
        for (ECReport report : theReports) {
            // log.debug("Report Count: "+report.getGroup().size());
            log.debug("***************Report Name:" + report.getReportName() + "**************");
            if (report.getGroup() != null) {
                for (ECReportGroup group : report.getGroup()) {

                    if (WarehouseManagement.getEntryDateTextField().equals("")) {
                        WarehouseManagement.setEntryDateTextField(
                                now.getDay() + "/" + now.getMonth() + "/" + now.getYear());
                    }
                    if (WarehouseManagement.getEntryHourTextField().equals("")) {
                        WarehouseManagement.setEntryHourTextField(
                                now.getHour() + ":" + now.getMinute() + ":" + now.getSecond());
                    }

                    WarehouseManagement.setZoneIDTextField(zoneID);
                    WarehouseManagement.setWarehouseIDTextField(warehouseID);

                    log.debug("Group Count: " + group.getGroupCount().getCount());
                    log.debug("Group Name: " + group.getGroupName());
                    if (group.getGroupList() != null) {
                        deliveredItem = null;

                        // warehousemen
                        if (group.getGroupName().equals(warehousemenGroupName)) {
                            for (ECReportGroupListMember member : group.getGroupList().getMember()) {
                                if (member.getEpc() != null) {
                                    WarehouseManagement
                                            .setUserIDTextField(member.getTag().getValue().split(":")[4]);
                                }
                            }
                        }

                        // Invoice
                        if (group.getGroupName().equals(invoiceGroupName)) {
                            for (ECReportGroupListMember member : group.getGroupList().getMember()) {
                                if (member.getEpc() != null) {
                                    WarehouseManagement
                                            .setInvoiceIDTextField(member.getTag().getValue().split(":")[4]);
                                    WarehouseManagement.setOfferingDateTextField("22/05/08");
                                    WarehouseManagement.setOfferingHourTextField("10:53:22");
                                }
                            }
                        }
                        //                     // Small Packets
                        //                     if (group.getGroupName().equals("urn:epc:pat:gid-96:145.56.*")) {
                        //                        for (ECReportGroupListMember member : group.getGroupList().getMember()) {
                        //                           if (member.getEpc() != null) {
                        //                              // WarehouseManagement.setInvoiceIDTextField(member.getTag().getValue().split(":")[4]);
                        //                           }
                        //                        }
                        //                     }
                        //                     // Medium Packets
                        //                     if (group.getGroupName().equals("urn:epc:pat:gid-96:145.87.*")) {
                        //                        for (ECReportGroupListMember member : group.getGroupList().getMember()) {
                        //                           if (member.getEpc() != null) {
                        //                              // WarehouseManagement.setInvoiceIDTextField(member.getTag().getValue().split(":")[4]);
                        //                           }
                        //                        }
                        //                     }

                        for (int i = 0; i < nOFmerchandise; i++) {

                            if (group.getGroupName().equals(packetsGroupName[i])) {
                                BigInteger quantity = new BigInteger(packetsQuantity[i]);
                                BigInteger expectedQuantity = new BigInteger(packetsExpectedQuantity[i]);
                                BigInteger quantityDelivered = new BigInteger(
                                        (group.getGroupCount().getCount()) + "");
                                BigInteger quantityRemain = quantity.add(quantityDelivered.negate());

                                for (ECReportGroupListMember member : group.getGroupList().getMember()) {
                                    if (member.getEpc() != null) {
                                        deliveredItem = new DeliveredItem();
                                        deliveredItem.setCompany(packetsCompany[i]);
                                        deliveredItem.setDeliveryDate(
                                                now.getDay() + "/" + now.getMonth() + "/" + now.getYear());
                                        deliveredItem.setDescription(packetsDescription[i]);
                                        deliveredItem.setExpectedQuantity(expectedQuantity);
                                        deliveredItem.setMeasurementID(packetsMeasurementID[i]);
                                        deliveredItem.setQuantity(quantity);
                                        deliveredItem.setQuantityDelivered(quantityDelivered);
                                        deliveredItem.setQuantityRemain(quantityRemain);
                                        deliveredItem.setItemCode(member.getTag().getValue().split(":")[4]);
                                        WarehouseManagement.updateDeliveryTableModel(deliveredItem);
                                        deliveredItem = null;
                                    }
                                }
                            }
                        }

                        // Print All
                        for (ECReportGroupListMember member : group.getGroupList().getMember()) {
                            if (member.getEpc() != null) {
                                log.debug("***Recieved Group Values***");
                                log.debug("RawDecimal Value: " + member.getRawDecimal().getValue());
                                {
                                    if (!(member.getEpc() == null))
                                        epcs.add(member.getEpc());
                                    log.debug("Epc Value: " + member.getEpc().getValue());
                                    if ((member.getEpc() == null))
                                        log.debug("Epc Value: null");
                                }
                                log.debug("RawHex Value: " + member.getRawHex().getValue());
                                log.debug("Tag Value: " + member.getTag().getValue());
                                // log.debug("Group
                                // Value:"+member.getExtension().getFieldList().toString());

                            }
                        }

                    }
                }
            }
        }
    }
    if (epcs.size() == 0) {
        log.debug("no epc received - generating no event");
        return;
    }
}

From source file:org.researchgraph.crosswalk.CrosswalkRG.java

private boolean processGrant(final Grant grant, final Graph graph, boolean deleted) {
    ++existingRecords;/*from ww w . j  a  v a 2  s .  c om*/

    if (verbose)
        System.out.println("Processing Grant");

    String key = grant.getKey();
    if (StringUtils.isEmpty(key)) {
        return false;
    }

    if (verbose)
        System.out.println("Key: " + key);

    String source = grant.getSource();
    if (StringUtils.isEmpty(source))
        source = this.source;

    GraphNode node = GraphNode.builder().withKey(new GraphKey(source, key)).withNodeSource(source)
            .withNodeType(GraphUtils.TYPE_GRANT).withLabel(this.source).withLabel(GraphUtils.TYPE_GRANT)
            .build();

    if (deleted) {
        node.setDeleted(true);
        graph.addNode(node);

        ++deletedRecords;

        return true;
    }

    String localId = grant.getLocalId();
    if (!StringUtils.isEmpty(localId))
        node.setProperty(GraphUtils.PROPERTY_LOCAL_ID, localId);

    XMLGregorianCalendar lastUpdated = grant.getLastUpdated();
    if (null != lastUpdated) {
        String lastUpdatedString = formatter.format(lastUpdated.toGregorianCalendar().getTime());
        if (!StringUtils.isEmpty(lastUpdatedString))
            node.setProperty(GraphUtils.PROPERTY_LAST_UPDATED, lastUpdatedString);
    }

    String url = GraphUtils.extractFormalizedUrl(grant.getUrl());
    if (!StringUtils.isEmpty(url))
        node.setProperty(GraphUtils.PROPERTY_URL, url);

    String title = grant.getTitle();
    if (!StringUtils.isEmpty(title))
        node.setProperty(GraphUtils.PROPERTY_TITLE, title);

    String purl = GraphUtils.extractFormalizedUrl(grant.getPurl());
    if (!StringUtils.isEmpty(purl))
        node.setProperty(GraphUtils.PROPERTY_PURL, purl);

    String participantList = grant.getParticipantList();
    if (!StringUtils.isEmpty(participantList)) {
        String[] participants = participantList.trim().split("\\s*,\\s*");
        if (participants.length > 0)
            node.setProperty(GraphUtils.PROPERTY_PARTICIPANTS, participants);
    }

    String funder = GraphUtils.extractFormalizedUrl(grant.getFunder());
    if (!StringUtils.isEmpty(funder))
        node.setProperty(GraphUtils.PROPERTY_FUNDER, funder);

    XMLGregorianCalendar startYear = grant.getStartYear();
    if (null != startYear && startYear.getYear() > 0)
        node.setProperty(GraphUtils.PROPERTY_START_YEAR, startYear.getYear());

    XMLGregorianCalendar endYear = grant.getEndYear();
    if (null != endYear && endYear.getYear() > 0)
        node.setProperty(GraphUtils.PROPERTY_END_YEAR, endYear.getYear());

    graph.addNode(node);

    return true;
}

From source file:org.researchgraph.crosswalk.CrosswalkRG.java

private boolean processDataset(final Dataset dataset, final Graph graph, boolean deleted) {
    ++existingRecords;/*  w w  w.  ja  va  2  s .  c  om*/

    if (verbose)
        System.out.println("Processing Dataset");

    String key = dataset.getKey();
    if (StringUtils.isEmpty(key)) {
        return false;
    }

    if (verbose)
        System.out.println("Key: " + key);

    String source = dataset.getSource();
    if (StringUtils.isEmpty(source))
        source = this.source;

    GraphNode node = GraphNode.builder().withKey(new GraphKey(source, key)).withNodeSource(source)
            .withNodeType(GraphUtils.TYPE_DATASET).withLabel(this.source).withLabel(GraphUtils.TYPE_DATASET)
            .build();

    if (deleted) {
        node.setDeleted(true);
        graph.addNode(node);

        ++deletedRecords;

        return true;
    }

    String localId = dataset.getLocalId();
    if (!StringUtils.isEmpty(localId))
        node.setProperty(GraphUtils.PROPERTY_LOCAL_ID, localId);

    XMLGregorianCalendar lastUpdated = dataset.getLastUpdated();
    if (null != lastUpdated) {
        String lastUpdatedString = formatter.format(lastUpdated.toGregorianCalendar().getTime());
        if (!StringUtils.isEmpty(lastUpdatedString))
            node.setProperty(GraphUtils.PROPERTY_LAST_UPDATED, lastUpdatedString);
    }

    String url = GraphUtils.extractFormalizedUrl(dataset.getUrl());
    if (!StringUtils.isEmpty(url))
        node.setProperty(GraphUtils.PROPERTY_URL, url);

    String title = dataset.getTitle();
    if (!StringUtils.isEmpty(title))
        node.setProperty(GraphUtils.PROPERTY_TITLE, title);

    String doi = GraphUtils.extractDoi(dataset.getDoi());
    if (!StringUtils.isEmpty(doi))
        node.setProperty(GraphUtils.PROPERTY_DOI, doi);

    XMLGregorianCalendar publicationYear = dataset.getPublicationYear();
    if (null != publicationYear && publicationYear.getYear() > 0)
        node.setProperty(GraphUtils.PROPERTY_PUBLICATION_YEAR, publicationYear.getYear());

    String license = GraphUtils.extractFormalizedUrl(dataset.getLicense());
    if (!StringUtils.isEmpty(license))
        node.setProperty(GraphUtils.PROPERTY_LICENSE, license);

    BigDecimal megabyte = dataset.getMegabyte();
    if (null != megabyte)
        node.setProperty(GraphUtils.PROPERTY_MEGABYTE, megabyte.toString());

    graph.addNode(node);

    return true;
}

From source file:org.researchgraph.crosswalk.CrosswalkRG.java

private boolean processPublication(final Publication publication, final Graph graph, boolean deleted) {
    ++existingRecords;// w w  w  .ja v a  2  s .c  o m

    if (verbose)
        System.out.println("Processing Publication");

    String key = publication.getKey();
    if (StringUtils.isEmpty(key)) {
        return false;
    }

    if (verbose)
        System.out.println("Key: " + key);

    String source = publication.getSource();
    if (StringUtils.isEmpty(source))
        source = this.source;

    GraphNode node = GraphNode.builder().withKey(new GraphKey(source, key)).withNodeSource(source)
            .withNodeType(GraphUtils.TYPE_PUBLICATION).withLabel(this.source)
            .withLabel(GraphUtils.TYPE_PUBLICATION).build();

    if (deleted) {
        node.setDeleted(true);
        graph.addNode(node);

        ++deletedRecords;

        return true;
    }

    String localId = publication.getLocalId();
    if (!StringUtils.isEmpty(localId))
        node.setProperty(GraphUtils.PROPERTY_LOCAL_ID, localId);

    XMLGregorianCalendar lastUpdated = publication.getLastUpdated();
    if (null != lastUpdated) {
        String lastUpdatedString = formatter.format(lastUpdated.toGregorianCalendar().getTime());
        if (!StringUtils.isEmpty(lastUpdatedString))
            node.setProperty(GraphUtils.PROPERTY_LAST_UPDATED, lastUpdatedString);
    }

    String url = GraphUtils.extractFormalizedUrl(publication.getUrl());
    if (!StringUtils.isEmpty(url))
        node.setProperty(GraphUtils.PROPERTY_URL, url);

    String title = publication.getTitle();
    if (!StringUtils.isEmpty(title))
        node.setProperty(GraphUtils.PROPERTY_TITLE, title);

    String authorsList = publication.getAuthorsList();
    if (!StringUtils.isEmpty(authorsList))
        node.setProperty(GraphUtils.PROPERTY_AUTHORS, authorsList);

    String doi = GraphUtils.extractDoi(publication.getDoi());
    if (!StringUtils.isEmpty(doi))
        node.setProperty(GraphUtils.PROPERTY_DOI, doi);

    XMLGregorianCalendar publicationYear = publication.getPublicationYear();
    if (null != publicationYear && publicationYear.getYear() > 0)
        node.setProperty(GraphUtils.PROPERTY_PUBLICATION_YEAR, publicationYear.getYear());

    String scopusEid = GraphUtils.extractScopusEID(publication.getScopusEid());
    if (!StringUtils.isEmpty(scopusEid))
        node.setProperty(GraphUtils.PROPERTY_SCOPUS_EID, scopusEid);

    graph.addNode(node);

    return true;
}

From source file:oscar.oscarLab.ca.all.parsers.HRMXMLHandler.java

private String getFormattedDate(XMLGregorianCalendar date, boolean omitTime) {
    if (date == null) {
        return "";
    }/* w ww  .j  a  v a 2  s  . c o m*/
    return date.getYear() + "-" + date.getMonth() + "-" + date.getDay()
            + (!omitTime ? date.getHour() + ":" + date.getMinute() : "");
}

From source file:se.skl.skltpservices.npoadapter.mapper.util.EHRUtil.java

/**
 * Returns a {@link Date} date and time representation.
 *
 * @param cal//w w  w . j av a2  s .c o m
 *            the actual date and time.
 * @return the {@link Date} representation.
 */
public static Date toDate(XMLGregorianCalendar cal) {
    if (cal != null) {
        final Calendar c = Calendar.getInstance();

        c.set(Calendar.DATE, cal.getDay());
        c.set(Calendar.MONTH, cal.getMonth() - 1);
        c.set(Calendar.YEAR, cal.getYear());
        c.set(Calendar.DAY_OF_MONTH, cal.getDay());
        c.set(Calendar.HOUR_OF_DAY, cal.getHour());
        c.set(Calendar.MINUTE, cal.getMinute());
        c.set(Calendar.SECOND, cal.getSecond());
        c.set(Calendar.MILLISECOND, cal.getMillisecond());

        return c.getTime();
    }
    return null;
}