Commit af27a456 authored by Sara Bertocco's avatar Sara Bertocco
Browse files

First commit

parents
target/**
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>it.oats.inaf</groupId>
<artifactId>vospace-datamodel</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<!-- JAXB dependency -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
</dependency>
<!-- Jackson-JAXB compatibility -->
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
<version>2.10.3</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package it.inaf.oats.vospace.datamodel;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.DatabindContext;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.jsontype.impl.TypeIdResolverBase;
import net.ivoa.xml.vospace.v2.Node;
/**
* This class is called during JSON serialization and deserialization and it is
* necessary to keep the vos prefix in the type property when performing a
* conversion between XML and JSON and considering also the inheritance of the
* Node class.
*
* The Node class must be annotated in this way:
*
* @JsonTypeInfo(use = JsonTypeInfo.Id.CUSTOM, property = "type", include =
* JsonTypeInfo.As.EXISTING_PROPERTY)
* @JsonTypeIdResolver(NodeTypeJsonResolver.class)
*/
public class NodeTypeJsonResolver extends TypeIdResolverBase {
@Override
public String idFromValueAndType(Object o, Class<?> type) {
return idFromValue(o);
}
@Override
public String idFromValue(Object o) {
Node node = (Node) o;
return node.getType();
}
@Override
public JsonTypeInfo.Id getMechanism() {
return JsonTypeInfo.Id.NAME;
}
@Override
public JavaType typeFromId(DatabindContext context, String id) {
String noPrefixId = id.replace("vos:", "");
return context.getTypeFactory().constructFromCanonical("net.ivoa.xml.vospace.v2." + noPrefixId);
}
}
package it.inaf.oats.vospace.datamodel;
import com.fasterxml.jackson.databind.util.StdConverter;
import net.ivoa.xml.vospace.v2.Node;
/**
* Fills the type field at the end of the JSON deserialization.
* Node implementations must be annotated with
* @JsonDeserialize(converter = NodeTypeAdder.<NodeType>.class)
*/
public class NodeTypeSetter<T extends Node> extends StdConverter<T, T> {
@Override
public T convert(T node) {
node.setType("vos:" + node.getClass().getSimpleName());
return node;
}
public static class UnstructuredDataNode extends NodeTypeSetter<net.ivoa.xml.vospace.v2.UnstructuredDataNode> {
}
public static class StructuredDataNode extends NodeTypeSetter<net.ivoa.xml.vospace.v2.StructuredDataNode> {
}
public static class ContainerNode extends NodeTypeSetter<net.ivoa.xml.vospace.v2.ContainerNode> {
}
public static class LinkNode extends NodeTypeSetter<net.ivoa.xml.vospace.v2.LinkNode> {
}
}
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2020.10.24 at 09:39:16 AM CEST
//
package net.ivoa.xml.uws.v1;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
*
* A short summary of an error - a fuller representation of the
* error may be retrieved from /{jobs}/{job-id}/error
*
*
* <p>Java class for ErrorSummary complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="ErrorSummary">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="message" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;/sequence>
* &lt;attribute name="type" use="required" type="{http://www.ivoa.net/xml/UWS/v1.0}ErrorType" />
* &lt;attribute name="hasDetail" use="required" type="{http://www.w3.org/2001/XMLSchema}boolean" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ErrorSummary", propOrder = {
"message"
})
public class ErrorSummary {
@XmlElement(required = true)
protected String message;
@XmlAttribute(name = "type", required = true)
protected ErrorType type;
@XmlAttribute(name = "hasDetail", required = true)
protected boolean hasDetail;
/**
* Gets the value of the message property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getMessage() {
return message;
}
/**
* Sets the value of the message property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setMessage(String value) {
this.message = value;
}
/**
* Gets the value of the type property.
*
* @return
* possible object is
* {@link ErrorType }
*
*/
public ErrorType getType() {
return type;
}
/**
* Sets the value of the type property.
*
* @param value
* allowed object is
* {@link ErrorType }
*
*/
public void setType(ErrorType value) {
this.type = value;
}
/**
* Gets the value of the hasDetail property.
*
*/
public boolean isHasDetail() {
return hasDetail;
}
/**
* Sets the value of the hasDetail property.
*
*/
public void setHasDetail(boolean value) {
this.hasDetail = value;
}
}
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2020.10.24 at 09:39:16 AM CEST
//
package net.ivoa.xml.uws.v1;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for ErrorType.
*
* <p>The following schema fragment specifies the expected content contained within this class.
* <p>
* <pre>
* &lt;simpleType name="ErrorType">
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
* &lt;enumeration value="transient"/>
* &lt;enumeration value="fatal"/>
* &lt;/restriction>
* &lt;/simpleType>
* </pre>
*
*/
@XmlType(name = "ErrorType")
@XmlEnum
public enum ErrorType {
@XmlEnumValue("transient")
TRANSIENT("transient"),
@XmlEnumValue("fatal")
FATAL("fatal");
private final String value;
ErrorType(String v) {
value = v;
}
public String value() {
return value;
}
public static ErrorType fromValue(String v) {
for (ErrorType c: ErrorType.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
}
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2020.10.24 at 09:39:16 AM CEST
//
package net.ivoa.xml.uws.v1;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for ExecutionPhase.
*
* <p>The following schema fragment specifies the expected content contained within this class.
* <p>
* <pre>
* &lt;simpleType name="ExecutionPhase">
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
* &lt;enumeration value="PENDING"/>
* &lt;enumeration value="QUEUED"/>
* &lt;enumeration value="EXECUTING"/>
* &lt;enumeration value="COMPLETED"/>
* &lt;enumeration value="ERROR"/>
* &lt;enumeration value="UNKNOWN"/>
* &lt;enumeration value="HELD"/>
* &lt;enumeration value="SUSPENDED"/>
* &lt;enumeration value="ABORTED"/>
* &lt;enumeration value="ARCHIVED"/>
* &lt;/restriction>
* &lt;/simpleType>
* </pre>
*
*/
@XmlType(name = "ExecutionPhase")
@XmlEnum
public enum ExecutionPhase {
/**
*
* The first phase a job is entered into - this is where
* a job is being set up but no request to run has
* occurred.
*
*
*/
PENDING,
/**
*
* A job has been accepted for execution but is waiting
* in a queue
*
*
*/
QUEUED,
/**
* A job is running
*
*/
EXECUTING,
/**
*
* A job has completed successfully
*
*
*/
COMPLETED,
/**
*
* Some form of error has occurred
*
*
*/
ERROR,
/**
*
* The job is in an unknown state.
*
*
*/
UNKNOWN,
/**
*
* The job is HELD pending execution and will not
* automatically be executed - can occur after a
* PHASE=RUN request has been made (cf PENDING).
*
*
*/
HELD,
/**
*
* The job has been suspended by the system during
* execution
*
*
*/
SUSPENDED,
/**
*
* The job has been aborted, either by user request or by
* the server because of lack or overuse of resources.
*
*
*/
ABORTED,
/**
*
* The job has been archived by the server at destruction time. An archived job
* may have deleted the results to reclaim resources, but must have job metadata preserved.
* This is an alternative that the server may choose in contrast to completely destroying all record of the job.
*
*
*/
ARCHIVED;
public String value() {
return name();
}
public static ExecutionPhase fromValue(String v) {
return valueOf(v);
}
}
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2020.10.24 at 09:39:16 AM CEST
//
package net.ivoa.xml.uws.v1;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;
import org.w3c.dom.Element;
/**
*
* The complete representation of the state of a job
*
*
* <p>Java class for JobSummary complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="JobSummary">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="jobId" type="{http://www.ivoa.net/xml/UWS/v1.0}JobIdentifier"/>
* &lt;element name="runId" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* &lt;element name="ownerId" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="phase" type="{http://www.ivoa.net/xml/UWS/v1.0}ExecutionPhase"/>
* &lt;element name="quote" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
* &lt;element name="creationTime" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
* &lt;element name="startTime" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
* &lt;element name="endTime" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
* &lt;element name="executionDuration" type="{http://www.w3.org/2001/XMLSchema}int"/>
* &lt;element name="destruction" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
* &lt;element ref="{http://www.ivoa.net/xml/UWS/v1.0}parameters" minOccurs="0"/>
* &lt;element ref="{http://www.ivoa.net/xml/UWS/v1.0}results"/>
* &lt;element name="errorSummary" type="{http://www.ivoa.net/xml/UWS/v1.0}ErrorSummary" minOccurs="0"/>
* &lt;element name="jobInfo" minOccurs="0">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;any processContents='lax' maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* &lt;/sequence>
* &lt;attribute name="version" type="{http://www.ivoa.net/xml/UWS/v1.0}UWSVersion" />
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "JobSummary", propOrder = {
"jobId",
"runId",
"ownerId",
"phase",
"quote",
"creationTime",
"startTime",
"endTime",
"executionDuration",
"destruction",
"parameters",
"results",
"errorSummary",
"jobInfo"
})
public class JobSummary {
@XmlElement(required = true)
protected String jobId;
protected String runId;
@XmlElement(required = true, nillable = true)
protected String ownerId;
@XmlElement(required = true)
@XmlSchemaType(name = "string")
protected ExecutionPhase phase;
@XmlElementRef(name = "quote", namespace = "http://www.ivoa.net/xml/UWS/v1.0", type = JAXBElement.class, required = false)
protected JAXBElement<XMLGregorianCalendar> quote;
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar creationTime;
@XmlElement(required = true, nillable = true)
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar startTime;
@XmlElement(required = true, nillable = true)
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar endTime;
protected int executionDuration;
@XmlElement(required = true, nillable = true)
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar destruction;
protected Parameters parameters;
@XmlElement(required = true)
protected Results results;
protected ErrorSummary errorSummary;
protected JobSummary.JobInfo jobInfo;
@XmlAttribute(name = "version")
protected String version;
/**
* Gets the value of the jobId property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getJobId() {
return jobId;
}
/**
* Sets the value of the jobId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setJobId(String value) {
this.jobId = value;
}
/**
* Gets the value of the runId property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getRunId() {
return runId;
}
/**
* Sets the value of the runId property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setRunId(String value) {
this.runId = value;
}
/**
* Gets the value of the ownerId property.