Redesigning E/R instance definition
This commit is contained in:
parent
85f75fff2a
commit
ec9e319792
|
@ -2,6 +2,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||||
|
|
||||||
# Changelog for Information System Model
|
# Changelog for Information System Model
|
||||||
|
|
||||||
|
## [v7.0.0]
|
||||||
|
|
||||||
|
- [#24992]
|
||||||
|
|
||||||
|
|
||||||
## [v6.0.0]
|
## [v6.0.0]
|
||||||
|
|
||||||
- Modified models discovery to make it easier and more powerful [#24548]
|
- Modified models discovery to make it easier and more powerful [#24548]
|
||||||
|
|
10
pom.xml
10
pom.xml
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.information-system</groupId>
|
<groupId>org.gcube.information-system</groupId>
|
||||||
<artifactId>information-system-model</artifactId>
|
<artifactId>information-system-model</artifactId>
|
||||||
<version>6.0.0</version>
|
<version>7.0.0-SNAPSHOT</version>
|
||||||
<name>Information System Model</name>
|
<name>Information System Model</name>
|
||||||
<description>Information System Model is the reference model of the gCube Information System</description>
|
<description>Information System Model is the reference model of the gCube Information System</description>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.distribution</groupId>
|
<groupId>org.gcube.distribution</groupId>
|
||||||
<artifactId>gcube-bom</artifactId>
|
<artifactId>gcube-bom</artifactId>
|
||||||
<version>2.2.0</version>
|
<version>2.4.0-SNAPSHOT</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -62,6 +62,12 @@
|
||||||
<artifactId>authorization-utils</artifactId>
|
<artifactId>authorization-utils</artifactId>
|
||||||
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
|
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-simple</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package org.gcube.informationsystem.base.impl.entities;
|
package org.gcube.informationsystem.base.impl.entities;
|
||||||
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
import org.gcube.informationsystem.base.impl.ElementImpl;
|
import org.gcube.informationsystem.base.impl.ElementImpl;
|
||||||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,20 +20,31 @@ public abstract class EntityElementImpl extends ElementImpl implements EntityEle
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -4488771434017342703L;
|
private static final long serialVersionUID = -4488771434017342703L;
|
||||||
|
|
||||||
protected Header header;
|
protected UUID uuid;
|
||||||
|
protected Metadata metadata;
|
||||||
|
|
||||||
protected EntityElementImpl(){
|
protected EntityElementImpl(){
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Header getHeader() {
|
public UUID getUUID() {
|
||||||
return header;
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUUID(UUID uuid) {
|
||||||
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeader(Header header){
|
public Metadata getMetadata() {
|
||||||
this.header = header;
|
return metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMetadata(Metadata metadata){
|
||||||
|
this.metadata = metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -43,7 +55,7 @@ public abstract class EntityElementImpl extends ElementImpl implements EntityEle
|
||||||
return stringWriter.toString();
|
return stringWriter.toString();
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
try {
|
try {
|
||||||
ElementMapper.marshal(this.header, stringWriter);
|
ElementMapper.marshal(this.metadata, stringWriter);
|
||||||
return stringWriter.toString();
|
return stringWriter.toString();
|
||||||
} catch(Exception e1){
|
} catch(Exception e1){
|
||||||
return super.toString();
|
return super.toString();
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package org.gcube.informationsystem.base.impl.relations;
|
package org.gcube.informationsystem.base.impl.relations;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
import org.gcube.informationsystem.base.impl.ElementImpl;
|
import org.gcube.informationsystem.base.impl.ElementImpl;
|
||||||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||||
import org.gcube.informationsystem.base.reference.relations.RelationElement;
|
import org.gcube.informationsystem.base.reference.relations.RelationElement;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
|
@ -17,7 +19,8 @@ public abstract class RelationElementImpl<S extends EntityElement, T extends Ent
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 28704968813390512L;
|
private static final long serialVersionUID = 28704968813390512L;
|
||||||
|
|
||||||
protected Header header;
|
protected UUID uuid;
|
||||||
|
protected Metadata metadata;
|
||||||
|
|
||||||
protected S source;
|
protected S source;
|
||||||
protected T target;
|
protected T target;
|
||||||
|
@ -25,21 +28,31 @@ public abstract class RelationElementImpl<S extends EntityElement, T extends Ent
|
||||||
protected RelationElementImpl() {
|
protected RelationElementImpl() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RelationElementImpl(S source, T target) {
|
protected RelationElementImpl(S source, T target) {
|
||||||
this();
|
this();
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUUID() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Header getHeader() {
|
public void setUUID(UUID uuid) {
|
||||||
return header;
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeader(Header header){
|
public Metadata getMetadata() {
|
||||||
this.header = header;
|
return metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMetadata(Metadata metadata){
|
||||||
|
this.metadata = metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,17 +1,24 @@
|
||||||
package org.gcube.informationsystem.base.reference;
|
package org.gcube.informationsystem.base.reference;
|
||||||
|
|
||||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interfaces is an helper to identify elements could be identified via {@link Header}
|
* This interfaces is an helper to identify elements could be identified via {@link Metadata}
|
||||||
*
|
*
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
public interface IdentifiableElement extends Element {
|
public interface IdentifiableElement extends Element {
|
||||||
|
|
||||||
public static final String HEADER_PROPERTY = "header";
|
public static final String UUID_PROPERTY = "@uuid";
|
||||||
|
public static final String METADATA_PROPERTY = "@metadata";
|
||||||
public Header getHeader();
|
|
||||||
|
|
||||||
public void setHeader(Header header);
|
public UUID getUUID();
|
||||||
|
|
||||||
|
public void setUUID(UUID uuid);
|
||||||
|
|
||||||
|
public Metadata getMetadata();
|
||||||
|
|
||||||
|
public void setMetadata(Metadata metadata);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package org.gcube.informationsystem.base.reference.entities;
|
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.JsonIgnoreProperties;
|
||||||
import org.gcube.informationsystem.base.reference.Element;
|
import org.gcube.informationsystem.base.reference.Element;
|
||||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||||
import org.gcube.informationsystem.types.annotations.Abstract;
|
import org.gcube.informationsystem.types.annotations.Abstract;
|
||||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||||
import org.gcube.informationsystem.types.reference.Change;
|
import org.gcube.informationsystem.types.reference.Change;
|
||||||
|
@ -22,9 +24,18 @@ public interface EntityElement extends Element, IdentifiableElement {
|
||||||
|
|
||||||
public static final String NAME = "EntityElement"; //Entity.class.getSimpleName();
|
public static final String NAME = "EntityElement"; //Entity.class.getSimpleName();
|
||||||
|
|
||||||
/* Overriding getHeader method to create Header property in type */
|
@ISProperty(name=METADATA_PROPERTY, mandatory=true, nullable=false, description="Metadata associated with the instance that is automatically created/updated by the system.")
|
||||||
@ISProperty(name=HEADER_PROPERTY, mandatory=true, nullable=false, description="Metadata associated with the instance that is automatically created/updated by the system.")
|
|
||||||
@Override
|
@Override
|
||||||
public Header getHeader();
|
public Metadata getMetadata();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMetadata(Metadata metadata);
|
||||||
|
|
||||||
|
@ISProperty(name = UUID_PROPERTY, description = "This UUID is be used to identify the instance univocally.", readonly = true, mandatory = true, nullable = false)
|
||||||
|
@Override
|
||||||
|
public UUID getUUID();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUUID(UUID uuid);
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,11 +1,13 @@
|
||||||
package org.gcube.informationsystem.base.reference.relations;
|
package org.gcube.informationsystem.base.reference.relations;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import org.gcube.informationsystem.base.reference.Element;
|
import org.gcube.informationsystem.base.reference.Element;
|
||||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||||
import org.gcube.informationsystem.types.annotations.Abstract;
|
import org.gcube.informationsystem.types.annotations.Abstract;
|
||||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||||
import org.gcube.informationsystem.types.reference.Change;
|
import org.gcube.informationsystem.types.reference.Change;
|
||||||
|
@ -23,13 +25,22 @@ public interface RelationElement<S extends EntityElement, T extends EntityElemen
|
||||||
|
|
||||||
public static final String NAME = "RelationElement"; // RelationElement.class.getSimpleName();
|
public static final String NAME = "RelationElement"; // RelationElement.class.getSimpleName();
|
||||||
|
|
||||||
public static final String SOURCE_PROPERTY = "source";
|
public static final String SOURCE_PROPERTY = "@source";
|
||||||
public static final String TARGET_PROPERTY = "target";
|
public static final String TARGET_PROPERTY = "@target";
|
||||||
|
|
||||||
/* Overriding getHeader method to create Header property in type */
|
@ISProperty(name=METADATA_PROPERTY, mandatory=true, nullable=false, description="Metadata associated with the instance that is automatically created/updated by the system.")
|
||||||
@ISProperty(name = HEADER_PROPERTY, mandatory = true, nullable = false)
|
|
||||||
@Override
|
@Override
|
||||||
public Header getHeader();
|
public Metadata getMetadata();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMetadata(Metadata metadata);
|
||||||
|
|
||||||
|
@ISProperty(name = UUID_PROPERTY, description = "This UUID is be used to identify the instance univocally.", readonly = true, mandatory = true, nullable = false)
|
||||||
|
@Override
|
||||||
|
public UUID getUUID();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUUID(UUID uuid);
|
||||||
|
|
||||||
@JsonGetter(value=SOURCE_PROPERTY)
|
@JsonGetter(value=SOURCE_PROPERTY)
|
||||||
public S getSource();
|
public S getSource();
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.gcube.informationsystem.base.impl.entities.EntityElementImpl;
|
||||||
import org.gcube.informationsystem.contexts.impl.relations.IsParentOfImpl;
|
import org.gcube.informationsystem.contexts.impl.relations.IsParentOfImpl;
|
||||||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||||
import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
|
import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
|
||||||
import org.gcube.informationsystem.model.impl.properties.HeaderImpl;
|
import org.gcube.informationsystem.model.impl.properties.MetadataImpl;
|
||||||
import org.gcube.informationsystem.utils.UUIDManager;
|
import org.gcube.informationsystem.utils.UUIDManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +28,7 @@ public final class ContextImpl extends EntityElementImpl implements Context {
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -5070590328223454087L;
|
private static final long serialVersionUID = -5070590328223454087L;
|
||||||
|
|
||||||
|
protected UUID uuid;
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
protected IsParentOf parent;
|
protected IsParentOf parent;
|
||||||
|
@ -39,6 +40,10 @@ public final class ContextImpl extends EntityElementImpl implements Context {
|
||||||
this.children = new ArrayList<>();
|
this.children = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ContextImpl(UUID uuid) {
|
||||||
|
this(null, uuid);
|
||||||
|
}
|
||||||
|
|
||||||
public ContextImpl(String name) {
|
public ContextImpl(String name) {
|
||||||
this(name, null);
|
this(name, null);
|
||||||
}
|
}
|
||||||
|
@ -47,9 +52,23 @@ public final class ContextImpl extends EntityElementImpl implements Context {
|
||||||
this();
|
this();
|
||||||
this.name = name;
|
this.name = name;
|
||||||
if(uuid == null){
|
if(uuid == null){
|
||||||
uuid = UUIDManager.generateValidRandomUUID();
|
uuid = UUIDManager.getInstance().generateValidRandomUUID();
|
||||||
}
|
}
|
||||||
this.header = new HeaderImpl(uuid);
|
this.uuid = uuid;
|
||||||
|
this.metadata = new MetadataImpl();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the uuid
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public UUID getUUID() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUUID(UUID uuid) {
|
||||||
|
this.uuid = uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -72,8 +91,8 @@ public final class ContextImpl extends EntityElementImpl implements Context {
|
||||||
public void setParent(UUID uuid) {
|
public void setParent(UUID uuid) {
|
||||||
Context parent = null;
|
Context parent = null;
|
||||||
if(uuid!=null) {
|
if(uuid!=null) {
|
||||||
parent = new ContextImpl();
|
parent = new ContextImpl(uuid);
|
||||||
parent.setHeader(new HeaderImpl(uuid));
|
parent.setMetadata(new MetadataImpl());
|
||||||
}
|
}
|
||||||
setParent(parent);
|
setParent(parent);
|
||||||
}
|
}
|
||||||
|
@ -121,8 +140,8 @@ public final class ContextImpl extends EntityElementImpl implements Context {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addChild(UUID uuid) {
|
public void addChild(UUID uuid) {
|
||||||
Context child = new ContextImpl();
|
Context child = new ContextImpl(uuid);
|
||||||
child.setHeader(new HeaderImpl(uuid));
|
child.setMetadata(new MetadataImpl());
|
||||||
addChild(child);
|
addChild(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ package org.gcube.informationsystem.model.impl.entities;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.informationsystem.model.impl.properties.HeaderImpl;
|
import org.gcube.informationsystem.model.impl.properties.MetadataImpl;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||||
import org.gcube.informationsystem.types.reference.Change;
|
import org.gcube.informationsystem.types.reference.Change;
|
||||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||||
|
@ -25,7 +25,8 @@ public class DummyFacet extends FacetImpl implements Facet {
|
||||||
|
|
||||||
public DummyFacet(UUID uuid) {
|
public DummyFacet(UUID uuid) {
|
||||||
super();
|
super();
|
||||||
this.header = new HeaderImpl(uuid);
|
this.uuid = uuid;
|
||||||
|
this.metadata = new MetadataImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DummyFacet(){
|
public DummyFacet(){
|
||||||
|
|
|
@ -5,7 +5,7 @@ package org.gcube.informationsystem.model.impl.entities;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.informationsystem.model.impl.properties.HeaderImpl;
|
import org.gcube.informationsystem.model.impl.properties.MetadataImpl;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||||
import org.gcube.informationsystem.types.reference.Change;
|
import org.gcube.informationsystem.types.reference.Change;
|
||||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||||
|
@ -25,7 +25,8 @@ public class DummyResource extends ResourceImpl implements Resource {
|
||||||
|
|
||||||
public DummyResource(UUID uuid){
|
public DummyResource(UUID uuid){
|
||||||
super();
|
super();
|
||||||
this.header = new HeaderImpl(uuid);
|
this.uuid = uuid;
|
||||||
|
this.metadata = new MetadataImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DummyResource(){
|
public DummyResource(){
|
||||||
|
|
|
@ -20,7 +20,7 @@ public abstract class EntityImpl extends EntityElementImpl implements Entity {
|
||||||
|
|
||||||
protected EntityImpl(){
|
protected EntityImpl(){
|
||||||
super();
|
super();
|
||||||
this.header = null;
|
this.metadata = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,14 +177,12 @@ public abstract class ResourceImpl extends EntityImpl implements Resource {
|
||||||
throw new RuntimeException(message);
|
throw new RuntimeException(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (relation.getSource().getHeader()!= null &&
|
if (relation.getSource().getMetadata()!= null &&
|
||||||
relation.getSource().getHeader().getUUID() != null &&
|
relation.getSource().getUUID() != null &&
|
||||||
this.header !=null &&
|
this.metadata !=null &&
|
||||||
this.header.getUUID() != null &&
|
this.uuid != null &&
|
||||||
relation.getSource().getHeader().getUUID().compareTo(this.header.getUUID())!=0) {
|
relation.getSource().getUUID().compareTo(this.uuid)!=0) {
|
||||||
|
|
||||||
throw new RuntimeException(message);
|
throw new RuntimeException(message);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(relation.getSource()!=this){
|
if(relation.getSource()!=this){
|
||||||
|
|
|
@ -5,13 +5,13 @@ package org.gcube.informationsystem.model.impl.properties;
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Vault;
|
import org.gcube.informationsystem.model.reference.properties.Encrypted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
@JsonTypeName(value = Vault.NAME)
|
@JsonTypeName(value = Encrypted.NAME)
|
||||||
public class VaultImpl extends PropertyImpl implements Vault {
|
public class EncryptedImpl extends PropertyImpl implements Encrypted {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated Serial Version UID
|
* Generated Serial Version UID
|
||||||
|
@ -21,7 +21,7 @@ public class VaultImpl extends PropertyImpl implements Vault {
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
protected String value;
|
protected String value;
|
||||||
|
|
||||||
public VaultImpl() {
|
public EncryptedImpl() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,49 +4,30 @@
|
||||||
package org.gcube.informationsystem.model.impl.properties;
|
package org.gcube.informationsystem.model.impl.properties;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
@JsonTypeName(value=Header.NAME)
|
@JsonTypeName(value=Metadata.NAME)
|
||||||
public final class HeaderImpl extends PropertyImpl implements Header {
|
public final class MetadataImpl extends PropertyImpl implements Metadata {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated Serial Version UID
|
* Generated Serial Version UID
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 5102553511155113169L;
|
private static final long serialVersionUID = 5102553511155113169L;
|
||||||
|
|
||||||
protected UUID uuid;
|
|
||||||
protected String createdBy;
|
protected String createdBy;
|
||||||
protected Date creationTime;
|
protected Date creationTime;
|
||||||
protected String lastUpdateBy;
|
protected String lastUpdateBy;
|
||||||
protected Date lastUpdateTime;
|
protected Date lastUpdateTime;
|
||||||
|
|
||||||
public HeaderImpl() {
|
public MetadataImpl() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public HeaderImpl(UUID uuid) {
|
|
||||||
this.uuid = uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the uuid
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public UUID getUUID() {
|
|
||||||
return uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setUUID(UUID uuid) {
|
|
||||||
this.uuid = uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCreatedBy() {
|
public String getCreatedBy() {
|
||||||
return createdBy;
|
return createdBy;
|
|
@ -3,7 +3,7 @@ package org.gcube.informationsystem.model.reference.properties;
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonSetter;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonSetter;
|
||||||
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
import org.gcube.informationsystem.model.impl.properties.VaultImpl;
|
import org.gcube.informationsystem.model.impl.properties.EncryptedImpl;
|
||||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||||
import org.gcube.informationsystem.types.reference.Change;
|
import org.gcube.informationsystem.types.reference.Change;
|
||||||
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||||
|
@ -12,12 +12,12 @@ import org.gcube.informationsystem.utils.Version;
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
@JsonDeserialize(as=VaultImpl.class)
|
@JsonDeserialize(as=EncryptedImpl.class)
|
||||||
@TypeMetadata(name = Vault.NAME, description = "This type is used to properly manage values must be stored safely (e.g. encrypted) in the IS.", version = Version.MINIMAL_VERSION_STRING)
|
@TypeMetadata(name = Encrypted.NAME, description = "This type is used to properly manage values must be stored safely (e.g. encrypted) in the IS.", version = Version.MINIMAL_VERSION_STRING)
|
||||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||||
public interface Vault extends Property {
|
public interface Encrypted extends Property {
|
||||||
|
|
||||||
public static final String NAME = "Vault"; // Vault.class.getSimpleName();
|
public static final String NAME = "Encrypted"; // Encrypted.class.getSimpleName();
|
||||||
|
|
||||||
public static final String VALUE = "value";
|
public static final String VALUE = "value";
|
||||||
|
|
|
@ -4,12 +4,11 @@
|
||||||
package org.gcube.informationsystem.model.reference.properties;
|
package org.gcube.informationsystem.model.reference.properties;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonFormat;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
import org.gcube.informationsystem.base.reference.Element;
|
import org.gcube.informationsystem.base.reference.Element;
|
||||||
import org.gcube.informationsystem.model.impl.properties.HeaderImpl;
|
import org.gcube.informationsystem.model.impl.properties.MetadataImpl;
|
||||||
import org.gcube.informationsystem.types.annotations.Final;
|
import org.gcube.informationsystem.types.annotations.Final;
|
||||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||||
import org.gcube.informationsystem.types.reference.Change;
|
import org.gcube.informationsystem.types.reference.Change;
|
||||||
|
@ -17,31 +16,28 @@ import org.gcube.informationsystem.types.reference.TypeMetadata;
|
||||||
import org.gcube.informationsystem.utils.Version;
|
import org.gcube.informationsystem.utils.Version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://wiki.gcube-system.org/gcube/Facet_Based_Resource_Model#Header
|
|
||||||
*
|
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
@JsonDeserialize(as=HeaderImpl.class)
|
@JsonDeserialize(as=MetadataImpl.class)
|
||||||
@TypeMetadata(name = Header.NAME, description = "This type provides metadata per every IdentifiableElement", version = Version.MINIMAL_VERSION_STRING)
|
@TypeMetadata(name = Metadata.NAME, description = "This type provides metadata per every IdentifiableElement", version = Version.MINIMAL_VERSION_STRING)
|
||||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||||
@Final
|
@Final
|
||||||
public interface Header extends Property {
|
public interface Metadata extends Property {
|
||||||
|
|
||||||
public static final String NAME = "Header"; // Header.class.getSimpleName();
|
public static final String NAME = "Metadata"; // Metadata.class.getSimpleName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to set Creator when the user is not known
|
* Used to set Creator when the user is not known
|
||||||
*/
|
*/
|
||||||
public static final String UNKNOWN_USER = "UNKNOWN_USER";
|
public static final String UNKNOWN_USER = "UNKNOWN_USER";
|
||||||
|
|
||||||
public static final String UUID_PROPERTY = "uuid";
|
|
||||||
public static final String CREATED_BY_PROPERTY = "createdBy";
|
public static final String CREATED_BY_PROPERTY = "createdBy";
|
||||||
public static final String CREATION_TIME_PROPERTY = "creationTime";
|
public static final String CREATION_TIME_PROPERTY = "creationTime";
|
||||||
public static final String LAST_UPDATE_BY_PROPERTY = "lastUpdateBy";
|
public static final String LAST_UPDATE_BY_PROPERTY = "lastUpdateBy";
|
||||||
public static final String LAST_UPDATE_TIME_PROPERTY = "lastUpdateTime";
|
public static final String LAST_UPDATE_TIME_PROPERTY = "lastUpdateTime";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used when requested to include contexts in header.
|
* Used when requested to include contexts in metadata.
|
||||||
* This is not a native property (it is just generated by server for administration clients convenience)
|
* This is not a native property (it is just generated by server for administration clients convenience)
|
||||||
*/
|
*/
|
||||||
public static final String __CONTEXTS = "contexts";
|
public static final String __CONTEXTS = "contexts";
|
||||||
|
@ -59,10 +55,5 @@ public interface Header extends Property {
|
||||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = Element.DATETIME_PATTERN)
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = Element.DATETIME_PATTERN)
|
||||||
@ISProperty(name = LAST_UPDATE_TIME_PROPERTY, description = "Last Update time. At creation time it assumes the same value of " + CREATION_TIME_PROPERTY + ". It is represented in the format " + Element.DATETIME_PATTERN, mandatory = true, nullable = false)
|
@ISProperty(name = LAST_UPDATE_TIME_PROPERTY, description = "Last Update time. At creation time it assumes the same value of " + CREATION_TIME_PROPERTY + ". It is represented in the format " + Element.DATETIME_PATTERN, mandatory = true, nullable = false)
|
||||||
public Date getLastUpdateTime();
|
public Date getLastUpdateTime();
|
||||||
|
|
||||||
@ISProperty(name = UUID_PROPERTY, description = "This UUID is be used to identify the Entity or the Relation univocally.", readonly = true, mandatory = true, nullable = false)
|
|
||||||
public UUID getUUID();
|
|
||||||
|
|
||||||
public void setUUID(UUID uuid);
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -37,7 +37,7 @@ public interface Relation<S extends Resource, T extends Entity> extends Relation
|
||||||
|
|
||||||
public static final String NAME = "Relation"; //Relation.class.getSimpleName();
|
public static final String NAME = "Relation"; //Relation.class.getSimpleName();
|
||||||
|
|
||||||
public static final String PROPAGATION_CONSTRAINT_PROPERTY = "propagationConstraint";
|
public static final String PROPAGATION_CONSTRAINT_PROPERTY = "@propagationConstraint";
|
||||||
|
|
||||||
@JsonIgnoreProperties({Resource.CONSISTS_OF_PROPERTY, Resource.IS_RELATED_TO_PROPERTY})
|
@JsonIgnoreProperties({Resource.CONSISTS_OF_PROPERTY, Resource.IS_RELATED_TO_PROPERTY})
|
||||||
@JsonGetter(value = SOURCE_PROPERTY)
|
@JsonGetter(value = SOURCE_PROPERTY)
|
||||||
|
|
|
@ -8,6 +8,7 @@ import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
|
||||||
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
@ -20,7 +21,7 @@ import org.gcube.informationsystem.base.reference.Element;
|
||||||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
||||||
import org.gcube.informationsystem.base.reference.relations.RelationElement;
|
import org.gcube.informationsystem.base.reference.relations.RelationElement;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||||
import org.gcube.informationsystem.types.TypeMapper;
|
import org.gcube.informationsystem.types.TypeMapper;
|
||||||
import org.gcube.informationsystem.types.annotations.Abstract;
|
import org.gcube.informationsystem.types.annotations.Abstract;
|
||||||
import org.gcube.informationsystem.types.annotations.Final;
|
import org.gcube.informationsystem.types.annotations.Final;
|
||||||
|
@ -57,8 +58,8 @@ public class TypeImpl implements Type {
|
||||||
DEFAULT_CHANGELOG_MAP_KEY_AS_STRING.put(Version.MINIMAL_VERSION_STRING, Version.MINIMAL_VERSION_DESCRIPTION);
|
DEFAULT_CHANGELOG_MAP_KEY_AS_STRING.put(Version.MINIMAL_VERSION_STRING, Version.MINIMAL_VERSION_DESCRIPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected UUID uuid;
|
||||||
protected Header header;
|
protected Metadata metadata;
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
protected String description;
|
protected String description;
|
||||||
|
@ -186,15 +187,25 @@ public class TypeImpl implements Type {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Header getHeader() {
|
public UUID getUUID() {
|
||||||
return header;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeader(Header header) {
|
public void setUUID(UUID uuid) {
|
||||||
this.header = header;
|
this.uuid = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Metadata getMetadata() {
|
||||||
|
return metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMetadata(Metadata metadata) {
|
||||||
|
this.metadata = metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,7 +11,7 @@ import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||||
import org.gcube.informationsystem.queries.templates.reference.entities.QueryTemplate;
|
import org.gcube.informationsystem.queries.templates.reference.entities.QueryTemplate;
|
||||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||||
import org.gcube.informationsystem.types.impl.TypeImpl;
|
import org.gcube.informationsystem.types.impl.TypeImpl;
|
||||||
|
@ -91,16 +91,16 @@ public class EntityTypeImpl extends TypeImpl implements EntityType {
|
||||||
* We need to copy them.
|
* We need to copy them.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected Header header;
|
protected Metadata metadata;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Header getHeader() {
|
public Metadata getMetadata() {
|
||||||
return header;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHeader(Header header){
|
public void setMetadata(Metadata metadata){
|
||||||
this.header = header;
|
this.metadata = metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -111,7 +111,7 @@ public class EntityTypeImpl extends TypeImpl implements EntityType {
|
||||||
return stringWriter.toString();
|
return stringWriter.toString();
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
try {
|
try {
|
||||||
ElementMapper.marshal(this.header, stringWriter);
|
ElementMapper.marshal(this.metadata, stringWriter);
|
||||||
return stringWriter.toString();
|
return stringWriter.toString();
|
||||||
} catch(Exception e1){
|
} catch(Exception e1){
|
||||||
return super.toString();
|
return super.toString();
|
||||||
|
|
|
@ -83,7 +83,7 @@ public final class PropertyTypeImpl<P extends PropertyElement> extends TypeImpl
|
||||||
return stringWriter.toString();
|
return stringWriter.toString();
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
try {
|
try {
|
||||||
ElementMapper.marshal(this.header, stringWriter);
|
ElementMapper.marshal(this.metadata, stringWriter);
|
||||||
return stringWriter.toString();
|
return stringWriter.toString();
|
||||||
} catch(Exception e1){
|
} catch(Exception e1){
|
||||||
return super.toString();
|
return super.toString();
|
||||||
|
|
|
@ -167,7 +167,7 @@ public class RelationTypeImpl<S extends EntityType, T extends EntityType>
|
||||||
return stringWriter.toString();
|
return stringWriter.toString();
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
try {
|
try {
|
||||||
ElementMapper.marshal(this.header, stringWriter);
|
ElementMapper.marshal(this.metadata, stringWriter);
|
||||||
return stringWriter.toString();
|
return stringWriter.toString();
|
||||||
} catch(Exception e1){
|
} catch(Exception e1){
|
||||||
return super.toString();
|
return super.toString();
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||||
import org.gcube.informationsystem.types.annotations.Final;
|
import org.gcube.informationsystem.types.annotations.Final;
|
||||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||||
import org.gcube.informationsystem.types.impl.properties.PropertyTypeImpl;
|
import org.gcube.informationsystem.types.impl.properties.PropertyTypeImpl;
|
||||||
|
@ -27,10 +27,10 @@ public interface PropertyType<P extends PropertyElement> extends PropertyElement
|
||||||
|
|
||||||
public static final String NAME = "PropertyType"; // PropertyTypeDefinition.class.getSimpleName();
|
public static final String NAME = "PropertyType"; // PropertyTypeDefinition.class.getSimpleName();
|
||||||
|
|
||||||
@ISProperty(name=IdentifiableElement.HEADER_PROPERTY, mandatory=true, nullable=false)
|
@ISProperty(name=IdentifiableElement.METADATA_PROPERTY, mandatory=true, nullable=false)
|
||||||
public Header getHeader();
|
public Metadata getMetadata();
|
||||||
|
|
||||||
public void setHeader(Header header);
|
public void setMetadata(Metadata metadata);
|
||||||
|
|
||||||
/* TypeDefinition is just a Java useful class. The type is not created in the IS. Hence the fields must be redefined */
|
/* TypeDefinition is just a Java useful class. The type is not created in the IS. Hence the fields must be redefined */
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,17 @@ import java.util.UUID;
|
||||||
*/
|
*/
|
||||||
public final class UUIDManager {
|
public final class UUIDManager {
|
||||||
|
|
||||||
public static final Set<String> RESERVED_UUID_STRING;
|
private static final Set<String> RESERVED_UUID_STRING;
|
||||||
public static final Set<UUID> RESERVED_UUID;
|
private static final Set<UUID> RESERVED_UUID;
|
||||||
|
|
||||||
|
private static UUIDManager uuidManager;
|
||||||
|
|
||||||
|
public static UUIDManager getInstance() {
|
||||||
|
if(uuidManager==null) {
|
||||||
|
uuidManager = new UUIDManager();
|
||||||
|
}
|
||||||
|
return uuidManager;
|
||||||
|
}
|
||||||
|
|
||||||
private UUIDManager() {
|
private UUIDManager() {
|
||||||
|
|
||||||
|
@ -31,27 +40,29 @@ public final class UUIDManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isReservedUUID(UUID uuid) {
|
public boolean isReservedUUID(UUID uuid) {
|
||||||
return RESERVED_UUID.contains(uuid);
|
return RESERVED_UUID.contains(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isReservedUUID(String uuid) {
|
public boolean isReservedUUID(String uuid) {
|
||||||
return RESERVED_UUID_STRING.contains(uuid);
|
return RESERVED_UUID_STRING.contains(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<String> getAllReservedUUIDAsStrings(){
|
public Set<String> getAllReservedUUIDAsStrings(){
|
||||||
return new TreeSet<>(RESERVED_UUID_STRING);
|
return new TreeSet<>(RESERVED_UUID_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<UUID> getAllReservedUUID(){
|
public Set<UUID> getAllReservedUUID(){
|
||||||
return new TreeSet<>(RESERVED_UUID);
|
return new TreeSet<>(RESERVED_UUID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UUID generateValidRandomUUID() {
|
public UUID generateValidRandomUUID() {
|
||||||
UUID generated = UUID.randomUUID();
|
UUID generated = UUID.randomUUID();
|
||||||
while(RESERVED_UUID.contains(generated)) {
|
while(RESERVED_UUID.contains(generated)) {
|
||||||
generated = UUID.randomUUID();
|
generated = UUID.randomUUID();
|
||||||
}
|
}
|
||||||
return generated;
|
return generated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,7 @@ import java.util.UUID;
|
||||||
import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
|
import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Entity;
|
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -22,14 +21,13 @@ public class Utility {
|
||||||
private static Logger logger = LoggerFactory.getLogger(Utility.class);
|
private static Logger logger = LoggerFactory.getLogger(Utility.class);
|
||||||
|
|
||||||
public static UUID getUUIDFromJsonNode(JsonNode jsonNode){
|
public static UUID getUUIDFromJsonNode(JsonNode jsonNode){
|
||||||
JsonNode header = jsonNode.get(Entity.HEADER_PROPERTY);
|
UUID uuid = UUID.fromString(jsonNode.get(IdentifiableElement.UUID_PROPERTY).asText());
|
||||||
UUID uuid = UUID.fromString(header.get(Header.UUID_PROPERTY).asText());
|
|
||||||
logger.trace("UUID got from {} is : {} ", jsonNode.toString(), uuid);
|
logger.trace("UUID got from {} is : {} ", jsonNode.toString(), uuid);
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UUID getUUIDFromJSONString(String json) throws JsonProcessingException, IOException {
|
public static UUID getUUIDFromJSONString(String json) throws JsonProcessingException, IOException {
|
||||||
logger.trace("Trying to get UUID from {} of {} ", Header.class.getSimpleName(), json);
|
logger.trace("Trying to get UUID of {} ", json);
|
||||||
JsonNode jsonNode = getJSONNode(json);
|
JsonNode jsonNode = getJSONNode(json);
|
||||||
return getUUIDFromJsonNode(jsonNode);
|
return getUUIDFromJsonNode(jsonNode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.gcube.common.authorization.utils.secret.SecretUtility;
|
||||||
import org.gcube.common.keycloak.KeycloakClientFactory;
|
import org.gcube.common.keycloak.KeycloakClientFactory;
|
||||||
import org.gcube.common.keycloak.model.TokenResponse;
|
import org.gcube.common.keycloak.model.TokenResponse;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -112,7 +112,7 @@ public class ContextTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getUser() {
|
public static String getUser() {
|
||||||
String user = Header.UNKNOWN_USER;
|
String user = Metadata.UNKNOWN_USER;
|
||||||
try {
|
try {
|
||||||
user = SecretManagerProvider.instance.get().getUser().getUsername();
|
user = SecretManagerProvider.instance.get().getUser().getUsername();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
|
|
@ -1,67 +0,0 @@
|
||||||
package org.gcube.informationsystem.model.impl.properties;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.core.JsonParseException;
|
|
||||||
import org.gcube.com.fasterxml.jackson.databind.JsonMappingException;
|
|
||||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
|
||||||
import org.gcube.informationsystem.model.reference.properties.Property;
|
|
||||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
|
||||||
*/
|
|
||||||
public class HeaderTest {
|
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(HeaderTest.class);
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void headerTest() throws Exception {
|
|
||||||
HeaderImpl header = new HeaderImpl(UUID.randomUUID());
|
|
||||||
Date date = Calendar.getInstance().getTime();
|
|
||||||
header.creationTime = date;
|
|
||||||
header.lastUpdateTime = date;
|
|
||||||
header.createdBy = Header.UNKNOWN_USER;
|
|
||||||
|
|
||||||
String json = ElementMapper.marshal(header);
|
|
||||||
logger.debug(json);
|
|
||||||
|
|
||||||
|
|
||||||
Property property = ElementMapper.unmarshal(Property.class, json);
|
|
||||||
Assert.assertTrue(property instanceof Header);
|
|
||||||
Assert.assertTrue(((Header) property).getCreationTime().compareTo(date)==0);
|
|
||||||
Assert.assertTrue(((Header) property).getLastUpdateTime().compareTo(date)==0);
|
|
||||||
logger.debug(ElementMapper.marshal(property));
|
|
||||||
|
|
||||||
Header h = ElementMapper.unmarshal(Header.class, json);
|
|
||||||
Assert.assertTrue(property instanceof Header);
|
|
||||||
Assert.assertTrue(h.getCreationTime().compareTo(date)==0);
|
|
||||||
Assert.assertTrue(h.getLastUpdateTime().compareTo(date)==0);
|
|
||||||
logger.debug(ElementMapper.marshal(h));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testContextsInHeader() throws JsonParseException, JsonMappingException, IOException {
|
|
||||||
|
|
||||||
String headerJson = "{\"@class\":\"Header\",\"uuid\":\"cee84aaf-030c-4170-b554-836e7df3f611\",\"creator\":\"UNKNOWN_USER\",\"modifiedBy\":null,\"creationTime\":\"2020-11-09 10:01:25.415 +0000\",\"lastUpdateTime\":\"2020-11-09 10:01:25.415 +0000\",\"contexts\":[\"167114e0-9027-4e9e-83af-57973a8f8f08\",\"bad5f350-345c-11e9-9f49-cef9b1608c3f\"]}";
|
|
||||||
|
|
||||||
Property property = ElementMapper.unmarshal(Property.class, headerJson);
|
|
||||||
logger.debug("{}", property);
|
|
||||||
|
|
||||||
Header h = ElementMapper.unmarshal(Header.class, headerJson);
|
|
||||||
logger.debug("{}", h);
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
List<String> contexts = (List<String>) h.getAdditionalProperty(Header.__CONTEXTS);
|
|
||||||
logger.debug("Contexts UUIDs are {}", contexts);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
package org.gcube.informationsystem.model.impl.properties;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.gcube.com.fasterxml.jackson.core.JsonParseException;
|
||||||
|
import org.gcube.com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
|
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||||
|
import org.gcube.informationsystem.model.reference.properties.Property;
|
||||||
|
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
|
*/
|
||||||
|
public class MetadataTest {
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(MetadataTest.class);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void metadataTest() throws Exception {
|
||||||
|
MetadataImpl metadata = new MetadataImpl();
|
||||||
|
Date date = Calendar.getInstance().getTime();
|
||||||
|
metadata.creationTime = date;
|
||||||
|
metadata.lastUpdateTime = date;
|
||||||
|
metadata.createdBy = Metadata.UNKNOWN_USER;
|
||||||
|
metadata.lastUpdateBy = Metadata.UNKNOWN_USER;
|
||||||
|
|
||||||
|
String json = ElementMapper.marshal(metadata);
|
||||||
|
logger.debug(json);
|
||||||
|
|
||||||
|
|
||||||
|
Property property = ElementMapper.unmarshal(Property.class, json);
|
||||||
|
Assert.assertTrue(property instanceof Metadata);
|
||||||
|
Assert.assertTrue(((Metadata) property).getCreationTime().compareTo(date)==0);
|
||||||
|
Assert.assertTrue(((Metadata) property).getLastUpdateTime().compareTo(date)==0);
|
||||||
|
logger.debug(ElementMapper.marshal(property));
|
||||||
|
|
||||||
|
Metadata h = ElementMapper.unmarshal(Metadata.class, json);
|
||||||
|
Assert.assertTrue(property instanceof Metadata);
|
||||||
|
Assert.assertTrue(h.getCreationTime().compareTo(date)==0);
|
||||||
|
Assert.assertTrue(h.getLastUpdateTime().compareTo(date)==0);
|
||||||
|
logger.debug(ElementMapper.marshal(h));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testContextsInMetadata() throws JsonParseException, JsonMappingException, IOException {
|
||||||
|
|
||||||
|
String metadataJson =
|
||||||
|
"{"
|
||||||
|
+ "\"@class\":\"Metadata\","
|
||||||
|
+ "\"createdBy\":\"UNKNOWN_USER\","
|
||||||
|
+ "\"lastUpdateBy\":\"UNKNOWN_USER\","
|
||||||
|
+ "\"creationTime\":\"2020-11-09 10:01:25.415 +0000\","
|
||||||
|
+ "\"lastUpdateTime\":\"2020-11-09 10:01:25.415 +0000\","
|
||||||
|
+ "\"contexts\": {"
|
||||||
|
+ "\"bad5f350-345c-11e9-9f49-cef9b1608c3f\": \"/gcube/devNext/NextNext\""
|
||||||
|
+ "}"
|
||||||
|
+ "}";
|
||||||
|
|
||||||
|
Property property = ElementMapper.unmarshal(Property.class, metadataJson);
|
||||||
|
logger.debug("{}", property);
|
||||||
|
|
||||||
|
Metadata h = ElementMapper.unmarshal(Metadata.class, metadataJson);
|
||||||
|
logger.debug("{}", h);
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Map<String,String> contexts = (Map<String, String>) h.getAdditionalProperty(Metadata.__CONTEXTS);
|
||||||
|
logger.debug("Contexts UUIDs are {}", contexts);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package org.gcube.informationsystem.model.impl.properties;
|
package org.gcube.informationsystem.model.impl.properties;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.gcube.informationsystem.base.reference.Element;
|
import org.gcube.informationsystem.base.reference.Element;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||||
|
@ -116,48 +115,38 @@ public class PropagationConstraintTest {
|
||||||
"}";
|
"}";
|
||||||
logger.debug(pcString);
|
logger.debug(pcString);
|
||||||
|
|
||||||
HeaderImpl header = new HeaderImpl();
|
MetadataImpl metadata = new MetadataImpl();
|
||||||
header.setUUID(UUID.randomUUID());
|
metadata.createdBy = "luca.frosini";
|
||||||
header.createdBy = "luca.frosini";
|
metadata.lastUpdateBy = "luca.frosini";
|
||||||
header.lastUpdateBy = "luca.frosini";
|
metadata.creationTime = Calendar.getInstance().getTime();
|
||||||
header.creationTime = Calendar.getInstance().getTime();
|
metadata.lastUpdateTime = Calendar.getInstance().getTime();
|
||||||
header.lastUpdateTime = Calendar.getInstance().getTime();
|
|
||||||
|
|
||||||
String hString = ElementMapper.marshal(header);
|
String hString = ElementMapper.marshal(metadata);
|
||||||
|
|
||||||
|
|
||||||
String consistsOfString = "{" +
|
String consistsOfString = "{" +
|
||||||
"\"" + Element.CLASS_PROPERTY + "\":\"" + ConsistsOf.NAME + "\"," +
|
"\"" + Element.CLASS_PROPERTY + "\":\"" + ConsistsOf.NAME + "\"," +
|
||||||
"\"" + ConsistsOf.PROPAGATION_CONSTRAINT_PROPERTY + "\":"+ pcString + "," +
|
"\"" + ConsistsOf.PROPAGATION_CONSTRAINT_PROPERTY + "\":"+ pcString + "," +
|
||||||
"\"" + ConsistsOf.HEADER_PROPERTY + "\": " + hString + "," +
|
"\"" + ConsistsOf.METADATA_PROPERTY + "\": " + hString + "," +
|
||||||
"\"" + ConsistsOf.SOURCE_PROPERTY + "\":{" +
|
"\"" + ConsistsOf.SOURCE_PROPERTY + "\":{" +
|
||||||
|
"\"@uuid\":\"4a971915-ca90-48cf-9975-63ee2dd28605\"," +
|
||||||
"\"@class\":\"MyEService\"," +
|
"\"@class\":\"MyEService\"," +
|
||||||
"\"@superClasses\":[\"EService\", \"Service\", \"Resource\"]," +
|
"\"@superClasses\":[\"EService\", \"Service\", \"Resource\"]," +
|
||||||
"\"header\":"+ "{" +
|
"\"" + ConsistsOf.METADATA_PROPERTY + "\": " + hString +
|
||||||
"\"@class\":\"Header\"," +
|
|
||||||
"\"uuid\":\"4a971915-ca90-48cf-9975-63ee2dd28605\"," +
|
|
||||||
"\"creator\":null, " +
|
|
||||||
"\"creationTime\":null, " +
|
|
||||||
"\"lastUpdateTime\":null}" +
|
|
||||||
"}," +
|
"}," +
|
||||||
"\"" + ConsistsOf.TARGET_PROPERTY + "\":{" +
|
"\"" + ConsistsOf.TARGET_PROPERTY + "\":{" +
|
||||||
|
"\"@uuid\":\"3ace4bd0-e5cd-49a3-97a8-a0a9468ce6d4\"," +
|
||||||
"\"@class\":\"MySoftwareFacet\"," +
|
"\"@class\":\"MySoftwareFacet\"," +
|
||||||
"\"@superClasses\":[\"SoftwareFacet\", \"Facet\"]," +
|
"\"@superClasses\":[\"SoftwareFacet\", \"Facet\"]," +
|
||||||
"\"header\":"+ "{" +
|
"\"" + ConsistsOf.METADATA_PROPERTY + "\": " + hString + "," +
|
||||||
"\"@class\":\"Header\"," +
|
"\"name\":\"WhnManager\"," +
|
||||||
"\"uuid\":\"3ace4bd0-e5cd-49a3-97a8-a0a9468ce6d4\"," +
|
|
||||||
"\"creator\":null, " +
|
|
||||||
"\"creationTime\":null, " +
|
|
||||||
"\"lastUpdateTime\":null" +
|
|
||||||
"}" +
|
|
||||||
",\"name\":\"WhnManager\"," +
|
|
||||||
"\"group\":\"VREManagement\"," +
|
"\"group\":\"VREManagement\"," +
|
||||||
"\"version\":\"2.0.0-SNAPSHOT\"," +
|
"\"version\":\"2.0.0-SNAPSHOT\"," +
|
||||||
"\"description\":\"Web Hosting Node Service\"," +
|
"\"description\":\"Web Hosting Node Service\"," +
|
||||||
"\"qualifier\":null,\"optional\":false" +
|
"\"qualifier\":null,\"optional\":false" +
|
||||||
"}" +
|
"}" +
|
||||||
"}";
|
"}";
|
||||||
logger.debug(consistsOfString);
|
logger.debug("--- {}", consistsOfString);
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
ConsistsOf<Resource,Facet> consistsOf = ElementMapper.unmarshal(ConsistsOf.class, consistsOfString);
|
ConsistsOf<Resource,Facet> consistsOf = ElementMapper.unmarshal(ConsistsOf.class, consistsOfString);
|
||||||
|
|
|
@ -6,7 +6,7 @@ package org.gcube.informationsystem.types;
|
||||||
import org.gcube.informationsystem.base.reference.Element;
|
import org.gcube.informationsystem.base.reference.Element;
|
||||||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||||
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -21,7 +21,7 @@ public class EntitySchemaDefinition {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
Class<? extends PropertyElement> clz = Header.class;
|
Class<? extends PropertyElement> clz = Metadata.class;
|
||||||
String json = TypeMapper.serializeType(clz);
|
String json = TypeMapper.serializeType(clz);
|
||||||
logger.trace(json);
|
logger.trace(json);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,10 @@ import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Entity;
|
import org.gcube.informationsystem.model.reference.entities.Entity;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Property;
|
import org.gcube.informationsystem.model.reference.properties.Property;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Vault;
|
import org.gcube.informationsystem.model.reference.properties.Encrypted;
|
||||||
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
|
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
|
||||||
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
||||||
import org.gcube.informationsystem.model.reference.relations.Relation;
|
import org.gcube.informationsystem.model.reference.relations.Relation;
|
||||||
|
@ -89,9 +89,9 @@ public class SerializationTest {
|
||||||
logger.info(ElementMapper.marshal(property));
|
logger.info(ElementMapper.marshal(property));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
PropertyType<Header> header = (PropertyType<Header>) TypeMapper.createTypeDefinition(Header.class);
|
PropertyType<Metadata> metadataType = (PropertyType<Metadata>) TypeMapper.createTypeDefinition(Metadata.class);
|
||||||
Assert.assertTrue(header.getAccessType()==AccessType.PROPERTY);
|
Assert.assertTrue(metadataType.getAccessType()==AccessType.PROPERTY);
|
||||||
logger.info(ElementMapper.marshal(header));
|
logger.info(ElementMapper.marshal(metadataType));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
PropertyType<PropagationConstraint> propagationConstraint = (PropertyType<PropagationConstraint>) TypeMapper.createTypeDefinition(PropagationConstraint.class);
|
PropertyType<PropagationConstraint> propagationConstraint = (PropertyType<PropagationConstraint>) TypeMapper.createTypeDefinition(PropagationConstraint.class);
|
||||||
|
@ -99,7 +99,7 @@ public class SerializationTest {
|
||||||
logger.info(ElementMapper.marshal(propagationConstraint));
|
logger.info(ElementMapper.marshal(propagationConstraint));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
PropertyType<Vault> vault = (PropertyType<Vault>) TypeMapper.createTypeDefinition(Vault.class);
|
PropertyType<Encrypted> vault = (PropertyType<Encrypted>) TypeMapper.createTypeDefinition(Encrypted.class);
|
||||||
Assert.assertTrue(vault.getAccessType()==AccessType.PROPERTY);
|
Assert.assertTrue(vault.getAccessType()==AccessType.PROPERTY);
|
||||||
logger.info(ElementMapper.marshal(vault));
|
logger.info(ElementMapper.marshal(vault));
|
||||||
|
|
||||||
|
@ -198,19 +198,19 @@ public class SerializationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTypeSerialization() throws Exception {
|
public void testTypeSerialization() throws Exception {
|
||||||
String serialized = TypeMapper.serializeType(Header.class);
|
String serialized = TypeMapper.serializeType(Metadata.class);
|
||||||
logger.info(serialized);
|
logger.info(serialized);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
PropertyType<Header> propertyType = (PropertyType<Header>) TypeMapper.deserializeTypeDefinition(serialized);
|
PropertyType<Metadata> propertyType = (PropertyType<Metadata>) TypeMapper.deserializeTypeDefinition(serialized);
|
||||||
Version typeVersion = propertyType.getVersion();
|
Version typeVersion = propertyType.getVersion();
|
||||||
logger.debug("Version {}", typeVersion.toString());
|
logger.debug("Version {}", typeVersion.toString());
|
||||||
logger.info(ElementMapper.marshal(propertyType));
|
logger.info(ElementMapper.marshal(propertyType));
|
||||||
|
|
||||||
String json = "{\"@class\":\"PropertyType\",\"header\":null,\"name\":\"Header\",\"description\":\"This class provides metadata per every IdentifiableElement\",\"superClasses\":[\"Property\"],\"properties\":[{\"@class\":\"PropertyDefinition\",\"name\":\"creationTime\",\"description\":\"Creation time. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"Date\"},{\"@class\":\"PropertyDefinition\",\"name\":\"lastUpdateTime\",\"description\":\"Last Update time. At creation time it assumes the same value of creationTime. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"Date\"},{\"@class\":\"PropertyDefinition\",\"name\":\"createdBy\",\"description\":\"The user that created the Entity or the Relation. It is initialized at creation time. \",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"String\"},{\"@class\":\"PropertyDefinition\",\"name\":\"uuid\",\"description\":\"This UUID is be used to identify the Entity or the Relation univocally.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":\"^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}){1}$\",\"type\":\"String\"},{\"@class\":\"PropertyDefinition\",\"name\":\"lastUpdateBy\",\"description\":\"The user that made the last update to the Entity or the Relation. At creation time, it assumes the same value of creator.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"String\"}],\"accessType\":\"PROPERTY\",\"abstract\":false,\"version\":\"1.0.0\",\"changelog\":{\"1.0.0\":\"First Version\"}}";
|
String json = "{\"@class\":\"PropertyType\",\"metadata\":null,\"name\":\"Metadata\",\"description\":\"This class provides metadata per every IdentifiableElement\",\"superClasses\":[\"Property\"],\"properties\":[{\"@class\":\"PropertyDefinition\",\"name\":\"creationTime\",\"description\":\"Creation time. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"Date\"},{\"@class\":\"PropertyDefinition\",\"name\":\"lastUpdateTime\",\"description\":\"Last Update time. At creation time it assumes the same value of creationTime. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"Date\"},{\"@class\":\"PropertyDefinition\",\"name\":\"createdBy\",\"description\":\"The user that created the Entity or the Relation. It is initialized at creation time. \",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"String\"},{\"@class\":\"PropertyDefinition\",\"name\":\"uuid\",\"description\":\"This UUID is be used to identify the Entity or the Relation univocally.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":\"^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}){1}$\",\"type\":\"String\"},{\"@class\":\"PropertyDefinition\",\"name\":\"lastUpdateBy\",\"description\":\"The user that made the last update to the Entity or the Relation. At creation time, it assumes the same value of creator.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"type\":\"String\"}],\"accessType\":\"PROPERTY\",\"abstract\":false,\"version\":\"1.0.0\",\"changelog\":{\"1.0.0\":\"First Version\"}}";
|
||||||
logger.info(json);
|
logger.info(json);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
PropertyType<Header> headerType = (PropertyType<Header>) TypeMapper.deserializeTypeDefinition(json);
|
PropertyType<Metadata> metadataType = (PropertyType<Metadata>) TypeMapper.deserializeTypeDefinition(json);
|
||||||
logger.info(ElementMapper.marshal(headerType));
|
logger.info(ElementMapper.marshal(metadataType));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package org.gcube.informationsystem.types;
|
package org.gcube.informationsystem.types;
|
||||||
|
|
||||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Vault;
|
import org.gcube.informationsystem.model.reference.properties.Encrypted;
|
||||||
import org.gcube.informationsystem.types.PropertyTypeName.BaseType;
|
import org.gcube.informationsystem.types.PropertyTypeName.BaseType;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -17,7 +17,7 @@ public class TypeNameTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getBaseType() throws Exception {
|
public void getBaseType() throws Exception {
|
||||||
Class<?> clz = Header.class;
|
Class<?> clz = Metadata.class;
|
||||||
BaseType baseType = PropertyTypeName.getBaseTypeByClass(clz);
|
BaseType baseType = PropertyTypeName.getBaseTypeByClass(clz);
|
||||||
logger.debug("{} for class {} is {}", BaseType.class.getSimpleName(), clz, baseType);
|
logger.debug("{} for class {} is {}", BaseType.class.getSimpleName(), clz, baseType);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public class TypeNameTest {
|
||||||
if(baseType.ordinal()>=BaseType.PROPERTY.ordinal()) {
|
if(baseType.ordinal()>=BaseType.PROPERTY.ordinal()) {
|
||||||
if(baseType == BaseType.PROPERTY) {
|
if(baseType == BaseType.PROPERTY) {
|
||||||
stringBuffer = new StringBuffer();
|
stringBuffer = new StringBuffer();
|
||||||
stringBuffer.append(Vault.NAME);
|
stringBuffer.append(Encrypted.NAME);
|
||||||
checkPropertyTypeName(stringBuffer.toString(), baseType);
|
checkPropertyTypeName(stringBuffer.toString(), baseType);
|
||||||
} else {
|
} else {
|
||||||
for(BaseType b : BaseType.values()) {
|
for(BaseType b : BaseType.values()) {
|
||||||
|
@ -79,7 +79,7 @@ public class TypeNameTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(b == BaseType.PROPERTY) {
|
if(b == BaseType.PROPERTY) {
|
||||||
sb.append(Vault.NAME);
|
sb.append(Encrypted.NAME);
|
||||||
} else {
|
} else {
|
||||||
sb.append(b.toString());
|
sb.append(b.toString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,21 +14,23 @@ public class UUIDManagerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReservedUUID() {
|
public void testReservedUUID() {
|
||||||
Set<UUID> allUUID = UUIDManager.getAllReservedUUID();
|
UUIDManager uuidManager = UUIDManager.getInstance();
|
||||||
|
|
||||||
|
Set<UUID> allUUID = uuidManager.getAllReservedUUID();
|
||||||
logger.debug("Reserved UUIDs are {}", allUUID);
|
logger.debug("Reserved UUIDs are {}", allUUID);
|
||||||
|
|
||||||
Set<String> allUUIDAsString = UUIDManager.getAllReservedUUIDAsStrings();
|
Set<String> allUUIDAsString = uuidManager.getAllReservedUUIDAsStrings();
|
||||||
Assert.assertTrue(allUUID.size()==allUUIDAsString.size());
|
Assert.assertTrue(allUUID.size()==allUUIDAsString.size());
|
||||||
Assert.assertTrue(allUUID.size()==16);
|
Assert.assertTrue(allUUID.size()==16);
|
||||||
Assert.assertTrue(allUUIDAsString.size()==16);
|
Assert.assertTrue(allUUIDAsString.size()==16);
|
||||||
for(UUID uuid : allUUID) {
|
for(UUID uuid : allUUID) {
|
||||||
Assert.assertTrue(UUIDManager.isReservedUUID(uuid));
|
Assert.assertTrue(uuidManager.isReservedUUID(uuid));
|
||||||
Assert.assertTrue(UUIDManager.isReservedUUID(uuid.toString()));
|
Assert.assertTrue(uuidManager.isReservedUUID(uuid.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(String uuidString : allUUIDAsString) {
|
for(String uuidString : allUUIDAsString) {
|
||||||
Assert.assertTrue(UUIDManager.isReservedUUID(UUID.fromString(uuidString)));
|
Assert.assertTrue(uuidManager.isReservedUUID(UUID.fromString(uuidString)));
|
||||||
Assert.assertTrue(UUIDManager.isReservedUUID(uuidString));
|
Assert.assertTrue(uuidManager.isReservedUUID(uuidString));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
|
|
||||||
<logger name="org.gcube" level="WARN" />
|
<logger name="org.gcube" level="WARN" />
|
||||||
<logger name="org.gcube.informationsystem" level="INFO" />
|
<logger name="org.gcube.informationsystem" level="TRACE" />
|
||||||
<logger name="org.gcube.informationsystem.resourceregistry.dbinitialization" level="WARN" />
|
<logger name="org.gcube.informationsystem.resourceregistry.dbinitialization" level="WARN" />
|
||||||
|
|
||||||
<root level="WARN">
|
<root level="WARN">
|
||||||
|
|
Loading…
Reference in New Issue