use of fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusCourseIdentifier in project muikku by otavanopisto.
the class PyramusCourseMetaSchoolDataBridge method findCourseIdentifier.
@Override
public CourseIdentifier findCourseIdentifier(String identifier) {
if (StringUtils.isBlank(identifier)) {
return null;
}
if (identifier.indexOf("/") == -1)
throw new SchoolDataBridgeInternalException("Invalid CourseIdentifierId");
String[] idParts = identifier.split("/");
fi.otavanopisto.pyramus.rest.model.Subject subject = pyramusClient.get("/common/subjects/" + idParts[0], fi.otavanopisto.pyramus.rest.model.Subject.class);
return new PyramusCourseIdentifier(identifier, subject.getCode() + idParts[1], subject.getId().toString());
}
use of fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusCourseIdentifier 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.plugins.schooldatapyramus.entities.PyramusCourseIdentifier 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