Search in sources :

Example 11 with StaffMember

use of fi.otavanopisto.pyramus.domainmodel.users.StaffMember in project pyramus by otavanopisto.

the class UsersService method updateUser.

public void updateUser(@WebParam(name = "userId") Long userId, @WebParam(name = "firstName") String firstName, @WebParam(name = "lastName") String lastName, @WebParam(name = "role") String role) {
    StaffMemberDAO staffDAO = DAOFactory.getInstance().getStaffMemberDAO();
    StaffMember user = staffDAO.findById(userId);
    Role userRole = EnumType.valueOf(Role.class, role);
    Organization organization = user.getOrganization();
    staffDAO.update(user, organization, firstName, lastName, userRole);
    validateEntity(user);
}
Also used : Role(fi.otavanopisto.pyramus.domainmodel.users.Role) StaffMemberDAO(fi.otavanopisto.pyramus.dao.users.StaffMemberDAO) Organization(fi.otavanopisto.pyramus.domainmodel.base.Organization) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember)

Example 12 with StaffMember

use of fi.otavanopisto.pyramus.domainmodel.users.StaffMember in project pyramus by otavanopisto.

the class UsersService method addUserEmail.

public void addUserEmail(@WebParam(name = "userId") Long userId, @WebParam(name = "address") String address) {
    StaffMemberDAO userDAO = DAOFactory.getInstance().getStaffMemberDAO();
    EmailDAO emailDAO = DAOFactory.getInstance().getEmailDAO();
    ContactTypeDAO contactTypeDAO = DAOFactory.getInstance().getContactTypeDAO();
    StaffMember user = userDAO.findById(userId);
    // Trim the email address
    address = StringUtils.trim(address);
    if (StringUtils.isNotBlank(address)) {
        // TODO contact type, default address
        ContactType contactType = contactTypeDAO.findById(new Long(1));
        if (!UserUtils.isAllowedEmail(address, contactType, user.getPerson().getId()))
            throw new RuntimeException("Email address is in use");
        Email email = emailDAO.create(user.getContactInfo(), contactType, Boolean.TRUE, address);
        validateEntity(email);
    }
}
Also used : StaffMemberDAO(fi.otavanopisto.pyramus.dao.users.StaffMemberDAO) ContactType(fi.otavanopisto.pyramus.domainmodel.base.ContactType) Email(fi.otavanopisto.pyramus.domainmodel.base.Email) ContactTypeDAO(fi.otavanopisto.pyramus.dao.base.ContactTypeDAO) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) EmailDAO(fi.otavanopisto.pyramus.dao.base.EmailDAO)

Example 13 with StaffMember

use of fi.otavanopisto.pyramus.domainmodel.users.StaffMember in project pyramus by otavanopisto.

the class UsersService method createUser.

public UserEntity createUser(@WebParam(name = "firstName") String firstName, @WebParam(name = "lastName") String lastName, @WebParam(name = "externalId") String externalId, @WebParam(name = "authProvider") String authProvider, @WebParam(name = "role") String role) {
    StaffMemberDAO staffMemberDAO = DAOFactory.getInstance().getStaffMemberDAO();
    PersonDAO personDAO = DAOFactory.getInstance().getPersonDAO();
    UserIdentificationDAO userIdentificationDAO = DAOFactory.getInstance().getUserIdentificationDAO();
    // TODO: should not create if user exists
    Person person = personDAO.create(null, null, null, null, Boolean.FALSE);
    userIdentificationDAO.create(person, authProvider, externalId);
    Role userRole = EnumType.valueOf(Role.class, role);
    // TODO organization
    Organization organization = null;
    StaffMember staffMember = staffMemberDAO.create(organization, firstName, lastName, userRole, person, false);
    personDAO.updateDefaultUser(person, staffMember);
    validateEntity(staffMember);
    return EntityFactoryVault.buildFromDomainObject(staffMember);
}
Also used : Role(fi.otavanopisto.pyramus.domainmodel.users.Role) PersonDAO(fi.otavanopisto.pyramus.dao.base.PersonDAO) StaffMemberDAO(fi.otavanopisto.pyramus.dao.users.StaffMemberDAO) Organization(fi.otavanopisto.pyramus.domainmodel.base.Organization) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) Person(fi.otavanopisto.pyramus.domainmodel.base.Person) UserIdentificationDAO(fi.otavanopisto.pyramus.dao.users.UserIdentificationDAO)

Example 14 with StaffMember

use of fi.otavanopisto.pyramus.domainmodel.users.StaffMember in project pyramus by otavanopisto.

the class UsersAutoCompleteBinaryRequestController method process.

/**
 * Processes a binary request.
 * The request should contain the following parameters:
 * <dl>
 *   <dt><code>text</code></dt>
 *   <dd>Already typed characters.</dd>
 * </dl>
 *
 * @param binaryRequestContext The context of the binary request.
 */
public void process(BinaryRequestContext binaryRequestContext) {
    StaffMemberDAO userDAO = DAOFactory.getInstance().getStaffMemberDAO();
    String text = binaryRequestContext.getString("text");
    StringBuilder resultBuilder = new StringBuilder();
    resultBuilder.append("<ul>");
    if (!StringUtils.isBlank(text)) {
        text = QueryParser.escape(StringUtils.trim(text)) + '*';
        List<StaffMember> users = userDAO.searchUsersBasic(100, 0, text).getResults();
        for (User user : users) {
            addUser(resultBuilder, user);
        }
    }
    resultBuilder.append("</ul>");
    try {
        binaryRequestContext.setResponseContent(resultBuilder.toString().getBytes("UTF-8"), "text/html;charset=UTF-8");
    } catch (UnsupportedEncodingException e) {
        throw new SmvcRuntimeException(e);
    }
}
Also used : StaffMemberDAO(fi.otavanopisto.pyramus.dao.users.StaffMemberDAO) User(fi.otavanopisto.pyramus.domainmodel.users.User) UnsupportedEncodingException(java.io.UnsupportedEncodingException) SmvcRuntimeException(fi.internetix.smvc.SmvcRuntimeException) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember)

Example 15 with StaffMember

use of fi.otavanopisto.pyramus.domainmodel.users.StaffMember in project pyramus by otavanopisto.

the class StudentGroupsAutoCompleteBinaryRequestController method process.

/**
 * Processes a binary request.
 * The request should contain the following parameters:
 * <dl>
 *   <dt><code>text</code></dt>
 *   <dd>Already typed characters.</dd>
 * </dl>
 *
 * @param binaryRequestContext The context of the binary request.
 */
public void process(BinaryRequestContext binaryRequestContext) {
    StudentGroupDAO studentGroupDAO = DAOFactory.getInstance().getStudentGroupDAO();
    StaffMemberDAO staffMemberDAO = DAOFactory.getInstance().getStaffMemberDAO();
    String text = binaryRequestContext.getString("text");
    StringBuilder resultBuilder = new StringBuilder();
    resultBuilder.append("<ul>");
    if (!StringUtils.isBlank(text)) {
        text = QueryParser.escape(StringUtils.trim(text)) + '*';
        StaffMember loggedUser = staffMemberDAO.findById(binaryRequestContext.getLoggedUserId());
        Organization organization = UserUtils.canAccessAllOrganizations(loggedUser) ? null : loggedUser.getOrganization();
        List<StudentGroup> studentGroups = studentGroupDAO.searchStudentGroupsBasic(100, 0, organization, text).getResults();
        for (StudentGroup studentGroup : studentGroups) {
            addResult(resultBuilder, studentGroup);
        }
    }
    resultBuilder.append("</ul>");
    try {
        binaryRequestContext.setResponseContent(resultBuilder.toString().getBytes("UTF-8"), "text/html;charset=UTF-8");
    } catch (UnsupportedEncodingException e) {
        throw new SmvcRuntimeException(e);
    }
}
Also used : StudentGroupDAO(fi.otavanopisto.pyramus.dao.students.StudentGroupDAO) StaffMemberDAO(fi.otavanopisto.pyramus.dao.users.StaffMemberDAO) Organization(fi.otavanopisto.pyramus.domainmodel.base.Organization) UnsupportedEncodingException(java.io.UnsupportedEncodingException) SmvcRuntimeException(fi.internetix.smvc.SmvcRuntimeException) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) StudentGroup(fi.otavanopisto.pyramus.domainmodel.students.StudentGroup)

Aggregations

StaffMember (fi.otavanopisto.pyramus.domainmodel.users.StaffMember)128 StaffMemberDAO (fi.otavanopisto.pyramus.dao.users.StaffMemberDAO)83 Student (fi.otavanopisto.pyramus.domainmodel.students.Student)38 RESTPermit (fi.otavanopisto.pyramus.rest.annotation.RESTPermit)26 Path (javax.ws.rs.Path)26 User (fi.otavanopisto.pyramus.domainmodel.users.User)25 Date (java.util.Date)24 StudentDAO (fi.otavanopisto.pyramus.dao.students.StudentDAO)23 Organization (fi.otavanopisto.pyramus.domainmodel.base.Organization)23 SmvcRuntimeException (fi.internetix.smvc.SmvcRuntimeException)22 CourseStudent (fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent)20 Tag (fi.otavanopisto.pyramus.domainmodel.base.Tag)18 OrganizationDAO (fi.otavanopisto.pyramus.dao.base.OrganizationDAO)16 Course (fi.otavanopisto.pyramus.domainmodel.courses.Course)16 StudentGroup (fi.otavanopisto.pyramus.domainmodel.students.StudentGroup)16 ApplicationDAO (fi.otavanopisto.pyramus.dao.application.ApplicationDAO)14 Person (fi.otavanopisto.pyramus.domainmodel.base.Person)14 HashMap (java.util.HashMap)14 HashSet (java.util.HashSet)14 Curriculum (fi.otavanopisto.pyramus.domainmodel.base.Curriculum)13