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 = fieldManager.addFieldById(name, id);
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);
}