Fixed Type Mapper Name
This commit is contained in:
parent
8c020591eb
commit
fe31ce5f25
|
@ -24,7 +24,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class TypeBinder {
|
||||
public class TypeMapper {
|
||||
|
||||
private final static String NAME = "NAME";
|
||||
|
|
@ -6,12 +6,12 @@ import java.lang.annotation.RetentionPolicy;
|
|||
import java.lang.annotation.Target;
|
||||
|
||||
import org.gcube.informationsystem.model.reference.entities.Entity;
|
||||
import org.gcube.informationsystem.types.TypeBinder;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
* It is used by {@link TypeBinder} to identify which getter method are
|
||||
* It is used by {@link TypeMapper} to identify which getter method are
|
||||
* related to and {@link Entity} {@link PropertyDefinition}.
|
||||
* The name of the property is obtained by removing "get" or "is" from method
|
||||
* name and lower casing the first letter.
|
||||
|
|
|
@ -8,14 +8,14 @@ import java.lang.annotation.Target;
|
|||
import org.gcube.informationsystem.model.reference.entities.Entity;
|
||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
|
||||
import org.gcube.informationsystem.types.TypeBinder;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
* It is used by {@link TypeBinder} to identify which getter method are
|
||||
* It is used by {@link TypeMapper} to identify which getter method are
|
||||
* related to and {@link Entity} {@link PropertyDefinition}.
|
||||
* The name of the property is obtained by removing "get" or "is" from method
|
||||
* name and lower casing the first letter.
|
||||
|
|
|
@ -8,14 +8,14 @@ import java.lang.annotation.Target;
|
|||
import org.gcube.informationsystem.model.reference.entities.Entity;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
||||
import org.gcube.informationsystem.types.TypeBinder;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
* It is used by {@link TypeBinder} to identify which getter method are
|
||||
* It is used by {@link TypeMapper} to identify which getter method are
|
||||
* related to and {@link Entity} {@link PropertyDefinition}.
|
||||
* The name of the property is obtained by removing "get" or "is" from method
|
||||
* name and lower casing the first letter.
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
|||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
||||
import org.gcube.informationsystem.base.reference.relations.RelationElement;
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.types.TypeBinder;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.types.annotations.Abstract;
|
||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||
import org.gcube.informationsystem.types.impl.entities.EntityTypeImpl;
|
||||
|
@ -68,7 +68,7 @@ public class TypeImpl implements Type {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends Element> clz = (Class<? extends Element>) interfaceClass;
|
||||
interfaceList.add(TypeBinder.getType(clz));
|
||||
interfaceList.add(TypeMapper.getType(clz));
|
||||
}
|
||||
|
||||
return interfaceList;
|
||||
|
@ -132,8 +132,8 @@ public class TypeImpl implements Type {
|
|||
protected TypeImpl() {}
|
||||
|
||||
protected TypeImpl(Class<? extends Element> clz) {
|
||||
this.name = TypeBinder.getType(clz);
|
||||
this.description = TypeBinder.getStaticStringFieldByName(clz, DESCRIPTION, "");
|
||||
this.name = TypeMapper.getType(clz);
|
||||
this.description = TypeMapper.getStaticStringFieldByName(clz, DESCRIPTION, "");
|
||||
this.abstractType = false;
|
||||
|
||||
if(clz.isAnnotationPresent(Abstract.class)){
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.List;
|
|||
|
||||
import org.gcube.informationsystem.model.reference.entities.Entity;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.types.TypeBinder;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.types.annotations.ResourceSchema;
|
||||
import org.gcube.informationsystem.types.annotations.ResourceSchemaEntry;
|
||||
import org.gcube.informationsystem.types.annotations.ResourceSchemaRelatedEntry;
|
||||
|
@ -48,9 +48,9 @@ public class ResourceTypeImpl extends EntityTypeImpl implements ResourceType {
|
|||
ResourceSchema[] resourceSchemaArray = clz.getAnnotationsByType(ResourceSchema.class);
|
||||
for(ResourceSchemaEntry resourceSchemaEntry : resourceSchemaArray[0].facets()) {
|
||||
LinkedEntityImpl resourceSchemaEntryDefinition = new LinkedEntityImpl();
|
||||
resourceSchemaEntryDefinition.setSource(TypeBinder.getType(clz));
|
||||
resourceSchemaEntryDefinition.setRelation(TypeBinder.getType(resourceSchemaEntry.relation()));
|
||||
resourceSchemaEntryDefinition.setTarget(TypeBinder.getType(resourceSchemaEntry.facet()));
|
||||
resourceSchemaEntryDefinition.setSource(TypeMapper.getType(clz));
|
||||
resourceSchemaEntryDefinition.setRelation(TypeMapper.getType(resourceSchemaEntry.relation()));
|
||||
resourceSchemaEntryDefinition.setTarget(TypeMapper.getType(resourceSchemaEntry.facet()));
|
||||
resourceSchemaEntryDefinition.setDescription(resourceSchemaEntry.description());
|
||||
resourceSchemaEntryDefinition.setMin(resourceSchemaEntry.min());
|
||||
resourceSchemaEntryDefinition.setMax(resourceSchemaEntry.max());
|
||||
|
@ -58,9 +58,9 @@ public class ResourceTypeImpl extends EntityTypeImpl implements ResourceType {
|
|||
}
|
||||
for(ResourceSchemaRelatedEntry resourceSchemaRelatedEntry : resourceSchemaArray[0].resources()) {
|
||||
LinkedEntity resourceSchemaEntryDefinition = new LinkedEntityImpl();
|
||||
resourceSchemaEntryDefinition.setSource(TypeBinder.getType(resourceSchemaRelatedEntry.source()));
|
||||
resourceSchemaEntryDefinition.setRelation(TypeBinder.getType(resourceSchemaRelatedEntry.relation()));
|
||||
resourceSchemaEntryDefinition.setTarget(TypeBinder.getType(resourceSchemaRelatedEntry.target()));
|
||||
resourceSchemaEntryDefinition.setSource(TypeMapper.getType(resourceSchemaRelatedEntry.source()));
|
||||
resourceSchemaEntryDefinition.setRelation(TypeMapper.getType(resourceSchemaRelatedEntry.relation()));
|
||||
resourceSchemaEntryDefinition.setTarget(TypeMapper.getType(resourceSchemaRelatedEntry.target()));
|
||||
resourceSchemaEntryDefinition.setDescription(resourceSchemaRelatedEntry.description());
|
||||
resourceSchemaEntryDefinition.setMin(resourceSchemaRelatedEntry.min());
|
||||
resourceSchemaEntryDefinition.setMax(resourceSchemaRelatedEntry.max());
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.gcube.informationsystem.base.reference.Element;
|
|||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
||||
import org.gcube.informationsystem.types.OrientDBType;
|
||||
import org.gcube.informationsystem.types.OrientDBType.OType;
|
||||
import org.gcube.informationsystem.types.TypeBinder;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.types.annotations.ISProperty;
|
||||
import org.gcube.informationsystem.types.impl.TypeImpl;
|
||||
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
||||
|
@ -86,7 +86,7 @@ public final class PropertyDefinitionImpl implements PropertyDefinition {
|
|||
|
||||
if(PropertyElement.class.isAssignableFrom(type)){
|
||||
if(type != PropertyElement.class){
|
||||
this.linkedClass = TypeBinder.getType(type);
|
||||
this.linkedClass = TypeMapper.getType(type);
|
||||
}
|
||||
}else if (OrientDBType.getTypeByClass(type)!=null) {
|
||||
this.type = OrientDBType.getTypeByClass(type).getIntValue();
|
||||
|
@ -108,7 +108,7 @@ public final class PropertyDefinitionImpl implements PropertyDefinition {
|
|||
if(linkedOType!=null){
|
||||
this.linkedType = linkedOType.getIntValue();
|
||||
}else{
|
||||
this.linkedClass = TypeBinder.getType(genericClass);
|
||||
this.linkedClass = TypeMapper.getType(genericClass);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.gcube.informationsystem.ContextTest;
|
|||
import org.gcube.informationsystem.model.impl.properties.EncryptedImpl;
|
||||
import org.gcube.informationsystem.model.reference.properties.Encrypted;
|
||||
import org.gcube.informationsystem.model.reference.properties.Property;
|
||||
import org.gcube.informationsystem.types.TypeBinder;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.utils.ElementMapper;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -75,7 +75,7 @@ public class EncryptedTest extends ContextTest {
|
|||
@Test
|
||||
public void testClassDefinition() throws Exception {
|
||||
Class<? extends Property> clz = Encrypted.class;
|
||||
String json = TypeBinder.serializeType(clz);
|
||||
String json = TypeMapper.serializeType(clz);
|
||||
logger.trace(json);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,21 +24,21 @@ public class EntitySchemaDefinition {
|
|||
@Test
|
||||
public void test() throws Exception {
|
||||
Class<? extends PropertyElement> clz = Header.class;
|
||||
String json = TypeBinder.serializeType(clz);
|
||||
String json = TypeMapper.serializeType(clz);
|
||||
logger.trace(json);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRelationSerialization() throws Exception {
|
||||
Class<? extends Element> clz = IsRelatedTo.class;
|
||||
String json = TypeBinder.serializeType(clz);
|
||||
String json = TypeMapper.serializeType(clz);
|
||||
logger.trace(json);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResourceSerialization() throws Exception {
|
||||
Class<? extends Resource> clz = Resource.class;
|
||||
String json = TypeBinder.serializeType(clz);
|
||||
String json = TypeMapper.serializeType(clz);
|
||||
logger.trace(json);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,109 +39,109 @@ public class SerializationTest {
|
|||
|
||||
@Test
|
||||
public void serialize() throws Exception{
|
||||
TypeBinder.serializeType(EntityTest.class);
|
||||
TypeMapper.serializeType(EntityTest.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void makeFacetTypeDefinition() throws Exception{
|
||||
EntityType facetTypeDefinitionSelf = (EntityType) TypeBinder.createTypeDefinition(FacetType.class);
|
||||
EntityType facetTypeDefinitionSelf = (EntityType) TypeMapper.createTypeDefinition(FacetType.class);
|
||||
logger.info(ElementMapper.marshal(facetTypeDefinitionSelf));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void makeResourceTypeDefinition() throws Exception{
|
||||
EntityType resourceTypeDefinitionSelf = (EntityType) TypeBinder.createTypeDefinition(ResourceType.class);
|
||||
EntityType resourceTypeDefinitionSelf = (EntityType) TypeMapper.createTypeDefinition(ResourceType.class);
|
||||
logger.info(ElementMapper.marshal(resourceTypeDefinitionSelf));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPropertyTypeDefinition() throws Exception{
|
||||
@SuppressWarnings("unchecked")
|
||||
PropertyType<PropertyElement> basePropertyTypeDefinition = (PropertyType<PropertyElement>) TypeBinder.createTypeDefinition(PropertyElement.class);
|
||||
PropertyType<PropertyElement> basePropertyTypeDefinition = (PropertyType<PropertyElement>) TypeMapper.createTypeDefinition(PropertyElement.class);
|
||||
logger.info(ElementMapper.marshal(basePropertyTypeDefinition));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
PropertyType<Property> propertyTypeDefinition = (PropertyType<Property>) TypeBinder.createTypeDefinition(Property.class);
|
||||
PropertyType<Property> propertyTypeDefinition = (PropertyType<Property>) TypeMapper.createTypeDefinition(Property.class);
|
||||
logger.info(ElementMapper.marshal(propertyTypeDefinition));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
PropertyType<Header> headerTypeDefinition = (PropertyType<Header>) TypeBinder.createTypeDefinition(Header.class);
|
||||
PropertyType<Header> headerTypeDefinition = (PropertyType<Header>) TypeMapper.createTypeDefinition(Header.class);
|
||||
logger.info(ElementMapper.marshal(headerTypeDefinition));
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
PropertyType<PropagationConstraint> propagationConstraintDefinition = (PropertyType<PropagationConstraint>) TypeBinder.createTypeDefinition(PropagationConstraint.class);
|
||||
PropertyType<PropagationConstraint> propagationConstraintDefinition = (PropertyType<PropagationConstraint>) TypeMapper.createTypeDefinition(PropagationConstraint.class);
|
||||
logger.info(ElementMapper.marshal(propagationConstraintDefinition));
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
PropertyType<Encrypted> encryptedTypeDefinition = (PropertyType<Encrypted>) TypeBinder.createTypeDefinition(Encrypted.class);
|
||||
PropertyType<Encrypted> encryptedTypeDefinition = (PropertyType<Encrypted>) TypeMapper.createTypeDefinition(Encrypted.class);
|
||||
logger.info(ElementMapper.marshal(encryptedTypeDefinition));
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
PropertyType<PropertyDefinition> propertyDefinition = (PropertyType<PropertyDefinition>) TypeBinder.createTypeDefinition(PropertyDefinition.class);
|
||||
PropertyType<PropertyDefinition> propertyDefinition = (PropertyType<PropertyDefinition>) TypeMapper.createTypeDefinition(PropertyDefinition.class);
|
||||
logger.info(ElementMapper.marshal(propertyDefinition));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
PropertyType<LinkedEntity> resourceEntryDefinition = (PropertyType<LinkedEntity>) TypeBinder.createTypeDefinition(LinkedEntity.class);
|
||||
PropertyType<LinkedEntity> resourceEntryDefinition = (PropertyType<LinkedEntity>) TypeMapper.createTypeDefinition(LinkedEntity.class);
|
||||
logger.info(ElementMapper.marshal(resourceEntryDefinition));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEntityTypeDefinition() throws Exception{
|
||||
EntityType baseEntityTypeDefinition = (EntityType) TypeBinder.createTypeDefinition(EntityElement.class);
|
||||
EntityType baseEntityTypeDefinition = (EntityType) TypeMapper.createTypeDefinition(EntityElement.class);
|
||||
logger.info(ElementMapper.marshal(baseEntityTypeDefinition));
|
||||
|
||||
EntityType entityTypeDefinition = (EntityType) TypeBinder.createTypeDefinition(Entity.class);
|
||||
EntityType entityTypeDefinition = (EntityType) TypeMapper.createTypeDefinition(Entity.class);
|
||||
logger.info(ElementMapper.marshal(entityTypeDefinition));
|
||||
|
||||
ResourceType resourceTypeDefinition = (ResourceType) TypeBinder.createTypeDefinition(Resource.class);
|
||||
ResourceType resourceTypeDefinition = (ResourceType) TypeMapper.createTypeDefinition(Resource.class);
|
||||
logger.info(ElementMapper.marshal(resourceTypeDefinition));
|
||||
|
||||
FacetType facetTypeDefinition = (FacetType) TypeBinder.createTypeDefinition(Facet.class);
|
||||
FacetType facetTypeDefinition = (FacetType) TypeMapper.createTypeDefinition(Facet.class);
|
||||
logger.info(ElementMapper.marshal(facetTypeDefinition));
|
||||
|
||||
EntityType contextTypeDefinition = (EntityType) TypeBinder.createTypeDefinition(Context.class);
|
||||
EntityType contextTypeDefinition = (EntityType) TypeMapper.createTypeDefinition(Context.class);
|
||||
logger.info(ElementMapper.marshal(contextTypeDefinition));
|
||||
|
||||
EntityType entityTypeDefinitionSelf = (EntityType) TypeBinder.createTypeDefinition(EntityType.class);
|
||||
EntityType entityTypeDefinitionSelf = (EntityType) TypeMapper.createTypeDefinition(EntityType.class);
|
||||
logger.info(ElementMapper.marshal(entityTypeDefinitionSelf));
|
||||
|
||||
EntityType resourceTypeDefinitionSelf = (EntityType) TypeBinder.createTypeDefinition(ResourceType.class);
|
||||
EntityType resourceTypeDefinitionSelf = (EntityType) TypeMapper.createTypeDefinition(ResourceType.class);
|
||||
logger.info(ElementMapper.marshal(resourceTypeDefinitionSelf));
|
||||
|
||||
EntityType facetTypeDefinitionSelf = (EntityType) TypeBinder.createTypeDefinition(FacetType.class);
|
||||
EntityType facetTypeDefinitionSelf = (EntityType) TypeMapper.createTypeDefinition(FacetType.class);
|
||||
logger.info(ElementMapper.marshal(facetTypeDefinitionSelf));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRelationTypeDefinition() throws Exception{
|
||||
@SuppressWarnings("unchecked")
|
||||
RelationType<EntityType,EntityType> relationTypeDefinition = (RelationType<EntityType,EntityType>) TypeBinder.createTypeDefinition(Relation.class);
|
||||
RelationType<EntityType,EntityType> relationTypeDefinition = (RelationType<EntityType,EntityType>) TypeMapper.createTypeDefinition(Relation.class);
|
||||
logger.info(ElementMapper.marshal(relationTypeDefinition));
|
||||
|
||||
IsRelatedToType isRelatedToTypeDefinition = (IsRelatedToType) TypeBinder.createTypeDefinition(IsRelatedTo.class);
|
||||
IsRelatedToType isRelatedToTypeDefinition = (IsRelatedToType) TypeMapper.createTypeDefinition(IsRelatedTo.class);
|
||||
logger.info(ElementMapper.marshal(isRelatedToTypeDefinition));
|
||||
|
||||
ConsistsOfType consistsOfTypeDefinition = (ConsistsOfType) TypeBinder.createTypeDefinition(ConsistsOf.class);
|
||||
ConsistsOfType consistsOfTypeDefinition = (ConsistsOfType) TypeMapper.createTypeDefinition(ConsistsOf.class);
|
||||
logger.info(ElementMapper.marshal(consistsOfTypeDefinition));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
RelationType<EntityType,EntityType> isParentOfTypeDefinition = (RelationType<EntityType,EntityType>) TypeBinder.createTypeDefinition(IsParentOf.class);
|
||||
RelationType<EntityType,EntityType> isParentOfTypeDefinition = (RelationType<EntityType,EntityType>) TypeMapper.createTypeDefinition(IsParentOf.class);
|
||||
logger.info(ElementMapper.marshal(isParentOfTypeDefinition));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
RelationType<EntityType,EntityType> rtdSelf = (RelationType<EntityType,EntityType>) TypeBinder.createTypeDefinition(RelationType.class);
|
||||
RelationType<EntityType,EntityType> rtdSelf = (RelationType<EntityType,EntityType>) TypeMapper.createTypeDefinition(RelationType.class);
|
||||
logger.info(ElementMapper.marshal(rtdSelf));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
RelationType<EntityType,EntityType> isRelatedToTypeDefinitionSelf = (RelationType<EntityType,EntityType>) TypeBinder.createTypeDefinition(IsRelatedToType.class);
|
||||
RelationType<EntityType,EntityType> isRelatedToTypeDefinitionSelf = (RelationType<EntityType,EntityType>) TypeMapper.createTypeDefinition(IsRelatedToType.class);
|
||||
logger.info(ElementMapper.marshal(isRelatedToTypeDefinitionSelf));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
RelationType<EntityType,EntityType> consistsOfTypeDefinitionSelf = (RelationType<EntityType,EntityType>) TypeBinder.createTypeDefinition(ConsistsOfType.class);
|
||||
RelationType<EntityType,EntityType> consistsOfTypeDefinitionSelf = (RelationType<EntityType,EntityType>) TypeMapper.createTypeDefinition(ConsistsOfType.class);
|
||||
logger.info(ElementMapper.marshal(consistsOfTypeDefinitionSelf));
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ public class SerializationTest {
|
|||
|
||||
@Test
|
||||
public void testTypeSerialization() throws Exception {
|
||||
String serialized = TypeBinder.serializeType(Header.class);
|
||||
String serialized = TypeMapper.serializeType(Header.class);
|
||||
logger.info(serialized);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue