Package org.apache.openmeetings.db.entity.label

Examples of org.apache.openmeetings.db.entity.label.FieldLanguage


    if (rtl != null && rtl.equals("true")) {
      langRtl = true;
    }

    long ticks = System.currentTimeMillis();
    FieldLanguage lang = fieldLanguageDaoImpl.addLanguage(langId, langName, langRtl, code);

    SAXReader reader = new SAXReader();
    Document document = reader.read(new File(
        OmFileHelper.getLanguagesDir(), langName + ".xml"));

    Element root = document.getRootElement();

    Map<Long, Fieldlanguagesvalues> flvMap = lang.getLanguageValuesMap();
    for (@SuppressWarnings("rawtypes")
    Iterator it = root.elementIterator("string"); it.hasNext();) {
      Element item = (Element) it.next();
      // log.error(item.getName());

      Long id = Long.valueOf(item.attributeValue("id")).longValue();
      String name = item.attributeValue("name");
      String value = "";

      for (@SuppressWarnings("rawtypes")
      Iterator t2 = item.elementIterator("value"); t2.hasNext();) {
        Element val = (Element) t2.next();
        value = val.getText();
      }

      // log.error("result: "+langFieldIdIsInited+" "+id+" "+name+" "+value);

      if (flvMap.containsKey(id)) {
        Fieldlanguagesvalues flv = flvMap.get(id);
        flv.setUpdatetime(new Date());
        flv.setValue(value);
      } else {
        Fieldvalues fv = null;
        // Only do that for the first field-set
        if (!fieldCache.containsKey(id)) {
          fv = new Fieldvalues();
          fv.setFieldvalues_id(id);
          fv.setStarttime(new Date());
          fv.setName(name);
          fv.setDeleted(false);
          fv = fieldValueDao.update(fv, null);
          fieldCache.put(id, fv);
        } else {
          fv = fieldCache.get(id);
        }
        Fieldlanguagesvalues flv = new Fieldlanguagesvalues();
        flv.setStarttime(new Date());
        flv.setValue(value);
        flv.setLanguage_id(lang.getLanguage_id());
        flv.setFieldvalues(fv);
        flv.setDeleted(false);
        flvMap.put(id, flv);
      }
    }
    lang.setLanguageValues(flvMap.values());
    fieldLanguageDaoImpl.updateLanguage(lang);
    log.debug("Lang ADDED: " + lang + "; seconds passed: " + (System.currentTimeMillis() - ticks) / 1000);
  }
View Full Code Here


    return q.getSingleResult() + 1;
  }
 
  public FieldLanguage addLanguage(int langId, String langName, Boolean langRtl, String code) {
    try {
      FieldLanguage fl = new FieldLanguage();
      fl.setLanguage_id((long)langId);
      fl.setStarttime(new Date());
      fl.setDeleted(false);
      fl.setName(langName);
      fl.setRtl(langRtl);
      fl.setCode(code);

      fl = em.merge(fl);

      //Eagerly FETCH values list
      TypedQuery<FieldLanguage> q = em.createQuery("select fl from FieldLanguage fl LEFT JOIN FETCH fl.languageValues WHERE fl.language_id = :langId", FieldLanguage.class);
View Full Code Here

          + "WHERE c.deleted <> :deleted "
          + "AND c.language_id = :language_id";
      TypedQuery<FieldLanguage> query = em.createQuery(hql, FieldLanguage.class);
      query.setParameter("deleted", true);
      query.setParameter("language_id", language_id);
      FieldLanguage fl = null;
      try {
        fl = query.getSingleResult();
      } catch (NoResultException ex) {
      }
      return fl;
View Full Code Here

  private Map<Long, Fieldlanguagesvalues> masterLabels;

  @Test
  public void testCount() throws Exception {
    FieldLanguage prevLanguage = null;
    long prevCount = -1;
    for (FieldLanguage l : fieldLanguageDao.getLanguages()) {
      long count = fieldValueDao.count(l.getLanguage_id(), null);
      if (prevLanguage != null) {
        assertEquals(String.format("Language: %s contains %d labels while %s contains %d labels"
            , prevLanguage.getCode(), prevCount, l.getCode(), count), prevCount, count);
      }
      prevLanguage = l;
      prevCount = count;
    }
  }
View Full Code Here

      protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

        final List<Fieldlanguagesvalues> flvList = getBean(FieldLanguagesValuesDao.class).getMixedFieldValuesList(language.getLanguage_id());

        FieldLanguage fl = getBean(FieldLanguageDao.class).getFieldLanguageById(language.getLanguage_id());
        if (fl != null && flvList != null) {
          download.setFileName(fl.getName() + ".xml");
          download.setResourceStream(new AbstractResourceStream() {
            private static final long serialVersionUID = 1L;
            private StringWriter sw;
            private InputStream is;
           
View Full Code Here

      @Override
      public void onSubmit(AjaxRequestTarget target, Form<?> form) {
        FieldLanguageDao langDao = Application.getBean(FieldLanguageDao.class);
       
        FieldLanguage fl = new FieldLanguage();
        fl.setLanguage_id(langDao.getNextAvailableId());
        fl.setStarttime(new Date());
        fl.setDeleted(false);
        fl.setName(newLanguageName);
        fl.setRtl(false); //FIXME
        fl.setCode(newLanguageISO);
       
        try {
          langDao.updateLanguage(fl);
        } catch (Exception e) {
          // TODO add feedback message
View Full Code Here

    options = new HashMap<String, String>();
    options.put("fragmentIdentifierSuffix", "");
    options.put("keyValueDelimiter", "/");
    String appName = getApplicationName();

    FieldLanguage lang = getLanguage();
    String code = lang.getCode();
    add(new TransparentWebMarkupContainer("html")
        .add(new AttributeModifier("xml:lang", code))
        .add(new AttributeModifier("lang", code))
        .add(new AttributeModifier("dir", Boolean.TRUE.equals(lang.getRtl()) ? "rtl" : "ltr")));
    add(new Label("pageTitle", appName));
    add(new HeaderPanel("header", appName));
  }
View Full Code Here

        Object[] row = (Object[])fl;
        map.put("id", row[0]);
        map.put("value", performReplace((String)row[1], appName));
        returnList.add(map);
      }
      FieldLanguage fieldLanguage = fieldLanguageDaoImpl
          .getFieldLanguageById(language_id);

      log.debug("Getting Labels for Language " + fieldLanguage.getName());

      // Check for Right To Left Languages
      if (fieldLanguage.getRtl()) {
        log.debug("Language requieres RTL!");

        List<Map<String, Object>> returnRtlList = new LinkedList<Map<String, Object>>();

        for (Iterator<Map<String, Object>> iter = returnList.iterator(); iter
View Full Code Here

      query.setParameter("language_id", language_id);
      query.setParameter("start", start);
      query.setParameter("max", start + max);

      List<Fieldlanguagesvalues> returnList = performReplace(query.getResultList());
      FieldLanguage fieldLanguage = fieldLanguageDaoImpl
          .getFieldLanguageById(language_id);

      log.debug("GEtting all fields by language : "
          + fieldLanguage.getName());

      // Check for Right To Left Languages
      if (fieldLanguage.getRtl()) {
        log.debug("language : " + fieldLanguage.getName()
            + " requieres RTL");

        List<Fieldlanguagesvalues> returnRtlList = new LinkedList<Fieldlanguagesvalues>();

        for (Iterator<Fieldlanguagesvalues> iter = returnList
            .iterator(); iter.hasNext();) {
          Fieldlanguagesvalues remote = iter.next();
          Fieldlanguagesvalues toAdd = new Fieldlanguagesvalues();
          toAdd.setFieldlanguagesvalues_id(remote
              .getFieldlanguagesvalues_id());
          toAdd.setFieldvalues_id(remote.getFieldvalues_id());
          toAdd.setLanguage_id(remote.getLanguage_id());

          String[] splitted = remote.getValue().split(" ");
          String reverseOrder = "";
          for (int i = splitted.length - 1; i >= 0; i--) {
            reverseOrder += splitted[i];
            if (splitted.length != 1) {
              reverseOrder += " ";
            }
          }
          toAdd.setValue(reverseOrder);

          returnRtlList.add(toAdd);
        }

        return returnRtlList;
      } else {
        log.debug("language : " + fieldLanguage.getName()
            + " requieres NO RTL");

        return returnList;

      }
View Full Code Here

    if (rtl != null && rtl.equals("true")) {
      langRtl = true;
    }

    long ticks = System.currentTimeMillis();
    FieldLanguage lang = fieldLanguageDaoImpl.addLanguage(langId, langName, langRtl, code);

    SAXReader reader = new SAXReader();
    Document document = reader.read(new File(
        OmFileHelper.getLanguagesDir(), langName + ".xml"));

    Element root = document.getRootElement();

    Map<Long, Fieldlanguagesvalues> flvMap = lang.getLanguageValuesMap();
    for (@SuppressWarnings("rawtypes")
    Iterator it = root.elementIterator("string"); it.hasNext();) {
      Element item = (Element) it.next();
      // log.error(item.getName());

      Long id = Long.valueOf(item.attributeValue("id")).longValue();
      String name = item.attributeValue("name");
      String value = "";

      for (@SuppressWarnings("rawtypes")
      Iterator t2 = item.elementIterator("value"); t2.hasNext();) {
        Element val = (Element) t2.next();
        value = val.getText();
      }

      // log.error("result: "+langFieldIdIsInited+" "+id+" "+name+" "+value);

      if (flvMap.containsKey(id)) {
        Fieldlanguagesvalues flv = flvMap.get(id);
        flv.setUpdatetime(new Date());
        flv.setValue(value);
      } else {
        Fieldvalues fv = null;
        // Only do that for the first field-set
        if (!fieldCache.containsKey(id)) {
          fv = new Fieldvalues();
          fv.setFieldvalues_id(id);
          fv.setStarttime(new Date());
          fv.setName(name);
          fv.setDeleted(false);
          fv = fieldValueDao.update(fv, null);
          fieldCache.put(id, fv);
        } else {
          fv = fieldCache.get(id);
        }
        Fieldlanguagesvalues flv = new Fieldlanguagesvalues();
        flv.setStarttime(new Date());
        flv.setValue(value);
        flv.setLanguage_id(lang.getLanguage_id());
        flv.setFieldvalues(fv);
        flv.setDeleted(false);
        flvMap.put(id, flv);
      }
    }
    lang.setLanguageValues(flvMap.values());
    fieldLanguageDaoImpl.updateLanguage(lang);
    log.debug("Lang ADDED: " + lang + "; seconds passed: " + (System.currentTimeMillis() - ticks) / 1000);
  }
View Full Code Here

TOP

Related Classes of org.apache.openmeetings.db.entity.label.FieldLanguage

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.