Search in sources :

Example 1 with UserProperty

use of fi.otavanopisto.muikku.schooldata.entity.UserProperty in project muikku by otavanopisto.

the class PyramusUserSchoolDataBridge method listUserPropertiesByUser.

@Override
public List<UserProperty> listUserPropertiesByUser(String userIdentifier) {
    Long studentId = identifierMapper.getPyramusStudentId(userIdentifier);
    if (studentId != null) {
        Student student = pyramusClient.get("/students/students/" + studentId, Student.class);
        Map<String, String> variables = student.getVariables();
        List<UserProperty> userProperties = new ArrayList<>();
        for (String key : variables.keySet()) {
            String value = variables.get(key);
            if (value != null) {
                userProperties.add(new PyramusUserProperty(userIdentifier, key, value));
            }
        }
        return userProperties;
    }
    logger.warning(String.format("PyramusUserSchoolDataBridge.listUserPropertiesByUser malformed user identifier %s\n%s", userIdentifier, ExceptionUtils.getStackTrace(new Throwable())));
    throw new SchoolDataBridgeInternalException(String.format("Malformed user identifier %s", userIdentifier));
}
Also used : PyramusUserProperty(fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusUserProperty) UserProperty(fi.otavanopisto.muikku.schooldata.entity.UserProperty) PyramusUserProperty(fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusUserProperty) SchoolDataBridgeInternalException(fi.otavanopisto.muikku.schooldata.SchoolDataBridgeInternalException) ArrayList(java.util.ArrayList) Student(fi.otavanopisto.pyramus.rest.model.Student) StudentGroupStudent(fi.otavanopisto.pyramus.rest.model.StudentGroupStudent)

Aggregations

PyramusUserProperty (fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusUserProperty)1 SchoolDataBridgeInternalException (fi.otavanopisto.muikku.schooldata.SchoolDataBridgeInternalException)1 UserProperty (fi.otavanopisto.muikku.schooldata.entity.UserProperty)1 Student (fi.otavanopisto.pyramus.rest.model.Student)1 StudentGroupStudent (fi.otavanopisto.pyramus.rest.model.StudentGroupStudent)1 ArrayList (java.util.ArrayList)1