Fixing imports and code to be aligned with model reorganization
This commit is contained in:
parent
d77456ad98
commit
d69f0435bc
|
@ -7,6 +7,7 @@ import java.util.List;
|
|||
import org.gcube.informationsystem.base.reference.ISManageable;
|
||||
import org.gcube.informationsystem.types.impl.TypeDefinitionImpl;
|
||||
import org.gcube.informationsystem.types.reference.TypeDefinition;
|
||||
import org.gcube.informationsystem.utils.ISMapper;
|
||||
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
@ -19,14 +20,17 @@ public class TypeBinder {
|
|||
private final static String NAME = "NAME";
|
||||
|
||||
public static <ISM extends ISManageable> String serializeTypeDefinition(TypeDefinition<ISM> typeDefinition) throws Exception{
|
||||
/*
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String json = mapper.writeValueAsString(typeDefinition);
|
||||
*/
|
||||
String json = ISMapper.marshal(typeDefinition);
|
||||
return json;
|
||||
}
|
||||
|
||||
public static <ISM extends ISManageable> String serializeType(Class<ISM> type) throws Exception{
|
||||
TypeDefinition<ISM> typeDefinition = createTypeDefinition(type);
|
||||
return serializeTypeDefinition(typeDefinition);
|
||||
return ISMapper.marshal(typeDefinition);
|
||||
}
|
||||
|
||||
public static <ISM extends ISManageable> TypeDefinition<ISM> deserializeTypeDefinition(String json) throws Exception{
|
||||
|
|
|
@ -28,7 +28,7 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
|||
|
||||
// @JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.ANY)
|
||||
@JsonTypeName(value=TypeDefinition.NAME)
|
||||
public abstract class TypeDefinitionImpl<ISM extends ISManageable> extends ISManageableImpl implements TypeDefinition<ISM> {
|
||||
public class TypeDefinitionImpl<ISM extends ISManageable> extends ISManageableImpl implements TypeDefinition<ISM> {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
|
@ -103,6 +103,8 @@ public abstract class TypeDefinitionImpl<ISM extends ISManageable> extends ISMan
|
|||
return new RelationTypeDefinitionImpl(clz);
|
||||
} else if(BaseProperty.class.isAssignableFrom(clz)){
|
||||
return new PropertyTypeDefinitionImpl(clz);
|
||||
} else if(TypeDefinition.class.isAssignableFrom(clz)) {
|
||||
return new TypeDefinitionImpl(clz);
|
||||
} else {
|
||||
throw new RuntimeException("Serialization required");
|
||||
}
|
||||
|
|
|
@ -4,10 +4,12 @@ import java.io.StringWriter;
|
|||
|
||||
import org.gcube.informationsystem.base.reference.entities.BaseEntity;
|
||||
import org.gcube.informationsystem.base.reference.properties.Header;
|
||||
import org.gcube.informationsystem.context.reference.entities.Context;
|
||||
import org.gcube.informationsystem.model.reference.entities.Entity;
|
||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.types.impl.TypeDefinitionImpl;
|
||||
import org.gcube.informationsystem.types.reference.TypeDefinition;
|
||||
import org.gcube.informationsystem.types.reference.entities.EntityTypeDefinition;
|
||||
import org.gcube.informationsystem.utils.ISMapper;
|
||||
|
||||
|
@ -34,8 +36,13 @@ public class EntityTypeDefinitionImpl<E extends BaseEntity> extends TypeDefiniti
|
|||
@SuppressWarnings({"unchecked"})
|
||||
Class<? extends Facet> c = (Class<? extends Facet>) clz;
|
||||
this.superClasses = retrieveSuperClasses(c, Facet.class, Entity.NAME);
|
||||
} else {
|
||||
} else if(EntityTypeDefinition.class.isAssignableFrom(clz)){
|
||||
this.superClasses = retrieveSuperClasses(clz, BaseEntity.class, VERTEX_CLASS_NAME);
|
||||
this.superClasses.add(TypeDefinition.class.getSimpleName());
|
||||
} else if(Context.class.isAssignableFrom(clz)){
|
||||
this.superClasses = retrieveSuperClasses(clz, BaseEntity.class, VERTEX_CLASS_NAME);
|
||||
} else {
|
||||
throw new RuntimeException("Type Hierachy Error");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.informationsystem.types.impl.properties;
|
|||
|
||||
import org.gcube.informationsystem.base.reference.properties.BaseProperty;
|
||||
import org.gcube.informationsystem.types.impl.TypeDefinitionImpl;
|
||||
import org.gcube.informationsystem.types.reference.TypeDefinition;
|
||||
import org.gcube.informationsystem.types.reference.properties.PropertyTypeDefiniton;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
@ -17,6 +18,9 @@ public class PropertyTypeDefinitionImpl<P extends BaseProperty> extends TypeDefi
|
|||
public PropertyTypeDefinitionImpl(Class<P> clz) {
|
||||
super(clz);
|
||||
this.superClasses = retrieveSuperClasses(clz, BaseProperty.class, clz == BaseProperty.class ? null : BaseProperty.NAME);
|
||||
if(PropertyTypeDefiniton.class.isAssignableFrom(clz)) {
|
||||
this.superClasses.add(TypeDefinition.class.getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -5,11 +5,13 @@ import java.io.StringWriter;
|
|||
import org.gcube.informationsystem.base.reference.entities.BaseEntity;
|
||||
import org.gcube.informationsystem.base.reference.properties.Header;
|
||||
import org.gcube.informationsystem.base.reference.relations.BaseRelation;
|
||||
import org.gcube.informationsystem.context.reference.relations.IsParentOf;
|
||||
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
|
||||
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
||||
import org.gcube.informationsystem.model.reference.relations.Relation;
|
||||
import org.gcube.informationsystem.types.TypeBinder;
|
||||
import org.gcube.informationsystem.types.impl.TypeDefinitionImpl;
|
||||
import org.gcube.informationsystem.types.reference.TypeDefinition;
|
||||
import org.gcube.informationsystem.types.reference.entities.EntityTypeDefinition;
|
||||
import org.gcube.informationsystem.types.reference.relations.RelationTypeDefinition;
|
||||
import org.gcube.informationsystem.utils.ISMapper;
|
||||
|
@ -44,8 +46,13 @@ public class RelationTypeDefinitionImpl<Out extends BaseEntity, In extends BaseE
|
|||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
Class<? extends ConsistsOf> c = (Class<? extends ConsistsOf>) clz;
|
||||
this.superClasses = retrieveSuperClasses(c, ConsistsOf.class, Relation.NAME);
|
||||
} else {
|
||||
} else if(RelationTypeDefinition.class.isAssignableFrom(clz)){
|
||||
this.superClasses = retrieveSuperClasses(clz, BaseRelation.class, EDGE_CLASS_NAME);
|
||||
this.superClasses.add(TypeDefinition.class.getSimpleName());
|
||||
} else if(IsParentOf.class.isAssignableFrom(clz)){
|
||||
this.superClasses = retrieveSuperClasses(clz, BaseRelation.class, EDGE_CLASS_NAME);
|
||||
} else {
|
||||
throw new RuntimeException("Type Hierachy Error");
|
||||
}
|
||||
|
||||
java.lang.reflect.Type[] typeParameters = clz.getTypeParameters();
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Set;
|
|||
|
||||
import org.gcube.informationsystem.base.reference.ISManageable;
|
||||
import org.gcube.informationsystem.types.annotations.Abstract;
|
||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
@ -13,16 +14,27 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|||
//@JsonDeserialize(as=TypeDefinitionImpl.class) Do not uncomment to manage subclasses
|
||||
public interface TypeDefinition<ISM extends ISManageable> extends ISManageable {
|
||||
|
||||
public static final String NAME = "TypeDefinition"; //Entity.class.getSimpleName();
|
||||
public static final String NAME = "TypeDefinition"; //TypeDefinition.class.getSimpleName();
|
||||
|
||||
public static final String NAME_PROPERTY = "name";
|
||||
public static final String DESCRIPTION_PROPERTY = "description";
|
||||
public static final String ABSTRACT_PROPERTY = "abstract";
|
||||
public static final String SUPERCLASSES_PROPERTY = "superClasses";
|
||||
public static final String PROPERTIES_PROPERTY = "properties";
|
||||
|
||||
@ISProperty(name = NAME_PROPERTY, readonly = true, mandatory = true, nullable = false)
|
||||
public String getName();
|
||||
|
||||
|
||||
@ISProperty(name = DESCRIPTION_PROPERTY, readonly = false, mandatory = true, nullable = false)
|
||||
public String getDescription();
|
||||
|
||||
|
||||
@ISProperty(name = ABSTRACT_PROPERTY, readonly = true, mandatory = true, nullable = false)
|
||||
public boolean isAbstract();
|
||||
|
||||
@ISProperty(name = SUPERCLASSES_PROPERTY, readonly = true, mandatory = true, nullable = false)
|
||||
public Set<String> getSuperClasses();
|
||||
|
||||
@ISProperty(name = PROPERTIES_PROPERTY, readonly = false, mandatory = true, nullable = false)
|
||||
public Set<PropertyDefinition> getProperties();
|
||||
|
||||
}
|
||||
|
|
|
@ -16,4 +16,29 @@ public interface PropertyDefinition extends BaseProperty {
|
|||
|
||||
public static final String NAME = "PropertyDefinition"; // PropertyDefinition.class.getSimpleName();
|
||||
|
||||
|
||||
|
||||
|
||||
public String getName();
|
||||
|
||||
public String getDescription();
|
||||
|
||||
public boolean isMandatory();
|
||||
|
||||
public boolean isReadonly();
|
||||
|
||||
public boolean isNotnull();
|
||||
|
||||
public Integer getMax();
|
||||
|
||||
public Integer getMin();
|
||||
|
||||
public String getRegexp();
|
||||
|
||||
public Integer getLinkedType();
|
||||
|
||||
public String getLinkedClass();
|
||||
|
||||
public Integer getType();
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue