use of fi.otavanopisto.muikku.schooldata.entity.CourseIdentifier in project muikku by otavanopisto.
the class PyramusCourseMetaSchoolDataBridge method listCourseIdentifiers.
@Override
public List<CourseIdentifier> listCourseIdentifiers() {
List<CourseIdentifier> result = new ArrayList<>();
fi.otavanopisto.pyramus.rest.model.Subject[] subjects = pyramusClient.get("/common/subjects/", fi.otavanopisto.pyramus.rest.model.Subject[].class);
if (subjects != null) {
for (fi.otavanopisto.pyramus.rest.model.Subject subject : subjects) {
List<String> courseNumbers = new ArrayList<String>();
String identifier = subject.getId().toString();
Course[] courses = pyramusClient.get("/common/subjects/" + identifier + "/courses", fi.otavanopisto.pyramus.rest.model.Course[].class);
if (courses != null) {
for (Course course : courses) {
String courseNumber = course.getCourseNumber() != null ? course.getCourseNumber().toString() : "null";
if (!courseNumbers.contains(courseNumber))
courseNumbers.add(courseNumber);
}
for (String cn : courseNumbers) {
result.add(new PyramusCourseIdentifier(subject.getId().toString() + "/" + cn, subject.getCode(), subject.getId().toString()));
}
}
}
}
return result;
}
use of fi.otavanopisto.muikku.schooldata.entity.CourseIdentifier in project muikku by otavanopisto.
the class PyramusCourseMetaSchoolDataBridge method listCourseIdentifiersBySubject.
@Override
public List<CourseIdentifier> listCourseIdentifiersBySubject(String subjectIdentifier) {
if (!StringUtils.isNumeric(subjectIdentifier)) {
throw new SchoolDataBridgeInternalException("Identifier has to be numeric");
}
// TODO Fix workaround
fi.otavanopisto.pyramus.rest.model.Subject subject = pyramusClient.get("/common/subjects/" + subjectIdentifier, fi.otavanopisto.pyramus.rest.model.Subject.class);
List<CourseIdentifier> result = new ArrayList<>();
List<String> courseNumbers = new ArrayList<String>();
String identifier = subject.getId().toString();
Course[] courses = pyramusClient.get("/common/subjects/" + identifier + "/courses", fi.otavanopisto.pyramus.rest.model.Course[].class);
for (Course course : courses) {
String courseNumber = course.getCourseNumber() != null ? course.getCourseNumber().toString() : "null";
if (!courseNumbers.contains(courseNumber))
courseNumbers.add(courseNumber);
}
for (String cn : courseNumbers) {
result.add(new PyramusCourseIdentifier(subject.getId().toString() + "/" + cn, subject.getCode(), subject.getId().toString()));
}
return result;
}
Aggregations