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

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

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

Query.first介绍

[英]Returns the first object matching this query in a #getDatabase.
[中]返回#getDatabase中与此查询匹配的第一个对象。

代码示例

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

@Override
  protected Section produce(String name) {
    return Query.from(Section.class).where("internalName = ?", name).first();
  }
});

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

@Override
  @SuppressWarnings("unchecked")
  public void ping() {
    Database defaultDatabase = Database.Static.getDefault();

    if (defaultDatabase instanceof Iterable) {
      for (Database delegate : (Iterable<Database>) defaultDatabase) {
        Query.from(Object.class).using(delegate).first();
      }

    } else {
      Query.from(Object.class).first();
    }
  }
}

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

/**
 * Get the Production Guide for the given content type {@code content}
 */
public static GuidePage getPageTypeProductionGuide(ObjectType contentType) {
  if (contentType != null) {
    GuidePage guide = Query.from(GuidePage.class)
        .where("pageTypes = ?", contentType).first();
    if (guide != null) {
      return guide;
    }
  }
  return null;
}

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

public static Search named(String name) {
  return Query.from(Search.class).where("internalName = ?", name).first();
}

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

public static ToolUser getByTotpToken(String totpToken) {
  ToolUser user = Query.from(ToolUser.class).option(Database.DISABLE_FUNNEL_CACHE_QUERY_OPTION, true).where("totpToken = ?", totpToken).first();
  return user != null && user.totpTokenTime + 60000 > System.currentTimeMillis() ? user : null;
}

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

/**
 * Returns the item that the given {@code user} is currently working
 * on.
 *
 * @param user Can't be {@code null}.
 * @return May be {@code null}.
 */
public Object getCurrentItem(ToolUser user) {
  ErrorUtils.errorIfNull(user, "user");
  return currentItems != null
      ? Query.from(Object.class).where("_id = ?", currentItems.get(user.getId().toString())).first()
      : null;
}

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

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

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

/**
 * Retrieve the existing GuideType instance for a given {@code objectType}.
 * If none exists, null is returned
 */
public static GuideType getGuideType(ObjectType objectType) {
  return Query.from(GuideType.class)
      .where("documentedType = ?", objectType.getId()).first();
}

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

/**
 * Finds the last action from this device.
 *
 * @return May be {@code null}.
 */
public ToolUserAction findLastAction() {
  return Query
      .from(ToolUserAction.class)
      .where("device = ?", this)
      .sortDescending("time")
      .first();
}

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

private Map<String, Object> readFirst(Database database, WebPageContext context) {
  State state = State.getInstance(createQuery(database, context).first());
  return state != null ? state.getSimpleValues() : null;
}

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

@Override
  public String load(UUID directoryId) {
    Directory directory = Query
        .from(Directory.class)
        .where("_id = ?", directoryId)
        .first();
    if (directory != null) {
      return directory.getPath();
    } else {
      throw DIRECTORY_NOT_FOUND;
    }
  }
});

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

public static ToolUser getByToken(String token) {
    ToolUser user = Query.from(ToolUser.class).option(Database.DISABLE_FUNNEL_CACHE_QUERY_OPTION, true).where("loginTokens/token = ?", token).first();
    return user != null && user.getLoginToken(token) != null ? user : null;
  }
}

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

/**
 * Returns {@code true} if any instances of the types associated
 * with the given {@code name} have been updated since the given
 * {@code time}.
 */
public static boolean isUpdated(String name, long time) {
  Tracker tracker = Query
      .from(Tracker.class)
      .where("_id = ?", createTrackerId(name))
      .master()
      .noCache()
      .first();
  return tracker != null && tracker.getLastUpdate() > time;
}

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

public void renderAction(ToolPageContext page, ToolUser user, ToolUserAction action) throws IOException {
  Object content = Query
      .from(Object.class)
      .where("_id = ?", action.getContentId())
      .first();
  Preview preview = Query
      .from(Preview.class)
      .where("_id = ?", user.getCurrentPreviewId())
      .first();
  String mirrorUrl = StringUtils.addQueryParameters(preview != null && ObjectUtils.equals(action.getContentId(), preview.getObjectId())
      ? JspUtils.getAbsolutePath(page.getRequest(), "/_preview", "_cms.db.previewId", preview.getId())
      : action.getUrl(), "_mirror", true);
  doRenderAction(page, content, mirrorUrl);
}

相关文章