예제 #1
0
  private void applyAssignedToContentsHql(
      ContentSpecification specification, SelectBuilder hqlQuery) {
    hqlQuery.addFilter(
        "AND", "c.assignee = '" + specification.getAssignee().getKey().toString() + "'");

    if (specification.assignedDraftsOnly()) {
      hqlQuery.addFilter("AND", "c.draftVersion != null");
    }
  }
예제 #2
0
 private String getRelatedChildrenByKeyHQL(List<ContentVersionKey> contentVersionKeys) {
   final SelectBuilder hqlQuery = new SelectBuilder(0);
   hqlQuery.addSelect("rc.key.parentContentVersionKey");
   hqlQuery.addSelectColumn("c");
   hqlQuery.addFromTable(RelatedContentEntity.class.getName(), "rc", SelectBuilder.NO_JOIN, null);
   hqlQuery.addFromTable(ContentEntity.class.getName(), "c", SelectBuilder.NO_JOIN, null);
   // hqlQuery.addFromTable( "c.mainVersion", null, SelectBuilder.LEFT_JOIN_FETCH, null );
   // hqlQuery.addFromTable( "c.sectionContents", null, SelectBuilder.LEFT_JOIN_FETCH, null );
   // hqlQuery.addFromTable( "c.contentHomes", null, SelectBuilder.LEFT_JOIN_FETCH, null );
   hqlQuery.addFilter("AND", "rc.key.childContentKey = c.key");
   hqlQuery.addFilter(
       "AND",
       new InClauseBuilder<ContentVersionKey>(
           "rc.key.parentContentVersionKey", contentVersionKeys) {
         public void appendValue(StringBuffer sql, ContentVersionKey value) {
           sql.append(value.toString());
         }
       }.toString());
   hqlQuery.addFilter("AND", "c.deleted = 0");
   hqlQuery.addOrderBy("c.createdAt");
   return hqlQuery.toString();
 }
예제 #3
0
  public String getNumberOfRelatedParentsByKeyHQL(List<ContentKey> contentKeys) {
    final SelectBuilder hqlQuery = new SelectBuilder(0);
    hqlQuery.addSelect("count(*)");
    hqlQuery.addFromTable(ContentVersionEntity.class.getName(), "cv", SelectBuilder.NO_JOIN, null);
    hqlQuery.addFromTable(RelatedContentEntity.class.getName(), "rc", SelectBuilder.NO_JOIN, null);
    hqlQuery.addFromTable(ContentEntity.class.getName(), "c", SelectBuilder.NO_JOIN, null);
    hqlQuery.addFilter("AND", "cv.key = rc.key.parentContentVersionKey");
    hqlQuery.addFilter("AND", "c.mainVersion.key = cv.key");
    hqlQuery.addFilter(
        "AND",
        new InClauseBuilder<ContentKey>("rc.key.childContentKey", contentKeys) {
          public void appendValue(StringBuffer sql, ContentKey value) {
            sql.append(value.toString());
          }
        }.toString());

    hqlQuery.addFilter("AND", "c.deleted = 0");
    return hqlQuery.toString();
  }
예제 #4
0
  private String getContentKeysHQL(
      ContentSpecification specification, String orderBy, boolean count) {
    final SelectBuilder hqlQuery = new SelectBuilder(0);

    if (count) {
      hqlQuery.addSelect("count (c.key) ");
    } else {
      hqlQuery.addSelect("c.key");
    }
    hqlQuery.addFromTable("ContentEntity", "c", SelectBuilder.NO_JOIN, null);

    applyIsDeletedFilter(specification, hqlQuery);

    applyAssignedToContentsHql(specification, hqlQuery);

    if (orderBy != null) {
      hqlQuery.addOrderBy(orderBy);
    }

    return hqlQuery.toString();
  }
예제 #5
0
 private void applyIsDeletedFilter(
     ContentSpecification specification, final SelectBuilder hqlQuery) {
   if (!specification.doIncludeDeleted()) {
     hqlQuery.addFilter("AND", "c.deleted = 0");
   }
 }