/*
* This method returns the portuguese name and the english name with the
* rules implemented in getNome() method
*/
public MultiLanguageString getNameI18N() {
MultiLanguageString nameI18N = new MultiLanguageString();
nameI18N = nameI18N.with(MultiLanguageString.pt, super.getNome());
final StringBuilder stringBuilder = new StringBuilder();
final Set<String> names = new HashSet<String>();
for (final CurricularCourse curricularCourse : getAssociatedCurricularCoursesSet()) {
if (!curricularCourse.getActiveDegreeModuleScopesInExecutionPeriod(getExecutionPeriod()).isEmpty()) {
final String name = curricularCourse.getNameEn();
if (!names.contains(name)) {
names.add(name);
if (stringBuilder.length() > 0) {
stringBuilder.append(" / ");
}
stringBuilder.append(name);
}
}
}
if (stringBuilder.length() > 0) {
nameI18N = nameI18N.with(MultiLanguageString.en, stringBuilder.toString());
return nameI18N;
}
boolean unique = true;
final String nameEn = getAssociatedCurricularCoursesSet().iterator().next().getNameEn();
for (final CurricularCourse curricularCourse : getAssociatedCurricularCoursesSet()) {
if (curricularCourse.getNameEn() == null || !curricularCourse.getNameEn().equals(nameEn)) {
unique = false;
break;
}
}
if (unique) {
nameI18N = nameI18N.with(MultiLanguageString.en, nameEn);
return nameI18N;
} else {
nameI18N = nameI18N.with(MultiLanguageString.en, super.getNome());
return nameI18N;
}
}