use of fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier in project muikku by otavanopisto.
the class UserIndexer method indexUser.
public void indexUser(UserEntity userEntity) {
schoolDataBridgeSessionController.startSystemSession();
try {
List<UserSchoolDataIdentifier> identifiers = userSchoolDataIdentifierController.listUserSchoolDataIdentifiersByUserEntity(userEntity);
for (UserSchoolDataIdentifier schoolDataIdentifier : identifiers) {
SchoolDataIdentifier identifier = new SchoolDataIdentifier(schoolDataIdentifier.getIdentifier(), schoolDataIdentifier.getDataSource().getIdentifier());
indexUser(identifier);
}
} finally {
schoolDataBridgeSessionController.endSystemSession();
}
}
use of fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier in project muikku by otavanopisto.
the class ForgotPasswordController method getUsername.
public String getUsername(String confirmationHash) {
UserPendingPasswordChange userPendingPasswordChange = userPendingPasswordChangeDAO.findByConfirmationHash(confirmationHash);
if (userPendingPasswordChange != null) {
Long userEntityId = userPendingPasswordChange.getUserEntity();
if (userEntityId == null) {
logger.severe(String.format("UserPendingPasswordChange with hash %s did not contain userEnityId", confirmationHash));
return null;
}
UserEntity userEntity = userEntityController.findUserEntityById(userEntityId);
if (userEntity == null) {
logger.severe(String.format("UserPendingPasswordChange with hash %s contained invalid userEnityId", confirmationHash));
return null;
}
schoolDataBridgeSessionController.startSystemSession();
try {
User user = userSchoolDataController.findUser(userEntity.getDefaultSchoolDataSource(), userEntity.getDefaultIdentifier());
if (user == null) {
logger.severe(String.format("Failed to retrieve user for UserEntity %d", userEntity.getId()));
return null;
}
SchoolDataIdentifier userIdentifier = new SchoolDataIdentifier(user.getIdentifier(), user.getSchoolDataSource());
try {
return userSchoolDataController.findUsername(user);
} catch (Exception e) {
logger.log(Level.SEVERE, String.format("Failed to fetch username for user %s", userIdentifier.toId()));
return null;
}
} finally {
schoolDataBridgeSessionController.endSystemSession();
}
}
return null;
}
use of fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier in project muikku by otavanopisto.
the class NotifierEmailMethod method sendNotification.
@Override
public void sendNotification(NotifierAction action, NotifierContext context) {
NotifierEmailMessageComposer message = emailMessageComposer.select(new NotifierEmailContentAnnotationLiteral(action.getName())).get();
if (message != null) {
// List email addresses of user entity (only default identifier)
UserEntity userEntity = context.getRecipient();
SchoolDataIdentifier identifier = new SchoolDataIdentifier(userEntity.getDefaultIdentifier(), userEntity.getDefaultSchoolDataSource().getIdentifier());
List<String> addresses = userEmailEntityController.getUserEmailAddresses(identifier);
if (CollectionUtils.isNotEmpty(addresses))
mailer.sendMail(message.getEmailMimeType(context), systemSettingsController.getSystemEmailSenderAddress(), addresses, message.getEmailSubject(context), message.getEmailContent(context));
}
}
use of fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier in project muikku by otavanopisto.
the class SchoolDataIndexListeners method onSchoolDataUserUpdatedEvent.
public void onSchoolDataUserUpdatedEvent(@Observes SchoolDataUserUpdatedEvent event) {
List<SchoolDataIdentifier> removeIdentifiers = new ArrayList<>(event.getRemovedIdentifiers());
List<SchoolDataIdentifier> updatedIdentifiers = new ArrayList<>(event.getDiscoveredIdentifiers());
updatedIdentifiers.addAll(event.getUpdatedIdentifiers());
for (SchoolDataIdentifier identifier : updatedIdentifiers) {
userIndexer.indexUser(identifier.getDataSource(), identifier.getIdentifier());
}
for (SchoolDataIdentifier identifier : removeIdentifiers) {
userIndexer.removeUser(identifier.getDataSource(), identifier.getIdentifier());
}
}
use of fi.otavanopisto.muikku.schooldata.SchoolDataIdentifier in project muikku by otavanopisto.
the class Evaluation2RESTService method listAssessmentRequests.
@GET
@Path("/compositeAssessmentRequests")
@RESTPermit(handling = Handling.INLINE, requireLoggedIn = true)
public Response listAssessmentRequests(@QueryParam("workspaceEntityId") Long workspaceEntityId) {
if (!sessionController.isLoggedIn()) {
return Response.status(Status.UNAUTHORIZED).build();
}
if (!sessionController.hasEnvironmentPermission(MuikkuPermissions.ACCESS_EVALUATION)) {
return Response.status(Status.FORBIDDEN).build();
}
List<RestAssessmentRequest> restAssessmentRequests = new ArrayList<RestAssessmentRequest>();
if (workspaceEntityId == null) {
// List assessment requests by staff member
SchoolDataIdentifier loggedUser = sessionController.getLoggedUser();
List<CompositeAssessmentRequest> assessmentRequests = gradingController.listAssessmentRequestsByStaffMember(loggedUser);
for (CompositeAssessmentRequest assessmentRequest : assessmentRequests) {
restAssessmentRequests.add(toRestAssessmentRequest(assessmentRequest));
}
} else {
// List assessment requests by workspace
List<String> workspaceStudentIdentifiers = new ArrayList<String>();
WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceEntityById(workspaceEntityId);
SchoolDataIdentifier workspaceIdentifier = new SchoolDataIdentifier(workspaceEntity.getIdentifier(), workspaceEntity.getDataSource().getIdentifier());
List<WorkspaceUserEntity> workspaceUserEntities = workspaceUserEntityController.listActiveWorkspaceStudents(workspaceEntity);
for (WorkspaceUserEntity workspaceUserEntity : workspaceUserEntities) {
workspaceStudentIdentifiers.add(workspaceUserEntity.getIdentifier());
}
List<CompositeAssessmentRequest> assessmentRequests = gradingController.listAssessmentRequestsByWorkspace(workspaceIdentifier, workspaceStudentIdentifiers);
for (CompositeAssessmentRequest assessmentRequest : assessmentRequests) {
restAssessmentRequests.add(toRestAssessmentRequest(assessmentRequest));
}
}
return Response.ok(restAssessmentRequests).build();
}
Aggregations