com.psddev.dari.db.Query.fromAll()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(195)

本文整理了Java中com.psddev.dari.db.Query.fromAll方法的一些代码示例,展示了Query.fromAll的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.fromAll方法的具体详情如下:
包路径:com.psddev.dari.db.Query
类名称:Query
方法名:fromAll

Query.fromAll介绍

[英]Queries over all objects.
[中]对所有对象的查询。

代码示例

代码示例来源:origin: perfectsense/brightspot-cms

  1. @Override
  2. public void run() {
  3. while (triggerTime > System.currentTimeMillis()) {
  4. try {
  5. Thread.sleep(1000);
  6. } catch (InterruptedException error) {
  7. break;
  8. }
  9. }
  10. Query.fromAll()
  11. .where("_id = ?", cacheId)
  12. .deleteAll();
  13. }
  14. }

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public Query<?> getSubQueryWithGroupBy() {
  3. if (subQueryTypes == null) {
  4. return null;
  5. }
  6. Query<?> subQuery = Query.fromAll();
  7. String keySuffix = "/" + subQueryKey;
  8. for (ObjectType type : subQueryTypes) {
  9. subQuery.sortAscending(type.getInternalName() + keySuffix);
  10. }
  11. return subQuery;
  12. }

代码示例来源:origin: perfectsense/brightspot-cms

  1. /** Returns the number of items completed. */
  2. public long countComplete() {
  3. return Query.fromAll()
  4. .where("cms.workstream.completeIds ^= ?", getId().toString() + ",")
  5. .count();
  6. }

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public Query<?> getSubQueryWithSorter(Sorter sorter, int index) {
  3. if (subQueryTypes == null) {
  4. return null;
  5. }
  6. Query<?> subQuery = Query.fromAll();
  7. String keySuffix = "/" + subQueryKey;
  8. for (ObjectType type : subQueryTypes) {
  9. List<Object> options = new ArrayList<Object>(sorter.getOptions());
  10. options.set(index, type.getInternalName() + keySuffix);
  11. subQuery.sort(new Sorter(sorter.getOperator(), options));
  12. break;
  13. }
  14. return subQuery;
  15. }

代码示例来源:origin: perfectsense/brightspot-cms

  1. private long getReferencesCount(Object item) {
  2. return Query
  3. .fromAll()
  4. .where("* matches ?", State.getInstance(item).getId())
  5. .count();
  6. }
  7. }

代码示例来源:origin: perfectsense/brightspot-cms

  1. /**
  2. * Generates a {@link Query} for the items contained within this {@link SearchResultSelection}. The returned
  3. * Query is {@code .fromAll()} and includes visibility-restricted items.
  4. * @return a {@link Query} for the items contained within this {@link SearchResultSelection}.
  5. */
  6. public Query<Object> createItemsQuery() {
  7. Set<UUID> itemIds = new HashSet<>();
  8. for (SearchResultSelectionItem item : Query
  9. .from(SearchResultSelectionItem.class)
  10. .where("selectionId = ?", getId())
  11. .selectAll()) {
  12. itemIds.add(item.getItemId());
  13. }
  14. return Query.fromAll().where("_id = ?", itemIds);
  15. }

代码示例来源:origin: perfectsense/dari

  1. public <T> List<T> getObjects() {
  2. Map<String, FacetField.Count> index = new HashMap<String, FacetField.Count>();
  3. List<String> ids = new ArrayList<String>();
  4. for (FacetField.Count c : this.field.getValues()) {
  5. index.put(c.getName(), c);
  6. ids.add(c.getName());
  7. }
  8. @SuppressWarnings("unchecked")
  9. List<T> objects = (List<T>) (this.klass == null || this.klass == Query.class
  10. ? Query.fromAll().where("id = ?", ids).selectAll()
  11. : Query.from(this.klass).where("id = ?", ids).selectAll());
  12. if (objects != null) {
  13. for (Object o : objects) {
  14. Record record = (Record) o;
  15. FacetField.Count c = index.get(record.getId().toString());
  16. record.getState().getExtras().put("count", Long.valueOf(c.getCount()));
  17. }
  18. }
  19. return objects;
  20. }
  21. }

代码示例来源:origin: perfectsense/brightspot-cms

  1. @Override
  2. protected void afterDelete() {
  3. State state = getState();
  4. if (state.isVisible()) {
  5. return;
  6. }
  7. for (Object item : Query
  8. .fromAll()
  9. .where("cms.bulkUpload.containerId = ?", state.getId().toString())
  10. .selectAll()) {
  11. State.getInstance(item).deleteImmediately();
  12. }
  13. }
  14. }

代码示例来源:origin: perfectsense/brightspot-cms

  1. @Override
  2. public void after(Element body) {
  3. for (Element a : body.getElementsByTag("a")) {
  4. if (ObjectUtils.equals(a.attr("href"), a.attr("data-cms-href"))) {
  5. UUID id = ObjectUtils.to(UUID.class, a.attr("data-cms-id"));
  6. if (id != null) {
  7. Object item = Query.fromAll().where("_id = ?", id).first();
  8. if (item != null) {
  9. String href = item instanceof Content
  10. ? ((Content) item).getPermalink()
  11. : State.getInstance(item).as(Directory.ObjectModification.class).getPermalink();
  12. if (href != null) {
  13. a.attr("href", href);
  14. }
  15. }
  16. }
  17. }
  18. a.removeAttr("data-cms-href");
  19. a.removeAttr("data-cms-id");
  20. }
  21. }
  22. }

代码示例来源:origin: perfectsense/brightspot-cms

  1. public Object createCompareObject() {
  2. UUID compareId = getCompareId();
  3. if (compareId != null) {
  4. Object compareObject = Query.fromAll().where("_id = ?", compareId).first();
  5. if (compareObject != null) {
  6. if (compareObject instanceof Draft) {
  7. return ((Draft) compareObject).recreate();
  8. } else if (compareObject instanceof History) {
  9. return ((History) compareObject).getObject();
  10. } else {
  11. return compareObject;
  12. }
  13. }
  14. }
  15. return null;
  16. }

代码示例来源:origin: perfectsense/dari

  1. private Query<?> createQuery(Database database, WebPageContext context) {
  2. String queryString = context.param(String.class, WebDatabase.QUERY_PARAMETER);
  3. Object queryObject = ObjectUtils.fromJson(queryString);
  4. if (!(queryObject instanceof Map)) {
  5. throw new DatabaseException(database, String.format(
  6. "Invalid query string! (%s)", queryString));
  7. }
  8. @SuppressWarnings("unchecked")
  9. Map<String, Object> queryMap = (Map<String, Object>) queryObject;
  10. convertTypeNameToId(database.getEnvironment(), queryMap);
  11. Query<?> query = Query.fromAll();
  12. query.getState().putAll(queryMap);
  13. query.using(database);
  14. return query;
  15. }

代码示例来源:origin: perfectsense/brightspot-cms

  1. @Override
  2. protected Query<?> createQuery(Directory directory) {
  3. return (itemType != null ? Query.fromType(itemType) : Query.fromAll())
  4. .and(page.siteItemsSearchPredicate())
  5. .and(directory.itemsPredicate(page.getSite()))
  6. .sortAscending(Directory.PATHS_FIELD);
  7. }
  8. });

代码示例来源:origin: perfectsense/brightspot-cms

  1. @Override
  2. protected void afterSave() {
  3. if (!isRunAfterSave()
  4. || !getState().isVisible()) {
  5. return;
  6. }
  7. for (Object item : Query
  8. .fromAll()
  9. .where("cms.bulkUpload.containerId = ?", getId().toString())
  10. .selectAll()) {
  11. State itemState = State.getInstance(item);
  12. itemState.as(BulkUploadDraft.class).setContainerId(null);
  13. itemState.saveImmediately();
  14. }
  15. }

代码示例来源:origin: perfectsense/brightspot-cms

  1. @Override
  2. protected Query<?> createQuery(Directory directory) {
  3. return (itemType != null ? Query.fromType(itemType) : Query.fromAll())
  4. .and(page.siteItemsPredicate())
  5. .and(directory.itemsPredicate(page.getSite()))
  6. .and("* matches ?", value)
  7. .and("cms.directory.paths != missing");
  8. }
  9. });

代码示例来源:origin: perfectsense/dari

  1. @Override
  2. public Query<?> getSubQueryWithComparison(ComparisonPredicate comparison) {
  3. if (subQueryTypes == null) {
  4. return comparison.findValueQuery();
  5. }
  6. Query<?> subQuery = Query.fromAll();
  7. String keySuffix = "/" + subQueryKey;
  8. for (ObjectType type : subQueryTypes) {
  9. subQuery.or(new ComparisonPredicate(
  10. comparison.getOperator(),
  11. comparison.isIgnoreCase(),
  12. type.getInternalName() + keySuffix,
  13. comparison.getValues()));
  14. }
  15. return subQuery;
  16. }

代码示例来源:origin: perfectsense/brightspot-cms

  1. @Override
  2. protected void doService(ToolPageContext page) throws IOException, ServletException {
  3. page.getRequest().setAttribute("containerObject", Query
  4. .fromAll()
  5. .where("_id = ?", page.param(UUID.class, "containerObjectId"))
  6. .first());
  7. page.writeHeader();
  8. page.writeStart("div", "class", "widget widget-queryField");
  9. JspUtils.include(
  10. page.getRequest(),
  11. page.getResponse(),
  12. page,
  13. page.toolPath(CmsTool.class, "/WEB-INF/search.jsp"),
  14. "resultJsp", "/queryFieldResult");
  15. page.writeEnd();
  16. page.writeFooter();
  17. }
  18. }

代码示例来源:origin: perfectsense/dari

  1. /**
  2. * Creates a query that can return all objects that reference this
  3. * index.
  4. */
  5. public Query<Object> createItemsQuery() {
  6. Query<Object> query;
  7. String declaringClass = getJavaDeclaringClassName();
  8. if (ObjectUtils.isBlank(declaringClass)) {
  9. query = Query.fromGroup(declaringClass);
  10. } else {
  11. ObjectStruct parent = getParent();
  12. if (parent instanceof ObjectType) {
  13. query = Query.fromType((ObjectType) parent);
  14. } else {
  15. query = Query.fromAll();
  16. }
  17. }
  18. query.resolveToReferenceOnly();
  19. query.fields(getField());
  20. return query;
  21. }

代码示例来源:origin: perfectsense/brightspot-cms

  1. /**
  2. * Recreates the originating object with the differences merged.
  3. *
  4. * @return {@code null} if the object type is {@code null}.
  5. */
  6. @SuppressWarnings("deprecation")
  7. public Object recreate() {
  8. ObjectType type = getObjectType();
  9. if (type == null) {
  10. return null;
  11. }
  12. UUID id = getObjectId();
  13. Object object = Query.fromAll()
  14. .where("_id = ?", id)
  15. .noCache()
  16. .resolveInvisible()
  17. .first();
  18. if (object == null) {
  19. object = type.createObject(id);
  20. }
  21. merge(object);
  22. return object;
  23. }

代码示例来源:origin: perfectsense/brightspot-cms

  1. public static History publishDifferences(
  2. Object object,
  3. Map<String, Map<String, Object>> differences,
  4. Site site,
  5. ToolUser user) {
  6. State state = State.getInstance(object);
  7. UUID id = state.getId();
  8. DistributedLock lock = DistributedLock.Static.getInstance(
  9. Database.Static.getDefault(),
  10. Content.class.getName() + "/publish/" + id);
  11. lock.lock();
  12. try {
  13. Object oldObject = Query.fromAll().where("_id = ?", id).noCache().first();
  14. if (oldObject != null) {
  15. state.setValues(Draft.mergeDifferences(
  16. state.getDatabase().getEnvironment(),
  17. State.getInstance(oldObject).getSimpleValues(),
  18. differences));
  19. }
  20. return publish(object, site, user);
  21. } finally {
  22. lock.unlock();
  23. }
  24. }

代码示例来源:origin: perfectsense/brightspot-cms

  1. @Override
  2. protected void doService(ToolPageContext page) throws IOException, ServletException {
  3. Object content = Query
  4. .fromAll()
  5. .where("_id = ?", page.param(UUID.class, "id"))
  6. .first();
  7. if (content != null) {
  8. ContentLock.Static.unlock(content, null, page.getUser());
  9. }
  10. String returnUrl = page.param(String.class, "returnUrl");
  11. if (ObjectUtils.isBlank(returnUrl)) {
  12. page.writeRaw(page.localize(ContentUnlock.class, "label.ok"));
  13. } else {
  14. JspUtils.redirect(
  15. page.getRequest(),
  16. page.getResponse(),
  17. page.param(String.class, "returnUrl"));
  18. }
  19. }
  20. }

相关文章