private void executeCommand(String query, Object... args) { activateOnCurrentThread(); db.command(new OCommandSQL(query)).execute(args); }
String command="CREATE CLASS User"; int modified=graph.command(new OCommandSQL(command)).execute(); String command2="CREATE PROPERTY User.firstName String"; int modified2=graph.command(new OCommandSQL(command2)).execute(); String command3="CREATE PROPERTY User.password String"; int modified3=graph.command(new OCommandSQL(command3)).execute(); String command4="ALTER PROPERTY User.password NOTNULL true"; graph.command(new OCommandSQL(command4)).execute();
OrientGraphFactory graphFactory=new OrientGraphFactory(path+DB); OrientGraph graph=graphFactory.getTx(); List<String> Command=new ArrayList<String>(); Command.add("CREATE CLASS User"); Command.add("CREATE PROPERTY User.firstName String"); Command.add("CREATE PROPERTY User.password String"); Command.add("ALTER PROPERTY User.password NOTNULL true"); for(int i=0;i<Command.size();i++) { String command=Command.get(i); graph.command(new OCommandSQL(command)).execute(); }
OCommandSQL declareIn= new OCommandSQL(); declareIn.setText("CREATE PROPERTY E.in LINK"); OCommandSQL declareOut= new OCommandSQL(); declareOut.setText("CREATE PROPERTY E.out LINK"); OCommandSQL createIndexUniqueEdge= new OCommandSQL(); createIndexUniqueEdge.setText("CREATE INDEX unique_edge ON E (in, out) UNIQUE"); graph.command(declareIn).execute(); graph.command(declareOut).execute(); graph.command(createIndexUniqueEdge).execute();
public boolean execute(final ODatabaseDocumentTx db, final Object... values) { checkNotNull(db); checkArgument(values.length > 0); int records = db.command(new OCommandSQL(query)) .execute(values); return records == 1; }
private Iterable<ODocument> buildAndRunQuery(final ODatabaseDocumentTx db, final String whereClause, final Map<String, String> parameters) { StringBuilder query = new StringBuilder("SELECT FROM " + DB_CLASS + whereClause); log.debug("Finding {}s with query: {}, parameters: {}", getTypeName(), query, parameters); return db.command(new OCommandSQL(query.toString())).execute(parameters); }
T findByProperty(final ODatabaseDocumentTx db, final String propName, final Object propValue) { checkNotNull(propName); checkNotNull(propValue); Map<String, Object> parameters = ImmutableMap.of("propValue", propValue); String query = String.format("select from %s where %s = :propValue", getTypeName(), propName); Iterable<ODocument> docs = db.command(new OCommandSQL(query)).execute(parameters); ODocument first = Iterables.getFirst(docs, null); return first != null ? readEntity(first) : null; }
/** * @since 3.2 */ public void clear(final ODatabaseDocumentTx db) { db.command(new OCommandSQL(DELETE_ALL)).execute(); } }
private List<ODocument> execute(final ODatabaseDocumentTx db, // NOSONAR final String query, final Map<String, Object> parameters) { return db.command(new OCommandSQL(query)).execute(parameters); } }
@Override public OResultSet execute(ODatabase db, Map args, OCommandContext parentContext) { StringBuilder builder = new StringBuilder(); toString(args, builder); Object result = db.command(new OCommandSQL(builder.toString())).execute(); List listResult; if (result instanceof List) { listResult = (List) result; } else { listResult = Collections.singletonList(result); } return new OIteratorResultSet(listResult.iterator()); }
@Override public void notFilter(String type, String value) { try (ODatabaseDocumentTx db = docDb()) { db.command(new OCommandSQL(String.format("delete from Filter where type=\"%s\" and value=\"%s\"", type, value))).execute(); } }
@Override protected OCommandSQL doCreateCommand(Object[] values) { OrientParameterAccessor accessor = new OrientParametersParameterAccessor(parameters, values); OrientQueryCreator creator = new OrientQueryCreator(tree, method, accessor); return new OCommandSQL(creator.createQuery()); }
public Iterable<ODocument> documents(final ODatabaseDocumentTx db, final Iterable<EntityId> ids) { Set<ORID> rids = stream(ids).map(id -> { if (id instanceof AttachedEntityId) { return ((AttachedEntityId) id).getIdentity(); } return getRecordIdObfuscator().decode(getSchemaType(), id.getValue()); }).collect(toSet()); return db.command(new OCommandSQL("select from :rids")).execute(singletonMap("rids", rids)); }
@Override public boolean delete(T entity) { if (super.delete(entity)) { // delete connected locations and periods db.command(new OCommandSQL("delete from Location where parent = " + entity.getId())).execute(); db.command(new OCommandSQL("delete from Period where parent = " + entity.getId())).execute(); return true; } return false; } }
private void renameAssetLastAccessedField() { try (ODatabaseDocumentTx db = componentDatabaseInstance.get().connect()) { OClass assetClass = getAssetDbClass(db); if (assetClass.existsProperty(P_LAST_ACCESSED)) { db.command(new OCommandSQL(ALTER_ASSET_LAST_ACCESSED)).execute(); } } }
@Override protected OCommandSQL doCreateCommand(Object[] values) { OrientParameterAccessor accessor = new OrientParametersParameterAccessor(getQueryMethod().getParameters(), values); String sortedQuery = QueryUtils.applySorting(queryString, accessor.getSort()); return new OCommandSQL(sortedQuery); }
@Statement public void deleteProcessDefinitionsByDeploymentId(OPersistenceSession session, String deploymentId) { session.getDatabase().command(new OCommandSQL("delete from "+getSchemaClass()+" where deployment.id = ?")) .execute(deploymentId); }
@Override public void connectCommentToEntity(IComment comment, SegradaAnnotatedEntity entity) { initDb(); // no double connections if (isCommentOf(comment, entity)) return; // add edge db.command(new OCommandSQL("create edge IsCommentOf from " + comment.getId() + " to " + entity.getId())).execute(); }
@Override public void delete(T entity, OPersistenceSession session) { ODatabaseDocument db = session.getDatabase(); String id = entity.getId(); String oid = (String) convertValueFromEntity("id", id); OIdentifiable oIdentifiable = session.lookupOIdentifiableForIdInCache(oid); if(oIdentifiable!=null) { db.delete(oIdentifiable.getIdentity()); } else { db.command(new OCommandSQL("delete from "+getSchemaClass()+" where "+getPkField()+" = ?")).execute(oid); } }
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(); }