private void populateLaboratoryFields(Laboratory laboratory) throws DaoEntityNotFoundException {
    Hour from = hourDao.getHourByValue(laboratory.getFrom().getValue());
    Hour to = hourDao.getHourByValue(laboratory.getTo().getValue());
    Professor professor = professorDao.getProfessorByPnc(laboratory.getProfessor().getPnc());
    Room room = roomDao.getRoomByName(laboratory.getRoom().getName());
    Day day = dayDao.getDayByValue(laboratory.getDay().getValue());
    Section section = sectionDao.getSectionByName(laboratory.getSection().getName());
    Group group = groupDao.getGroupByName(laboratory.getGroup().getName());
    Subgroup subgroup = subgroupDao.getSubgroupByName(laboratory.getSubgroup().getName());
    Year year = yearDao.getYearByValue(laboratory.getYear().getValue());
    Semester semester = semesterDao.getSemesterByValue(laboratory.getSemester().getValue());
    WeeklyOccurrence weeklyOccurrence =
        weeklyOccurrenceDao.getWeeklyOccurrenceByName(laboratory.getWeeklyOccurrence().getName());
    List<Student> students = studentDao.getStudents(section, year, semester, group, subgroup);

    laboratory.setFrom(from);
    laboratory.setTo(to);
    laboratory.setProfessor(professor);
    laboratory.setRoom(room);
    laboratory.setDay(day);
    laboratory.setSection(section);
    laboratory.setGroup(group);
    laboratory.setSubgroup(subgroup);
    laboratory.setYear(year);
    laboratory.setSemester(semester);
    laboratory.setWeeklyOccurrence(weeklyOccurrence);
    laboratory.setStudents(students);
  }
  private void updateLaboratoryFields(Laboratory laboratory, LaboratoryDto laboratoryDto)
      throws DaoEntityNotFoundException {

    String compressedFields = laboratoryDto.getFormProfessorDto().getCompressedFields();
    String pnc = compressedFields.replaceAll("\\)", " ").replaceAll("\\(", " ").split(" ")[0];

    Hour from = hourDao.getHourByValue(laboratoryDto.getFrom());
    Hour to = hourDao.getHourByValue(laboratoryDto.getTo());
    Professor professor = professorDao.getProfessorByPnc(pnc);
    Room room = roomDao.getRoomByName(laboratoryDto.getRoom());
    Day day = dayDao.getDayByValue(laboratoryDto.getDay());
    Section section = sectionDao.getSectionByName(laboratoryDto.getSection());
    Group group = groupDao.getGroupByName(laboratoryDto.getGroup());
    Subgroup subgroup = subgroupDao.getSubgroupByName(laboratoryDto.getSubgroup());
    Year year = yearDao.getYearByValue(laboratoryDto.getYear());
    Semester semester = semesterDao.getSemesterByValue(laboratoryDto.getSemester());
    WeeklyOccurrence weeklyOccurrence =
        weeklyOccurrenceDao.getWeeklyOccurrenceByName(laboratoryDto.getWeeklyOccurrence());

    laboratory.setFrom(from);
    laboratory.setTo(to);
    laboratory.setProfessor(professor);
    laboratory.setRoom(room);
    laboratory.setDay(day);
    laboratory.setSection(section);
    laboratory.setGroup(group);
    laboratory.setSubgroup(subgroup);
    laboratory.setYear(year);
    laboratory.setSemester(semester);
    laboratory.setWeeklyOccurrence(weeklyOccurrence);
  }
Esempio n. 3
0
  public Long save(SectionCFODto bean, Long cfoId) throws AnyServiceException {
    SectionCFO entity = null;
    if (bean.getId() != null) {
      entity = findById(bean.getId());
    } else {
      entity = new SectionCFO();
    }

    /*
     * CFO cfo = null; if (bean.getCfo() == null) throw new
     * AcdpsException("ЦФО не указан!"); cfo =
     * cfoDao.findById(bean.getCfo().getId()); if (cfo == null) throw new
     * AcdpsException("ЦФО не найден!");
     */

    Section section = null;
    if (bean.getSection() == null) throw new AcdpsException("Статья не указана!");
    section = sectionDao.findById(bean.getSection().getId());
    if (section == null) throw new AcdpsException("Статья не найдена!");

    // entity.setCfo(cfo);
    entity.setSection(section);
    entity.setStartDate(
        bean.getStartDate() != null ? bean.getStartDate() : SystemConstants.startDate);
    entity.setEndDate(bean.getEndDate() != null ? bean.getEndDate() : SystemConstants.endDate);

    persist(entity);
    return entity.getId();
  }
Esempio n. 4
0
  public SectionCFODto toDto(SectionCFO sectionCfo, boolean full) {

    if (sectionCfo == null) return null;

    SectionCFODto dto =
        new SectionCFODto(
            sectionCfo.getId(),
            sectionDao.toDto(sectionCfo.getSection()),
            sectionCfo.getStartDate(),
            sectionCfo.getEndDate());

    return dto;
  }