Java Code Examples for com.orientechnologies.orient.core.sql.query.OSQLSynchQuery

The following examples show how to use com.orientechnologies.orient.core.sql.query.OSQLSynchQuery. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private Stream<ODocument> findAssets(
    final ODatabaseDocumentTx db,
    final List<String> repositoryNames,
    final String SQL)
{
  return repositoryNames
      .stream()
      .flatMap(repositoryName -> {
        OIndex<?> bucketIdx = db.getMetadata().getIndexManager().getIndex(new OIndexNameBuilder()
            .type("bucket")
            .property(P_REPOSITORY_NAME)
            .build());
        OIdentifiable bucket = (OIdentifiable) bucketIdx.get(repositoryName);
        if (bucket == null) {
          log.debug("Unable to find bucket for {}", repositoryName);
          return Stream.empty();
        }
        List<ODocument> assets =
            db.query(new OSQLSynchQuery<ODocument>(SQL), bucket.getIdentity());
        return assets.stream();
      });
}
 
Example 2
/**
 * Find all GAVs that qualify for deletion.
 */
@VisibleForTesting
Set<GAV> findSnapshotCandidates(final StorageTx tx, final Repository repository)
{
  log.info(PROGRESS, "Searching for GAVS with snapshots that qualify for deletion on repository '{}'",
      repository.getName());

  final Bucket bucket = tx.findBucket(repository);
  final OResultSet<ODocument> result = tx.getDb().command(new OSQLSynchQuery<>(GAVS_WITH_SNAPSHOTS))
      .execute(AttachedEntityHelper.id(bucket));
  return result.stream().map((doc) -> {
    String group = doc.field(P_GROUP, String.class);
    String name = doc.field(P_NAME, String.class);
    String baseVersion = doc.field("baseVersion", String.class);
    Integer count = doc.field("cnt", Integer.class);
    return new GAV(group, name, baseVersion, count);
  }).collect(Collectors.toSet());
}
 
Example 3
@Override
public void apply() throws Exception {
  List<String> repositoryNames;

  try (ODatabaseDocumentTx configDb = configDatabaseInstance.get().connect()) {
    repositoryNames = configDb.<List<ODocument>>query(
        new OSQLSynchQuery<ODocument>(SELECT_DOCKER_REPOSITORIES)).stream()
        .map(d -> (String) d.field(P_REPOSITORY_NAME))
        .collect(toList());
  }

  if (repositoryNames != null && !repositoryNames.isEmpty()) {
    log.info("Deleting browse_node data from docker repositories to be rebuilt ({}).", repositoryNames);

    try (ODatabaseDocumentTx componentDb = componentDatabaseInstance.get().connect()) {
      OSchemaProxy schema = componentDb.getMetadata().getSchema();
      if (schema.existsClass(C_BROWSE_NODE)) {
        componentDb.command(new OCommandSQL(DELETE_BROWSE_NODE_FROM_REPOSITORIES)).execute(repositoryNames);
      }
    }
  }
}
 
Example 4
private void fixComponentBatch(final ODatabaseDocumentTx db, final OIdentifiable bucket) {
  log.debug("Processing batch of {} yum component records...", BATCH_SIZE);

  OSQLSynchQuery<Object> query = new OSQLSynchQuery<>(SELECT_COMPONENT_BATCH_SQL);

  List<ODocument> components = db.query(query, bucket, new ORecordId());

  while (!components.isEmpty()) {
    ORID last = components.get(components.size() - 1).getIdentity();

    for (ODocument component : components) {
      fixComponent(db, component, bucket);
    }

    components = db.query(query, bucket, last);
  }
}
 
Example 5
@VisibleForTesting
void updateAssetBlobStoreRefs(final Map<String, String> renamedBlobStores) {
  try (ODatabaseDocumentTx db = componentDatabaseInstance.get().connect()) {
    renamedBlobStores.forEach((originalName, newName) -> {
      log.debug("Searching for BlobStoreRefs, original name: {}, new name: {} ", originalName, newName);

      OSQLSynchQuery query = new OSQLSynchQuery<>("select from asset where blob_ref like ? and @rid > ? limit 100");
      String nameTestValue = originalName + "@%";

      List<ODocument> results = db.query(query, nameTestValue, new ORecordId());

      while (!results.isEmpty()) {
        log.debug("Updating set of {} Refs", results.size());
        ORID last = results.get(results.size() - 1).getIdentity();

        results.forEach(doc -> updateDocWithNewName(originalName, newName, doc));

        results = db.query(query, nameTestValue, last);
      }
    });
  }
}
 
Example 6
Source Project: wicket-orientdb   Source File: OQueryModel.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Get the size of the data
 * @return results size
 */
public long size()
{
	if(size==null)
	{
 	ODatabaseDocument db = OrientDbWebSession.get().getDatabase();
 	OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(queryManager.getCountSql());
 	List<ODocument> ret = db.query(enhanceContextByVariables(query), prepareParams());
 	if(ret!=null && ret.size()>0)
 	{
 		Number sizeNumber = ret.get(0).field("count");
 		size = sizeNumber!=null?sizeNumber.longValue():0;
 	}
 	else
 	{
 		size = 0L;
 	}
	}
	return size;
}
 
Example 7
Source Project: orientdb-lucene   Source File: LuceneBooleanIndex.java    License: Apache License 2.0 6 votes vote down vote up
public void insertPerson() {

    for (int i = 0; i < 1000; i++) {
      ODocument doc = new ODocument("Person");
      doc.field("isDeleted", i % 2 == 0);
      databaseDocumentTx.save(doc);
    }

    List<ODocument> docs = databaseDocumentTx
        .query(new OSQLSynchQuery<ODocument>("select from Person where isDeleted lucene false"));

    Assert.assertEquals(500, docs.size());
    Assert.assertEquals(false, docs.get(0).field("isDeleted"));
    docs = databaseDocumentTx.query(new OSQLSynchQuery<ODocument>("select from Person where isDeleted lucene true"));

    Assert.assertEquals(500, docs.size());
    Assert.assertEquals(true, docs.get(0).field("isDeleted"));
  }
 
Example 8
Source Project: light   Source File: AbstractFormRule.java    License: Apache License 2.0 6 votes vote down vote up
protected String getAllForm(String host) {
    String sql = "SELECT FROM Form";
    if(host != null) {
        sql = sql + " WHERE host = '" + host + "' OR host IS NULL";
    }
    String json = null;
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<>(sql);
        List<ODocument> forms = graph.getRawGraph().command(query).execute();
        if(forms != null && forms.size() > 0) {
            json = OJSONWriter.listToJSON(forms, null);
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
        throw e;
    } finally {
        graph.shutdown();
    }
    return json;
}
 
Example 9
Source Project: light   Source File: AbstractRoleRule.java    License: Apache License 2.0 6 votes vote down vote up
protected String getRoles(OrientGraph graph, String host) {
    String sql = "SELECT FROM Role";
    if(host != null) {
        sql = sql + " WHERE host = '" + host + "' OR host IS NULL";
    }
    String json = null;
    try {
        OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<>(sql);
        List<ODocument> roles = graph.getRawGraph().command(query).execute();
        json = OJSONWriter.listToJSON(roles, null);
    } catch (Exception e) {
        logger.error("Exception:", e);
        throw e;
    } finally {
        graph.shutdown();
    }
    return json;
}
 
Example 10
Source Project: light   Source File: AbstractCatalogRule.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected List<String> getCategoryEntityListDb(String categoryRid, String sortedBy, String sortDir) {
    List<String> entityList = null;
    String sql = "select @rid from (traverse out_Own, out_HasProduct from ?) where @class = 'Product' order by " + sortedBy + " " + sortDir;
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(sql);
        List<ODocument> entities = graph.getRawGraph().command(query).execute(categoryRid);
        if(entities.size() > 0) {
            entityList = new ArrayList<String>();
            for(ODocument entity: entities) {
                entityList.add(((ODocument)entity.field("rid")).field("@rid").toString());
            }
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
    } finally {
        graph.shutdown();
    }
    return entityList;
}
 
Example 11
Source Project: light   Source File: AbstractCatalogRule.java    License: Apache License 2.0 6 votes vote down vote up
protected String getProductDb(String host) {
    String json = null;
    String sql = "select from product where host = ?";
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(sql);
        List<ODocument> products = graph.getRawGraph().command(query).execute(host);
        if(products.size() > 0) {
            json = OJSONWriter.listToJSON(products, null);
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
    } finally {
        graph.shutdown();
    }
    return json;
}
 
Example 12
Source Project: light   Source File: AbstractCatalogRule.java    License: Apache License 2.0 6 votes vote down vote up
protected String getProductDb() {
    String json = null;
    String sql = "select from product";
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(sql);
        List<ODocument> products = graph.getRawGraph().command(query).execute();
        if(products.size() > 0) {
            json = OJSONWriter.listToJSON(products, null);
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
    } finally {
        graph.shutdown();
    }
    return json;
}
 
Example 13
Source Project: light   Source File: AbstractBfnRule.java    License: Apache License 2.0 6 votes vote down vote up
protected List<String> getCategoryEntityListDb(String categoryRid, String sortedBy, String sortDir) {
    List<String> entityList = null;
    String sql = "select @rid from (traverse out_Own, out_HasPost from ?) where @class = 'Post' order by " + sortedBy + " " + sortDir;
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(sql);
        List<ODocument> entities = graph.getRawGraph().command(query).execute(categoryRid);
        if(entities.size() > 0) {
            entityList = new ArrayList<String>();
            for(ODocument entity: entities) {
                entityList.add(((ODocument)entity.field("rid")).field("@rid").toString());
            }
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
    } finally {
        graph.shutdown();
    }
    return entityList;
}
 
Example 14
Source Project: light   Source File: AbstractBfnRule.java    License: Apache License 2.0 6 votes vote down vote up
protected List<String> getRecentEntityListDb(String host, String categoryType, String sortedBy, String sortDir) {
    List<String> entityList = null;
    String sql = "select @rid from Post where host = ? and in_HasPost[0][email protected] = ? order by " + sortedBy + " " + sortDir;
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(sql);
        List<ODocument> entities = graph.getRawGraph().command(query).execute(host, categoryType);
        if(entities.size() > 0) {
            entityList = new ArrayList<String>();
            for(ODocument entity: entities) {
                entityList.add(((ODocument)entity.field("rid")).field("@rid").toString());
            }
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
    } finally {
        graph.shutdown();
    }
    return entityList;
}
 
Example 15
Source Project: light   Source File: AbstractTagRule.java    License: Apache License 2.0 6 votes vote down vote up
protected String getTagDropdownDb(String host) {
    String json = null;
    String sql = "SELECT FROM Tag WHERE host = ? ORDER BY tagId";
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(sql);
        List<ODocument> docs = graph.getRawGraph().command(query).execute(host);
        if (docs.size() > 0) {
            List<Map<String, String>> list = new ArrayList<Map<String, String>>();
            for (ODocument doc : docs) {
                Map<String, String> map = new HashMap<String, String>();
                map.put("label", (String) doc.field("tagId"));
                map.put("value", (String) doc.field("tagId"));
                list.add(map);
            }
            json = mapper.writeValueAsString(list);
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
    } finally {
        graph.shutdown();
    }
    return json;
}
 
Example 16
Source Project: light   Source File: BranchRule.java    License: Apache License 2.0 6 votes vote down vote up
protected String getBranchDropdownDb(String branchType, String host) {
    String json = null;
    String sql = "SELECT FROM " + branchType + " WHERE host = ? ORDER BY categoryId";
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(sql);
        List<ODocument> docs = graph.getRawGraph().command(query).execute(host);
        if(docs.size() > 0) {
            List<Map<String, String>> list = new ArrayList<Map<String, String>>();
            for(ODocument doc: docs) {
                Map<String, String> map = new HashMap<String, String>();
                map.put("label", (String)doc.field("categoryId"));
                map.put("value", doc.field("@rid").toString());
                list.add(map);
            }
            json = mapper.writeValueAsString(list);
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
    } finally {
        graph.shutdown();
    }
    return json;
}
 
Example 17
Source Project: light   Source File: AbstractRuleRule.java    License: Apache License 2.0 6 votes vote down vote up
protected String getRules(String host) {
    String sql = "SELECT FROM Rule";
    if(host != null) {
        sql = sql + " WHERE host = '" + host;
    }
    String json = null;
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<>(sql);
        List<ODocument> rules = graph.getRawGraph().command(query).execute();
        json = OJSONWriter.listToJSON(rules, null);
    } catch (Exception e) {
        logger.error("Exception:", e);
        throw e;
    } finally {
        graph.shutdown();
    }
    return json;
}
 
Example 18
Source Project: light   Source File: AbstractCommentRule.java    License: Apache License 2.0 6 votes vote down vote up
protected long getTotal(Map<String, Object> data, Map<String, Object> criteria) {
    long total = 0;
    StringBuilder sb = new StringBuilder("SELECT COUNT(*) as count FROM (TRAVERSE out_HasComment FROM ").append(data.get("@rid")).append(") ");
    String whereClause = DbService.getWhereClause(criteria);
    if(whereClause != null && whereClause.length() > 0) {
        sb.append(whereClause);
    }
    //System.out.println("sql=" + sb);
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        total = ((ODocument)graph.getRawGraph().query(new OSQLSynchQuery<ODocument>(sb.toString())).get(0)).field("count");
    } catch (Exception e) {
        logger.error("Exception:", e);
    } finally {
        graph.shutdown();
    }
    return total;
}
 
Example 19
Source Project: light   Source File: AbstractCommentRule.java    License: Apache License 2.0 6 votes vote down vote up
protected String getCommentTreeDb(String rid, String sortedBy, String sortDir) {
    String sql = "select from Comment where in_HasComment[0] = " + rid + " ORDER BY " + sortedBy + " " + sortDir;
    String json = null;
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(sql);
        List<ODocument> list = graph.getRawGraph().command(query).execute();
        if(list.size() > 0) {
            json = OJSONWriter.listToJSON(list, "rid,fetchPlan:[*]in_HasComment:-2 [*]out_ReportSpam:-2 [*]out_UpVote:-2 [*]out_DownVote:-2 in_Create[]:0 [*]out_Create:-2 [*]out_Update:-2 [*]out_HasComment:-1");
            // need to fixed the in_Create within the json using json path.
            DocumentContext dc = JsonPath.parse(json);
            MapFunction propsFunction = new StripPropsMapFunction();
            dc.map("$..in_UpVote[*]", propsFunction);
            dc.map("$..in_DownVote[*]", propsFunction);
            dc.map("$..in_ReportSpam[*]", propsFunction);

            MapFunction createFunction = new StripInCreateMapFunction();
            json = dc.map("$..in_Create[0]", createFunction).jsonString();
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
    } finally {
        graph.shutdown();
    }
    return json;
}
 
Example 20
Source Project: light   Source File: AbstractConfigRule.java    License: Apache License 2.0 6 votes vote down vote up
protected String getAllConfig() {
    String sql = "SELECT FROM Config";
    String json = null;
    OrientGraph graph = ServiceLocator.getInstance().getGraph();
    try {
        OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<>(sql);
        List<ODocument> configs = graph.getRawGraph().command(query).execute();
        if(configs != null && configs.size() > 0) {
            json = OJSONWriter.listToJSON(configs, null);
        }
    } catch (Exception e) {
        logger.error("Exception:", e);
        throw e;
    } finally {
        graph.shutdown();
    }
    return json;
}
 
Example 21
Source Project: Orienteer   Source File: ODocumentAliasRepository.java    License: Apache License 2.0 5 votes vote down vote up
public static List<Pair<String, OClass>> getAliasClasses(ODatabaseDocument db) {
    String sql = "select name from (select expand(classes) from metadata:schema) where customFields containsKey ?";
    List<ODocument> result = db.query(new OSQLSynchQuery<>(sql), PagesModule.ALIAS.getName(), PagesModule.ALIAS.getName());

    OSchema schema = db.getMetadata().getSchema();

    return result.stream()
            .map(d -> (String) d.field("name"))
            .map(schema::getClass)
            .map(oClass -> Pair.of((String) PagesModule.ALIAS.getValue(oClass), oClass))
            .collect(Collectors.toCollection(LinkedList::new));
}
 
Example 22
private List<String> findRepositoryNames(final List<String> recipes) {
  try (ODatabaseDocumentTx oDatabaseDocumentTx = configDatabaseInstance.get().connect()) {
    final List<ODocument> documents = oDatabaseDocumentTx.query(
        new OSQLSynchQuery<ODocument>("select from repository where recipe_name in ?"), recipes);
    return documents
        .stream()
        .map(entries -> (String) entries.field(P_REPOSITORY_NAME))
        .collect(Collectors.toList());
  }
}
 
Example 23
Source Project: nexus-public   Source File: PypiUpgrade_1_1.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private void deleteIndexes() {
  List<String> pypiRepositoryNames;
  try (ODatabaseDocumentTx db = configDatabaseInstance.get().connect()) {
    pypiRepositoryNames = db.<List<ODocument>>query(new OSQLSynchQuery<ODocument>(SELECT_PYPI_REPOSITORIES)).stream()
        .map(d -> (String) d.field(P_REPOSITORY_NAME))
        .collect(Collectors.toList());
  }

  if (!pypiRepositoryNames.isEmpty()) {
    OCommandSQL deleteIndexCommand = new OCommandSQL(DELETE_INDEXES);
    OCommandSQL deleteBrowseNodesCommand = new OCommandSQL(DELETE_BROWSE_NODES);
    try (ODatabaseDocumentTx db = componentDatabaseInstance.get().connect()) {
      OIndex<?> bucketIdx = db.getMetadata().getIndexManager().getIndex(I_REPOSITORY_NAME);
      pypiRepositoryNames.forEach(repositoryName -> {
        log.info("Scanning pypi repository {} for index file assets", repositoryName);
        OIdentifiable bucket = (OIdentifiable) bucketIdx.get(repositoryName);
        if (bucket == null) {
          log.warn("Unable to find bucket for {}", repositoryName);
        }
        else {
          // Deleting index files
          int deletes = db.command(deleteIndexCommand).execute(bucket.getIdentity());
          if (deletes > 0) {
            log.info(
                "Deleted {} pypi index asset(s) in repository {}: ", deletes, repositoryName);
          }

          if (db.getMetadata().getSchema().existsClass(BROWSE_NODE_CLASS)) {
            // Deleting browse nodes
            deletes = db.command(deleteBrowseNodesCommand).execute(repositoryName);
            if (deletes > 0) {
              log.info(
                  "Deleted {} browse node(s) in repository {}", deletes, repositoryName);
            }
          }
        }
      });
    }
  }
}
 
Example 24
Source Project: divide   Source File: OrientDBDao.java    License: Apache License 2.0 5 votes vote down vote up
@Override
    public Collection<TransientObject> get(String objectType, String... keys) throws DAOException {
        if(keys.length == 0) return Arrays.asList();
//        String objectType = Query.safeTable(type);

        checkDb();
        OTransaction transaction = db.getTransaction();
        transaction.begin();
//        System.err.println(db.browseCluster(objectType).next());
        StringBuilder sb = new StringBuilder();
        sb.append("SELECT * FROM " + objectType + " WHERE ");
        for(int x=0;x<keys.length;x++){
            sb.append("meta_data.object_key = '" + keys[x] +"'");
            if(x+1<keys.length) sb.append( " OR ");
        }
        List<TransientObject> objects = new ArrayList<TransientObject>();
        System.err.println("Query: " + sb.toString());
        List<ODocument> list = db.query(new OSQLSynchQuery<ODocument>(sb.toString()));
        System.err.println("Found: " + list.size());
        for(ODocument w : list){
            System.err.println("Get: " + w);
            TransientObject to = ODocumentWrapper.toObject(w, TransientObject.class);
            objects.add(to);
        }
        transaction.commit();
        transaction.close();
        return objects;
    }
 
Example 25
Source Project: nexus-public   Source File: MavenUpgrade_1_1.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private void updateMavenIndexFileAssetKind() {
  List<String> mavenRepositoryNames;
  try (ODatabaseDocumentTx db = configDatabaseInstance.get().connect()) {
    mavenRepositoryNames = db.<List<ODocument>>query(new OSQLSynchQuery<ODocument>(SELECT_MAVEN_REPOSITORIES)).stream()
        .map(d -> (String)d.field(P_REPOSITORY_NAME))
        .collect(Collectors.toList());
  }
  if (!mavenRepositoryNames.isEmpty()) {
    OCommandSQL updateAssetCommand = new OCommandSQL(UPDATE_ASSET_KIND);
    try (ODatabaseDocumentTx db = componentDatabaseInstance.get().connect()) {
      OIndex<?> bucketIdx = db.getMetadata().getIndexManager().getIndex(I_REPOSITORY_NAME);
      mavenRepositoryNames.forEach(repositoryName -> {
        log.info("Scanning maven2 repository {} for maven index file assets", repositoryName);
        OIdentifiable bucket = (OIdentifiable) bucketIdx.get(repositoryName);
        if (bucket == null) {
          log.warn("Unable to find bucket for {}", repositoryName);
        }
        else {
          int updates = db.command(updateAssetCommand).execute(bucket.getIdentity());
          if (updates > 0) {
            log.info(
                "Updated {} maven index file asset(s) in repository {}: " +
                    "set attributes.maven2.asset_kind='REPOSITORY_INDEX'", updates, repositoryName);
          }
        }
      });
    }
  }
}
 
Example 26
public Iterable<T> execute(final ODatabaseDocumentTx db, final Object... values) {
  checkNotNull(db);
  checkArgument(values.length > 0);

  Iterable<ODocument> results = db.command(new OSQLSynchQuery<>(query))
      .execute(values);

  return adapter.transform(results);
}
 
Example 27
public Iterable<T> execute(final ODatabaseDocumentTx db, final Collection<? extends Object> values) {
  checkNotNull(db);
  checkArgument(values != null && values.size() > 0);

  String valueFields = values.stream().map(value -> "?").collect(joining(","));
  String adjustedQuery = String.format(query, valueFields);

  Iterable<ODocument> results = db.command(new OSQLSynchQuery<>(adjustedQuery)).execute(values.toArray());

  return adapter.transform(results);
}
 
Example 28
@Nullable
public List<T> execute(final ODatabaseDocumentTx db, final Set<?> values) {
  checkNotNull(db);
  checkArgument(!values.isEmpty());

  String q = query + buildIn(values);
  List<ODocument> results = db.command(new OSQLSynchQuery<>(q)).execute(values);

  return newArrayList(results.stream().map(adapter::readEntity).collect(toList()));
}
 
Example 29
@Nullable
public T execute(final ODatabaseDocumentTx db, final Object... values) {
  checkNotNull(db);
  checkArgument(values.length > 0);

  List<ODocument> results = db.command(new OSQLSynchQuery<>(query))
      .execute(values);

  if (results.isEmpty()) {
    return null;
  }
  return adapter.readEntity(results.get(0));
}
 
Example 30
public boolean execute(final ODatabaseDocumentTx db, final T entity, final Object... values) {
  checkNotNull(db);
  checkArgument(values.length > 0);

  List<ODocument> results = db.command(new OSQLSynchQuery<>(query))
      .execute(values);

  if (results.isEmpty()) {
    return false;
  }
  else {
    adapter.writeEntity(results.get(0), entity);
    return true;
  }
}