public void addDirectly() {
    JsfUtil.addSuccessMessage("1");
    try {

      current.setCreatedAt(Calendar.getInstance().getTime());
      current.setCreater(sessionController.loggedUser);

      getFacade().create(current);
      JsfUtil.addSuccessMessage(new MessageProvider().getValue("savedNewSuccessfully"));
      current = new Atm();
    } catch (Exception e) {
      JsfUtil.addErrorMessage(e, "Error");
    }
  }
 public Atm searchItem(String itemName, boolean createNewIfNotPresent) {
   Atm searchedItem = null;
   items = new ListDataModel(getFacade().findAll("name", itemName, true));
   if (items.getRowCount() > 0) {
     items.setRowIndex(0);
     searchedItem = (Atm) items.getRowData();
   } else if (createNewIfNotPresent) {
     searchedItem = new Atm();
     searchedItem.setName(itemName);
     searchedItem.setCreatedAt(Calendar.getInstance().getTime());
     searchedItem.setCreater(sessionController.loggedUser);
     getFacade().create(searchedItem);
   }
   return searchedItem;
 }
 public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
   if (object == null) {
     return null;
   }
   if (object instanceof Atm) {
     Atm o = (Atm) object;
     return getStringKey(o.getId());
   } else {
     throw new IllegalArgumentException(
         "object "
             + object
             + " is of type "
             + object.getClass().getName()
             + "; expected type: "
             + AtmController.class.getName());
   }
 }
 public void delete() {
   if (current != null) {
     current.setRetired(true);
     current.setRetiredAt(Calendar.getInstance().getTime());
     current.setRetirer(sessionController.loggedUser);
     getFacade().edit(current);
     JsfUtil.addSuccessMessage(new MessageProvider().getValue("deleteSuccessful"));
   } else {
     JsfUtil.addErrorMessage(new MessageProvider().getValue("nothingToDelete"));
   }
   recreateModel();
   getItems();
   selectText = "";
   selectedItemIndex = -1;
   current = null;
   this.prepareSelect();
 }
 public void prepareEdit() {
   if (current != null) {
     selectedItemIndex = intValue(current.getId());
     this.prepareSelectControlDisable();
   } else {
     JsfUtil.addErrorMessage(new MessageProvider().getValue("nothingToEdit"));
   }
 }
 public void saveSelected() {
   if (sessionController.getPrivilege().isMsEdit() == false) {
     JsfUtil.addErrorMessage("You are not autherized to make changes to any content");
     return;
   }
   if (selectedItemIndex > 0) {
     getFacade().edit(current);
     JsfUtil.addSuccessMessage(new MessageProvider().getValue("savedOldSuccessfully"));
   } else {
     current.setCreatedAt(Calendar.getInstance().getTime());
     current.setCreater(sessionController.loggedUser);
     getFacade().create(current);
     JsfUtil.addSuccessMessage(new MessageProvider().getValue("savedNewSuccessfully"));
   }
   this.prepareSelect();
   recreateModel();
   getItems();
   selectText = "";
   selectedItemIndex = intValue(current.getId());
 }
 public DataModel searchItems() {
   recreateModel();
   if (items == null) {
     if (selectText.equals("")) {
       items = new ListDataModel(getFacade().findAll("name", true));
     } else {
       items = new ListDataModel(getFacade().findAll("name", "%" + selectText + "%", true));
       if (items.getRowCount() > 0) {
         items.setRowIndex(0);
         current = (Atm) items.getRowData();
         Long temLong = current.getId();
         selectedItemIndex = intValue(temLong);
       } else {
         current = null;
         selectedItemIndex = -1;
       }
     }
   }
   return items;
 }