Changed orientdb deprecated api for query
This commit is contained in:
parent
f683681a8a
commit
e59af36a4f
|
@ -153,7 +153,15 @@ public abstract class ERManagement<El extends OElement> {
|
|||
checkJsonNode();
|
||||
}
|
||||
|
||||
public static OClass getOClass(OElement oElement) throws SchemaException, ResourceRegistryException {
|
||||
public static <E extends OElement> E getElementFromOptional(Optional<E> optional) throws ResourceRegistryException {
|
||||
if(optional.isPresent()) {
|
||||
return optional.get();
|
||||
}else {
|
||||
throw new ResourceRegistryException("An element not belonging to any defined type should not exists. Please contact the administrator.");
|
||||
}
|
||||
}
|
||||
|
||||
public static OClass getOClass(OElement oElement) throws ResourceRegistryException {
|
||||
Optional<OClass> optional = oElement.getSchemaType();
|
||||
if(optional.isPresent()) {
|
||||
return optional.get();
|
||||
|
|
|
@ -12,9 +12,9 @@ import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
|||
import org.gcube.informationsystem.model.reference.relations.Relation;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.EntityManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.FacetManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.ResourceManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.EntityManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.relation.ConsistsOfManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.relation.IsRelatedToManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.relation.RelationManagement;
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.Rela
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaException;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.base.entities.BaseEntityManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.FacetManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.security.SecurityContext;
|
||||
import org.gcube.informationsystem.resourceregistry.utils.Utility;
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.gcube.informationsystem.resourceregistry.instances.context;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.UUID;
|
||||
|
@ -17,6 +16,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseEnvironment;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.security.AdminSecurityContext;
|
||||
import org.gcube.informationsystem.resourceregistry.security.SecurityContext;
|
||||
import org.gcube.informationsystem.resourceregistry.security.SecurityContext.PermissionMode;
|
||||
|
@ -28,7 +28,8 @@ import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal;
|
|||
import com.orientechnologies.orient.core.db.document.ODatabaseDocument;
|
||||
import com.orientechnologies.orient.core.record.ODirection;
|
||||
import com.orientechnologies.orient.core.record.OVertex;
|
||||
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
|
||||
import com.orientechnologies.orient.core.sql.executor.OResult;
|
||||
import com.orientechnologies.orient.core.sql.executor.OResultSet;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
|
@ -209,30 +210,25 @@ public class ContextUtility {
|
|||
ScopeBean scopeBean = new ScopeBean(fullName);
|
||||
String name = scopeBean.name();
|
||||
|
||||
// TODO Rewrite the query using Gremlin
|
||||
// Please note that this query works because all the scope parts has a
|
||||
// different name
|
||||
String select = "SELECT FROM " + Context.class.getSimpleName() + " WHERE " + Context.NAME_PROPERTY + " = \""
|
||||
+ name + "\"";
|
||||
;
|
||||
OSQLSynchQuery<OVertex> osqlSynchQuery = new OSQLSynchQuery<OVertex>(select);
|
||||
|
||||
// TODO Rewrite better query. This query works because all the scope parts has a different name
|
||||
String select = "SELECT FROM " + Context.class.getSimpleName() + " WHERE " + Context.NAME_PROPERTY + " = :name";
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("name", name);
|
||||
|
||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
|
||||
Iterable<OVertex> vertexes = getAdminSecurityContext().getDatabaseDocument(PermissionMode.READER).command(osqlSynchQuery)
|
||||
.execute();
|
||||
OResultSet resultSet = getAdminSecurityContext().getDatabaseDocument(PermissionMode.READER).query(select, map);
|
||||
|
||||
if(vertexes == null || !vertexes.iterator().hasNext()) {
|
||||
if(resultSet == null || !resultSet.hasNext()) {
|
||||
throw new ContextNotFoundException("Error retrieving context with name " + fullName);
|
||||
}
|
||||
|
||||
Iterator<OVertex> iterator = vertexes.iterator();
|
||||
OVertex context = iterator.next();
|
||||
OResult oResult = resultSet.next();
|
||||
OVertex context = ERManagement.getElementFromOptional(oResult.getVertex());
|
||||
|
||||
logger.trace("Context Representing Vertex : {}", Utility.toJsonString(context, true));
|
||||
|
||||
if(iterator.hasNext()) {
|
||||
if(resultSet.hasNext()) {
|
||||
throw new ContextNotFoundException("Found more than one context with name " + name
|
||||
+ "but required the one with path" + fullName + ". Please Reimplement the query");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.gcube.informationsystem.resourceregistry.instances.context.entities;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -36,7 +37,7 @@ import com.orientechnologies.orient.core.record.ODirection;
|
|||
import com.orientechnologies.orient.core.record.OEdge;
|
||||
import com.orientechnologies.orient.core.record.OVertex;
|
||||
import com.orientechnologies.orient.core.record.impl.ODocument;
|
||||
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
|
||||
import com.orientechnologies.orient.core.sql.executor.OResultSet;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
|
@ -107,7 +108,6 @@ public class ContextManagement extends BaseEntityManagement<Context> {
|
|||
if(parentContext != null) {
|
||||
String parentId = parentContext.getElement().getIdentity().toString();
|
||||
|
||||
// TODO Rewrite using Gremlin
|
||||
String select = "SELECT FROM (TRAVERSE out(" + IsParentOf.NAME + ") FROM " + parentId
|
||||
+ " MAXDEPTH 1) WHERE " + Context.NAME_PROPERTY + "=\"" + getName() + "\" AND "
|
||||
+ Context.HEADER_PROPERTY + "." + Header.UUID_PROPERTY + "<>\"" + parentContext.uuid + "\"";
|
||||
|
@ -122,23 +122,20 @@ public class ContextManagement extends BaseEntityManagement<Context> {
|
|||
|
||||
logger.trace("Checking if {} -> {}", message, select);
|
||||
|
||||
OSQLSynchQuery<OVertex> osqlSynchQuery = new OSQLSynchQuery<OVertex>(select);
|
||||
Iterable<OVertex> vertexes = oDatabaseDocument.command(osqlSynchQuery).execute();
|
||||
OResultSet resultSet = oDatabaseDocument.command(select, new HashMap<>());
|
||||
|
||||
if(vertexes != null && vertexes.iterator().hasNext()) {
|
||||
if(resultSet != null && resultSet.hasNext()) {
|
||||
throw new ContextAlreadyPresentException(message.toString());
|
||||
}
|
||||
|
||||
} else {
|
||||
// TODO Rewrite using Gremlin
|
||||
String select = "SELECT FROM " + Context.NAME + " WHERE "
|
||||
+ Context.NAME_PROPERTY + " = \"" + getName() + "\"" + " AND in(\"" + IsParentOf.NAME
|
||||
+ "\").size() = 0";
|
||||
|
||||
OSQLSynchQuery<OVertex> osqlSynchQuery = new OSQLSynchQuery<OVertex>(select);
|
||||
Iterable<OVertex> vertexes = oDatabaseDocument.command(osqlSynchQuery).execute();
|
||||
OResultSet resultSet = oDatabaseDocument.command(select, new HashMap<>());
|
||||
|
||||
if(vertexes != null && vertexes.iterator().hasNext()) {
|
||||
if(resultSet != null && resultSet.hasNext()) {
|
||||
throw new ContextAlreadyPresentException(
|
||||
"A root context with the same name (" + this.getName() + ") already exist");
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.informationsystem.resourceregistry.instances.model.entity;
|
||||
package org.gcube.informationsystem.resourceregistry.instances.model.entities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -40,7 +40,8 @@ import com.orientechnologies.orient.core.record.OEdge;
|
|||
import com.orientechnologies.orient.core.record.OElement;
|
||||
import com.orientechnologies.orient.core.record.OVertex;
|
||||
import com.orientechnologies.orient.core.record.impl.ODocument;
|
||||
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
|
||||
import com.orientechnologies.orient.core.sql.executor.OResult;
|
||||
import com.orientechnologies.orient.core.sql.executor.OResultSet;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
|
@ -387,10 +388,11 @@ public abstract class EntityManagement<E extends BaseEntity> extends BaseEntityM
|
|||
String select = selectStringBuilder.toString();
|
||||
logger.trace(select);
|
||||
|
||||
OSQLSynchQuery<OElement> osqlSynchQuery = new OSQLSynchQuery<OElement>(select);
|
||||
Iterable<OElement> elements = oDatabaseDocument.command(osqlSynchQuery).execute();
|
||||
OResultSet resultSet = oDatabaseDocument.command(select,new HashMap<>());
|
||||
|
||||
for(OElement element : elements) {
|
||||
while(resultSet.hasNext()) {
|
||||
OResult oResult = resultSet.next();
|
||||
OElement element = ERManagement.getElementFromOptional(oResult.getElement());
|
||||
|
||||
if(polymorphic) {
|
||||
OClass oClass = null;
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.informationsystem.resourceregistry.instances.model.entity;
|
||||
package org.gcube.informationsystem.resourceregistry.instances.model.entities;
|
||||
|
||||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.informationsystem.resourceregistry.instances.model.entity;
|
||||
package org.gcube.informationsystem.resourceregistry.instances.model.entities;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
|
@ -13,7 +13,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.consistsOf.ConsistsOfAlreadyPresentException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.consistsOf.ConsistsOfAvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.consistsOf.ConsistsOfNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.FacetManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.security.SecurityContext;
|
||||
|
||||
import com.orientechnologies.orient.core.db.document.ODatabaseDocument;
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.isrelatedto.IsRelatedToAlreadyPresentException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.isrelatedto.IsRelatedToAvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.isrelatedto.IsRelatedToNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.ResourceManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.security.SecurityContext;
|
||||
|
||||
import com.orientechnologies.orient.core.db.document.ODatabaseDocument;
|
||||
|
|
|
@ -21,9 +21,9 @@ import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement;
|
|||
import org.gcube.informationsystem.resourceregistry.instances.base.ERManagementUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.base.relations.BaseRelationManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.context.ContextUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.EntityManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.FacetManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.ResourceManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.EntityManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.security.SecurityContext;
|
||||
import org.gcube.informationsystem.resourceregistry.security.SecurityContext.PermissionMode;
|
||||
import org.gcube.informationsystem.resourceregistry.utils.PropagationConstraintOrient;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package org.gcube.informationsystem.resourceregistry.query;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.query.InvalidQueryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath;
|
||||
|
@ -17,8 +20,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.orientechnologies.orient.core.db.document.ODatabaseDocument;
|
||||
import com.orientechnologies.orient.core.record.OElement;
|
||||
import com.orientechnologies.orient.core.record.impl.ODocument;
|
||||
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
|
||||
import com.orientechnologies.orient.core.sql.executor.OResult;
|
||||
import com.orientechnologies.orient.core.sql.executor.OResultSet;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
|
@ -34,35 +37,46 @@ public class QueryImpl implements Query {
|
|||
}
|
||||
limit = (limit <= 0) ? AccessPath.UNBOUNDED : limit;
|
||||
|
||||
ODatabaseDocument orientGraph = null;
|
||||
ODatabaseDocument oDatabaseDocument = null;
|
||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
|
||||
try {
|
||||
SecurityContext securityContext = ContextUtility.getCurrentSecurityContext();
|
||||
|
||||
orientGraph = securityContext.getDatabaseDocument(PermissionMode.READER);
|
||||
orientGraph.begin();
|
||||
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.READER);
|
||||
oDatabaseDocument.begin();
|
||||
|
||||
OSQLSynchQuery<ODocument> osqlSynchQuery = new OSQLSynchQuery<>(query, limit);
|
||||
osqlSynchQuery.setFetchPlan(fetchPlan);
|
||||
osqlSynchQuery.setCacheableResult(true);
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(query);
|
||||
stringBuffer.append(" limit :limit");
|
||||
|
||||
logger.debug("Going to execute query : \"{}\", fetchPlan : \"{}\", limit : {}", osqlSynchQuery.getText(),
|
||||
osqlSynchQuery.getFetchPlan(), osqlSynchQuery.getLimit());
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("limit", limit);
|
||||
|
||||
Iterable<OElement> elements = orientGraph.command(osqlSynchQuery).execute();
|
||||
if(fetchPlan!=null) {
|
||||
stringBuffer.append(" fetchplan ");
|
||||
stringBuffer.append(fetchPlan);
|
||||
logger.debug("Going to execute query '{} limit {} fetchPlan {}'", query, limit, fetchPlan);
|
||||
}else {
|
||||
logger.debug("Going to execute query '{} limit {}'", query, limit);
|
||||
}
|
||||
|
||||
OResultSet resultSet = oDatabaseDocument.query(stringBuffer.toString(), map);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
ArrayNode arrayNode = objectMapper.createArrayNode();
|
||||
|
||||
while(resultSet.hasNext()) {
|
||||
OResult oResult = resultSet.next();
|
||||
OElement element = ERManagement.getElementFromOptional(oResult.getElement());
|
||||
|
||||
for(OElement element : elements) {
|
||||
try {
|
||||
JsonNode jsonNode = null;
|
||||
if(raw) {
|
||||
jsonNode = Utility.toJsonNode(element, false);
|
||||
} else {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ERManagement erManagement = ERManagementUtility.getERManagement(securityContext, orientGraph,
|
||||
ERManagement erManagement = ERManagementUtility.getERManagement(securityContext, oDatabaseDocument,
|
||||
element);
|
||||
jsonNode = erManagement.serializeAsJson();
|
||||
}
|
||||
|
@ -79,8 +93,11 @@ public class QueryImpl implements Query {
|
|||
} catch(Exception e) {
|
||||
throw new InvalidQueryException(e.getMessage());
|
||||
} finally {
|
||||
if(orientGraph != null) {
|
||||
orientGraph.close();
|
||||
if(oDatabaseDocument != null) {
|
||||
oDatabaseDocument.close();
|
||||
}
|
||||
if(current!=null) {
|
||||
current.activateOnCurrentThread();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement;
|
|||
import org.gcube.informationsystem.resourceregistry.instances.base.ERManagementUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.context.ContextUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.context.entities.ContextManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.ResourceManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.type.SchemaManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.type.SchemaManagementImpl;
|
||||
import org.gcube.informationsystem.resourceregistry.query.Query;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.gcube.informationsystem.resourceregistry.utils;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.informationsystem.base.reference.properties.BaseProperty;
|
||||
|
@ -9,6 +9,7 @@ import org.gcube.informationsystem.model.reference.entities.Entity;
|
|||
import org.gcube.informationsystem.model.reference.relations.Relation;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.context.ContextUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.security.AdminSecurityContext;
|
||||
import org.gcube.informationsystem.resourceregistry.security.SecurityContext.PermissionMode;
|
||||
|
@ -24,7 +25,8 @@ import com.orientechnologies.orient.core.record.OElement;
|
|||
import com.orientechnologies.orient.core.record.ORecord;
|
||||
import com.orientechnologies.orient.core.record.OVertex;
|
||||
import com.orientechnologies.orient.core.record.impl.ODocument;
|
||||
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
|
||||
import com.orientechnologies.orient.core.sql.executor.OResult;
|
||||
import com.orientechnologies.orient.core.sql.executor.OResultSet;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
|
@ -97,21 +99,22 @@ public class Utility {
|
|||
String select = "SELECT FROM " + elementType + " WHERE " + Relation.HEADER_PROPERTY + "." + Header.UUID_PROPERTY
|
||||
+ " = \"" + uuid.toString() + "\"";
|
||||
|
||||
OSQLSynchQuery<El> osqlSynchQuery = new OSQLSynchQuery<>(select);
|
||||
OResultSet resultSet = oDatabaseDocument.query(select, new HashMap<>());
|
||||
|
||||
Iterable<El> elements = oDatabaseDocument.command(osqlSynchQuery).execute();
|
||||
if(elements == null || !elements.iterator().hasNext()) {
|
||||
|
||||
if(resultSet == null || !resultSet.hasNext()) {
|
||||
String error = String.format("No %s with UUID %s was found", elementType, uuid.toString());
|
||||
logger.info(error);
|
||||
throw new NotFoundException(error);
|
||||
}
|
||||
|
||||
Iterator<El> iterator = elements.iterator();
|
||||
El element = iterator.next();
|
||||
OResult oResult = resultSet.next();
|
||||
@SuppressWarnings("unchecked")
|
||||
El element = (El) ERManagement.getElementFromOptional(oResult.getElement());
|
||||
|
||||
logger.trace("{} with id {} is : {}", elementType, uuid.toString(), Utility.toJsonString(element, true));
|
||||
|
||||
if(iterator.hasNext()) {
|
||||
if(resultSet.hasNext()) {
|
||||
throw new ResourceRegistryException("Found more than one " + elementType + " with uuid " + uuid.toString()
|
||||
+ ". This is a fatal error please contact Admnistrator");
|
||||
}
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.informationsystem.resourceregistry.access;
|
||||
|
||||
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.query.InvalidQueryException;
|
||||
import org.gcube.informationsystem.resourceregistry.query.QueryImpl;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public class QueryImplTest extends ContextTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(QueryImplTest.class);
|
||||
|
||||
@Test
|
||||
public void testQuery() throws InvalidQueryException{
|
||||
QueryImpl queryImpl = new QueryImpl();
|
||||
|
||||
String query = "select * from SoftwareFacet";
|
||||
String ret = queryImpl.query(query, -7, null, false);
|
||||
|
||||
logger.debug(ret);
|
||||
}
|
||||
|
||||
}
|
|
@ -13,9 +13,9 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextAlreadyPresentException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.er.entity.FacetManagementTest;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.context.ContextUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.context.entities.ContextManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.FacetManagementTest;
|
||||
import org.gcube.informationsystem.resourceregistry.security.ContextSecurityContext;
|
||||
import org.gcube.informationsystem.resourceregistry.security.SecurityContext;
|
||||
import org.gcube.informationsystem.resourceregistry.security.SecurityContext.PermissionMode;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.informationsystem.resourceregistry.er;
|
||||
package org.gcube.informationsystem.resourceregistry.instances;
|
||||
|
||||
import org.gcube.informationsystem.base.reference.ER;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.informationsystem.resourceregistry.er;
|
||||
package org.gcube.informationsystem.resourceregistry.instances;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.informationsystem.resourceregistry.er;
|
||||
package org.gcube.informationsystem.resourceregistry.instances;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
@ -35,8 +35,8 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.query.InvalidQueryException;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.base.ERManagementUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.FacetManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.ResourceManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.relation.ConsistsOfManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.relation.IsRelatedToManagement;
|
||||
import org.gcube.informationsystem.utils.ISMapper;
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.informationsystem.resourceregistry.er;
|
||||
package org.gcube.informationsystem.resourceregistry.instances;
|
||||
|
||||
import java.security.Key;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.informationsystem.resourceregistry.er;
|
||||
package org.gcube.informationsystem.resourceregistry.instances;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
|
@ -35,7 +35,7 @@ import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
|
|||
import org.gcube.informationsystem.model.reference.relations.IsIdentifiedBy;
|
||||
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.ResourceManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||
import org.gcube.informationsystem.utils.ISMapper;
|
||||
import org.gcube.resourcemanagement.model.impl.entities.facets.CPUFacetImpl;
|
||||
import org.gcube.resourcemanagement.model.impl.entities.facets.ContainerStateFacetImpl;
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.informationsystem.resourceregistry.er.entity;
|
||||
package org.gcube.informationsystem.resourceregistry.instances.model.entity;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -9,9 +9,9 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetAvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.utils.Utility;
|
||||
import org.gcube.informationsystem.resourceregistry.er.ERManagementTest;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.ERManagementTest;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.context.ContextUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.FacetManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.utils.HeaderUtility;
|
||||
import org.gcube.informationsystem.utils.ISMapper;
|
||||
import org.gcube.resourcemanagement.model.impl.entities.facets.SoftwareFacetImpl;
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.informationsystem.resourceregistry.er.entity;
|
||||
package org.gcube.informationsystem.resourceregistry.instances.model.entity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -12,7 +12,7 @@ import org.gcube.informationsystem.resourceregistry.ContextTest;
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.base.ERManagementUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.ResourceManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||
import org.gcube.informationsystem.utils.ISMapper;
|
||||
import org.gcube.resourcemanagement.model.impl.entities.resources.EServiceImpl;
|
||||
import org.gcube.resourcemanagement.model.reference.entities.facets.SoftwareFacet;
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.informationsystem.resourceregistry.er.multicontext;
|
||||
package org.gcube.informationsystem.resourceregistry.instances.multicontext;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
|
@ -22,10 +22,10 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceAvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.RelationAvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.er.SmartgearResourcesTest;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.SmartgearResourcesTest;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.context.ContextUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.FacetManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.ResourceManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.relation.IsRelatedToManagement;
|
||||
import org.gcube.informationsystem.utils.ISMapper;
|
||||
import org.gcube.resourcemanagement.model.impl.entities.facets.AccessPointFacetImpl;
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.informationsystem.resourceregistry.er.multicontext;
|
||||
package org.gcube.informationsystem.resourceregistry.instances.multicontext;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -8,8 +8,8 @@ import org.gcube.informationsystem.model.reference.relations.IsIdentifiedBy;
|
|||
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetAlreadyPresentException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceAlreadyPresentException;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.FacetManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.ResourceManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||
import org.gcube.informationsystem.utils.ISMapper;
|
||||
import org.gcube.resourcemanagement.model.impl.entities.facets.SoftwareFacetImpl;
|
||||
import org.gcube.resourcemanagement.model.impl.entities.resources.EServiceImpl;
|
|
@ -1,19 +1,36 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.informationsystem.resourceregistry.query;
|
||||
|
||||
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.query.InvalidQueryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath;
|
||||
import org.gcube.informationsystem.resourceregistry.query.QueryImpl;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*
|
||||
*/
|
||||
public class QueryTest extends ContextTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(QueryTest.class);
|
||||
|
||||
//@Test
|
||||
public void testGremlinQuery() throws InvalidQueryException {
|
||||
Query query = new QueryImpl();
|
||||
String ret = query.gremlinQuery("g.V()");
|
||||
logger.debug("Gremlin Query Result is : {}", ret);
|
||||
@Test
|
||||
public void testQuery() throws InvalidQueryException{
|
||||
QueryImpl queryImpl = new QueryImpl();
|
||||
|
||||
String query = "select from SoftwareFacet";
|
||||
String ret = queryImpl.query(query, -7, AccessPath.DEFAULT_FETCH_PLAN_PARAM, false);
|
||||
|
||||
logger.debug(ret);
|
||||
|
||||
ret = queryImpl.query(query, -7, null, false);
|
||||
|
||||
logger.debug(ret);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue