Package org.vosao.entity

Examples of org.vosao.entity.TemplateEntity


  private void checkTheme(String path) {
    if (path.startsWith("theme/")) {
      String[] parts = path.split("/");
      if (parts.length == 2) {
        String url = parts[1];
        TemplateEntity template = getDao().getTemplateDao()
          .getByUrl(url);
        if (template == null) {
          template = new TemplateEntity(url, "", url);
          getDao().getTemplateDao().save(template);
        }
      }
    }
  }
View Full Code Here


    "org/vosao/resources/html/search.html";
 
  private void initPages() {
    List<PageEntity> roots = getDao().getPageDao().getByParent("");
    if (roots.size() == 0) {
      TemplateEntity template = getDao().getTemplateDao().getByUrl("simple");
      addPage("Home page", "/", HOME_PAGE_FILE, template.getId(), 0, true,
          true);
      getBusiness().getContentPermissionBusiness().setPermission(
          "/", guests, ContentPermissionType.READ);
          addPage("Site user Login", "/login", LOGIN_PAGE_FILE,
              template.getId(), 0, true, false);
          addPage("Search", "/search", SEARCH_PAGE_FILE, template.getId(), 1,
              false, false);
    }
  }
View Full Code Here

 
  private void initTemplates() {
    List<TemplateEntity> list = getDao().getTemplateDao().select();
    if (list.size() == 0) {
      String content = loadResource(SIMPLE_TEMPLATE_FILE);
      TemplateEntity template = new TemplateEntity("Simple", content,
          "simple");
      getDao().getTemplateDao().save(template);
          log.info("Adding default template.");
    }
  }
View Full Code Here

 
  private TemplateEntity readThemeImportXML(final String xml)
      throws DocumentException {
    Document doc = DocumentHelper.parseText(xml);
    Element root = doc.getRootElement();
    TemplateEntity template = new TemplateEntity();
    for (Iterator<Element> i = root.elementIterator(); i.hasNext();) {
      Element element = i.next();
      if (element.getName().equals("title")) {
        template.setTitle(element.getStringValue());
      }
      if (element.getName().equals("url")) {
        template.setUrl(element.getStringValue());
      }
    }
    return template;
 
View Full Code Here

  public void createThemeByDescription(final ZipEntry entry, String xml)
      throws UnsupportedEncodingException, DocumentException,
      DaoTaskException {
    String[] chain = FolderUtil.getPathChain(entry);
    String themeName = chain[1];
    TemplateEntity theme = getDao().getTemplateDao().getByUrl(themeName);
    if (theme == null) {
      theme = new TemplateEntity();
      theme.setContent("");
    }
    String content = theme.getContent();
    TemplateEntity parsedEntity = readThemeImportXML(xml);
    theme.copy(parsedEntity);
    theme.setContent(content);
    getDaoTaskAdapter().templateSave(theme);
 
View Full Code Here

      final String content)
      throws UnsupportedEncodingException, DocumentException,
      DaoTaskException {
    String[] chain = FolderUtil.getPathChain(entry);
    String themeName = chain[1];
    TemplateEntity theme = getDao().getTemplateDao().getByUrl(themeName);
    if (theme == null) {
      theme = new TemplateEntity();
      theme.setTitle(themeName);
      theme.setUrl(themeName);
    }
    theme.setContent(content);
    getDaoTaskAdapter().templateSave(theme);
  }
View Full Code Here

    String folderPath = FolderUtil.getFilePath(path);
    String templateName = getTemplateName(folderPath);
    if (templateName == null) {
      return false;
    }
    TemplateEntity template = getDao().getTemplateDao().getByUrl(
        templateName);
    if (template == null) {
      template = new TemplateEntity();
      template.setUrl(templateName);
    }
    Element root = DocumentHelper.parseText(xml).getRootElement();
    String title = root.elementText("title");
    if (!StringUtils.isEmpty(title)) {
      template.setTitle(title);
    }
    String content = root.elementText("content");
    if (!StringUtils.isEmpty(content)) {
      template.setContent(content);
    }
    getDaoTaskAdapter().templateSave(template);
    return true;
  }
View Full Code Here

import org.vosao.entity.TemplateEntity;

public class TemplateDaoTest extends AbstractDaoTest {

  private TemplateEntity addTemplate(final String title, final String content) {
    TemplateEntity Template = new TemplateEntity(title, content, title);
    getDao().getTemplateDao().save(Template);
    return Template;
  }
View Full Code Here

 
  public void testSave() {
    addTemplate("title", "content");
    List<TemplateEntity> Templates = getDao().getTemplateDao().select();
    assertEquals(1, Templates.size());
    TemplateEntity Template1 = Templates.get(0);
    assertEquals("title", Template1.getTitle());
 
View Full Code Here

    TemplateEntity Template1 = Templates.get(0);
    assertEquals("title", Template1.getTitle());
 
 
  public void testGetById() {
    TemplateEntity Template = addTemplate("title","content");
    assertNotNull(Template.getId());
    TemplateEntity Template2 = getDao().getTemplateDao().getById(Template.getId());
    assertEquals(Template.getTitle(), Template2.getTitle());
    assertEquals(Template.getContent(), Template2.getContent());
 
View Full Code Here

TOP

Related Classes of org.vosao.entity.TemplateEntity

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.