Example usage for org.jdom2 Element Element

List of usage examples for org.jdom2 Element Element

Introduction

In this page you can find the example usage for org.jdom2 Element Element.

Prototype

public Element(final String name, final String uri) 

Source Link

Document

Creates a new element with the supplied (local) name and a namespace given by a URI.

Usage

From source file:ca.nrc.cadc.uws.JobListWriter.java

License:Open Source License

/**
 * Get an Element representing the Job phase.
 *
 * @return The Job phase Element./*from  w w w  . j  av a2 s  . c  o m*/
 */
private Element getPhase(JobRef jobRef) {
    Element element = new Element(JobAttribute.EXECUTION_PHASE.getAttributeName(), UWS.NS);
    element.addContent(jobRef.getExecutionPhase().toString());
    return element;
}

From source file:ca.nrc.cadc.uws.JobListWriter.java

License:Open Source License

/**
 * Get an Element representing the runID.
 *
 * @return The runID element.//w ww. j av a 2s .c o m
 */
private Element getRunID(JobRef jobRef) {
    Element element = new Element(JobAttribute.RUN_ID.getAttributeName(), UWS.NS);
    String runID = jobRef.getRunID();
    if (runID == null)
        element.setAttribute("nil", "true", UWS.XSI_NS);
    else
        element.addContent(runID);
    return element;
}

From source file:ca.nrc.cadc.uws.JobListWriter.java

License:Open Source License

/**
 * Get an Element representing the creation time.
 *
 * @return The creation time element./* w  w w  . ja v a  2s .co  m*/
 */
private Element getCreationTime(JobRef jobRef) {
    Element element = new Element(JobAttribute.CREATION_TIME.getAttributeName(), UWS.NS);
    Date creationTime = jobRef.getCreationTime();
    if (creationTime == null)
        element.setAttribute("nil", "true", UWS.XSI_NS);
    else
        element.addContent(dateFormat.format(jobRef.getCreationTime()));
    return element;
}

From source file:ca.nrc.cadc.uws.JobListWriter.java

License:Open Source License

/**
 * Get an Element representing the owner ID.
 *
 * @return The owner ID Element./*w ww  . j  a va2s.c o m*/
 */
private Element getOwnerID(JobRef jobRef) {
    Element element = new Element(JobAttribute.OWNER_ID.getAttributeName(), UWS.NS);
    element.addContent(jobRef.getOwnerID());
    return element;
}

From source file:ca.nrc.cadc.uws.JobWriter.java

License:Open Source License

/**
 * Get an Element representing a job Element.
 *
 * @return A job Element./*  w  w  w  .  j av a  2  s  . c  o  m*/
 */
public static Element getJob() {
    Element element = new Element(JobAttribute.JOB.getAttributeName(), UWS.NS);
    element.addNamespaceDeclaration(UWS.NS);
    element.addNamespaceDeclaration(UWS.XLINK_NS);
    //element.setAttribute("schemaLocation", "http://www.ivoa.net/xml/UWS/v1.0 UWS.xsd", UWS.XSI_NS);
    return element;
}

From source file:ca.nrc.cadc.uws.JobWriter.java

License:Open Source License

/**
 * Create the root element of a job document.
 * @param job//from  w w  w . j a  va2 s .  c om
 * @return
 */
public Element getRootElement(Job job) {
    Element root = new Element(JobAttribute.JOB.getAttributeName(), UWS.NS);
    root.addNamespaceDeclaration(UWS.NS);
    root.addNamespaceDeclaration(UWS.XLINK_NS);
    root.setAttribute(JobAttribute.VERSION.getAttributeName(), UWS.XSD_VERSION);

    root.addContent(getJobId(job));
    root.addContent(getRunId(job));
    root.addContent(getOwnerId(job));
    root.addContent(getPhase(job));
    root.addContent(getQuote(job));
    root.addContent(getStartTime(job));
    root.addContent(getEndTime(job));
    root.addContent(getCreationTime(job));
    root.addContent(getExecutionDuration(job));
    root.addContent(getDestruction(job));
    root.addContent(getParameters(job));
    root.addContent(getResults(job));
    Element errorSummary = getErrorSummary(job);
    if (errorSummary != null)
        root.addContent(errorSummary);

    Element jobInfo = getJobInfo(job);
    if (jobInfo != null)
        root.addContent(jobInfo);

    return root;
}

From source file:ca.nrc.cadc.uws.JobWriter.java

License:Open Source License

/**
 * Get an Element representing the Job jobId.
 *
 * @return The Job jobId Element./*w w w  .ja v  a 2 s .c  o m*/
 */
public Element getJobId(Job job) {
    Element element = new Element(JobAttribute.JOB_ID.getAttributeName(), UWS.NS);
    element.addContent(job.getID());
    return element;
}

From source file:ca.nrc.cadc.uws.JobWriter.java

License:Open Source License

/**
 * Get an Element representing the Job jobref.
 *
 * @param host The host part of the Job request URL.
 * @return The Job jobref Element.//from  www .j a  v  a2 s . c o  m
 */
public Element getJobRef(String host, Job job) {
    Element element = new Element(JobAttribute.JOB_REF.getAttributeName(), UWS.NS);
    element.setAttribute("id", job.getID());
    element.setAttribute("xlink:href", host + job.getRequestPath() + "/" + job.getID());
    return element;
}

From source file:ca.nrc.cadc.uws.JobWriter.java

License:Open Source License

/**
 * Get an Element representing the Job runId.
 *
 * @return The Job runId Element.//from ww w  .ja  va 2  s.c om
 */
public Element getRunId(Job job) {
    Element element = new Element(JobAttribute.RUN_ID.getAttributeName(), UWS.NS);
    element.addContent(job.getRunID());
    return element;
}

From source file:ca.nrc.cadc.uws.JobWriter.java

License:Open Source License

/**
 * Get an Element representing the Job ownerId.
 *
 * @return The Job ownerId Element./*from w ww  .j  av  a  2  s . c o m*/
 */
public Element getOwnerId(Job job) {
    Element element = new Element(JobAttribute.OWNER_ID.getAttributeName(), UWS.NS);
    if (job.getOwnerID() != null)
        element.addContent(job.getOwnerID());
    else
        element.setAttribute("nil", "true", UWS.XSI_NS);
    return element;
}