default OResultSet indexQuery(String indexName, String query, Object... args) { return command(query, args); } }
@Override public <RET extends OCommandRequest> RET command(OCommandRequest iCommand) { checkOpenness(); return internal.command(iCommand); }
@Override public OResultSet command(String query, Object... args) throws OCommandSQLParsingException, OCommandExecutionException { checkOpenness(); return internal.command(query, args); }
public OResultSet command(String query, Map args) throws OCommandSQLParsingException, OCommandExecutionException { checkOpenness(); return internal.command(query, args); }
public Object command(final String iText, final Object... iParameters) { try (OResultSet rs = database.command(iText, iParameters)) { return rs.stream().map(x -> x.toElement()).toArray(size -> new OIdentifiable[size]); } }
public OIndexRemote<T> clear() { getDatabase().command(String.format(QUERY_CLEAR, name)).close(); return this; }
public long rebuild() { try (OResultSet rs = getDatabase().command(String.format(QUERY_REBUILD, name))) { return (Long) rs.next().getProperty("totalIndexed"); } }
public boolean dropRole(final String iRoleName) { final Number removed = getDatabase().command("delete from ORole where name = '" + iRoleName + "'").next().getProperty("count"); return removed != null && removed.intValue() > 0; }
public ORole getRole(final String iRoleName) { if (iRoleName == null) return null; final List<ODocument> result = getDatabase().<OCommandRequest>command( new OSQLSynchQuery<ODocument>("select from ORole where name = ? limit 1")).execute(iRoleName); if (result != null && !result.isEmpty()) return new ORole(result.get(0)); return null; }
public ORID getRoleRID(final String iRoleName) { if (iRoleName == null) return null; final List<ODocument> result = getDatabase().<OCommandRequest>command( new OSQLSynchQuery<ODocument>("select rid from index:ORole.name where key = ? limit 1")).execute(iRoleName); if (result != null && !result.isEmpty()) return result.get(0).rawField("rid"); return null; }
public boolean dropUser(final String iUserName) { final Number removed = getDatabase().command("delete from OUser where name = ?", iUserName).next().getProperty("count"); return removed != null && removed.intValue() > 0; }
public ORID getUserRID(final String iUserName) { List<ODocument> result = getDatabase().<OCommandRequest>command( new OSQLSynchQuery<ODocument>("select rid from index:OUser.name where key = ? limit 1")).execute(iUserName); if (result != null && !result.isEmpty()) return result.get(0).rawField("rid"); return null; }
@Override public OUser getUser(final String iUserName) { List<ODocument> result = getDatabase().<OCommandRequest>command( new OSQLSynchQuery<ODocument>("select from OUser where name = ? limit 1").setFetchPlan("roles:1")).execute(iUserName); if (result != null && !result.isEmpty()) return new OUser(result.get(0)); return null; }
public boolean remove(final Object key) { try(OResultSet result = getDatabase().command(String.format(QUERY_REMOVE, name), key)) { if (!result.hasNext()) { return false; } return ((long) result.next().getProperty("count")) > 0; } }
public int remove(final OIdentifiable iRecord) { try (OResultSet rs = getDatabase().command(String.format(QUERY_REMOVE3, name, iRecord.getIdentity()), iRecord)) { return (Integer) rs.next().getProperty("value"); } }
public ODatabaseImport removeExportImportRIDsMap() { listener.onMessage("\nDeleting RID Mapping table..."); if (exportImportHashTable != null) { database.command("drop index " + EXPORT_IMPORT_MAP_NAME).close(); exportImportHashTable = null; } listener.onMessage("OK\n"); return this; }
public OIndexManager dropIndex(final String iIndexName) { acquireExclusiveLock(); try { final String text = String.format(QUERY_DROP, iIndexName); getDatabase().command(text).close(); // REMOVE THE INDEX LOCALLY indexes.remove(iIndexName); reload(); return this; } finally { releaseExclusiveLock(); } }
protected void renameCluster(String oldName, String newName) { oldName = oldName.toLowerCase(Locale.ENGLISH); newName = newName.toLowerCase(Locale.ENGLISH); final ODatabaseDocumentInternal database = getDatabase(); final OStorage storage = database.getStorage(); if (storage.getClusterIdByName(newName) != -1) return; final int clusterId = storage.getClusterIdByName(oldName); if (clusterId == -1) return; if (!hasClusterId(clusterId)) return; database.command("alter cluster `" + oldName + "` NAME \"" + newName + "\"").close(); }
public OIndexRemote<T> put(final Object iKey, final OIdentifiable iValue) { if (iValue instanceof ORecord && !iValue.getIdentity().isValid()) // SAVE IT BEFORE TO PUT ((ORecord) iValue).save(); if (iValue.getIdentity().isNew()) throw new OIndexException( "Cannot insert values in manual indexes against remote protocol during a transaction. Temporary RID cannot be managed at server side"); getDatabase().command(String.format(QUERY_PUT, name), iKey, iValue.getIdentity()).close(); return this; }
private void distributedDropIndex(final String iName) { String dropIndexDDL = "DROP INDEX `" + iName + "`"; //noinspection deprecation getDatabase().command(new OCommandSQL(dropIndexDDL)).execute(); ORecordInternal .setIdentity(delegate.getDocument(), new ORecordId(getDatabase().getStorage().getConfiguration().getIndexMgrRecordId())); reload(); }