/**
  * Busca todas las cajas y las retorna como json.
  *
  * @return json con las cajas. Si no encuentra cajas retorna 1 y si ocurre una excepcion retorna 2
  */
 public static String getAll() {
   Date fechaInicio = new Date();
   String json = null;
   orm.DAOFactory lDAOFactory = orm.DAOFactory.getDAOFactory();
   Collection<CajaSOAPVO> coleccionCajaSOAPVO = new ArrayList<CajaSOAPVO>();
   orm.Tap_caja[] ormCajas;
   try {
     ormCajas = lDAOFactory.getTap_cajaDAO().listTap_cajaByQuery(null, null);
     // busqueda de todos los registros existentes
     if (ormCajas.length == 0) { // si no se encontraron registros
       json = "1";
     } else { // si se encontraron registros
       for (int i = 0; i < ormCajas.length; i++) {
         CajaSOAPVO objeto = CajaSOAPVO.crearCajaSOAPVO(ormCajas[i]);
         coleccionCajaSOAPVO.add(objeto);
       } // fin guardando resultados
       Gson gson = new Gson();
       json = gson.toJson(coleccionCajaSOAPVO);
     }
   } catch (PersistentException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
     json = "2";
   }
   // log
   LogSOA log = new LogSOA();
   Date fechaTermino = new Date();
   log.add("Todos las cajas", fechaInicio, fechaTermino);
   return json;
 }
Exemplo n.º 2
0
 /**
  * registra el rce de un paciente
  *
  * @param json son los datos pertinentes del rce
  * @return id del rce almacenado en la bd local
  */
 public String registrarRce(String json) {
   System.out.println(json);
   if (json != null) {
     try {
       RceVO rceVo = Transformar.jsonToRce2(json);
       Rce rce = new Rce();
       String idRce = rce.registrarRce(rceVo);
       // falta la uuid agregar para almacenar
       return idRce;
     } catch (NullPointerException e) {
       return "no registrado";
     } catch (PersistentException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
       return "no registrado";
     }
   }
   return "no registrado";
 }
  @Override
  public void initialize(URL location, ResourceBundle resources) {

    // Anlegen der Items in die Dropdown-Liste
    kategorieComboBox.getItems().add("Haushalt");
    kategorieComboBox.getItems().add("Heimwerk");
    kategorieComboBox.getItems().add("Notfall");
    kategorieComboBox.getItems().add("Tiere");
    kategorieComboBox.getItems().add("Sonstiges");

    try {

      // Lese Benutzername aus Datenbank
      user = BewohnerDAO.getBewohnerByORMID(1);
      benutzernameID.setText(user.getVorname() + " " + user.getNachname());

    } catch (PersistentException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
 /**
  * Busca una caja por id y la retorna como json.
  *
  * @param id
  * @return json con la caja. Si el id es nulo retorna 0, si no encuentra el curso retorna 1 y si
  *     ocurre una excepcion retorna 2
  */
 public static String getById(int id) {
   Date fechaInicio = new Date();
   String json = null;
   // Comprueba si la variable ingresada es nula
   if (id == 0) {
     // Retorna un 0, indicando que el dato ingresado es nulo
     json = "0";
   } else {
     try {
       orm.DAOFactory lDAOFactory = orm.DAOFactory.getDAOFactory();
       Collection<CajaSOAPVO> colectionCajaSOAPVO = new ArrayList<CajaSOAPVO>();
       orm.Tap_caja ormCaja;
       // Busca la caja con esa id
       ormCaja = lDAOFactory.getTap_cajaDAO().loadTap_cajaByQuery("caj_id='" + id + "'", null);
       // Si no se encuentra la caja, devuelve un 1, de lo contrario,
       // agrega la caja a la coleccion y la retorna
       if (ormCaja == null) {
         json = "1";
       } else {
         CajaSOAPVO curso = CajaSOAPVO.crearCajaSOAPVO(ormCaja);
         colectionCajaSOAPVO.add(curso);
         Gson gson = new Gson();
         json = gson.toJson(colectionCajaSOAPVO);
       } // fin guardando resultado
     } catch (PersistentException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
       // Retorna 2 indicando excepcion
       json = "2";
     }
   }
   // log
   LogSOA log = new LogSOA();
   Date fechaTermino = new Date();
   log.add("Caja por id", fechaInicio, fechaTermino);
   return json;
 }
  @FXML
  void sendAction(ActionEvent event) {

    // Anlegen der Variablen für
    String titel = titelField.getText().trim();
    String beschreibung = beschreibungTextField.getText().trim();
    String kategorie = "";

    // Wenn etwas in der Combobox ausgewählt wurde, schreibe Inhalt in die
    // Variable kategorie
    if (!(kategorieComboBox.getSelectionModel().isEmpty())) {
      kategorie = kategorieComboBox.getSelectionModel().getSelectedItem().trim();
    }

    // Falls in einem der Felder nichts ausgewählt wurde, melde Fehler
    if (titel.equals("") || kategorie.equals("") || beschreibung.equals("")) {
      messageField.setText("Eingaben fehlerhaft");
      return;
    }

    // überprüfen,ob Datum = null. Ansonsten Datum umwandeln (vonDatum)
    if ((vonDatePicker.getValue() != null)) {
      vonDate =
          Date.from(
              vonDatePicker.getValue().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
    }

    // überprüfen,ob Datum = null. Ansonsten Datum umwandeln (bisDatum)
    if ((bisDatePicker.getValue() != null)) {
      bisDate =
          Date.from(
              bisDatePicker.getValue().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
    }

    Dienstleistung neueDienstleistung = DienstleistungDAO.createDienstleistung();

    // Bereite Daten für Datenbank vor
    neueDienstleistung.setBeschreibung(beschreibung);
    neueDienstleistung.dienstnutzer.add(user);
    neueDienstleistung.setKategorie(kategorie);

    // Setze Zeit
    neueDienstleistung.setVonTermin(vonDate);
    neueDienstleistung.setBisTermin(bisDate);

    // Erfolgsmeldung
    messageField.setText("Anfrage erfolgreich erstellt");

    // reset Eingabfelder
    titelField.clear();
    beschreibungTextField.clear();
    kategorieComboBox.getSelectionModel().clearSelection();

    // reset Kalender
    vonDatePicker.setValue(null);
    bisDatePicker.setValue(null);

    try {
      DienstleistungDAO.save(neueDienstleistung);
    } catch (PersistentException e) {
      messageField.setText("Datenbankfehler");
      e.printStackTrace();
    }
  }