Beispiel #1
0
 private String getBlogEntryWhereClause(
     WikiDocument ignoreDoc, Integer year, Integer month, Integer day, String tag) {
   StringBuilder clause = new StringBuilder();
   clause.append("where doc2.PARENT_NODE_ID in (:directoryIDs)").append(" ");
   clause.append("and doc.HEADER_MACROS like '%blogEntry%'").append(" ");
   clause.append("and doc2.READ_ACCESS_LEVEL <= :currentAccessLevel").append(" ");
   if (ignoreDoc != null && ignoreDoc.getId() != null)
     clause.append("and doc.NODE_ID<>:ignoreDoc").append(" ");
   if (tag != null && tag.length() > 0) clause.append("and t.TAG = :tag").append(" ");
   if (year != null) clause.append("and year(doc2.CREATED_ON) = :limitYear").append(" ");
   if (month != null) clause.append("and month(doc2.CREATED_ON) = :limitMonth").append(" ");
   if (day != null) clause.append("and day(doc2.CREATED_ON) = :limitDay").append(" ");
   return clause.toString();
 }
Beispiel #2
0
  private void bindBlogEntryWhereClause(
      Query query,
      WikiDirectory startDir,
      WikiDocument ignoreDoc,
      Integer year,
      Integer month,
      Integer day,
      String tag) {
    query.setParameterList("directoryIDs", wikiNodeDAO.findWikiDirectoryTreeIDs(startDir));
    query.setParameter("currentAccessLevel", currentAccessLevel);

    if (ignoreDoc != null && ignoreDoc.getId() != null) query.setParameter("ignoreDoc", ignoreDoc);
    if (tag != null && tag.length() > 0) query.setParameter("tag", tag);
    if (year != null) query.setParameter("limitYear", year);
    if (month != null) query.setParameter("limitMonth", month);
    if (day != null) query.setParameter("limitDay", day);
  }
  @Test
  public void macrosFromDefaultStrings() throws Exception {
    WikiDocument doc = new WikiDocument();

    WikiDocumentDefaults defaults =
        new WikiDocumentDefaults() {
          @Override
          public String[] getContentMacrosAsString() {
            return new String[] {"contentMacro1", "contentMacro2"};
          }

          @Override
          public String getContentText() {
            return "foo";
          }

          @Override
          public String[] getHeaderMacrosAsString() {
            return new String[] {"headerMacro1", "headerMacro2"};
          }

          @Override
          public String getHeaderText() {
            return "bar";
          }

          @Override
          public String[] getFooterMacrosAsString() {
            return new String[] {"footerMacro1", "footerMacro2"};
          }

          @Override
          public String getFooterText() {
            return "baz";
          }
        };
    doc.setDefaults(defaults);

    assert doc.getContentMacros().size() == 2;
    assert doc.getContentMacrosString().contains("contentMacro1");
    assert doc.getContentMacrosString().contains("contentMacro1");
    assert doc.getContent().contains("[<=contentMacro1]");
    assert doc.getContent().contains("[<=contentMacro2]");
    assert doc.getContent().indexOf("foo") == doc.getContent().length() - 3;

    assert doc.getHeaderMacros().size() == 2;
    assert doc.getHeaderMacrosString().contains("headerMacro1");
    assert doc.getHeaderMacrosString().contains("headerMacro2");
    assert doc.getHeader().contains("[<=headerMacro1]");
    assert doc.getHeader().contains("[<=headerMacro2]");
    assert doc.getHeader().indexOf("bar") == doc.getHeader().length() - 3;

    assert doc.getFooterMacros().size() == 2;
    assert doc.getFooterMacrosString().contains("footerMacro1");
    assert doc.getFooterMacrosString().contains("footerMacro2");
    assert doc.getFooter().contains("[<=footerMacro1]");
    assert doc.getFooter().contains("[<=footerMacro2]");
    assert doc.getFooter().indexOf("baz") == 0;
  }
  @Test
  public void macrosFromDefaultTypesafe() throws Exception {
    WikiDocument doc = new WikiDocument();

    WikiDocumentDefaults defaults =
        new WikiDocumentDefaults() {
          @Override
          public List<WikiTextMacro> getContentMacros() {
            return new ArrayList<WikiTextMacro>() {
              {
                add(new WikiTextMacro("contentMacro1", 0));
                add(new WikiTextMacro("contentMacro2", 1));
              }
            };
          }

          @Override
          public String getContentText() {
            return "foo";
          }

          @Override
          public List<WikiTextMacro> getHeaderMacros() {
            return new ArrayList<WikiTextMacro>() {
              {
                add(new WikiTextMacro("headerMacro1", 0));
                add(new WikiTextMacro("headerMacro2", 1));
              }
            };
          }

          @Override
          public String getHeaderText() {
            return "bar";
          }

          @Override
          public List<WikiTextMacro> getFooterMacros() {
            return new ArrayList<WikiTextMacro>() {
              {
                add(new WikiTextMacro("footerMacro1", 0));
                add(new WikiTextMacro("footerMacro2", 1));
              }
            };
          }

          @Override
          public String getFooterText() {
            return "baz";
          }
        };
    doc.setDefaults(defaults);

    assert doc.getContentMacros().size() == 2;
    assert doc.getContentMacrosString().contains("contentMacro1");
    assert doc.getContentMacrosString().contains("contentMacro1");
    assert doc.getContent().contains("[<=contentMacro1]");
    assert doc.getContent().contains("[<=contentMacro2]");
    assert doc.getContent().indexOf("foo") == doc.getContent().length() - 3;

    assert doc.getHeaderMacros().size() == 2;
    assert doc.getHeaderMacrosString().contains("headerMacro1");
    assert doc.getHeaderMacrosString().contains("headerMacro2");
    assert doc.getHeader().contains("[<=headerMacro1]");
    assert doc.getHeader().contains("[<=headerMacro2]");
    assert doc.getHeader().indexOf("bar") == doc.getHeader().length() - 3;

    assert doc.getFooterMacros().size() == 2;
    assert doc.getFooterMacrosString().contains("footerMacro1");
    assert doc.getFooterMacrosString().contains("footerMacro2");
    assert doc.getFooter().contains("[<=footerMacro1]");
    assert doc.getFooter().contains("[<=footerMacro2]");
    assert doc.getFooter().indexOf("baz") == 0;
  }