Package org.vosao.entity

Examples of org.vosao.entity.LanguageEntity


    return getDao().getLanguageDao().getById(id);
  }

  private List<String> validate(LanguageEntity entity) {
    List<String> errors = new ArrayList<String>();
    LanguageEntity found = getDao().getLanguageDao().getByCode(
        entity.getCode());
    if (found != null && !found.getId().equals(entity.getId())) {
        errors.add(Messages.get("language.code_registered"));
    }
    return errors;
  }
View Full Code Here


    return errors;
  }
  @Override
 
  public ServiceResponse save(Map<String, String> vo) {
    LanguageEntity language = null;
    if (!StringUtils.isEmpty(vo.get("id"))) {
      language = getDao().getLanguageDao().getById(Long.valueOf(
          vo.get("id")));
    }
    if (language == null) {
      language = new LanguageEntity();
    }
    language.setCode(vo.get("code"));
    language.setTitle(vo.get("title"));
    List<String> errors = validate(language);
    if (errors.isEmpty()) {
      getDao().getLanguageDao().save(language);
      return ServiceResponse.createSuccessResponse(
            Messages.get("language.success_save"));
View Full Code Here

  }

  @Override
  public String getLanguage() {
      String localeLanguage = VosaoContext.getInstance().getLanguage();
      LanguageEntity language = getDao().getLanguageDao().getByCode(
          localeLanguage);
      if (language == null) {
        localeLanguage = getDefaultLanguage();
      }
    return localeLanguage;
View Full Code Here

    return localeLanguage;
  }

  @Override
  public String getDefaultLanguage() {
       LanguageEntity language = getDao().getLanguageDao().getByCode(
          VosaoContext.getInstance().getConfig().getDefaultLanguage());
       if (language == null) {
         List<LanguageEntity> langs = getDao().getLanguageDao().select();
         if (langs.isEmpty()) {
           return LanguageEntity.ENGLISH_CODE;
         }
         language = langs.get(0);
       }
    return language.getCode();
  }
View Full Code Here

    initForms();
    initLanguages();
  }
 
  private void initLanguages() {
    LanguageEntity lang = getDao().getLanguageDao().getByCode(
        LanguageEntity.ENGLISH_CODE);
    if (lang == null) {
      lang = new LanguageEntity(
        LanguageEntity.ENGLISH_CODE, LanguageEntity.ENGLISH_TITLE);
      getDao().getLanguageDao().save(lang);
    }
  }
View Full Code Here


public class LanguageDaoTest extends AbstractDaoTest {

  private LanguageEntity addLanguage(String code) {
    return getDao().getLanguageDao().save(new LanguageEntity(code, code));
  }
View Full Code Here

  public void testGetByCode() {
    addLanguage("en");
    addLanguage("ru");
    addLanguage("uk");
    addLanguage("fr");
    LanguageEntity l = getDao().getLanguageDao().getByCode("eng");
    assertNull(l);
    l = getDao().getLanguageDao().getByCode(null);
    assertNull(l);
    l = getDao().getLanguageDao().getByCode("en");
    assertNotNull(l);
    assertEquals("en", l.getCode());
 
View Full Code Here

    for (Iterator<Element> i = languagesElement.elementIterator(); i.hasNext(); ) {
            Element element = i.next();
            if (element.getName().equals("language")) {
              String code = element.attributeValue("code");
              String title = element.attributeValue("title");
              LanguageEntity language = getDao().getLanguageDao().getByCode(
                  code);
              if (language == null) {
                  language = new LanguageEntity(code, title);
              }
              else {
                language.setTitle(title);
              }
              getDaoTaskAdapter().languageSave(language);
            }
    }
  }
View Full Code Here

  @Override
  public void languageSave(LanguageEntity entity) throws DaoTaskException {
    if (isSkip()) {
      if (entity.getId() == null) {
        LanguageEntity found = getDao().getLanguageDao().getByCode(
            entity.getCode());
        if (found == null) {
          throw new DaoTaskException("Language not found while "
            + "skipping save operation. code=" + entity.getCode());
        }
        entity.setId(found.getId());
      }
    }
    else {
      getDao().getLanguageDao().save(entity);
    }
View Full Code Here

  }

  @Override
  public VelocityContext createContext(final String languageCode,
      PageEntity page) {
    LanguageEntity language = getDao().getLanguageDao().getByCode(
        languageCode);
    VelocityContext context = new VelocityContext();
    ConfigEntity configEntity = getBusiness().getConfigBusiness().getConfig();
    addVelocityTools(context);
    context.put("language", language);
    context.put("locale", new Locale(language.getCode()));
    context.put("config", configEntity);
    context.put("service", getVelocityService());
    context.put("plugin", getVelocityPluginService().getPlugins());
    context.put("messages", getBusiness().getMessageBusiness().getBundle(
        languageCode));
View Full Code Here

TOP

Related Classes of org.vosao.entity.LanguageEntity

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.