Added the possibility to get the AccessType from Type definition

This commit is contained in:
Luca Frosini 2021-02-11 17:24:22 +01:00
parent 603e8f2cf7
commit 44056157e1
11 changed files with 92 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package org.gcube.informationsystem.types.impl.entities;
import java.io.StringWriter;
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.base.reference.entities.EntityElement;
import org.gcube.informationsystem.context.reference.entities.Context;
import org.gcube.informationsystem.model.reference.entities.Facet;
@ -97,5 +98,23 @@ public class EntityTypeImpl extends TypeImpl implements EntityType {
}
}
}
@Override
public AccessType getAccessType() {
if(name.compareTo(Context.NAME)==0) {
return AccessType.CONTEXT;
}
if(name.compareTo(EntityType.NAME)==0) {
return AccessType.ENTITY_TYPE;
}
if(name.compareTo(EntityElement.NAME)==0) {
return AccessType.ENTITY_ELEMENT;
}
return AccessType.ENTITY;
}
}

View File

@ -3,6 +3,7 @@ package org.gcube.informationsystem.types.impl.properties;
import java.util.Set;
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
import org.gcube.informationsystem.types.impl.TypeImpl;
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
@ -39,4 +40,13 @@ public final class PropertyTypeImpl<P extends PropertyElement> extends TypeImpl
return properties;
}
@Override
public AccessType getAccessType() {
if(name.compareTo(PropertyElement.NAME)==0) {
return AccessType.PROPERTY_ELEMENT;
}
return AccessType.PROPERTY;
}
}

View File

@ -4,6 +4,7 @@ import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.base.reference.entities.EntityElement;
import org.gcube.informationsystem.base.reference.relations.RelationElement;
import org.gcube.informationsystem.context.reference.relations.IsParentOf;
@ -132,4 +133,21 @@ public class RelationTypeImpl<S extends EntityType, T extends EntityType>
this.target = target;
}
@Override
public AccessType getAccessType() {
if(name.compareTo(IsParentOf.NAME)==0) {
return AccessType.IS_PARENT_OF;
}
if(name.compareTo(RelationType.NAME)==0) {
return AccessType.RELATION_TYPE;
}
if(name.compareTo(RelationElement.NAME)==0) {
return AccessType.RELATION_ELEMENT;
}
return AccessType.RELATION;
}
}

View File

@ -6,6 +6,7 @@ import java.util.Set;
import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnore;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.base.reference.IdentifiableElement;
import org.gcube.informationsystem.types.annotations.Abstract;
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
@ -52,5 +53,10 @@ public interface Type extends IdentifiableElement {
public Set<String> getSuperClasses();
public Set<PropertyDefinition> getProperties();
@JsonIgnore
public default AccessType getAccessType() {
return null;
}
}

View File

@ -4,6 +4,7 @@ import java.util.Set;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.base.reference.entities.EntityElement;
import org.gcube.informationsystem.types.annotations.ISProperty;
import org.gcube.informationsystem.types.impl.entities.EntityTypeImpl;
@ -43,5 +44,9 @@ public interface EntityType extends Type, EntityElement {
/* {@link Type} is just a Java useful class. The type is not created in the IS. Hence the fields must be redefined */
@Override
public default AccessType getAccessType() {
return AccessType.ENTITY_ELEMENT;
}
}

View File

@ -4,6 +4,7 @@ import java.util.Set;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.types.annotations.ISProperty;
import org.gcube.informationsystem.types.impl.entities.FacetTypeImpl;
import org.gcube.informationsystem.types.reference.Change;
@ -26,5 +27,9 @@ public interface FacetType extends EntityType {
@ISProperty(name = Type.PROPERTIES_PROPERTY, readonly = false, mandatory = true, nullable = false)
public Set<PropertyDefinition> getProperties();
@Override
public default AccessType getAccessType() {
return AccessType.FACET;
}
}

View File

@ -3,6 +3,7 @@ package org.gcube.informationsystem.types.reference.entities;
import java.util.List;
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.types.annotations.ISProperty;
import org.gcube.informationsystem.types.impl.entities.ResourceTypeImpl;
import org.gcube.informationsystem.types.reference.Change;
@ -29,4 +30,9 @@ public interface ResourceType extends EntityType {
@ISProperty(name = RESOURCES_PROPERTY, readonly = false, mandatory = true, nullable = false)
public List<LinkedEntity> getResources();
@Override
public default AccessType getAccessType() {
return AccessType.RESOURCE;
}
}

View File

@ -4,6 +4,7 @@ import java.util.Set;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.base.reference.IdentifiableElement;
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
import org.gcube.informationsystem.model.reference.properties.Header;
@ -52,5 +53,8 @@ public interface PropertyType<P extends PropertyElement> extends PropertyElement
public Set<PropertyDefinition> getProperties();
/* TypeDefinition is just a Java useful class. The type is not created in the IS. Hence the fields must be redefined */
@Override
public default AccessType getAccessType() {
return AccessType.PROPERTY_ELEMENT;
}
}

View File

@ -1,6 +1,7 @@
package org.gcube.informationsystem.types.reference.relations;
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.types.impl.relations.ConsistsOfTypeImpl;
import org.gcube.informationsystem.types.reference.Change;
import org.gcube.informationsystem.types.reference.TypeMetadata;
@ -18,4 +19,9 @@ public interface ConsistsOfType extends RelationType<ResourceType, FacetType> {
public static final String NAME = "ConsistsOfType"; // ConsistsOfType.class.getSimpleName();
@Override
public default AccessType getAccessType() {
return AccessType.CONSISTS_OF;
}
}

View File

@ -1,6 +1,7 @@
package org.gcube.informationsystem.types.reference.relations;
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.types.impl.relations.IsRelatedToTypeImpl;
import org.gcube.informationsystem.types.reference.Change;
import org.gcube.informationsystem.types.reference.TypeMetadata;
@ -17,4 +18,9 @@ public interface IsRelatedToType extends RelationType<ResourceType, ResourceType
public static final String NAME = "IsRelatedToType"; // IsRelatedToType.class.getSimpleName();
@Override
public default AccessType getAccessType() {
return AccessType.IS_RELATED_TO;
}
}

View File

@ -4,6 +4,7 @@ import java.util.Set;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.base.reference.relations.RelationElement;
import org.gcube.informationsystem.types.annotations.ISProperty;
import org.gcube.informationsystem.types.impl.relations.RelationTypeImpl;
@ -61,4 +62,9 @@ public interface RelationType<S extends EntityType, T extends EntityType>
@JsonGetter(value=TARGET_PROPERTY)
public String getTargetType();*/
@Override
public default AccessType getAccessType() {
return AccessType.RELATION_ELEMENT;
}
}