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);
}
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);
}
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);
}
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);
}
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();
}
Aggregations