First attempt to add gremlin query support

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@146773 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2017-04-11 17:21:32 +00:00
parent 6e4e0fe259
commit d4b69c2c1e
2 changed files with 40 additions and 2 deletions

View File

@ -22,4 +22,6 @@ public interface Query {
public String query(String query, Integer limit, String fetchPlan) public String query(String query, Integer limit, String fetchPlan)
throws InvalidQueryException; throws InvalidQueryException;
public String gremlinQuery(String query) throws InvalidQueryException;
} }

View File

@ -167,7 +167,43 @@ public class QueryImpl implements Query {
} }
} }
}
@Override
public String gremlinQuery(String query) throws InvalidQueryException {
throw new UnsupportedOperationException();
/*
OGremlinHelper.global().create();
ODatabaseDocumentTx oDatabaseDocumentTx = null;
try {
oDatabaseDocumentTx = ContextUtility
.getActualSecurityContextDatabaseTx(PermissionMode.READER);
String finalQuery = String.format("select gremlin('%s')", query);
OCommandSQL OCommandSQL = new OCommandSQL(finalQuery);
OCommandRequest oCommandRequest = oDatabaseDocumentTx.command(OCommandSQL);
OBasicResultSet res = oCommandRequest.execute();
Iterator iterator = res.iterator();
while(iterator.hasNext()){
ODocument oDocument = (ODocument) iterator.next();
logger.debug("{}", oDocument);
}
return res.toString();
} catch (Exception e) {
throw new InvalidQueryException(e.getMessage());
} finally {
if (oDatabaseDocumentTx != null) {
oDatabaseDocumentTx.close();
}
}
*/
}
}
} }