Added GCubeResource as base class for all resources declared in gCube
Model. GCubeResource declares as requirements a facet with IsIdentifiedBy consist of relation.
This commit is contained in:
parent
6a7b95b9a2
commit
c9b6f5aba3
|
@ -0,0 +1,37 @@
|
|||
package org.gcube.resourcemanagement.model.impl.entities.resources;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.informationsystem.model.impl.entities.ResourceImpl;
|
||||
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.resourcemanagement.model.reference.entities.resources.GCubeResource;
|
||||
import org.gcube.resourcemanagement.model.reference.relations.consistsof.IsIdentifiedBy;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonTypeName(value=GCubeResource.NAME)
|
||||
public abstract class GCubeResourceImpl extends ResourceImpl implements GCubeResource {
|
||||
|
||||
/**
|
||||
* Generated Serial version UID
|
||||
*/
|
||||
private static final long serialVersionUID = 8005284153516839231L;
|
||||
|
||||
@Override
|
||||
public List<? extends Facet> getIdentificationFacets() {
|
||||
List<Facet> identificationFacets = new ArrayList<>();
|
||||
for(ConsistsOf<? extends Resource, ? extends Facet> consistsOfInstance : consistsOfList){
|
||||
if (IsIdentifiedBy.class.isAssignableFrom(consistsOfInstance.getClass())) {
|
||||
identificationFacets.add(consistsOfInstance.getTarget());
|
||||
}
|
||||
}
|
||||
return identificationFacets;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package org.gcube.resourcemanagement.model.reference.entities.resources;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.types.annotations.Abstract;
|
||||
import org.gcube.informationsystem.types.annotations.ResourceSchema;
|
||||
import org.gcube.informationsystem.types.annotations.ResourceSchemaEntry;
|
||||
import org.gcube.resourcemanagement.model.impl.entities.resources.GCubeResourceImpl;
|
||||
import org.gcube.resourcemanagement.model.reference.relations.consistsof.IsIdentifiedBy;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@Abstract
|
||||
@JsonDeserialize(as=GCubeResourceImpl.class)
|
||||
@ResourceSchema({@ResourceSchemaEntry(consistOfType=IsIdentifiedBy.class, min=1)})
|
||||
public interface GCubeResource extends Resource {
|
||||
|
||||
public static final String NAME = "GCubeResource"; // GCubeResource.class.getSimpleName();
|
||||
public static final String DESCRIPTION = "Base Class for any gCube Resource";
|
||||
public static final String VERSION = "1.0.0";
|
||||
|
||||
@JsonIgnore
|
||||
public List<? extends Facet> getIdentificationFacets();
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue