Package freemarker.template

Examples of freemarker.template.SimpleSequence$SynchronizedSequence


        @Override
        public TemplateModel get(final String key) throws TemplateModelException {
            if ("published_posts".equals(key)) {
                List<ODocument> query = db.query(new OSQLSynchQuery<ODocument>("select * from post where status='published' order by date desc"));
                return new SimpleSequence(DocumentList.wrap(query.iterator()));
            }
            if ("published_pages".equals(key)) {
                List<ODocument> query = db.query(new OSQLSynchQuery<ODocument>("select * from page where status='published' order by date desc"));
                return new SimpleSequence(DocumentList.wrap(query.iterator()));
            }
            if ("published_content".equals(key)) {
              List<ODocument> publishedContent = new ArrayList<ODocument>();
              String[] documentTypes = DocumentTypes.getDocumentTypes();
              for (String docType : documentTypes) {
                List<ODocument> query = db.query(new OSQLSynchQuery<ODocument>("select * from "+docType+" where status='published' order by date desc"));
                publishedContent.addAll(query);
              }
              return new SimpleSequence(DocumentList.wrap(publishedContent.iterator()));
            }
            if ("all_content".equals(key)) {
              List<ODocument> allContent = new ArrayList<ODocument>();
              String[] documentTypes = DocumentTypes.getDocumentTypes();
              for (String docType : documentTypes) {
                List<ODocument> query = db.query(new OSQLSynchQuery<ODocument>("select * from "+docType+" order by date desc"));
                allContent.addAll(query);
              }
              return new SimpleSequence(DocumentList.wrap(allContent.iterator()));
            }
            if ("alltags".equals(key)) {
                List<ODocument> query = db.query(new OSQLSynchQuery<ODocument>("select tags from post where status='published'"));
                Set<String> result = new HashSet<String>();
                for (ODocument document : query) {
                    String[] tags = DBUtil.toStringArray(document.field("tags"));
                    Collections.addAll(result, tags);
                }
                return new SimpleCollection(result);
            }
            String[] documentTypes = DocumentTypes.getDocumentTypes();
            for (String docType : documentTypes) {
                if ((docType+"s").equals(key)) {
                    return new SimpleSequence(DocumentList.wrap(DBUtil.query(db, "select * from "+docType+" order by date desc").iterator()));
                }
            }
            if ("tag_posts".equals(key)) {
                String tag = eagerModel.get("tag").toString();
                // fetch the tag posts from db
                List<ODocument> query = DBUtil.query(db, "select * from post where status='published' where ? in tags order by date desc", tag);
                return new SimpleSequence(DocumentList.wrap(query.iterator()));
            }
            if ("published_date".equals(key)) {
                return new SimpleDate(new Date(), TemplateDateModel.UNKNOWN);
            }
            return eagerModel.get(key);
View Full Code Here


            Scope scope = new NamedParameterMapScope(env.getCurrentScope(),
                    result);
            fillInDefaults(env, scope, params.subList(argsSize, paramsSize));
        }
        if(catchall != null) {
            SimpleSequence catchAllVars = new SimpleSequence();
            result.put(catchall, catchAllVars);
            for (int i = paramsSize; i < argsSize; i++) {
                catchAllVars.add(args.getValueAt(i, env));
            }
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of freemarker.template.SimpleSequence$SynchronizedSequence

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.