Locale locale = locales.get(0);
//Provider provider = this.providerService.getProviderById(providerId, locale);
//MediationService mediation = this.mediationService.getMediationService(provider.getMediationService(), locale);
Collection<ExtendedCourse> courses = this.courseService.getCoursesByOwner(mediationService.getId(), null, locale);
for(ExtendedCourse course : courses) {
ExtendedSchool school = this.schoolService.getSchool(course.getSchool(), locale);
if(school != null) schools.put(school.getId(), school);
}
for(ExtendedSchool school : schools.values()) {
Element schoolNode = new Element(SCHOOL_ELEMENT);
for(String attr : SCHOOL_ATTRS) {
Element attrNode = new Element(attr);
if(SCHOOL_ATTR_ID.equals(attr)) {
//attrNode.setContent(school.getId() != null ? this.createCData(school.getId().toString()) : "");
attrNode.setContent(mediationService.getId() != null && school.getId() != null ? new CDATA(new StringBuffer(String.valueOf(mediationService.getId())).append("-").append(String.valueOf(school.getId())).toString()) : new CDATA(""));
} else if(SCHOOL_ATTR_NAME.equals(attr)) {
attrNode.setContent(school.getName() != null ? new CDATA(school.getName()) : new CDATA(""));
} else if(SCHOOL_ATTR_PHONE.equals(attr)) {
attrNode.addContent(school.getContactInfo() != null && school.getContactInfo().getTelephone() != null ?
new CDATA(school.getContactInfo().getTelephone()) : new CDATA(""));
} else if(SCHOOL_ATTR_FAX.equals(attr)) {
attrNode.addContent(school.getContactInfo() != null &&school.getContactInfo().getFax() != null ?
new CDATA(school.getContactInfo().getFax()) : new CDATA(""));
} else if(SCHOOL_ATTR_MAIL.equals(attr)) {
attrNode.addContent(school.getContactInfo() != null && school.getContactInfo().getEmail() != null ?
new CDATA(school.getContactInfo().getEmail()) : new CDATA(""));
} else if(SCHOOL_ATTR_ADDR.equals(attr)) {
attrNode.addContent(school.getContactInfo() != null && school.getContactInfo().getStreetAddress() != null ?
new CDATA(school.getContactInfo().getStreetAddress()) : new CDATA(""));
} else if(SCHOOL_ATTR_PK.equals(attr)) {
attrNode.addContent(school.getContactInfo() != null && school.getContactInfo().getZipCode() != null ?
new CDATA(school.getContactInfo().getZipCode()) : new CDATA(""));
} else if(SCHOOL_ATTR_WEB.equals(attr)) {
attrNode.addContent(school.getContactInfo() != null && school.getContactInfo().getWebSite() != null ?
new CDATA(school.getContactInfo().getWebSite()) : new CDATA(""));
} else if(SCHOOL_ATTR_CITY.equals(attr)) {
attrNode.addContent(school.getContactInfo() != null && school.getContactInfo().getCity() != null ?
new CDATA(school.getContactInfo().getCity()) : new CDATA(""));
} else if(SCHOOL_ATTR_FEED.equals(attr)) {
StringBuffer sb = new StringBuffer(contextPath).append("/").append(locale).append(COURSES_FEED).append(provider.getId()).append("/").append(school.getId());
attrNode.addContent(new CDATA(sb.toString()));
}
schoolNode.addContent(attrNode);
}