Fixed API interface
This commit is contained in:
parent
c171876186
commit
8bccea574f
|
@ -9,6 +9,7 @@ import org.gcube.informationsystem.base.reference.Direction;
|
||||||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||||
import org.gcube.informationsystem.model.knowledge.ModelKnowledge;
|
import org.gcube.informationsystem.model.knowledge.ModelKnowledge;
|
||||||
import org.gcube.informationsystem.model.reference.ERElement;
|
import org.gcube.informationsystem.model.reference.ERElement;
|
||||||
|
import org.gcube.informationsystem.model.reference.ModelElement;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Entity;
|
import org.gcube.informationsystem.model.reference.entities.Entity;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||||
|
@ -72,24 +73,24 @@ public interface ResourceRegistryClient extends RequestInfo {
|
||||||
|
|
||||||
public boolean existType(String typeName) throws ResourceRegistryException;
|
public boolean existType(String typeName) throws ResourceRegistryException;
|
||||||
|
|
||||||
public <ERElem extends ERElement> boolean existType(Class<ERElem> clazz) throws ResourceRegistryException;
|
public <ME extends ModelElement> boolean existType(Class<ME> clazz) throws ResourceRegistryException;
|
||||||
|
|
||||||
public String getType(String typeName, Boolean polymorphic)
|
public String getType(String typeName, Boolean polymorphic)
|
||||||
throws SchemaNotFoundException, ResourceRegistryException;
|
throws SchemaNotFoundException, ResourceRegistryException;
|
||||||
|
|
||||||
public <ERElem extends ERElement> List<Type> getType(Class<ERElem> clazz, Boolean polymorphic)
|
|
||||||
throws SchemaNotFoundException, ResourceRegistryException;
|
|
||||||
|
|
||||||
public String getType(String typeName, int level)
|
public String getType(String typeName, int level)
|
||||||
throws SchemaNotFoundException, ResourceRegistryException;
|
throws SchemaNotFoundException, ResourceRegistryException;
|
||||||
|
|
||||||
public <ERElem extends ERElement> List<Type> getType(Class<ERElem> clazz, int level)
|
public <ME extends ModelElement> List<Type> getType(Class<ME> clazz, Boolean polymorphic)
|
||||||
throws SchemaNotFoundException, ResourceRegistryException;
|
throws SchemaNotFoundException, ResourceRegistryException;
|
||||||
|
|
||||||
public <ERElem extends ERElement> Node<Type> getTypeTreeNode(String typeName)
|
public <ME extends ModelElement> List<Type> getType(Class<ME> clazz, int level)
|
||||||
throws SchemaNotFoundException, ResourceRegistryException;
|
throws SchemaNotFoundException, ResourceRegistryException;
|
||||||
|
|
||||||
public <ERElem extends ERElement> Node<Type> getTypeTreeNode(Class<ERElem> clazz)
|
public <ME extends ModelElement> Node<Type> getTypeTreeNode(Class<ME> clazz)
|
||||||
|
throws SchemaNotFoundException, ResourceRegistryException;
|
||||||
|
|
||||||
|
public Node<Type> getTypeTreeNode(String typeName)
|
||||||
throws SchemaNotFoundException, ResourceRegistryException;
|
throws SchemaNotFoundException, ResourceRegistryException;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.gcube.informationsystem.base.reference.Direction;
|
||||||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||||
import org.gcube.informationsystem.model.knowledge.ModelKnowledge;
|
import org.gcube.informationsystem.model.knowledge.ModelKnowledge;
|
||||||
import org.gcube.informationsystem.model.reference.ERElement;
|
import org.gcube.informationsystem.model.reference.ERElement;
|
||||||
|
import org.gcube.informationsystem.model.reference.ModelElement;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Entity;
|
import org.gcube.informationsystem.model.reference.entities.Entity;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||||
|
@ -362,7 +363,7 @@ public class ResourceRegistryClientImpl extends BaseRequestInfo implements Resou
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <ERElem extends ERElement> boolean existType(Class<ERElem> clazz) throws ResourceRegistryException {
|
public <ME extends ModelElement> boolean existType(Class<ME> clazz) throws ResourceRegistryException {
|
||||||
return existType(TypeUtility.getTypeName(clazz));
|
return existType(TypeUtility.getTypeName(clazz));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,18 +461,6 @@ public class ResourceRegistryClientImpl extends BaseRequestInfo implements Resou
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public <ERElem extends ERElement> List<Type> getType(Class<ERElem> clazz, Boolean polymorphic)
|
|
||||||
throws SchemaNotFoundException, ResourceRegistryException {
|
|
||||||
try {
|
|
||||||
String typeName = TypeUtility.getTypeName(clazz);
|
|
||||||
return getTypeFromTypesKnowledge(typeName, polymorphic);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new ResourceRegistryException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getType(String typeName, int level) throws SchemaNotFoundException, ResourceRegistryException {
|
public String getType(String typeName, int level) throws SchemaNotFoundException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
|
@ -485,7 +474,18 @@ public class ResourceRegistryClientImpl extends BaseRequestInfo implements Resou
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <ERElem extends ERElement> List<Type> getType(Class<ERElem> clazz, int level)
|
public <ME extends ModelElement> List<Type> getType(Class<ME> clazz, Boolean polymorphic)
|
||||||
|
throws SchemaNotFoundException, ResourceRegistryException {
|
||||||
|
try {
|
||||||
|
String typeName = TypeUtility.getTypeName(clazz);
|
||||||
|
return getTypeFromTypesKnowledge(typeName, polymorphic);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ResourceRegistryException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <ME extends ModelElement> List<Type> getType(Class<ME> clazz, int level)
|
||||||
throws SchemaNotFoundException, ResourceRegistryException {
|
throws SchemaNotFoundException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
String typeName = TypeUtility.getTypeName(clazz);
|
String typeName = TypeUtility.getTypeName(clazz);
|
||||||
|
@ -513,7 +513,7 @@ public class ResourceRegistryClientImpl extends BaseRequestInfo implements Resou
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <ERElem extends ERElement> Node<Type> getTypeTreeNode(Class<ERElem> clazz)
|
public <ME extends ModelElement> Node<Type> getTypeTreeNode(Class<ME> clazz)
|
||||||
throws SchemaNotFoundException, ResourceRegistryException {
|
throws SchemaNotFoundException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
String typeName = TypeUtility.getTypeName(clazz);
|
String typeName = TypeUtility.getTypeName(clazz);
|
||||||
|
@ -523,7 +523,7 @@ public class ResourceRegistryClientImpl extends BaseRequestInfo implements Resou
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public <ERElem extends ERElement> List<Type> getTypeFromServer(Class<ERElem> clazz, Boolean polymorphic)
|
public <ME extends ModelElement> List<Type> getTypeFromServer(Class<ME> clazz, Boolean polymorphic)
|
||||||
throws SchemaNotFoundException, ResourceRegistryException {
|
throws SchemaNotFoundException, ResourceRegistryException {
|
||||||
try {
|
try {
|
||||||
String json = getTypeFromServer(TypeUtility.getTypeName(clazz), polymorphic);
|
String json = getTypeFromServer(TypeUtility.getTypeName(clazz), polymorphic);
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||||
import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
|
import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
|
||||||
import org.gcube.informationsystem.model.impl.properties.MetadataImpl;
|
import org.gcube.informationsystem.model.impl.properties.MetadataImpl;
|
||||||
import org.gcube.informationsystem.model.knowledge.ModelKnowledge;
|
import org.gcube.informationsystem.model.knowledge.ModelKnowledge;
|
||||||
import org.gcube.informationsystem.model.reference.ERElement;
|
import org.gcube.informationsystem.model.reference.ModelElement;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||||
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
||||||
|
@ -76,7 +76,7 @@ public class ResourceRegistryClientTest extends ContextTest {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <ERElem extends ERElement> void getTypesFromKnowledge(Class<ERElem> clazz) throws SchemaNotFoundException, ResourceRegistryException {
|
protected <ME extends ModelElement> void getTypesFromKnowledge(Class<ME> clazz) throws SchemaNotFoundException, ResourceRegistryException {
|
||||||
List<Type> types = resourceRegistryClient.getType(clazz, true);
|
List<Type> types = resourceRegistryClient.getType(clazz, true);
|
||||||
logger.trace("List size {}\n{}", types.size(), getTypeNames(types));
|
logger.trace("List size {}\n{}", types.size(), getTypeNames(types));
|
||||||
}
|
}
|
||||||
|
@ -299,4 +299,17 @@ public class ResourceRegistryClientTest extends ContextTest {
|
||||||
Assert.assertTrue(contexts.get(0).getMetadata()==null);
|
Assert.assertTrue(contexts.get(0).getMetadata()==null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRunQueryTemplates() throws Exception {
|
||||||
|
String ret = resourceRegistryClient.runQueryTemplate("IS-Monitoring-All-HostingNode");
|
||||||
|
logger.trace(ret);
|
||||||
|
ret = resourceRegistryClient.runQueryTemplate("IS-Monitoring-All-EService");
|
||||||
|
logger.trace(ret);
|
||||||
|
ret = resourceRegistryClient.runQueryTemplate("IS-Monitoring-All-HostingNode", "{}");
|
||||||
|
logger.trace(ret);
|
||||||
|
ret = resourceRegistryClient.runQueryTemplate("IS-Monitoring-All-EService", "{}");
|
||||||
|
logger.trace(ret);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue