// Make course node element with i18n properties
Element courseNode = new Element(COURSE_ELEMENT);
for(String attr : COURSE_ATTRS) {
if(COURSE_ATTR_ID.equals(attr)) {
courseNode.setContent(new Element(attr).addContent(mediationService.getId() != null && course.getId() != null ? new CDATA(new StringBuffer(String.valueOf(mediationService.getId())).append("-").append(String.valueOf(course.getId())).toString()) : new CDATA("")));
} else if(COURSE_ATTR_NAME.equals(attr)) { // I18nProperty
Iterator<String> it = i18nCourse.keySet().iterator();
while(it.hasNext()) {
String language = it.next();
String i18nAttr = new StringBuffer(attr).append(language).toString();
ExtendedCourse c = i18nCourse.get(language);
courseNode.addContent(new Element(i18nAttr).setContent(c.getTitle() != null ? new CDATA(c.getTitle()) : new CDATA("")));
}
} else if(COURSE_ATTR_URL.equals(attr)) { // I18nProperty // TODO may be better a function...
Iterator<String> it = i18nCourse.keySet().iterator();
while(it.hasNext()) {
String language = it.next();
String i18nAttr = new StringBuffer(attr).append(language).toString();
ExtendedCourse c = i18nCourse.get(language);
String url = new StringBuffer(contextPath).append("/").append(language).append(COURSE_DETAIL_URL).append(course.getId()).toString();
courseNode.addContent(new Element(i18nAttr).setContent(new CDATA(url)));
}
} else if(COURSE_ATTR_START.equals(attr)) {
courseNode.addContent(new Element(attr).setContent(course.getStart() != null ? new CDATA(dateFormat.format(course.getStart())) : new CDATA("")));
} else if(COURSE_ATTR_END.equals(attr)) {
courseNode.addContent(new Element(attr).setContent(course.getEnd() != null ? new CDATA(dateFormat.format(course.getEnd())) : new CDATA("")));
} else if(COURSE_ATTR_INFO.equals(attr)) { // I18nProperty // TODO may be better a function...
Iterator<String> it = i18nCourse.keySet().iterator();
while(it.hasNext()) {
String language = it.next();
String i18nAttr = new StringBuffer(attr).append(language).toString();
ExtendedCourse c = i18nCourse.get(language);
courseNode.addContent(new Element(i18nAttr).setContent(c.getInformation() != null ? new CDATA(c.getInformation().getValue()) : new CDATA("")));
}
} else if(COURSE_ATTR_GAIAK.equals(attr)) {
Element tagsNode = new Element(attr);
for(Category category : course.getTags()) {
Element tagNode = new Element(COURSE_ATTR_GAIA);
for(String gaiaAttr : GAIA_ATTRS) {
Element tagAttrNode = new Element(gaiaAttr);
if(GAIA_ATTR_ID.equals(gaiaAttr)) {
tagAttrNode.setText("");
} else if(GAIA_ATTR_NAME.equals(gaiaAttr)) {
tagAttrNode.setContent(new CDATA(category.getCategory()));
}
tagNode.addContent(tagAttrNode);
}
tagsNode.addContent(tagNode);
}