public void saveSelected() { if (current == null) { UtilityController.addErrorMessage("Nothing to save"); return; } if (current.getPerson() == null) { UtilityController.addErrorMessage("Nothing to save"); return; } if (current.getPerson().getName().trim().equals("")) { UtilityController.addErrorMessage("Please enter a name"); return; } if (current.getPerson().getId() == null || current.getPerson().getId() == 0) { getPersonFacade().create(current.getPerson()); } else { getPersonFacade().edit(current.getPerson()); } if (getCurrent().getId() != null && getCurrent().getId() > 0) { getFacade().edit(current); UtilityController.addSuccessMessage("updated Successfully"); } else { current.setCreatedAt(Calendar.getInstance(TimeZone.getTimeZone("IST")).getTime()); current.setCreater(sessionController.getLoggedUser()); getFacade().create(current); UtilityController.addSuccessMessage("saved Successfully"); } recreateModel(); getItems(); }
public void delete() { if (current != null) { current.setRetired(true); current.setRetiredAt(Calendar.getInstance(TimeZone.getTimeZone("IST")).getTime()); current.setRetirer(sessionController.getLoggedUser()); getFacade().edit(current); UtilityController.addSuccessMessage("DeleteSuccessfull"); } else { UtilityController.addSuccessMessage("NothingToDelete"); } recreateModel(); getItems(); current = null; getCurrent(); }
public Doctor getCurrent() { if (current == null) { Person p = new Person(); current = new Doctor(); current.setPerson(p); } return current; }
@Override public String getAsString(FacesContext facesContext, UIComponent component, Object object) { if (object == null) { return null; } if (object instanceof Doctor) { Doctor o = (Doctor) object; return getStringKey(o.getId()); } else { throw new IllegalArgumentException( "object " + object + " is of type " + object.getClass().getName() + "; expected type: " + DoctorController.class.getName()); } }