本文整理汇总了Java中com.orientechnologies.orient.core.sql.query.OSQLSynchQuery类的典型用法代码示例。如果您正苦于以下问题:Java OSQLSynchQuery类的具体用法?Java OSQLSynchQuery怎么用?Java OSQLSynchQuery使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OSQLSynchQuery类属于com.orientechnologies.orient.core.sql.query包,在下文中一共展示了OSQLSynchQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeQuery
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; //导入依赖的package包/类
public IResultSet executeQuery() throws OdaException
{
String currentQueryText = queryText;
if(getMaxRows()!=0){
currentQueryText = currentQueryText+ " LIMIT "+getMaxRows();
}
try {
OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(currentQueryText);
List<ODocument> dbResult = getOrMakeDBResult(db.command(query).execute(parameters));
/*
ArrayList<ODocument> unCachedResult = new ArrayList<ODocument>(dbResult.size());
for (ODocument oDocument : dbResult) {
ODocument newDoc = new ODocument();
for (Entry<String, Object> entry : oDocument) {
newDoc.field(entry.getKey(),entry.getValue());
}
unCachedResult.add(newDoc);
}*/
return new ResultSet(dbResult,curMetaData);
} catch (OCommandSQLParsingException e) {
throw new OdaException(e);
}
}
示例2: convertToCatalogLinkIfAble
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; //导入依赖的package包/类
private Object convertToCatalogLinkIfAble(Object value,OProperty fieldProperty,ODocument mainDoc){
String catalogsLinkNameAttribute = getOrientDBEndpoint().getCatalogsLinkAttr();//
String catalogsLinkName = getOrientDBEndpoint().getCatalogsLinkName();//
String catalogNameField = fieldProperty.getLinkedClass().getCustom(catalogsLinkNameAttribute);
if (catalogNameField==null){
catalogNameField = catalogsLinkName;
}
List<OIdentifiable> catalogLinks = curDb.query(new OSQLSynchQuery<OIdentifiable>(
"select from "+fieldProperty.getLinkedClass().getName()+" where "+catalogNameField+"=?"), value);
if (catalogLinks.size()>0){
value = catalogLinks.get(0).getIdentity();
}else{
boolean updateCatalogs = getOrientDBEndpoint().isCatalogsUpdate();//
if (updateCatalogs){
ODocument catalogRecord = new ODocument(fieldProperty.getLinkedClass());
catalogRecord.field(catalogNameField,value);
catalogRecord.save(true);
value = catalogRecord.getIdentity();
}
}
return value;
}
示例3: start
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; //导入依赖的package包/类
@Override
public void start(final Future<Void> startFuture) throws Exception {
consumer = vertx.eventBus().consumer("read",
(Message<JsonObject> m) -> {
documentDatabase.exec(adb -> {
if (adb.failed()) {
log.warn("DB failure", adb.cause());
}
else {
ODatabaseDocumentTx db = adb.result();
List<ODocument> res = db.query(new OSQLSynchQuery<ODocument>("select count(*) as count from test"));
log.info("List size=" + res.get(0).field("count"));
}
});
}
);
super.start(startFuture);
}
示例4: updateTrigger
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; //导入依赖的package包/类
private void updateTrigger(Identifier triggerId, Consumer<AbstractTrigger> c) {
try (OObjectDatabaseTx db = db()) {
try {
db.begin();
List<AbstractTrigger> l = db.query(new OSQLSynchQuery<>(String.format(TRIGGER_QUERY, triggerId)));
if (l.size() != 1) {
throw new IllegalArgumentException("Can't find trigger with id=" + triggerId);
} else {
AbstractTrigger trigger = l.get(0);
c.accept(trigger);
db.save(trigger);
}
} catch (Throwable t) {
db.rollback();
throw Exceptions.runtime(t);
} finally {
db.commit();
}
}
}
示例5: importKeyStoreFiles
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; //导入依赖的package包/类
public void importKeyStoreFiles() throws Exception {
log.debug("Importing legacy trust store from {}", keyStoreBasedir);
try (ODatabaseDocumentTx db = databaseInstance.get().connect()) {
for (String filename : Arrays.asList(TRUSTED_KEYS_FILENAME, PRIVATE_KEYS_FILENAME)) {
String keyStoreName = "ssl/" + filename;
String query = "SELECT FROM " + DB_CLASS + " WHERE " + P_NAME + " = ?";
List<ODocument> results = db.command(new OSQLSynchQuery<>(query)).execute(keyStoreName);
if (!results.isEmpty()) {
log.debug("Skipped import of existing legacy key store {}", results.get(0));
// NOTE: Upgrade steps run on each node but within a cluster, another node might already have upgraded the db
continue;
}
Path keyStorePath = keyStoreBasedir.resolve(filename);
if (!Files.isRegularFile(keyStorePath)) {
continue;
}
ODocument doc = db.newInstance(DB_CLASS);
doc.field(P_NAME, keyStoreName);
doc.field(P_BYTES, Files.readAllBytes(keyStorePath));
doc.save();
log.debug("Imported legacy key store {}", doc);
}
}
}
示例6: findSnapshotCandidates
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; //导入依赖的package包/类
/**
* 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());
}
示例7: updateAssetBlobStoreRefs
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; //导入依赖的package包/类
@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);
}
});
}
}
示例8: deleteViewDefinition
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; //导入依赖的package包/类
public void deleteViewDefinition(Object id, boolean notify) throws RuntimeException {
ViewDefinition vd = null;
String viewUrl = null;
try (OObjectDatabaseTx database = getOObjectDatabaseTx()) {
vd = database.load(new ORecordId(id.toString()));
if (vd != null) {
viewUrl = vd.getUrl();
List<TabDefinition> tabs = database.query(new OSQLSynchQuery<TabDefinition>("SELECT * FROM TabDefinition WHERE viewId = ?"), id);
for (TabDefinition td : tabs) {
database.command(new OCommandSQL("DELETE VERTEX PanelDefinition WHERE tabId = " + td.getId())).execute();
}
database.command(new OCommandSQL("DELETE VERTEX TabDefinition WHERE viewId = " + id)).execute();
}
database.delete(new ORecordId(id.toString()));
database.commit();
}
if (notify && vd != null && vd instanceof ViewDefinition) {
HazelcastServer.getDashboardEventTopic().publish(DashboardEvent.createViewDeleteEvent(sessionId, viewUrl));
}
}
示例9: listUsers
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; //导入依赖的package包/类
public List<String> listUsers( String from, String max, String pattern ) {
String q = "SELECT FROM ouser";
if( pattern != null )
if( !"".equals( pattern ) )
q += " WHERE name like '" + pattern + "'";
q += " SKIP " + from;
q += " LIMIT " + max;
List<ODocument> list =
graph.getRawGraph().query(
new OSQLSynchQuery<ODocument>( q ) );
return new GenericNodeCollection<String>( list, new AttributeProvider<String>() {
@Override
public String getValue( ODocument doc ) {
return doc.field( "name" );
}} );
}
示例10: getMyProcessToStart
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; //导入依赖的package包/类
public List<StartProcess> getMyProcessToStart() {
List<StartProcess> result = new ArrayList<>();
String request = "SELECT FROM ("
+ "SELECT expand(in) FROM PERMISSION WHERE [email protected] = 'Module' AND in.type = 'PROCESS' AND permissions IN ('START') "
+ "AND out in (SELECT FROM Role WHERE @rid IN (SELECT out('UserGroup').in('RoleGroup') FROM User WHERE @rid = " + user.getId() + "))"
+ ")";
// String request = "SELECT FROM Module WHERE @rid IN "
// + " (SELECT in FROM (TRAVERSE * FROM " + user.getId() + " WHILE $depth < 7 strategy BREADTH_FIRST ) WHERE @class = 'Permission' AND [email protected] = 'Module' AND permissions IN ('START')) "
// + " AND type = 'PROCESS' ORDER BY name";
try (OObjectDatabaseTx database = getOObjectDatabaseTx()) {
List<Module> list = database.query(new OSQLSynchQuery<Module>(request));
for (Module module : list) {
ProcessModel processModel = HybridbpmCoreUtil.jsonToObject(module.getModel(), ProcessModel.class);
List<ODocument> taskNames = database.query(new OSQLSynchQuery<ODocument>("SELECT parameter FROM Permission WHERE in = " + module.getId()));
for (ODocument taskName : taskNames) {
result.add(new StartProcess(processModel, taskName.field("parameter").toString(), module.getIcon()));
}
}
}
return result;
}
示例11: getMyTasksDone
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; //导入依赖的package包/类
public List<Task> getMyTasksDone(Locale locale) {
String request1 = "SELECT FROM Task WHERE executor = ? AND status= ? ORDER BY updateDate DESC";
try (OObjectDatabaseTx database = getOObjectDatabaseTx()) {
Map<String, Translated> titles = new HashMap<>();
List<ODocument> docs = database.query(new OSQLSynchQuery<>("select name, title from Module WHERE type = '" + Module.MODULE_TYPE.PROCESS + "'"));
docs.stream().forEach((document) -> {
Translated translated = HybridbpmCoreUtil.jsonToObject(document.field("title").toString(), Translated.class);
titles.put(document.field("name").toString(), translated);
});
List<Task> list = database.query(new OSQLSynchQuery<>(request1), user.getUsername(), TaskModel.STATUS.FINISHED);
list = detachList(list);
for (Task task : list) {
task.setCaseTitle(titles.get(task.getProcessModelName()).getValue(locale));
}
return list;
}
}
示例12: getMyTasksToDo
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; //导入依赖的package包/类
public List<Task> getMyTasksToDo(Locale locale) {
String request1 = "SELECT FROM (SELECT expand(outV('Task') [status= ? ]) FROM ("
+ "SELECT expand(inE('UserTaskList')) FROM User WHERE username = ? ) )"
+ " WHERE (assigned = false OR (assigned = true AND executor = ?)) AND status= ? ORDER BY updateDate DESC";
try (OObjectDatabaseTx database = getOObjectDatabaseTx()) {
Map<String, Translated> titles = new HashMap<>();
List<ODocument> docs = database.query(new OSQLSynchQuery<ODocument>("select name, title from Module WHERE type = '" + Module.MODULE_TYPE.PROCESS + "'"));
for (ODocument document : docs) {
Translated translated = HybridbpmCoreUtil.jsonToObject(document.field("title").toString(), Translated.class);
titles.put(document.field("name").toString(), translated);
}
List<Task> list = database.query(new OSQLSynchQuery<Task>(request1), TaskModel.STATUS.TODO, user.getUsername(), user.getUsername(), TaskModel.STATUS.TODO);
list = detachList(list);
for (Task task : list){
task.setCaseTitle(titles.get(task.getProcessModelName()).getValue(locale));
}
return list;
}
}
示例13: getMyTasksDone
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; //导入依赖的package包/类
public List<Task> getMyTasksDone(Locale locale) {
String request1 = "SELECT FROM Task WHERE executor = ? AND status= ? ORDER BY updateDate DESC";
try (OObjectDatabaseTx database = getOObjectDatabaseTx()) {
Map<String, Translated> titles = new HashMap<>();
List<ODocument> docs = database.query(new OSQLSynchQuery<ODocument>("select name, title from Module WHERE type = '" + Module.MODULE_TYPE.PROCESS + "'"));
for (ODocument document : docs) {
Translated translated = HybridbpmCoreUtil.jsonToObject(document.field("title").toString(), Translated.class);
titles.put(document.field("name").toString(), translated);
}
List<Task> list = database.query(new OSQLSynchQuery<Task>(request1), user.getUsername(), TaskModel.STATUS.FINISHED);
list = detachList(list);
for (Task task : list){
task.setCaseTitle(titles.get(task.getProcessModelName()).getValue(locale));
}
return list;
}
}
示例14: getCases
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; //导入依赖的package包/类
public List<Case> getCases(Case.TYPE type, String name, String initiator, Date startFrom, Date endTo, Case.STATUS... statuses) {
StringBuilder statusCondition = new StringBuilder("status in [");
for (Case.STATUS stat : statuses) {
statusCondition.append("'").append(stat.name()).append("',");
}
statusCondition.deleteCharAt(statusCondition.length() - 1).append("] ");
StringBuilder request = new StringBuilder("SELECT FROM Case WHERE ");
request.append(statusCondition);
if (Objects.equals(type, Case.TYPE.PROCESS)) {
request.append(" AND type = '").append(Case.TYPE.PROCESS.name()).append("'");
request.append(name != null ? " AND name = '" + name + "'" : "");
} else if (Objects.equals(type, Case.TYPE.ADAPTIVE)) {
request.append(" AND type = '").append(Case.TYPE.ADAPTIVE.name()).append("'");
}
request.append(initiator != null ? " AND initiator = '" + initiator + "'" : "");
request.append(startFrom != null ? " AND startDate >= date('" + new SimpleDateFormat("yyyy-MM-dd").format(startFrom) + "', 'yyyy-MM-dd')" : "");
request.append(endTo != null ? " AND finishDate <= date('" + new SimpleDateFormat("yyyy-MM-dd").format(endTo) + "', 'yyyy-MM-dd')" : "");
System.out.println(request.toString());
try (OObjectDatabaseTx database = getOObjectDatabaseTx()) {
List<Case> list = database.query(new OSQLSynchQuery<Case>(request.toString()));
return detachList(list);
}
}
示例15: getMyDocuments
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery; //导入依赖的package包/类
public Map<Document, List<Permission.PERMISSION>> getMyDocuments(String parentId) {
String documentRequest = parentId != null
? "SELECT FROM Document WHERE @rid IN "
+ "(SELECT in FROM PERMISSION WHERE [email protected] = 'Document' AND permissions IN ('VIEW') "
+ "AND out in (SELECT FROM Role WHERE @rid IN (SELECT out('UserGroup').in('RoleGroup') FROM User WHERE @rid = " + user.getId() + "))) "
+ " AND parent = " + parentId
: "SELECT FROM Document WHERE @rid IN "
+ "(SELECT in FROM PERMISSION WHERE [email protected] = 'Document' AND permissions IN ('VIEW') "
+ "AND out in (SELECT FROM Role WHERE @rid IN (SELECT out('UserGroup').in('RoleGroup') FROM User WHERE @rid = " + user.getId() + ")))"
+ " AND parent IS NULL ";
try (OObjectDatabaseTx database = getOObjectDatabaseTx()) {
List<Document> documents = database.query(new OSQLSynchQuery<Document>(documentRequest));
documents = detachList(documents);
Map<Document, List<Permission.PERMISSION>> result = new HashMap<>(documents.size());
for (Document doc : documents) {
Edge edge = getOrientGraph().getVertex(doc.getId()).getEdges(Direction.IN, "Permission").iterator().next();
Permission p = getOObjectDatabaseTx().load(new ORecordId(edge.getId().toString()));
result.put(doc, p.getPermissions());
}
return result;
}
}