use of fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusUserProperty in project muikku by otavanopisto.
the class PyramusUserSchoolDataBridge method setUserProperty.
@Override
public UserProperty setUserProperty(String userIdentifier, String key, String value) {
Long studentId = identifierMapper.getPyramusStudentId(userIdentifier);
if (studentId != null) {
Student student = pyramusClient.get("/students/students/" + studentId, Student.class);
Map<String, String> variables = student.getVariables();
variables.put(key, value);
student.setVariables(variables);
pyramusClient.put(String.format("/students/students/%d", studentId), student);
return new PyramusUserProperty(userIdentifier, key, value);
}
logger.warning(String.format("PyramusUserSchoolDataBridge.setUserProperty malformed user identifier %s\n%s", userIdentifier, ExceptionUtils.getStackTrace(new Throwable())));
throw new SchoolDataBridgeInternalException(String.format("Malformed user identifier %s", userIdentifier));
}
use of fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusUserProperty in project muikku by otavanopisto.
the class PyramusUserSchoolDataBridge method getUserProperty.
@Override
public UserProperty getUserProperty(String userIdentifier, String key) {
Long studentId = identifierMapper.getPyramusStudentId(userIdentifier);
if (studentId != null) {
Student student = pyramusClient.get("/students/students/" + studentId, Student.class);
Map<String, String> variables = student.getVariables();
String value = variables.get(key);
if (value == null) {
return null;
} else {
return new PyramusUserProperty(userIdentifier, key, value);
}
}
logger.warning(String.format("PyramusUserSchoolDataBridge.getUserProperty malformed user identifier %s\n%s", userIdentifier, ExceptionUtils.getStackTrace(new Throwable())));
throw new SchoolDataBridgeInternalException(String.format("Malformed user identifier %s", userIdentifier));
}
use of fi.otavanopisto.muikku.plugins.schooldatapyramus.entities.PyramusUserProperty 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));
}
Aggregations