Search in sources :

Example 26 with StaffMember

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

the class StaffRESTService method listStaffMemberPhoneNumbers.

@Path("/members/{STAFFMEMBERID:[0-9]*}/phoneNumbers")
@GET
@RESTPermit(handling = Handling.INLINE)
public Response listStaffMemberPhoneNumbers(@PathParam("STAFFMEMBERID") Long staffMemberId) {
    StaffMember staffMember = userController.findStaffMemberById(staffMemberId);
    if (staffMember == null) {
        return Response.status(Status.NOT_FOUND).build();
    }
    if (staffMember.getArchived()) {
        return Response.status(Status.NOT_FOUND).build();
    }
    if (!restSecurity.hasPermission(new String[] { UserPermissions.LIST_STAFFMEMBERPHONENUMBERS }, staffMember) && !restSecurity.hasPermission(new String[] { PersonPermissions.PERSON_OWNER }, staffMember.getPerson())) {
        return Response.status(Status.FORBIDDEN).build();
    }
    List<PhoneNumber> phoneNumbers = staffMember.getContactInfo().getPhoneNumbers();
    if (phoneNumbers.isEmpty()) {
        return Response.noContent().build();
    }
    return Response.ok(objectFactory.createModel(phoneNumbers)).build();
}
Also used : PhoneNumber(fi.otavanopisto.pyramus.domainmodel.base.PhoneNumber) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.pyramus.rest.annotation.RESTPermit) GET(javax.ws.rs.GET)

Example 27 with StaffMember

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

the class StaffRESTService method findStaffMemberPhoneNumber.

@Path("/members/{STAFFMEMBERID:[0-9]*}/phoneNumbers/{ID:[0-9]*}")
@GET
@RESTPermit(handling = Handling.INLINE)
public Response findStaffMemberPhoneNumber(@PathParam("STAFFMEMBERID") Long staffMemberId, @PathParam("ID") Long id) {
    StaffMember staffMember = userController.findStaffMemberById(staffMemberId);
    if (staffMember == null) {
        return Response.status(Status.NOT_FOUND).build();
    }
    if (staffMember.getArchived()) {
        return Response.status(Status.NOT_FOUND).build();
    }
    if (!restSecurity.hasPermission(new String[] { UserPermissions.FIND_STAFFMEMBERPHONENUMBER }, staffMember) && !restSecurity.hasPermission(new String[] { PersonPermissions.PERSON_OWNER }, staffMember.getPerson())) {
        return Response.status(Status.FORBIDDEN).build();
    }
    PhoneNumber phoneNumber = commonController.findPhoneNumberById(id);
    if (phoneNumber == null) {
        return Response.status(Status.NOT_FOUND).build();
    }
    if (!phoneNumber.getContactInfo().getId().equals(staffMember.getContactInfo().getId())) {
        return Response.status(Status.NOT_FOUND).build();
    }
    return Response.ok(objectFactory.createModel(phoneNumber)).build();
}
Also used : PhoneNumber(fi.otavanopisto.pyramus.domainmodel.base.PhoneNumber) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.pyramus.rest.annotation.RESTPermit) GET(javax.ws.rs.GET)

Example 28 with StaffMember

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

the class StaffRESTService method listStaffMembersEmails.

@Path("/members/{ID:[0-9]*}/emails")
@GET
@RESTPermit(UserPermissions.LIST_STAFFMEMBER_EMAILS)
public Response listStaffMembersEmails(@PathParam("ID") Long id) {
    StaffMember user = userController.findStaffMemberById(id);
    if (user == null) {
        return Response.status(Status.NOT_FOUND).build();
    }
    List<Email> emails = user.getContactInfo().getEmails();
    if (emails.isEmpty()) {
        return Response.noContent().build();
    }
    return Response.ok(objectFactory.createModel(emails)).build();
}
Also used : Email(fi.otavanopisto.pyramus.domainmodel.base.Email) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.pyramus.rest.annotation.RESTPermit) GET(javax.ws.rs.GET)

Example 29 with StaffMember

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

the class StaffRESTService method deleteStaffMemberAddress.

@Path("/members/{STAFFMEMBERID:[0-9]*}/addresses/{ID:[0-9]*}")
@DELETE
@RESTPermit(handling = Handling.INLINE)
public Response deleteStaffMemberAddress(@PathParam("STAFFMEMBERID") Long staffMemberId, @PathParam("ID") Long id) {
    StaffMember staffMember = userController.findStaffMemberById(staffMemberId);
    if (staffMember == null) {
        return Response.status(Status.NOT_FOUND).build();
    }
    if (staffMember.getArchived()) {
        return Response.status(Status.NOT_FOUND).build();
    }
    if (!restSecurity.hasPermission(new String[] { UserPermissions.DELETE_STAFFMEMBERADDRESS }, staffMember) && !restSecurity.hasPermission(new String[] { PersonPermissions.PERSON_OWNER }, staffMember.getPerson())) {
        return Response.status(Status.FORBIDDEN).build();
    }
    Address address = commonController.findAddressById(id);
    if (address == null) {
        return Response.status(Status.NOT_FOUND).build();
    }
    if (!address.getContactInfo().getId().equals(staffMember.getContactInfo().getId())) {
        return Response.status(Status.NOT_FOUND).build();
    }
    commonController.deleteAddress(address);
    return Response.noContent().build();
}
Also used : Address(fi.otavanopisto.pyramus.domainmodel.base.Address) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RESTPermit(fi.otavanopisto.pyramus.rest.annotation.RESTPermit)

Example 30 with StaffMember

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

the class StaffRESTService method deleteStaffMemberPhoneNumber.

@Path("/members/{STAFFMEMBERID:[0-9]*}/phoneNumbers/{ID:[0-9]*}")
@DELETE
@RESTPermit(handling = Handling.INLINE)
public Response deleteStaffMemberPhoneNumber(@PathParam("STAFFMEMBERID") Long staffMemberId, @PathParam("ID") Long id) {
    StaffMember staffMember = userController.findStaffMemberById(staffMemberId);
    if (staffMember == null) {
        return Response.status(Status.NOT_FOUND).build();
    }
    if (staffMember.getArchived()) {
        return Response.status(Status.NOT_FOUND).build();
    }
    if (!restSecurity.hasPermission(new String[] { UserPermissions.DELETE_STAFFMEMBERPHONENUMBER }, staffMember) && !restSecurity.hasPermission(new String[] { PersonPermissions.PERSON_OWNER }, staffMember.getPerson())) {
        return Response.status(Status.FORBIDDEN).build();
    }
    PhoneNumber phoneNumber = commonController.findPhoneNumberById(id);
    if (phoneNumber == null) {
        return Response.status(Status.NOT_FOUND).build();
    }
    if (!phoneNumber.getContactInfo().getId().equals(staffMember.getContactInfo().getId())) {
        return Response.status(Status.NOT_FOUND).build();
    }
    commonController.deletePhoneNumber(phoneNumber);
    return Response.noContent().build();
}
Also used : PhoneNumber(fi.otavanopisto.pyramus.domainmodel.base.PhoneNumber) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RESTPermit(fi.otavanopisto.pyramus.rest.annotation.RESTPermit)

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