Search in sources :

Example 1 with ModuleComponent

use of fi.otavanopisto.pyramus.domainmodel.modules.ModuleComponent in project pyramus by otavanopisto.

the class ArchiveModuleComponentJSONRequestController method process.

public void process(JSONRequestContext requestContext) {
    ModuleComponentDAO moduleComponentDAO = DAOFactory.getInstance().getModuleComponentDAO();
    Long componentId = requestContext.getLong("componentId");
    ModuleComponent component = moduleComponentDAO.findById(componentId);
    moduleComponentDAO.archive(component);
}
Also used : ModuleComponentDAO(fi.otavanopisto.pyramus.dao.modules.ModuleComponentDAO) ModuleComponent(fi.otavanopisto.pyramus.domainmodel.modules.ModuleComponent)

Example 2 with ModuleComponent

use of fi.otavanopisto.pyramus.domainmodel.modules.ModuleComponent in project pyramus by otavanopisto.

the class CoursesService method createCourse.

public CourseEntity createCourse(@WebParam(name = "moduleId") Long moduleId, @WebParam(name = "name") String name, @WebParam(name = "nameExtension") String nameExtension, @WebParam(name = "subjectId") Long subjectId, @WebParam(name = "courseNumber") Integer courseNumber, @WebParam(name = "beginDate") Date beginDate, @WebParam(name = "endDate") Date endDate, @WebParam(name = "courseLength") Double courseLength, @WebParam(name = "courseLengthTimeUnitId") Long courseLengthTimeUnitId, @WebParam(name = "description") String description, @WebParam(name = "creatingUserId") Long creatingUserId) {
    StaffMemberDAO userDAO = DAOFactory.getInstance().getStaffMemberDAO();
    CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
    ModuleDAO moduleDAO = DAOFactory.getInstance().getModuleDAO();
    CourseComponentDAO componentDAO = DAOFactory.getInstance().getCourseComponentDAO();
    CourseDescriptionDAO descriptionDAO = DAOFactory.getInstance().getCourseDescriptionDAO();
    CourseEducationTypeDAO educationTypeDAO = DAOFactory.getInstance().getCourseEducationTypeDAO();
    CourseEducationSubtypeDAO educationSubtypeDAO = DAOFactory.getInstance().getCourseEducationSubtypeDAO();
    EducationalTimeUnitDAO educationalTimeUnitDAO = DAOFactory.getInstance().getEducationalTimeUnitDAO();
    SubjectDAO subjectDAO = DAOFactory.getInstance().getSubjectDAO();
    DefaultsDAO defaultsDAO = DAOFactory.getInstance().getDefaultsDAO();
    Module module = moduleId == null ? null : moduleDAO.findById(moduleId);
    Subject subject = subjectId == null ? null : subjectDAO.findById(subjectId);
    EducationalTimeUnit courseLengthTimeUnit = courseLengthTimeUnitId == null ? null : educationalTimeUnitDAO.findById(courseLengthTimeUnitId);
    User creatingUser = userDAO.findById(creatingUserId);
    if (module != null) {
        name = name == null ? module.getName() : name;
        subject = subject == null ? module.getSubject() : subject;
        courseNumber = courseNumber == null ? module.getCourseNumber() : courseNumber;
        if (courseLength == null && module.getCourseLength() != null) {
            courseLength = module.getCourseLength().getUnits();
            courseLengthTimeUnit = module.getCourseLength().getUnit();
        }
        description = description == null ? module.getDescription() : description;
    }
    CourseState state = defaultsDAO.getDefaults().getInitialCourseState();
    CourseType type = null;
    // Course creation
    Course course = courseDAO.create(module, name, nameExtension, state, type, subject, courseNumber, beginDate, endDate, courseLength, courseLengthTimeUnit, null, null, null, null, null, null, description, null, null, null, null, creatingUser);
    validateEntity(course);
    if (module != null) {
        // Course Description copying from module to course
        descriptionDAO.copy(module, course);
        // Curriculums
        courseDAO.updateCurriculums(course, new HashSet<Curriculum>(module.getCurriculums()));
        // Components
        List<ModuleComponent> moduleComponents = module.getModuleComponents();
        if (moduleComponents != null) {
            for (ModuleComponent moduleComponent : moduleComponents) {
                EducationalLength educationalLength = moduleComponent.getLength();
                CourseComponent courseComponent = componentDAO.create(course, educationalLength == null ? null : educationalLength.getUnits(), educationalLength == null ? null : educationalLength.getUnit(), moduleComponent.getName(), moduleComponent.getDescription());
                validateEntity(courseComponent);
            }
        }
        // Education types
        List<CourseEducationType> typesInModule = module.getCourseEducationTypes();
        if (typesInModule != null) {
            for (CourseEducationType typeInModule : typesInModule) {
                CourseEducationType typeInCourse = educationTypeDAO.create(course, typeInModule.getEducationType());
                validateEntity(typeInCourse);
                // Education subtypes
                List<CourseEducationSubtype> subTypesInModule = typeInModule.getCourseEducationSubtypes();
                if (subTypesInModule != null) {
                    for (CourseEducationSubtype subtypeInModule : subTypesInModule) {
                        CourseEducationSubtype courseEducationSubtype = educationSubtypeDAO.create(typeInCourse, subtypeInModule.getEducationSubtype());
                        validateEntity(courseEducationSubtype);
                    }
                }
            }
        }
    }
    return EntityFactoryVault.buildFromDomainObject(course);
}
Also used : User(fi.otavanopisto.pyramus.domainmodel.users.User) SubjectDAO(fi.otavanopisto.pyramus.dao.base.SubjectDAO) CourseDAO(fi.otavanopisto.pyramus.dao.courses.CourseDAO) CourseDescriptionDAO(fi.otavanopisto.pyramus.dao.courses.CourseDescriptionDAO) ModuleDAO(fi.otavanopisto.pyramus.dao.modules.ModuleDAO) CourseComponent(fi.otavanopisto.pyramus.domainmodel.courses.CourseComponent) StaffMemberDAO(fi.otavanopisto.pyramus.dao.users.StaffMemberDAO) CourseStaffMemberDAO(fi.otavanopisto.pyramus.dao.courses.CourseStaffMemberDAO) CourseState(fi.otavanopisto.pyramus.domainmodel.courses.CourseState) CourseType(fi.otavanopisto.pyramus.domainmodel.courses.CourseType) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course) EducationalLength(fi.otavanopisto.pyramus.domainmodel.base.EducationalLength) EducationalTimeUnit(fi.otavanopisto.pyramus.domainmodel.base.EducationalTimeUnit) CourseEducationType(fi.otavanopisto.pyramus.domainmodel.base.CourseEducationType) CourseComponentDAO(fi.otavanopisto.pyramus.dao.courses.CourseComponentDAO) EducationalTimeUnitDAO(fi.otavanopisto.pyramus.dao.base.EducationalTimeUnitDAO) CourseEducationSubtype(fi.otavanopisto.pyramus.domainmodel.base.CourseEducationSubtype) CourseEducationTypeDAO(fi.otavanopisto.pyramus.dao.base.CourseEducationTypeDAO) DefaultsDAO(fi.otavanopisto.pyramus.dao.base.DefaultsDAO) CourseEducationSubtypeDAO(fi.otavanopisto.pyramus.dao.base.CourseEducationSubtypeDAO) Subject(fi.otavanopisto.pyramus.domainmodel.base.Subject) ModuleComponent(fi.otavanopisto.pyramus.domainmodel.modules.ModuleComponent) Curriculum(fi.otavanopisto.pyramus.domainmodel.base.Curriculum) Module(fi.otavanopisto.pyramus.domainmodel.modules.Module)

Example 3 with ModuleComponent

use of fi.otavanopisto.pyramus.domainmodel.modules.ModuleComponent in project pyramus by otavanopisto.

the class ModulesService method updateModuleComponent.

public ModuleComponentEntity updateModuleComponent(@WebParam(name = "moduleComponentId") Long moduleComponentId, @WebParam(name = "length") Double length, @WebParam(name = "lengthTimeUnitId") Long lengthTimeUnitId, @WebParam(name = "name") String name, @WebParam(name = "description") String description) {
    ModuleComponentDAO moduleComponentDAO = DAOFactory.getInstance().getModuleComponentDAO();
    EducationalTimeUnitDAO educationalTimeUnitDAO = DAOFactory.getInstance().getEducationalTimeUnitDAO();
    ModuleComponent moduleComponent = moduleComponentDAO.findById(moduleComponentId);
    EducationalTimeUnit lengthTimeUnit = lengthTimeUnitId == null ? null : educationalTimeUnitDAO.findById(lengthTimeUnitId);
    moduleComponentDAO.update(moduleComponent, length, lengthTimeUnit, name, description);
    validateEntity(moduleComponent);
    return EntityFactoryVault.buildFromDomainObject(moduleComponent);
}
Also used : ModuleComponentDAO(fi.otavanopisto.pyramus.dao.modules.ModuleComponentDAO) EducationalTimeUnitDAO(fi.otavanopisto.pyramus.dao.base.EducationalTimeUnitDAO) ModuleComponent(fi.otavanopisto.pyramus.domainmodel.modules.ModuleComponent) EducationalTimeUnit(fi.otavanopisto.pyramus.domainmodel.base.EducationalTimeUnit)

Example 4 with ModuleComponent

use of fi.otavanopisto.pyramus.domainmodel.modules.ModuleComponent in project pyramus by otavanopisto.

the class ModulesService method createModuleComponent.

public ModuleComponentEntity createModuleComponent(@WebParam(name = "moduleId") Long moduleId, @WebParam(name = "length") Double length, @WebParam(name = "lengthTimeUnitId") Long lengthTimeUnitId, @WebParam(name = "name") String name, @WebParam(name = "description") String description) {
    ModuleDAO moduleDAO = DAOFactory.getInstance().getModuleDAO();
    ModuleComponentDAO moduleComponentDAO = DAOFactory.getInstance().getModuleComponentDAO();
    EducationalTimeUnitDAO educationalTimeUnitDAO = DAOFactory.getInstance().getEducationalTimeUnitDAO();
    Module module = moduleDAO.findById(moduleId);
    EducationalTimeUnit lengthTimeUnit = lengthTimeUnitId == null ? null : educationalTimeUnitDAO.findById(lengthTimeUnitId);
    ModuleComponent moduleComponent = moduleComponentDAO.create(module, length, lengthTimeUnit, name, description);
    validateEntity(moduleComponent);
    return EntityFactoryVault.buildFromDomainObject(moduleComponent);
}
Also used : ModuleComponentDAO(fi.otavanopisto.pyramus.dao.modules.ModuleComponentDAO) EducationalTimeUnitDAO(fi.otavanopisto.pyramus.dao.base.EducationalTimeUnitDAO) ModuleDAO(fi.otavanopisto.pyramus.dao.modules.ModuleDAO) Module(fi.otavanopisto.pyramus.domainmodel.modules.Module) EducationalTimeUnit(fi.otavanopisto.pyramus.domainmodel.base.EducationalTimeUnit) ModuleComponent(fi.otavanopisto.pyramus.domainmodel.modules.ModuleComponent)

Example 5 with ModuleComponent

use of fi.otavanopisto.pyramus.domainmodel.modules.ModuleComponent in project pyramus by otavanopisto.

the class ModuleRESTService method findModuleComponentById.

@Path("/modules/{MODULEID:[0-9]*}/components/{ID:[0-9]*}")
@GET
@RESTPermit(ModulePermissions.FIND_MODULECOMPONENT)
public Response findModuleComponentById(@PathParam("MODULEID") Long moduleId, @PathParam("ID") Long componentId) {
    Module module = moduleController.findModuleById(moduleId);
    if (module == null) {
        return Response.status(Status.NOT_FOUND).build();
    }
    if (module.getArchived()) {
        return Response.status(Status.NOT_FOUND).build();
    }
    ModuleComponent component = moduleController.findModuleComponentById(componentId);
    if (component == null) {
        return Response.status(Status.NOT_FOUND).build();
    }
    if (component.getArchived()) {
        return Response.status(Status.NOT_FOUND).build();
    }
    if (!component.getModule().getId().equals(moduleId)) {
        return Response.status(Status.NOT_FOUND).build();
    }
    return Response.status(Status.OK).entity(objectFactory.createModel(component)).build();
}
Also used : Module(fi.otavanopisto.pyramus.domainmodel.modules.Module) ModuleComponent(fi.otavanopisto.pyramus.domainmodel.modules.ModuleComponent) Path(javax.ws.rs.Path) RESTPermit(fi.otavanopisto.pyramus.rest.annotation.RESTPermit) GET(javax.ws.rs.GET)

Aggregations

ModuleComponent (fi.otavanopisto.pyramus.domainmodel.modules.ModuleComponent)13 Module (fi.otavanopisto.pyramus.domainmodel.modules.Module)8 EducationalTimeUnit (fi.otavanopisto.pyramus.domainmodel.base.EducationalTimeUnit)6 EducationalTimeUnitDAO (fi.otavanopisto.pyramus.dao.base.EducationalTimeUnitDAO)4 ModuleComponentDAO (fi.otavanopisto.pyramus.dao.modules.ModuleComponentDAO)4 ModuleDAO (fi.otavanopisto.pyramus.dao.modules.ModuleDAO)3 CourseEducationSubtype (fi.otavanopisto.pyramus.domainmodel.base.CourseEducationSubtype)3 CourseEducationType (fi.otavanopisto.pyramus.domainmodel.base.CourseEducationType)3 Subject (fi.otavanopisto.pyramus.domainmodel.base.Subject)3 RESTPermit (fi.otavanopisto.pyramus.rest.annotation.RESTPermit)3 Path (javax.ws.rs.Path)3 SubjectDAO (fi.otavanopisto.pyramus.dao.base.SubjectDAO)2 CourseDescriptionDAO (fi.otavanopisto.pyramus.dao.courses.CourseDescriptionDAO)2 StaffMemberDAO (fi.otavanopisto.pyramus.dao.users.StaffMemberDAO)2 Curriculum (fi.otavanopisto.pyramus.domainmodel.base.Curriculum)2 EducationSubtype (fi.otavanopisto.pyramus.domainmodel.base.EducationSubtype)2 EducationType (fi.otavanopisto.pyramus.domainmodel.base.EducationType)2 Organization (fi.otavanopisto.pyramus.domainmodel.base.Organization)2 Tag (fi.otavanopisto.pyramus.domainmodel.base.Tag)2 CourseParticipationType (fi.otavanopisto.pyramus.domainmodel.courses.CourseParticipationType)2