private boolean save() { LocationDepartmentTypesVo locationDepartmentType = populateDataFromScreen(form.getLocalContext().getSelectedInstance()); String[] errors = locationDepartmentType.validate(); if(errors != null && errors.length > 0) { engine.showErrors(errors); return false; } try { form.getLocalContext().setSelectedInstance(domain.save(locationDepartmentType)); } catch (StaleObjectException e) { e.printStackTrace(); engine.showMessage(ConfigFlag.UI.STALE_OBJECT_MESSAGE.getValue()); open(); return false; } return true; }
public LocationDepartmentTypesVo getLocationDepartmentTypes(LocationRefVo edLocation) { if(edLocation == null || edLocation.getID_Location() == null) return null; DomainFactory factory = getDomainFactory(); String query = "from LocationDepartmentTypes as ldt where ldt.eDLocation.id = :EmergencyLocation"; List<?> departments = factory.find(query, new String[] {"EmergencyLocation"}, new Object[] {edLocation.getID_Location()}); if(departments != null && departments.size() > 0) { return LocationDepartmentTypesVoAssembler.create((LocationDepartmentTypes) departments.get(0)); } return null; }
public ims.emergency.vo.LocationDepartmentTypesVo save(ims.emergency.vo.LocationDepartmentTypesVo locationDepartmentTypes) throws ims.domain.exceptions.StaleObjectException { if(locationDepartmentTypes == null) throw new CodingRuntimeException("Cannnot save a null LocationDepartmentType."); if(!locationDepartmentTypes.isValidated()) throw new CodingRuntimeException("LocationDepartmentType is not validated."); DomainFactory factory = getDomainFactory(); LocationDepartmentTypes doLocationDepartmentType = LocationDepartmentTypesVoAssembler.extractLocationDepartmentTypes(factory, locationDepartmentTypes); if(locationDepartmentTypes.getID_LocationDepartmentTypes() == null) { LocationDepartmentTypesVo locationDepartmentTypesFromDB = get(locationDepartmentTypes.getEDLocation()); if(locationDepartmentTypesFromDB != null && locationDepartmentTypesFromDB.getID_LocationDepartmentTypes() != null) throw new StaleObjectException(doLocationDepartmentType); } factory.save(doLocationDepartmentType); return LocationDepartmentTypesVoAssembler.create(doLocationDepartmentType); }
private void newInstance() { form.setMode(FormMode.EDIT); LocationDepartmentTypesVo locationDepartmentType = new LocationDepartmentTypesVo(); locationDepartmentType.setEDLocation(form.cmbEDLocation().getValue()); populateScreenFromData(locationDepartmentType); }
public LocationDepartmentTypesVo get(LocationRefVo edLocation) { if(edLocation == null || edLocation.getID_Location() == null) return null; String query = "from LocationDepartmentTypes as locConfig where locConfig.eDLocation.id = :EDLocationId"; DomainFactory factory = getDomainFactory(); List<?> list = factory.find(query, new String[] {"EDLocationId"}, new Object[] {edLocation.getID_Location()}); if(list != null && list.size() > 0) return LocationDepartmentTypesVoAssembler.create((LocationDepartmentTypes) list.get(0)); return null; }
private void populateScreenFromData(LocationDepartmentTypesVo locationDepartmentTypes) { populateDepartmentsGrid(locationDepartmentTypes); }
private void populateDepartmentsGrid(LocationDepartmentTypesVo locationDepartmentTypes) { form.dyngrdDepartments().getRows().clear(); if(FormMode.EDIT.equals(form.getMode())) { populateDepartmentsGridWithDefault(); } if(locationDepartmentTypes == null || locationDepartmentTypes.getDepartmentTypes() == null) return; for(int i=0; i<locationDepartmentTypes.getDepartmentTypes().size(); i++) { if(locationDepartmentTypes.getDepartmentTypes().get(i) == null) continue; DynamicGridRow row = getRowByDepartment(locationDepartmentTypes.getDepartmentTypes().get(i)); if(row == null) row = form.dyngrdDepartments().getRows().newRow(); DynamicGridCell cell = row.getCells().newCell(getSelectedColumn(COLDEPARTMENT), DynamicCellType.LABEL); cell.setValue(locationDepartmentTypes.getDepartmentTypes().get(i).getText()); cell.setTooltip(locationDepartmentTypes.getDepartmentTypes().get(i).getText()); cell.setReadOnly(true); cell = row.getCells().newCell(getSelectedColumn(COLSELECTED), DynamicCellType.BOOL); cell.setAutoPostBack(true); cell.setValue(true); cell = row.getCells().newCell(getSelectedColumn(COLDEFAULT), DynamicCellType.BOOL); cell.setAutoPostBack(true); if(locationDepartmentTypes.getDepartmentTypes().get(i).equals(locationDepartmentTypes.getDefaultDepartmentType())) { cell.setValue(true); } row.setValue(locationDepartmentTypes.getDepartmentTypes().get(i)); } }