Ordering Json Properties
This commit is contained in:
parent
ad6018d5fb
commit
a79ed8fd56
|
@ -4,6 +4,7 @@
|
|||
package org.gcube.informationsystem.base.impl;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
|
@ -21,6 +22,18 @@ public class ElementImpl implements Element {
|
|||
*/
|
||||
private static final long serialVersionUID = 7338083489551084860L;
|
||||
|
||||
private List<String> supertypes;
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TypeUtility.getTypeName(this.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupertypes() {
|
||||
return this.supertypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
|
@ -32,9 +45,4 @@ public class ElementImpl implements Element {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TypeUtility.getTypeName(this.getClass());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,8 +4,13 @@
|
|||
package org.gcube.informationsystem.base.reference;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import org.gcube.informationsystem.types.annotations.Abstract;
|
||||
import org.gcube.informationsystem.types.reference.Change;
|
||||
|
@ -16,6 +21,7 @@ import org.gcube.informationsystem.utils.Version;
|
|||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@Abstract
|
||||
@JsonPropertyOrder({ Element.TYPE_PROPERTY, Element.SUPERTYPES_PROPERTY })
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = Element.TYPE_PROPERTY)
|
||||
// @JsonTypeIdResolver(ElementTypeIdResolver.class)
|
||||
@TypeMetadata(name = Element.NAME, description = "This is the base type for Element", version = Version.MINIMAL_VERSION_STRING)
|
||||
|
@ -36,4 +42,8 @@ public interface Element extends Serializable {
|
|||
@JsonIgnore
|
||||
public String getTypeName();
|
||||
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonGetter(value = SUPERTYPES_PROPERTY)
|
||||
public List<String> getSupertypes();
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.gcube.informationsystem.base.reference.entities;
|
|||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
|
@ -17,6 +18,7 @@ import org.gcube.informationsystem.utils.Version;
|
|||
*/
|
||||
@Abstract
|
||||
@JsonIgnoreProperties(ignoreUnknown=true)
|
||||
@JsonPropertyOrder({ Element.TYPE_PROPERTY, Element.SUPERTYPES_PROPERTY, IdentifiableElement.UUID_PROPERTY, IdentifiableElement.METADATA_PROPERTY })
|
||||
//@JsonDeserialize(as=EntityElementImpl.class) Do not uncomment to manage subclasses
|
||||
@TypeMetadata(name = EntityElement.NAME, description = "This is the base type for any EntityElement", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
|
|
|
@ -19,6 +19,10 @@ public final class PropagationConstraintImpl extends PropertyImpl implements Pro
|
|||
*/
|
||||
private static final long serialVersionUID = -4708881022038107688L;
|
||||
|
||||
@JsonFormat(shape=JsonFormat.Shape.STRING)
|
||||
@JsonProperty(value=ADD_PROPERTY)
|
||||
protected AddConstraint addConstraint;
|
||||
|
||||
@JsonFormat(shape=JsonFormat.Shape.STRING)
|
||||
@JsonProperty(value=DELETE_PROPERTY)
|
||||
protected DeleteConstraint deleteConstraint;
|
||||
|
@ -27,14 +31,20 @@ public final class PropagationConstraintImpl extends PropertyImpl implements Pro
|
|||
@JsonProperty(value=REMOVE_PROPERTY)
|
||||
protected RemoveConstraint removeConstraint;
|
||||
|
||||
@JsonFormat(shape=JsonFormat.Shape.STRING)
|
||||
@JsonProperty(value=ADD_PROPERTY)
|
||||
protected AddConstraint addConstraint;
|
||||
|
||||
public PropagationConstraintImpl(){
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddConstraint getAddConstraint() {
|
||||
return this.addConstraint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAddConstraint(AddConstraint addConstraint) {
|
||||
this.addConstraint = addConstraint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeleteConstraint getDeleteConstraint() {
|
||||
return this.deleteConstraint;
|
||||
|
@ -55,14 +65,4 @@ public final class PropagationConstraintImpl extends PropertyImpl implements Pro
|
|||
this.removeConstraint = removeConstraint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddConstraint getAddConstraint() {
|
||||
return this.addConstraint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAddConstraint(AddConstraint addConstraint) {
|
||||
this.addConstraint = addConstraint;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
*/
|
||||
package org.gcube.informationsystem.model.reference.entities;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||
import org.gcube.informationsystem.model.reference.ERElement;
|
||||
import org.gcube.informationsystem.types.annotations.Abstract;
|
||||
|
@ -16,6 +19,7 @@ import org.gcube.informationsystem.utils.Version;
|
|||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@Abstract
|
||||
@JsonPropertyOrder({ Element.TYPE_PROPERTY, Element.SUPERTYPES_PROPERTY, IdentifiableElement.UUID_PROPERTY, IdentifiableElement.METADATA_PROPERTY })
|
||||
//@JsonDeserialize(as=EntityImpl.class) Do not uncomment to manage subclasses
|
||||
@TypeMetadata(name = Entity.NAME, description = "This is the base type for any Entity", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
|
|
|
@ -4,7 +4,10 @@ import java.util.Map;
|
|||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonAnyGetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.base.reference.SchemaMixedElement;
|
||||
import org.gcube.informationsystem.serialization.AdditionalPropertiesSerializer;
|
||||
import org.gcube.informationsystem.types.annotations.Abstract;
|
||||
|
@ -18,6 +21,8 @@ import org.gcube.informationsystem.utils.Version;
|
|||
* https://wiki.gcube-system.org/gcube/Facet_Based_Resource_Model#Facet
|
||||
*/
|
||||
@Abstract
|
||||
@JsonPropertyOrder({ Element.TYPE_PROPERTY, Element.SUPERTYPES_PROPERTY, IdentifiableElement.UUID_PROPERTY, IdentifiableElement.METADATA_PROPERTY })
|
||||
|
||||
// @JsonDeserialize(as=FacetImpl.class) Do not uncomment to manage subclasses
|
||||
@TypeMetadata(name = "Facet", description = "This is the base type for any Facet", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
|
|
|
@ -8,6 +8,9 @@ import java.util.UUID;
|
|||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
|
||||
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
||||
import org.gcube.informationsystem.types.annotations.Abstract;
|
||||
|
@ -25,6 +28,7 @@ import org.gcube.informationsystem.utils.Version;
|
|||
*/
|
||||
@Abstract
|
||||
@JsonIgnoreProperties(ignoreUnknown=true)
|
||||
@JsonPropertyOrder({ Element.TYPE_PROPERTY, Element.SUPERTYPES_PROPERTY, IdentifiableElement.UUID_PROPERTY, IdentifiableElement.METADATA_PROPERTY, Resource.CONSISTS_OF_PROPERTY, Resource.IS_RELATED_TO_PROPERTY })
|
||||
// @JsonDeserialize(as=ResourceImpl.class) Do not uncomment to manage subclasses
|
||||
@ResourceSchema(
|
||||
facets={
|
||||
|
|
|
@ -107,6 +107,12 @@ public interface PropagationConstraint extends Property {
|
|||
unpropagate
|
||||
|
||||
}
|
||||
|
||||
@ISProperty(name=ADD_PROPERTY, description = "It indicates the behaviour to implement for the target Entity when an 'add' action is performed on the source Resource. Add action is the operation of adding an instance to a context.", mandatory = true, nullable = false)
|
||||
public AddConstraint getAddConstraint();
|
||||
|
||||
public void setAddConstraint(AddConstraint addConstraint);
|
||||
|
||||
|
||||
@ISProperty(name=DELETE_PROPERTY, description = "It indicates the behaviour to implement for the target Entity when a 'delete' action is performed on the source Resource. Delet action is the operation of deleting an instance (it has an impact on all contexts).", mandatory = true, nullable = false)
|
||||
public DeleteConstraint getDeleteConstraint();
|
||||
|
@ -119,10 +125,4 @@ public interface PropagationConstraint extends Property {
|
|||
|
||||
public void setRemoveConstraint(RemoveConstraint removeConstraint);
|
||||
|
||||
|
||||
@ISProperty(name=ADD_PROPERTY, description = "It indicates the behaviour to implement for the target Entity when an 'add' action is performed on the source Resource. Add action is the operation of adding an instance to a context.", mandatory = true, nullable = false)
|
||||
public AddConstraint getAddConstraint();
|
||||
|
||||
public void setAddConstraint(AddConstraint addConstraint);
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,12 @@ import org.gcube.com.fasterxml.jackson.annotation.JsonAnySetter;
|
|||
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.base.reference.SchemaMixedElement;
|
||||
import org.gcube.informationsystem.base.reference.relations.RelationElement;
|
||||
import org.gcube.informationsystem.model.reference.ERElement;
|
||||
|
@ -30,6 +35,7 @@ import org.gcube.informationsystem.utils.Version;
|
|||
* https://wiki.gcube-system.org/gcube/Facet_Based_Resource_Model#Relation
|
||||
*/
|
||||
@Abstract
|
||||
@JsonPropertyOrder({ Element.TYPE_PROPERTY, Element.SUPERTYPES_PROPERTY, IdentifiableElement.UUID_PROPERTY, IdentifiableElement.METADATA_PROPERTY, Relation.PROPAGATION_CONSTRAINT_PROPERTY })
|
||||
// @JsonDeserialize(as=RelationImpl.class) Do not uncomment to manage subclasses
|
||||
@TypeMetadata(name = Relation.NAME, description = "This is the base type for any Relation", version = Version.MINIMAL_VERSION_STRING)
|
||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||
|
@ -39,6 +45,7 @@ public interface Relation<S extends Resource, T extends Entity> extends Relation
|
|||
|
||||
public static final String PROPAGATION_CONSTRAINT_PROPERTY = "propagationConstraint";
|
||||
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties({Resource.CONSISTS_OF_PROPERTY, Resource.IS_RELATED_TO_PROPERTY})
|
||||
@JsonGetter(value = SOURCE_PROPERTY)
|
||||
@Override
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.lang.reflect.ParameterizedType;
|
|||
import java.lang.reflect.TypeVariable;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
@ -61,7 +62,8 @@ public class TypeImpl implements Type {
|
|||
|
||||
protected UUID uuid;
|
||||
protected Metadata metadata;
|
||||
|
||||
private List<String> supertypes;
|
||||
|
||||
protected String name;
|
||||
protected String description;
|
||||
protected Version version;
|
||||
|
@ -295,4 +297,8 @@ public class TypeImpl implements Type {
|
|||
return TypeUtility.getTypeName(this.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupertypes() {
|
||||
return this.supertypes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.gcube.informationsystem.types.impl.properties;
|
|||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -35,6 +36,8 @@ public final class PropertyDefinitionImpl implements PropertyDefinition {
|
|||
public final static String URI_REGEX = null;
|
||||
public final static String URL_REGEX = null;
|
||||
|
||||
private List<String> supertypes;
|
||||
|
||||
private String name= "";
|
||||
private String description= "";
|
||||
private boolean mandatory = false;
|
||||
|
@ -287,4 +290,8 @@ public final class PropertyDefinitionImpl implements PropertyDefinition {
|
|||
return TypeUtility.getTypeName(this.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupertypes() {
|
||||
return this.supertypes;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue