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

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

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

Query.selectAll介绍

[英]Returns a list of all objects matching this query in a #getDatabase.
[中]返回#getDatabase中与此查询匹配的所有对象的列表。

代码示例

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

/** @deprecated Use {@link #selectAll} instead. */
@Deprecated
public List<E> select() {
  return selectAll();
}

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

/**
 * Returns all users that are currently working.
 *
 * @return Never {@code null} but may be empty.
 */
public List<ToolUser> getUsers() {
  return currentItems != null
      ? Query.from(ToolUser.class).where("_id = ?", currentItems.keySet()).selectAll()
      : new ArrayList<ToolUser>();
}

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

@Override
public Iterable<?> create(Map<String, Object> data) {
  return Query.from(EditFieldUpdate.class)
      .where("contentId = ?", data.get("contentId"))
      .selectAll();
}

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

/**
 * Returns SearchResultSelections that were created by the specified {@link ToolUser}.
 * @param user the {@link ToolUser} for which SearchResultSelections should be returned.
 * @return {@link SearchResultSelection}s that were created by the specified {@link ToolUser}.
 */
public static List<SearchResultSelection> findOwnSelections(ToolUser user) {
  if (user == null) {
    return null;
  }
  return Query.from(SearchResultSelection.class).where("entities = ?", user).selectAll();
}

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

/**
 * Returns a cached list of all templates in the given {@code site}.
 */
public static List<Template> findAll(Site site) {
  List<Template> templates = new ArrayList<Template>();
  for (Template template : Query.from(Template.class).sortAscending("name").selectAll()) {
    if (Site.Static.isObjectAccessible(site, template)) {
      templates.add(template);
    }
  }
  return templates;
}

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

private List<Map<String, Object>> readAll(Database database, WebPageContext context) {
  List<Map<String, Object>> itemMaps = new ArrayList<Map<String, Object>>();
  for (Object item : createQuery(database, context).selectAll()) {
    itemMaps.add(State.getInstance(item).getSimpleValues());
  }
  return itemMaps;
}

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

public static List<Spotlight> getMatchingSpotlights(String... queryTerms) {
  return Query.from(Spotlight.class).where("spotLightTerms = ?", queryTerms).selectAll();
}

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

private <T extends SearchAdvancedPredicate> T findSearchAdvancedPredicate(Class<T> predicateClass, String value) {
  for (T p : Query
      .from(predicateClass)
      .sortAscending("dari.singleton.key")
      .selectAll()) {
    if (p.getParameterValue().equals(value)) {
      return p;
    }
  }
  return null;
}

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

public void addChanges(Schedule schedule) {
  for (Draft draft : Query
      .from(Draft.class)
      .where("schedule = ?", schedule)
      .selectAll()) {
    differencesById.put(draft.getObjectId(), draft.getDifferences());
  }
}

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

@Override
  public Iterable<?> close(Map<String, Object> data, UUID userId) {
    return Query
        .from(EditFieldUpdate.class)
        .where("_id = ?", EditFieldUpdate.id(userId, ObjectUtils.to(UUID.class, data.get("contentId"))))
        .selectAll();
  }
}

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

@Override
  public Iterable<?> findVisibilityValues(ObjectIndex index) {
    Set<Object> visibilityValues = new HashSet<Object>();
    for (Workflow workflow : Query.from(Workflow.class).where("contentTypes = ?", State.getInstance(getOriginalObject()).getType()).selectAll()) {
      visibilityValues.add(workflow.getStates());
    }
    return visibilityValues;
  }
}

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

public <T> List<T> getObjects() {
    Map<String, FacetField.Count> index = new HashMap<String, FacetField.Count>();
    List<String> ids = new ArrayList<String>();
    for (FacetField.Count c : this.field.getValues()) {
      index.put(c.getName(), c);
      ids.add(c.getName());
    }
    @SuppressWarnings("unchecked")
    List<T> objects = (List<T>) (this.klass == null || this.klass == Query.class
        ? Query.fromAll().where("id = ?", ids).selectAll()
        : Query.from(this.klass).where("id = ?", ids).selectAll());
    if (objects != null) {
      for (Object o : objects) {
        Record record = (Record) o;
        FacetField.Count c = index.get(record.getId().toString());
        record.getState().getExtras().put("count", Long.valueOf(c.getCount()));
      }
    }
    return objects;
  }
}

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

/**
 * Generates a {@link Query} for the items contained within this {@link SearchResultSelection}.  The returned
 * Query is {@code .fromAll()} and includes visibility-restricted items.
 * @return a {@link Query} for the items contained within this {@link SearchResultSelection}.
 */
public Query<Object> createItemsQuery() {
  Set<UUID> itemIds = new HashSet<>();
  for (SearchResultSelectionItem item : Query
      .from(SearchResultSelectionItem.class)
      .where("selectionId = ?", getId())
      .selectAll()) {
    itemIds.add(item.getItemId());
  }
  return Query.fromAll().where("_id = ?", itemIds);
}

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

public static <T extends Taxon> List<T> getRoots(Class<T> taxonClass, Site site, Predicate predicate) {
  Query<T> query = Query.from(taxonClass).where("cms.taxon.root = true");
  if (site != null) {
    query.and(site.itemsPredicate());
  }
  List<T> roots = query.selectAll();
  return filter(roots, predicate);
}

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

public List<?> findDropDownItems(ObjectField field, Search dropDownSearch) {
  List<?> items;
  if (field.getTypes().contains(ObjectType.getInstance(ObjectType.class))) {
    List<ObjectType> types = new ArrayList<ObjectType>();
    Predicate predicate = dropDownSearch.toQuery(getSite()).getPredicate();
    for (ObjectType t : Database.Static.getDefault().getEnvironment().getTypes()) {
      if (t.is(predicate)) {
        types.add(t);
      }
    }
    items = new ArrayList<Object>(types);
  } else {
    items = dropDownSearch.toQuery(getSite()).selectAll();
  }
  return items;
}

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

private long getAvailableActionCount(boolean archive) {
  if (getSelection() != null) {
    return itemsQuery().noCache().selectAll().stream().filter(i -> isItemActionable(i, archive)).count();
  } else if (getSearch() != null) {
    return isSearchActionable(getSearch(), archive) ? getSearch().toQuery(getSite()).count() : 0;
  }
  return 0;
}

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

/**
 * Finds a list of all templates that are usable with the given
 * {@code object}.
 *
 * @return Never {@code null}. Mutable.
 */
public static List<Template> findUsable(Object object) {
  List<Template> templates = new ArrayList<Template>();
  if (object != null) {
    State state = State.getInstance(object);
    Site owner = state.as(Site.ObjectModification.class).getOwner();
    ObjectType type = state.getType();
    for (Template template : Query.from(Template.class).sortAscending("name").selectAll()) {
      if (template.getContentTypes().contains(type) &&
          (owner == null ||
          Site.Static.isObjectAccessible(owner, template))) {
        templates.add(template);
      }
    }
  }
  return templates;
}

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

@Override
  protected void afterDelete() {
    State state = getState();

    if (state.isVisible()) {
      return;
    }

    for (Object item : Query
        .fromAll()
        .where("cms.bulkUpload.containerId = ?", state.getId().toString())
        .selectAll()) {
      State.getInstance(item).deleteImmediately();
    }
  }
}

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

@Override
protected void afterSave() {
  if (!isRunAfterSave()
      || !getState().isVisible()) {
    return;
  }
  for (Object item : Query
      .fromAll()
      .where("cms.bulkUpload.containerId = ?", getId().toString())
      .selectAll()) {
    State itemState = State.getInstance(item);
    itemState.as(BulkUploadDraft.class).setContainerId(null);
    itemState.saveImmediately();
  }
}

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

/**
 * Finds the most recent device that the user was using.
 *
 * @return May be {@code null}.
 */
public ToolUserDevice findRecentDevice() {
  ToolUserDevice device = null;
  for (ToolUserDevice d : Query
      .from(ToolUserDevice.class)
      .where("user = ?")
      .selectAll()) {
    if (device == null
        || device.findLastAction() == null
        || (d.findLastAction() != null
        && d.findLastAction().getTime() > device.findLastAction().getTime())) {
      device = d;
    }
  }
  return device;
}

相关文章