Fixing model
This commit is contained in:
parent
a58eec0cb3
commit
770155d5c5
|
@ -4,43 +4,43 @@ import org.gcube.informationsystem.base.impl.ERImpl;
|
||||||
import org.gcube.informationsystem.base.reference.entities.BaseEntity;
|
import org.gcube.informationsystem.base.reference.entities.BaseEntity;
|
||||||
import org.gcube.informationsystem.base.reference.relations.BaseRelation;
|
import org.gcube.informationsystem.base.reference.relations.BaseRelation;
|
||||||
|
|
||||||
public abstract class BaseRelationImpl<Out extends BaseEntity, In extends BaseEntity> extends ERImpl implements BaseRelation<Out, In> {
|
public abstract class BaseRelationImpl<S extends BaseEntity, T extends BaseEntity> extends ERImpl implements BaseRelation<S, T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated Serial Version UID
|
* Generated Serial Version UID
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 28704968813390512L;
|
private static final long serialVersionUID = 28704968813390512L;
|
||||||
|
|
||||||
protected Out source;
|
protected S source;
|
||||||
protected In target;
|
protected T target;
|
||||||
|
|
||||||
protected BaseRelationImpl() {
|
protected BaseRelationImpl() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BaseRelationImpl(Out source, In target) {
|
protected BaseRelationImpl(S source, T target) {
|
||||||
this();
|
this();
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Out getSource() {
|
public S getSource() {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSource(Out source) {
|
public void setSource(S source) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public In getTarget() {
|
public T getTarget() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTarget(In target) {
|
public void setTarget(T target) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
|
||||||
@Abstract
|
@Abstract
|
||||||
//@JsonDeserialize(as=BaseRelationImpl.class) Do not uncomment to manage subclasses
|
//@JsonDeserialize(as=BaseRelationImpl.class) Do not uncomment to manage subclasses
|
||||||
public interface BaseRelation<Out extends BaseEntity, In extends BaseEntity> extends ER {
|
public interface BaseRelation<S extends BaseEntity, T extends BaseEntity> extends ER {
|
||||||
|
|
||||||
public static final String NAME = "BaseRelation"; // BaseRelation.class.getSimpleName();
|
public static final String NAME = "BaseRelation"; // BaseRelation.class.getSimpleName();
|
||||||
|
|
||||||
|
@ -24,15 +24,15 @@ public interface BaseRelation<Out extends BaseEntity, In extends BaseEntity> ext
|
||||||
public Header getHeader();
|
public Header getHeader();
|
||||||
|
|
||||||
@JsonGetter(value=SOURCE_PROPERTY)
|
@JsonGetter(value=SOURCE_PROPERTY)
|
||||||
public Out getSource();
|
public S getSource();
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public void setSource(Out source);
|
public void setSource(S source);
|
||||||
|
|
||||||
@JsonGetter(value=TARGET_PROPERTY)
|
@JsonGetter(value=TARGET_PROPERTY)
|
||||||
public In getTarget();
|
public T getTarget();
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public void setTarget(In target);
|
public void setTarget(T target);
|
||||||
|
|
||||||
}
|
}
|
|
@ -31,8 +31,8 @@ public final class ContextImpl extends BaseEntityImpl implements Context {
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
||||||
protected IsParentOf<Context, Context> parent;
|
protected IsParentOf parent;
|
||||||
protected List<IsParentOf<Context, Context>> children;
|
protected List<IsParentOf> children;
|
||||||
|
|
||||||
protected ContextImpl() {
|
protected ContextImpl() {
|
||||||
super();
|
super();
|
||||||
|
@ -64,7 +64,7 @@ public final class ContextImpl extends BaseEntityImpl implements Context {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IsParentOf<Context, Context> getParent() {
|
public IsParentOf getParent() {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,15 +81,15 @@ public final class ContextImpl extends BaseEntityImpl implements Context {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParent(Context context) {
|
public void setParent(Context context) {
|
||||||
IsParentOf<Context, Context> isParentOf = null;
|
IsParentOf isParentOf = null;
|
||||||
if(context!=null) {
|
if(context!=null) {
|
||||||
isParentOf = new IsParentOfImpl<Context, Context>(context, this);
|
isParentOf = new IsParentOfImpl(context, this);
|
||||||
}
|
}
|
||||||
setParent(isParentOf);
|
setParent(isParentOf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonSetter(value=PARENT_PROPERTY)
|
@JsonSetter(value=PARENT_PROPERTY)
|
||||||
protected void setParentFromJson(IsParentOf<Context, Context> isParentOf) throws JsonProcessingException {
|
protected void setParentFromJson(IsParentOf isParentOf) throws JsonProcessingException {
|
||||||
if(isParentOf!=null) {
|
if(isParentOf!=null) {
|
||||||
Context parent = isParentOf.getSource();
|
Context parent = isParentOf.getSource();
|
||||||
isParentOf.setTarget(this);
|
isParentOf.setTarget(this);
|
||||||
|
@ -99,23 +99,23 @@ public final class ContextImpl extends BaseEntityImpl implements Context {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setParent(IsParentOf<Context, Context> isParentOf) {
|
public void setParent(IsParentOf isParentOf) {
|
||||||
this.parent = isParentOf;
|
this.parent = isParentOf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IsParentOf<Context, Context>> getChildren() {
|
public List<IsParentOf> getChildren() {
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonSetter(value=CHILDREN_PROPERTY)
|
@JsonSetter(value=CHILDREN_PROPERTY)
|
||||||
protected void setChildrenFromJson(List<IsParentOf<Context, Context>> children) throws JsonProcessingException {
|
protected void setChildrenFromJson(List<IsParentOf> children) throws JsonProcessingException {
|
||||||
for(IsParentOf<Context, Context> isParentOf : children){
|
for(IsParentOf isParentOf : children){
|
||||||
addChildFromJson(isParentOf);
|
addChildFromJson(isParentOf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addChildFromJson(IsParentOf<Context, Context> isParentOf) throws JsonProcessingException {
|
protected void addChildFromJson(IsParentOf isParentOf) throws JsonProcessingException {
|
||||||
isParentOf.setSource(this);
|
isParentOf.setSource(this);
|
||||||
addChild(isParentOf);
|
addChild(isParentOf);
|
||||||
}
|
}
|
||||||
|
@ -129,12 +129,12 @@ public final class ContextImpl extends BaseEntityImpl implements Context {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addChild(Context child) {
|
public void addChild(Context child) {
|
||||||
IsParentOf<Context, Context> isParentOf = new IsParentOfImpl<Context, Context>(this, child);
|
IsParentOf isParentOf = new IsParentOfImpl(this, child);
|
||||||
this.addChild(isParentOf);
|
this.addChild(isParentOf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addChild(IsParentOf<Context, Context> isParentOf) {
|
public void addChild(IsParentOf isParentOf) {
|
||||||
((ContextImpl) isParentOf.getTarget()).setParent(this);
|
((ContextImpl) isParentOf.getTarget()).setParent(this);
|
||||||
children.add(isParentOf);
|
children.add(isParentOf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
@JsonTypeName(value=IsParentOf.NAME)
|
@JsonTypeName(value=IsParentOf.NAME)
|
||||||
public final class IsParentOfImpl<Out extends Context, In extends Context> extends
|
public final class IsParentOfImpl extends BaseRelationImpl<Context, Context> implements IsParentOf {
|
||||||
BaseRelationImpl<Out, In> implements IsParentOf<Out, In> {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -25,7 +24,7 @@ public final class IsParentOfImpl<Out extends Context, In extends Context> exten
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IsParentOfImpl(Out source, In target) {
|
public IsParentOfImpl(Context source, Context target) {
|
||||||
super(source, target);
|
super(source, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ public interface Context extends BaseEntity {
|
||||||
|
|
||||||
@JsonGetter
|
@JsonGetter
|
||||||
@JsonIgnoreProperties({ Relation.TARGET_PROPERTY })
|
@JsonIgnoreProperties({ Relation.TARGET_PROPERTY })
|
||||||
public IsParentOf<Context, Context> getParent();
|
public IsParentOf getParent();
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public void setParent(UUID uuid);
|
public void setParent(UUID uuid);
|
||||||
|
@ -46,16 +46,16 @@ public interface Context extends BaseEntity {
|
||||||
public void setParent(Context context);
|
public void setParent(Context context);
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public void setParent(IsParentOf<Context, Context> isParentOf);
|
public void setParent(IsParentOf isParentOf);
|
||||||
|
|
||||||
@JsonGetter
|
@JsonGetter
|
||||||
@JsonIgnoreProperties({ Relation.SOURCE_PROPERTY })
|
@JsonIgnoreProperties({ Relation.SOURCE_PROPERTY })
|
||||||
public List<IsParentOf<Context, Context>> getChildren();
|
public List<IsParentOf> getChildren();
|
||||||
|
|
||||||
public void addChild(UUID uuid);
|
public void addChild(UUID uuid);
|
||||||
|
|
||||||
public void addChild(Context child);
|
public void addChild(Context child);
|
||||||
|
|
||||||
public void addChild(IsParentOf<Context, Context> isParentOf);
|
public void addChild(IsParentOf isParentOf);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,22 +17,22 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
* https://wiki.gcube-system.org/gcube/Facet_Based_Resource_Model#isParentOf
|
* https://wiki.gcube-system.org/gcube/Facet_Based_Resource_Model#isParentOf
|
||||||
*/
|
*/
|
||||||
@JsonDeserialize(as = IsParentOfImpl.class)
|
@JsonDeserialize(as = IsParentOfImpl.class)
|
||||||
public interface IsParentOf<Out extends Context, In extends Context> extends BaseRelation<Out,In> {
|
public interface IsParentOf extends BaseRelation<Context,Context> {
|
||||||
|
|
||||||
public static final String NAME = "IsParentOf"; //IsParentOf.class.getSimpleName();
|
public static final String NAME = "IsParentOf"; //IsParentOf.class.getSimpleName();
|
||||||
|
|
||||||
@JsonIgnoreProperties({Context.PARENT_PROPERTY, Context.CHILDREN_PROPERTY})
|
@JsonIgnoreProperties({Context.PARENT_PROPERTY, Context.CHILDREN_PROPERTY})
|
||||||
@JsonGetter(value = SOURCE_PROPERTY)
|
@JsonGetter(value = SOURCE_PROPERTY)
|
||||||
public Out getSource();
|
public Context getSource();
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public void setSource(Out source);
|
public void setSource(Context source);
|
||||||
|
|
||||||
@JsonIgnoreProperties({Context.PARENT_PROPERTY, Context.CHILDREN_PROPERTY})
|
@JsonIgnoreProperties({Context.PARENT_PROPERTY, Context.CHILDREN_PROPERTY})
|
||||||
@JsonGetter(value = TARGET_PROPERTY)
|
@JsonGetter(value = TARGET_PROPERTY)
|
||||||
public In getTarget();
|
public Context getTarget();
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public void setTarget(In target);
|
public void setTarget(Context target);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,8 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
@JsonTypeName(value=ConsistsOf.NAME)
|
@JsonTypeName(value=ConsistsOf.NAME)
|
||||||
public class ConsistsOfImpl<Out extends Resource, In extends Facet> extends
|
public class ConsistsOfImpl<S extends Resource, T extends Facet> extends
|
||||||
RelationImpl<Out, In> implements ConsistsOf<Out, In> {
|
RelationImpl<S, T> implements ConsistsOf<S, T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated Serial Version UID
|
* Generated Serial Version UID
|
||||||
|
@ -26,7 +26,7 @@ public class ConsistsOfImpl<Out extends Resource, In extends Facet> extends
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConsistsOfImpl(Out source, In target,
|
public ConsistsOfImpl(S source, T target,
|
||||||
PropagationConstraint propagationConstraint) {
|
PropagationConstraint propagationConstraint) {
|
||||||
super(source, target, propagationConstraint);
|
super(source, target, propagationConstraint);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,8 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
@JsonTypeName(value=ConsistsOf.NAME)
|
@JsonTypeName(value=ConsistsOf.NAME)
|
||||||
public class DummyConsistsOf<Out extends Resource, In extends Facet> extends
|
public class DummyConsistsOf<S extends Resource, T extends Facet> extends
|
||||||
ConsistsOfImpl<Out, In> implements ConsistsOf<Out, In> {
|
ConsistsOfImpl<S, T> implements ConsistsOf<S, T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated Serial Version UID
|
* Generated Serial Version UID
|
||||||
|
@ -26,7 +26,7 @@ public class DummyConsistsOf<Out extends Resource, In extends Facet> extends
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DummyConsistsOf(Out source, In target,
|
public DummyConsistsOf(S source, T target,
|
||||||
PropagationConstraint propagationConstraint) {
|
PropagationConstraint propagationConstraint) {
|
||||||
super(source, target, propagationConstraint);
|
super(source, target, propagationConstraint);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
@JsonTypeName(value=IsRelatedTo.NAME)
|
@JsonTypeName(value=IsRelatedTo.NAME)
|
||||||
public class DummyIsRelatedTo<Out extends Resource, In extends Resource>
|
public class DummyIsRelatedTo<S extends Resource, T extends Resource>
|
||||||
extends IsRelatedToImpl<Out, In> implements IsRelatedTo<Out, In>{
|
extends IsRelatedToImpl<S, T> implements IsRelatedTo<S, T>{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated Serial Version UID
|
* Generated Serial Version UID
|
||||||
|
@ -25,7 +25,7 @@ public class DummyIsRelatedTo<Out extends Resource, In extends Resource>
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DummyIsRelatedTo(Out source, In target,
|
public DummyIsRelatedTo(S source, T target,
|
||||||
PropagationConstraint propagationConstraint) {
|
PropagationConstraint propagationConstraint) {
|
||||||
super(source, target, propagationConstraint);
|
super(source, target, propagationConstraint);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,8 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
@JsonTypeName(value=IsIdentifiedBy.NAME)
|
@JsonTypeName(value=IsIdentifiedBy.NAME)
|
||||||
public class IsIdentifiedByImpl<Out extends Resource, In extends Facet> extends
|
public class IsIdentifiedByImpl<S extends Resource, T extends Facet> extends
|
||||||
ConsistsOfImpl<Out, In> implements IsIdentifiedBy<Out, In> {
|
ConsistsOfImpl<S, T> implements IsIdentifiedBy<S, T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated Serial Version UID
|
* Generated Serial Version UID
|
||||||
|
@ -26,7 +26,7 @@ public class IsIdentifiedByImpl<Out extends Resource, In extends Facet> extends
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IsIdentifiedByImpl(Out source, In target,
|
public IsIdentifiedByImpl(S source, T target,
|
||||||
PropagationConstraint propagationConstraint) {
|
PropagationConstraint propagationConstraint) {
|
||||||
super(source, target, propagationConstraint);
|
super(source, target, propagationConstraint);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
@JsonTypeName(value=IsRelatedTo.NAME)
|
@JsonTypeName(value=IsRelatedTo.NAME)
|
||||||
public abstract class IsRelatedToImpl<Out extends Resource, In extends Resource> extends
|
public abstract class IsRelatedToImpl<S extends Resource, T extends Resource> extends
|
||||||
RelationImpl<Out, In> implements IsRelatedTo<Out, In> {
|
RelationImpl<S, T> implements IsRelatedTo<S, T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated Serial Version UID
|
* Generated Serial Version UID
|
||||||
|
@ -25,7 +25,7 @@ public abstract class IsRelatedToImpl<Out extends Resource, In extends Resource>
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IsRelatedToImpl(Out source, In target,
|
public IsRelatedToImpl(S source, T target,
|
||||||
PropagationConstraint propagationConstraint) {
|
PropagationConstraint propagationConstraint) {
|
||||||
super(source, target, propagationConstraint);
|
super(source, target, propagationConstraint);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.util.Set;
|
||||||
import org.gcube.informationsystem.base.impl.relations.BaseRelationImpl;
|
import org.gcube.informationsystem.base.impl.relations.BaseRelationImpl;
|
||||||
import org.gcube.informationsystem.base.reference.ISManageable;
|
import org.gcube.informationsystem.base.reference.ISManageable;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Entity;
|
import org.gcube.informationsystem.model.reference.entities.Entity;
|
||||||
|
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||||
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.relations.Relation;
|
import org.gcube.informationsystem.model.reference.relations.Relation;
|
||||||
|
@ -23,8 +24,8 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
@JsonTypeName(value = Relation.NAME)
|
@JsonTypeName(value = Relation.NAME)
|
||||||
public abstract class RelationImpl<Out extends Entity, In extends Entity>
|
public abstract class RelationImpl<S extends Resource, T extends Entity>
|
||||||
extends BaseRelationImpl<Out,In> implements Relation<Out, In> {
|
extends BaseRelationImpl<S,T> implements Relation<S, T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -48,7 +49,7 @@ public abstract class RelationImpl<Out extends Entity, In extends Entity>
|
||||||
this.allowedAdditionalKeys.add(SUPERCLASSES_PROPERTY);
|
this.allowedAdditionalKeys.add(SUPERCLASSES_PROPERTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RelationImpl(Out source, In target,
|
protected RelationImpl(S source, T target,
|
||||||
PropagationConstraint propagationConstraint) {
|
PropagationConstraint propagationConstraint) {
|
||||||
this();
|
this();
|
||||||
this.source = source;
|
this.source = source;
|
||||||
|
|
|
@ -11,8 +11,8 @@ import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||||
* https://wiki.gcube-system.org/gcube/Facet_Based_Resource_Model#consistsOf
|
* https://wiki.gcube-system.org/gcube/Facet_Based_Resource_Model#consistsOf
|
||||||
*/
|
*/
|
||||||
// @JsonDeserialize(as=ConsistsOfImpl.class) Do not uncomment to manage subclasses
|
// @JsonDeserialize(as=ConsistsOfImpl.class) Do not uncomment to manage subclasses
|
||||||
public interface ConsistsOf<Out extends Resource, In extends Facet>
|
public interface ConsistsOf<S extends Resource, T extends Facet>
|
||||||
extends Relation<Out, In> {
|
extends Relation<S, T> {
|
||||||
|
|
||||||
public static final String NAME = "ConsistsOf"; //ConsistsOf.class.getSimpleName();
|
public static final String NAME = "ConsistsOf"; //ConsistsOf.class.getSimpleName();
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
* https://wiki.gcube-system.org/gcube/Facet_Based_Resource_Model#isIdentifiedBy
|
* https://wiki.gcube-system.org/gcube/Facet_Based_Resource_Model#isIdentifiedBy
|
||||||
*/
|
*/
|
||||||
@JsonDeserialize(as=IsIdentifiedByImpl.class)
|
@JsonDeserialize(as=IsIdentifiedByImpl.class)
|
||||||
public interface IsIdentifiedBy<Out extends Resource, In extends Facet>
|
public interface IsIdentifiedBy<S extends Resource, T extends Facet>
|
||||||
extends ConsistsOf<Out, In> {
|
extends ConsistsOf<S, T> {
|
||||||
|
|
||||||
public static final String NAME = "IsIdentifiedBy"; //IsIdentifiedBy.class.getSimpleName();
|
public static final String NAME = "IsIdentifiedBy"; //IsIdentifiedBy.class.getSimpleName();
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@ import org.gcube.informationsystem.types.annotations.Abstract;
|
||||||
*/
|
*/
|
||||||
@Abstract
|
@Abstract
|
||||||
// @JsonDeserialize(as=IsRelatedToImpl.class) Do not uncomment to manage subclasses
|
// @JsonDeserialize(as=IsRelatedToImpl.class) Do not uncomment to manage subclasses
|
||||||
public interface IsRelatedTo<Out extends Resource, In extends Resource>
|
public interface IsRelatedTo<S extends Resource, T extends Resource>
|
||||||
extends Relation<Out, In> {
|
extends Relation<S, T> {
|
||||||
|
|
||||||
public static final String NAME = "IsRelatedTo"; //IsRelatedTo.class.getSimpleName();
|
public static final String NAME = "IsRelatedTo"; //IsRelatedTo.class.getSimpleName();
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
*/
|
*/
|
||||||
@Abstract
|
@Abstract
|
||||||
// @JsonDeserialize(as=RelationImpl.class) Do not uncomment to manage subclasses
|
// @JsonDeserialize(as=RelationImpl.class) Do not uncomment to manage subclasses
|
||||||
public interface Relation<Out extends Entity, In extends Entity> extends BaseRelation<Out,In> {
|
public interface Relation<S extends Resource, T extends Entity> extends BaseRelation<S,T> {
|
||||||
|
|
||||||
public static final String NAME = "Relation"; //Relation.class.getSimpleName();
|
public static final String NAME = "Relation"; //Relation.class.getSimpleName();
|
||||||
|
|
||||||
|
@ -34,16 +34,16 @@ public interface Relation<Out extends Entity, In extends Entity> extends BaseRel
|
||||||
|
|
||||||
@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)
|
||||||
public Out getSource();
|
public S getSource();
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public void setSource(Out source);
|
public void setSource(S source);
|
||||||
|
|
||||||
@JsonGetter(value = TARGET_PROPERTY)
|
@JsonGetter(value = TARGET_PROPERTY)
|
||||||
public In getTarget();
|
public T getTarget();
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public void setTarget(In target);
|
public void setTarget(T target);
|
||||||
|
|
||||||
@ISProperty(name = PROPAGATION_CONSTRAINT)
|
@ISProperty(name = PROPAGATION_CONSTRAINT)
|
||||||
public PropagationConstraint getPropagationConstraint();
|
public PropagationConstraint getPropagationConstraint();
|
||||||
|
|
|
@ -15,56 +15,34 @@ public class TypeBinder {
|
||||||
|
|
||||||
private final static String NAME = "NAME";
|
private final static String NAME = "NAME";
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public static String serializeTypeDefinition(TypeDefinition typeDefinition) throws Exception{
|
public static String serializeTypeDefinition(TypeDefinition typeDefinition) throws Exception{
|
||||||
/*
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
String json = mapper.writeValueAsString(typeDefinition);
|
|
||||||
*/
|
|
||||||
String json = ISMapper.marshal(typeDefinition);
|
String json = ISMapper.marshal(typeDefinition);
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <ISM extends ISManageable> String serializeType(Class<ISM> type) throws Exception{
|
public static <ISM extends ISManageable> String serializeType(Class<ISM> type) throws Exception{
|
||||||
TypeDefinition<ISM> typeDefinition = createTypeDefinition(type);
|
TypeDefinition typeDefinition = createTypeDefinition(type);
|
||||||
return ISMapper.marshal(typeDefinition);
|
return ISMapper.marshal(typeDefinition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public static TypeDefinition deserializeTypeDefinition(String json) throws Exception{
|
public static TypeDefinition deserializeTypeDefinition(String json) throws Exception{
|
||||||
/*
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
TypeDefinition<ISM> readValue = mapper.readValue(json, TypeDefinition.class);
|
|
||||||
*/
|
|
||||||
TypeDefinition readValue = ISMapper.unmarshal(TypeDefinition.class, json);
|
TypeDefinition readValue = ISMapper.unmarshal(TypeDefinition.class, json);
|
||||||
return readValue;
|
return readValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <ISM extends ISManageable> String serializeTypeDefinitions(List<TypeDefinition<ISM>> typeDefinitions) throws Exception{
|
public static <ISM extends ISManageable> String serializeTypeDefinitions(List<TypeDefinition> typeDefinitions) throws Exception{
|
||||||
/*
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
String json = mapper.writeValueAsString(typeDefinitions);
|
|
||||||
return json;
|
|
||||||
*/
|
|
||||||
String json = ISMapper.marshal(typeDefinitions);
|
String json = ISMapper.marshal(typeDefinitions);
|
||||||
return json;
|
return json;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public static List<TypeDefinition> deserializeTypeDefinitions(String json) throws Exception{
|
public static List<TypeDefinition> deserializeTypeDefinitions(String json) throws Exception{
|
||||||
/*
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
JavaType type = mapper.getTypeFactory().constructCollectionType(ArrayList.class, TypeDefinition.class) ;
|
|
||||||
return mapper.readValue(json, type);
|
|
||||||
*/
|
|
||||||
List<TypeDefinition> list = ISMapper.unmarshalList(TypeDefinition.class, json);
|
List<TypeDefinition> list = ISMapper.unmarshalList(TypeDefinition.class, json);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <ISM extends ISManageable> TypeDefinition<ISM> createTypeDefinition(Class<ISM> clz) {
|
public static <ISM extends ISManageable> TypeDefinition createTypeDefinition(Class<ISM> clz) {
|
||||||
TypeDefinition<ISM> typeDefinition = TypeDefinitionImpl.getInstance(clz);
|
TypeDefinition typeDefinition = TypeDefinitionImpl.getInstance(clz);
|
||||||
return typeDefinition;
|
return typeDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.informationsystem.types.impl;
|
package org.gcube.informationsystem.types.impl;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.TypeVariable;
|
import java.lang.reflect.TypeVariable;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -28,7 +29,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
|
|
||||||
// @JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.ANY)
|
// @JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.ANY)
|
||||||
@JsonTypeName(value=TypeDefinition.NAME)
|
@JsonTypeName(value=TypeDefinition.NAME)
|
||||||
public class TypeDefinitionImpl<ISM extends ISManageable> extends ISManageableImpl implements TypeDefinition<ISM> {
|
public class TypeDefinitionImpl extends ISManageableImpl implements TypeDefinition {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated Serial Version UID
|
* Generated Serial Version UID
|
||||||
|
@ -94,11 +95,15 @@ public class TypeDefinitionImpl<ISM extends ISManageable> extends ISManageableIm
|
||||||
TypeVariable<?> typeVariable = (TypeVariable<?>) type;
|
TypeVariable<?> typeVariable = (TypeVariable<?>) type;
|
||||||
java.lang.reflect.Type[] bounds = typeVariable.getBounds();
|
java.lang.reflect.Type[] bounds = typeVariable.getBounds();
|
||||||
java.lang.reflect.Type t = bounds[0];
|
java.lang.reflect.Type t = bounds[0];
|
||||||
|
if(t instanceof ParameterizedType) {
|
||||||
|
ParameterizedType parameterizedType = (ParameterizedType) t;
|
||||||
|
return (Class<?>) parameterizedType.getRawType();
|
||||||
|
}
|
||||||
return (Class<?>) t;
|
return (Class<?>) t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
public static <ISM extends ISManageable> TypeDefinition<ISM> getInstance(Class<ISM> clz) {
|
public static TypeDefinition getInstance(Class<? extends ISManageable> clz) {
|
||||||
if(BaseEntity.class.isAssignableFrom(clz)) {
|
if(BaseEntity.class.isAssignableFrom(clz)) {
|
||||||
return new EntityTypeDefinitionImpl(clz);
|
return new EntityTypeDefinitionImpl(clz);
|
||||||
} else if(BaseRelation.class.isAssignableFrom(clz)){
|
} else if(BaseRelation.class.isAssignableFrom(clz)){
|
||||||
|
@ -114,7 +119,7 @@ public class TypeDefinitionImpl<ISM extends ISManageable> extends ISManageableIm
|
||||||
|
|
||||||
protected TypeDefinitionImpl() {}
|
protected TypeDefinitionImpl() {}
|
||||||
|
|
||||||
protected TypeDefinitionImpl(Class<ISM> clz) {
|
protected TypeDefinitionImpl(Class<? extends ISManageable> clz) {
|
||||||
this.name = TypeBinder.getType(clz);
|
this.name = TypeBinder.getType(clz);
|
||||||
this.description = TypeBinder.getStaticStringFieldByName(clz, DESCRIPTION, "");
|
this.description = TypeBinder.getStaticStringFieldByName(clz, DESCRIPTION, "");
|
||||||
this.abstractType = false;
|
this.abstractType = false;
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.gcube.informationsystem.utils.ISMapper;
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
|
|
||||||
@JsonTypeName(value=EntityTypeDefinition.NAME)
|
@JsonTypeName(value=EntityTypeDefinition.NAME)
|
||||||
public final class EntityTypeDefinitionImpl<E extends BaseEntity> extends TypeDefinitionImpl<E> implements EntityTypeDefinition<E> {
|
public final class EntityTypeDefinitionImpl<E extends BaseEntity> extends TypeDefinitionImpl implements EntityTypeDefinition<E> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated Serial Version UID
|
* Generated Serial Version UID
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.gcube.informationsystem.types.reference.properties.PropertyTypeDefini
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
|
|
||||||
@JsonTypeName(value=PropertyTypeDefinition.NAME)
|
@JsonTypeName(value=PropertyTypeDefinition.NAME)
|
||||||
public final class PropertyTypeDefinitionImpl<P extends BaseProperty> extends TypeDefinitionImpl<P> implements PropertyTypeDefinition<P> {
|
public final class PropertyTypeDefinitionImpl<P extends BaseProperty> extends TypeDefinitionImpl implements PropertyTypeDefinition<P> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated Serial Version UID
|
* Generated Serial Version UID
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
package org.gcube.informationsystem.types.impl.relations;
|
package org.gcube.informationsystem.types.impl.relations;
|
||||||
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.lang.reflect.ParameterizedType;
|
||||||
|
|
||||||
import org.gcube.informationsystem.base.reference.entities.BaseEntity;
|
import org.gcube.informationsystem.base.reference.entities.BaseEntity;
|
||||||
import org.gcube.informationsystem.base.reference.properties.Header;
|
import org.gcube.informationsystem.base.reference.properties.Header;
|
||||||
import org.gcube.informationsystem.base.reference.relations.BaseRelation;
|
import org.gcube.informationsystem.base.reference.relations.BaseRelation;
|
||||||
import org.gcube.informationsystem.context.reference.relations.IsParentOf;
|
import org.gcube.informationsystem.context.reference.relations.IsParentOf;
|
||||||
|
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||||
|
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||||
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;
|
||||||
|
@ -19,8 +22,8 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||||
|
|
||||||
@JsonTypeName(value=RelationTypeDefinition.NAME)
|
@JsonTypeName(value=RelationTypeDefinition.NAME)
|
||||||
public final class RelationTypeDefinitionImpl<Out extends BaseEntity, In extends BaseEntity, Rel extends BaseRelation<Out,In>>
|
public final class RelationTypeDefinitionImpl<ES extends EntityTypeDefinition<S>, ET extends EntityTypeDefinition<T>, S extends BaseEntity, T extends BaseEntity>
|
||||||
extends TypeDefinitionImpl<Rel> implements RelationTypeDefinition<Out,In,Rel> {
|
extends TypeDefinitionImpl implements RelationTypeDefinition<ES, ET, S,T> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated Serial Version UID
|
* Generated Serial Version UID
|
||||||
|
@ -38,23 +41,23 @@ public final class RelationTypeDefinitionImpl<Out extends BaseEntity, In extends
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelationTypeDefinitionImpl(Class<Rel> clz) {
|
public RelationTypeDefinitionImpl(Class<? extends BaseRelation<S,T>> clz) {
|
||||||
super(clz);
|
super(clz);
|
||||||
|
|
||||||
if(IsRelatedTo.class.isAssignableFrom(clz)){
|
if(IsRelatedTo.class.isAssignableFrom(clz)){
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
@SuppressWarnings({"unchecked"})
|
||||||
Class<? extends IsRelatedTo> c = (Class<? extends IsRelatedTo>) clz;
|
Class<? extends IsRelatedTo<? extends Resource, ? extends Resource>> c = (Class<? extends IsRelatedTo<? extends Resource, ? extends Resource>>) clz;
|
||||||
this.superClasses = retrieveSuperClasses(c, IsRelatedTo.class, Relation.NAME);
|
this.superClasses = retrieveSuperClasses(c, IsRelatedTo.class, Relation.NAME);
|
||||||
} else if(ConsistsOf.class.isAssignableFrom(clz)) {
|
} else if(ConsistsOf.class.isAssignableFrom(clz)) {
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
@SuppressWarnings({"unchecked"})
|
||||||
Class<? extends ConsistsOf> c = (Class<? extends ConsistsOf>) clz;
|
Class<? extends ConsistsOf<? extends Resource, ? extends Facet>> c = (Class<? extends ConsistsOf<? extends Resource, ? extends Facet>>) clz;
|
||||||
this.superClasses = retrieveSuperClasses(c, ConsistsOf.class, Relation.NAME);
|
this.superClasses = retrieveSuperClasses(c, ConsistsOf.class, Relation.NAME);
|
||||||
} else if(RelationTypeDefinition.class.isAssignableFrom(clz)){
|
} else if(RelationTypeDefinition.class.isAssignableFrom(clz)){
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
Class<? extends RelationTypeDefinition> c = (Class<? extends RelationTypeDefinition>) clz;
|
Class<? extends RelationTypeDefinition> c = (Class<? extends RelationTypeDefinition>) clz;
|
||||||
this.superClasses = retrieveSuperClasses(c, RelationTypeDefinition.class, BaseRelation.NAME);
|
this.superClasses = retrieveSuperClasses(c, RelationTypeDefinition.class, BaseRelation.NAME);
|
||||||
} else if(IsParentOf.class.isAssignableFrom(clz)){
|
} else if(IsParentOf.class.isAssignableFrom(clz)){
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
@SuppressWarnings({"unchecked"})
|
||||||
Class<? extends IsParentOf> c = (Class<? extends IsParentOf>) clz;
|
Class<? extends IsParentOf> c = (Class<? extends IsParentOf>) clz;
|
||||||
this.superClasses = retrieveSuperClasses(c, IsParentOf.class, BaseRelation.NAME);
|
this.superClasses = retrieveSuperClasses(c, IsParentOf.class, BaseRelation.NAME);
|
||||||
} else if(BaseRelation.class.isAssignableFrom(clz)){
|
} else if(BaseRelation.class.isAssignableFrom(clz)){
|
||||||
|
@ -64,13 +67,23 @@ public final class RelationTypeDefinitionImpl<Out extends BaseEntity, In extends
|
||||||
}
|
}
|
||||||
|
|
||||||
java.lang.reflect.Type[] typeParameters = clz.getTypeParameters();
|
java.lang.reflect.Type[] typeParameters = clz.getTypeParameters();
|
||||||
|
if(typeParameters.length==0) {
|
||||||
|
typeParameters = ((ParameterizedType) clz.getGenericInterfaces()[0]).getActualTypeArguments();
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Class<Out> sourceClass = (Class<Out>) getGenericClass(typeParameters[0]);
|
Class<S> sourceClass = (Class<S>) typeParameters[0];
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Class<In> targetClass = (Class<In>) getGenericClass(typeParameters[1]);
|
Class<T> targetClass = (Class<T>) typeParameters[1];
|
||||||
|
|
||||||
this.sourceType = TypeBinder.getType(sourceClass);
|
this.sourceType = TypeBinder.getType(sourceClass);
|
||||||
this.targetType = TypeBinder.getType(targetClass);
|
this.targetType = TypeBinder.getType(targetClass);
|
||||||
|
}else {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Class<S> sourceClass = (Class<S>) getGenericClass(typeParameters[0]);
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Class<T> targetClass = (Class<T>) getGenericClass(typeParameters[1]);
|
||||||
|
this.sourceType = TypeBinder.getType(sourceClass);
|
||||||
|
this.targetType = TypeBinder.getType(targetClass);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,29 +130,29 @@ public final class RelationTypeDefinitionImpl<Out extends BaseEntity, In extends
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected EntityTypeDefinition<Out> source;
|
protected ES source;
|
||||||
protected EntityTypeDefinition<In> target;
|
protected ET target;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityTypeDefinition<Out> getSource() {
|
public ES getSource() {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSource(EntityTypeDefinition<Out> source) {
|
public void setSource(ES source) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityTypeDefinition<In> getTarget() {
|
public ET getTarget() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTarget(EntityTypeDefinition<In> target) {
|
public void setTarget(ET target) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
@Abstract
|
@Abstract
|
||||||
@JsonIgnoreProperties(ignoreUnknown=true)
|
@JsonIgnoreProperties(ignoreUnknown=true)
|
||||||
//@JsonDeserialize(as=TypeDefinitionImpl.class) Do not uncomment to manage subclasses
|
//@JsonDeserialize(as=TypeDefinitionImpl.class) Do not uncomment to manage subclasses
|
||||||
public interface TypeDefinition<ISM extends ISManageable> extends ISManageable {
|
public interface TypeDefinition extends ISManageable {
|
||||||
|
|
||||||
public static final String NAME = "TypeDefinition"; //TypeDefinition.class.getSimpleName();
|
public static final String NAME = "TypeDefinition"; //TypeDefinition.class.getSimpleName();
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
@JsonDeserialize(as = EntityTypeDefinitionImpl.class)
|
@JsonDeserialize(as = EntityTypeDefinitionImpl.class)
|
||||||
public interface EntityTypeDefinition<E extends BaseEntity> extends TypeDefinition<E>, BaseEntity {
|
public interface EntityTypeDefinition<E extends BaseEntity> extends TypeDefinition, BaseEntity {
|
||||||
|
|
||||||
public static final String NAME = "EntityTypeDefinition"; //EntityTypeDefinition.class.getSimpleName();
|
public static final String NAME = "EntityTypeDefinition"; //EntityTypeDefinition.class.getSimpleName();
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
@JsonDeserialize(as = PropertyTypeDefinitionImpl.class)
|
@JsonDeserialize(as = PropertyTypeDefinitionImpl.class)
|
||||||
public interface PropertyTypeDefinition<P extends BaseProperty> extends TypeDefinition<P>, BaseProperty {
|
public interface PropertyTypeDefinition<P extends BaseProperty> extends TypeDefinition, BaseProperty {
|
||||||
|
|
||||||
public static final String NAME = "PropertyTypeDefinition"; // PropertyTypeDefinition.class.getSimpleName();
|
public static final String NAME = "PropertyTypeDefinition"; // PropertyTypeDefinition.class.getSimpleName();
|
||||||
|
|
||||||
|
|
|
@ -10,13 +10,14 @@ import org.gcube.informationsystem.types.reference.TypeDefinition;
|
||||||
import org.gcube.informationsystem.types.reference.entities.EntityTypeDefinition;
|
import org.gcube.informationsystem.types.reference.entities.EntityTypeDefinition;
|
||||||
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
@JsonDeserialize(as = RelationTypeDefinitionImpl.class)
|
@JsonDeserialize(as = RelationTypeDefinitionImpl.class)
|
||||||
public interface RelationTypeDefinition<Out extends BaseEntity, In extends BaseEntity, Rel extends BaseRelation<Out,In>>
|
public interface RelationTypeDefinition<ES extends EntityTypeDefinition<S>, ET extends EntityTypeDefinition<T>, S extends BaseEntity, T extends BaseEntity>
|
||||||
extends TypeDefinition<Rel>, BaseRelation<EntityTypeDefinition<Out>,EntityTypeDefinition<In>> {
|
extends TypeDefinition, BaseRelation<ES,ET> {
|
||||||
|
|
||||||
public static final String NAME = "RelationTypeDefinition"; // PropertyTypeDefiniton.class.getSimpleName();
|
public static final String NAME = "RelationTypeDefinition"; // PropertyTypeDefiniton.class.getSimpleName();
|
||||||
|
|
||||||
|
@ -42,6 +43,20 @@ public interface RelationTypeDefinition<Out extends BaseEntity, In extends BaseE
|
||||||
@ISProperty(name = TypeDefinition.PROPERTIES_PROPERTY, readonly = false, mandatory = true, nullable = false)
|
@ISProperty(name = TypeDefinition.PROPERTIES_PROPERTY, readonly = false, mandatory = true, nullable = false)
|
||||||
public Set<PropertyDefinition> getProperties();
|
public Set<PropertyDefinition> getProperties();
|
||||||
|
|
||||||
|
/*
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
public Header getHeader();
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
public ES getSource();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@JsonIgnore
|
||||||
|
public ET getTarget();
|
||||||
|
|
||||||
/* 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 */
|
||||||
|
|
||||||
public String getSourceType();
|
public String getSourceType();
|
||||||
|
|
|
@ -50,7 +50,6 @@ public abstract class ISMapper {
|
||||||
|
|
||||||
List<Package> packages = new ArrayList<Package>();
|
List<Package> packages = new ArrayList<Package>();
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
Class<TypeDefinition> tdClz = TypeDefinition.class;
|
Class<TypeDefinition> tdClz = TypeDefinition.class;
|
||||||
ISMapper.registerSubtypes(tdClz);
|
ISMapper.registerSubtypes(tdClz);
|
||||||
packages.add(tdClz.getPackage());
|
packages.add(tdClz.getPackage());
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
package org.gcube.informationsystem.types;
|
package org.gcube.informationsystem.types;
|
||||||
|
|
||||||
import org.gcube.informationsystem.base.reference.properties.Header;
|
import org.gcube.informationsystem.base.reference.properties.Header;
|
||||||
|
import org.gcube.informationsystem.context.reference.relations.IsParentOf;
|
||||||
import org.gcube.informationsystem.model.impl.properties.PropagationConstraintImpl;
|
import org.gcube.informationsystem.model.impl.properties.PropagationConstraintImpl;
|
||||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
||||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.AddConstraint;
|
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.AddConstraint;
|
||||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.RemoveConstraint;
|
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.RemoveConstraint;
|
||||||
import org.gcube.informationsystem.types.TypeBinder;
|
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
||||||
|
import org.gcube.informationsystem.types.reference.relations.RelationTypeDefinition;
|
||||||
|
import org.gcube.informationsystem.utils.ISMapper;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -21,6 +24,23 @@ public class SerializationTest {
|
||||||
TypeBinder.serializeType(EntityTest.class);
|
TypeBinder.serializeType(EntityTest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getISParentOfSchema() throws Exception{
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
RelationTypeDefinition relationTypeDefinition = (RelationTypeDefinition) TypeBinder.createTypeDefinition(IsRelatedTo.class);
|
||||||
|
logger.info(ISMapper.marshal(relationTypeDefinition));
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
RelationTypeDefinition rtd = (RelationTypeDefinition) TypeBinder.createTypeDefinition(IsParentOf.class);
|
||||||
|
logger.info(ISMapper.marshal(rtd));
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
RelationTypeDefinition rtdSelf = (RelationTypeDefinition) TypeBinder.createTypeDefinition(RelationTypeDefinition.class);
|
||||||
|
logger.info(ISMapper.marshal(rtdSelf));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetEnumcostants(){
|
public void testGetEnumcostants(){
|
||||||
Class<?> clz = PropagationConstraint.RemoveConstraint.class;
|
Class<?> clz = PropagationConstraint.RemoveConstraint.class;
|
||||||
|
|
Loading…
Reference in New Issue