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

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

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

Query.from介绍

[英]Queries over objects of types that are compatible with the given objectClass.
[中]对与给定objectClass兼容的类型的对象的查询。

代码示例

代码示例来源: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

/** @deprecated Use {@link Query#from} instead. */
@Deprecated
public <T> Query<T> queryFrom(Class<T> objectClass) {
  Query<T> query = Query.from(objectClass);
  query.setDatabase(getDatabase());
  return query;
}

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

/**
 * @deprecated Use {@link Query#from} and {@link Site#itemsPredicate}
 *             together instead.
 */
@Deprecated
public static <T> Query<T> queryFrom(HttpServletRequest request, Class<T> objectClass) {
  return Query.from(objectClass).where(Site.OWNER_FIELD + " = ?", getSite(request));
}

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

/**
 * Finds an object of the given {@code type} matching the given
 * {@code id} using the given {@code database}.
 */
public static <T> T findById(Database database, Class<T> type, UUID id) {
  return id == null ? null : database.readFirst(Query.from(type).where("_id = ?", id));
}

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

/**
 * Finds an unique object of the given {@code type} matching the
 * given {@code field} and {@code value} using the given
 * {@code database}.
 */
public static <T> T findUnique(Database database, Class<T> type, String field, String value) {
  return value == null ? null : database.readFirst(Query.from(type).where(field + " = ?", value));
}

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

public Object getContent() {
  return Query
      .from(Object.class)
      .where("_id = ?", getContentId())
      .first();
}

代码示例来源: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

public static ToolUser getByChangePasswordToken(String changePasswordToken) {
  ToolUser user = Query.from(ToolUser.class).option(Database.DISABLE_FUNNEL_CACHE_QUERY_OPTION, true).where("changePasswordToken = ?", changePasswordToken).first();
  long expiration = Settings.getOrDefault(long.class, "cms/tool/changePasswordTokenExpirationInHours", 24L) * 60L * 60L * 1000L;
  return user != null && user.changePasswordTokenTime + expiration > System.currentTimeMillis() ? user : null;
}

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

/**
 * Returns the number of items completed by the given {@code user}.
 *
 * @param user Can't be {@code null}.
 */
public long countComplete(ToolUser user) {
  ErrorUtils.errorIfNull(user, "user");
  return Query
      .from(Object.class)
      .where("cms.workstream.completeIds = ?", getId().toString() + "," + user.getId().toString())
      .count();
}

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

/**
 * Clear the SearchResultSelection by deleting all of the SearchResultSelectionItem that point to it.
 */
public void clear() {
  Query.from(SearchResultSelectionItem.class)
      .where("selectionId = ?", getId())
      .deleteAll();
}

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

/** @see Query#from */
public <T> Query<T> queryFrom(Class<T> objectClass) {
  Query<T> query = Query.from(objectClass);
  query.setDatabase(getState().getDatabase());
  return query;
}

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

/**
 * Returns a partial list of all the revisions of the object with the
 * given {@code objectId} within the given {@code offset} and
 * {@code limit}.
 */
public static PaginatedResult<History> findByObjectId(ToolUser user, UUID objectId, long offset, int limit) {
  return Query
      .from(History.class)
      .where("objectId = ?", objectId)
      .sortDescending("updateDate")
      .select(offset, limit);
}

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

private Taxon findParent(ToolPageContext page) {
  return Query
      .from(Taxon.class)
      .where("_id = ?", page.param(UUID.class, PARENT_ID_PARAMETER))
      .first();
}

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

/**
 * Returns the object.
 *
 * @return May be {@code null}.
 */
public Object getObject() {
  if (object == null) {
    object = Query.from(Object.class).where("_id = ?", getObjectId()).first();
  }
  return object;
}

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

/**
 * Returns the tool user that initiated the workflow transition.
 *
 * @return May be {@code null}.
 */
public ToolUser getUser() {
  return Query.from(ToolUser.class).where("_id = ?", getUserId()).first();
}

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

/**
 * Retrieve a GuideType instance for the given {@code documentedType}, creating one if it
 * doesn't already exist.
 */
public static GuideType findOrCreateGuide(ObjectType documentedType) {
  GuideType guide = Query.from(GuideType.class)
      .where("documentedType = ?", documentedType.getId()).first();
  if (guide == null) {
    guide = createGuide(documentedType);
  }
  return guide;
}

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

/** Returns the number of remaining items to be worked on. */
public long countIncomplete() {
  return getQuery().clone()
      .and("id != ?", Query.from(Object.class).where("cms.workstream.completeIds ^= ?", getId().toString() + ","))
      .count();
}

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

/**
 * Retrieve a GuideType instance for the parent type of a given {@code field}, creating one if it
 * doesn't already exist.
 */
public static GuideType findOrCreateGuide(ObjectField field) {
  GuideType guide = Query.from(GuideType.class)
      .where("documentedType = ?", field.getParentType().getId()).first();
  if (guide == null) {
    guide = createGuide(field.getParentType());
  }
  return guide;
}

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

private void deleteWorksInProgress(Object object) {
  UUID contentId = object instanceof Draft
      ? ((Draft) object).getObjectId()
      : State.getInstance(object).getId();
  Query.from(WorkInProgress.class)
      .where("owner = ?", getUser())
      .and("contentId = ?", contentId)
      .deleteAll();
}

相关文章