Exemplo n.º 1
0
 /** @return Aine-valitsimen malli, jossa on kaikki tietorakenteen aineet. */
 public DataComboBoxModel<Subject> getSubjectModel() {
   List<Subject> subjects = manager.getSubjects();
   Object[] arr = {"Valitse aine..."};
   Object[] temp = subjects.toArray();
   Object[] objects = Taulukot.combine(arr, temp);
   return new DataComboBoxModel<>(objects);
 }
Exemplo n.º 2
0
  /**
   * Luo paramatrien pohjalta uusi tai tallenna vanha koe tietorakenteeseen.
   *
   * @param unit Yksikkö, joka tallennetaan.
   * @param date Pvm.
   * @param subject Aine.
   * @return True, jos tallennettiin, muute false.
   */
  public boolean saveExam(Exam unit, String date, String subject) {
    boolean replace = false;
    if (unit.getRef() != null) {
      if (!confirmSave()) {
        return false;
      }
      replace = true;
    }
    Exam edit = unit;
    if (replace) {
      edit = getEditable(edit);
    }
    try {
      edit.parseField(FN.EXAM_DATE, date);

      if (subject != null) {
        List<Subject> match = manager.getSubjects(subject, FN.SUBJECT_NAME);
        Subject s;
        if (match.size() < 1) {
          s = new Subject();
          s.parseField(FN.SUBJECT_NAME, subject);
          manager.add(s);
        } else {
          s = match.get(0);
        }
        Ref subjectRef = s.getRef();

        edit.setField(FN.EXAM_SUBJECT_REF, subjectRef);
      }
    } catch (ParseException e) {
      showParseError(e);
      return false;
    }
    if (replace) {
      manager.remove(unit);
    }
    manager.add(edit);

    finishSave();

    return true;
  }
Exemplo n.º 3
0
 /** @return Kaikki tietorakenteen aineet. */
 public List<Subject> getSubjects() {
   return manager.getSubjects();
 }