ItEr34S08ValidacionEProbasFuncionaisItEr33S08: [Bug #76] Rename methods according to development guide; rearrange IWorkReportModel

This commit is contained in:
Diego Pino Garcia 2009-11-09 18:08:05 +01:00 committed by Javier Moran Rua
parent 4bca39e977
commit 9655f9e5c4
3 changed files with 42 additions and 45 deletions

View file

@ -40,32 +40,20 @@ import org.navalplanner.business.workreports.entities.WorkReportType;
public interface IWorkReportModel {
/**
* Gets the current {@link WorkReport}.
* Add new {@link WorkReportLine} to {@link WorkReport}
*
* @return A {@link WorkReport}
* @return
*/
WorkReport getWorkReport();
WorkReportLine addWorkReportLine();
/**
* Stores the current {@link WorkReport}.
* Converts @{link Resource} to @{link Worker}
*
* @throws ValidationException
* If validation fails
* @param resource
* @return
* @throws InstanceNotFoundException
*/
void save() throws ValidationException;
/**
* Makes some operations needed before create a new {@link WorkReport}.
*/
void prepareForCreate(WorkReportType workReportType);
/**
* Makes some operations needed before edit a {@link WorkReport}.
*
* @param workReport
* The object to be edited
*/
void prepareEditFor(WorkReport workReport);
Worker asWorker(Resource resource) throws InstanceNotFoundException;
/**
* Finds an @{link OrdrElement} by code
@ -85,13 +73,27 @@ public interface IWorkReportModel {
Worker findWorker(String nif) throws InstanceNotFoundException;
/**
* Converts @{link Resource} to @{link Worker}
* Returns distinguished code for {@link OrderElement}
*
* @param resource
* @param orderElement
* @return
* @throws InstanceNotFoundException
*/
Worker asWorker(Resource resource) throws InstanceNotFoundException;
String getDistinguishedCode(OrderElement orderElement)
throws InstanceNotFoundException;
/**
* Gets the current {@link WorkReport}.
*
* @return A {@link WorkReport}
*/
WorkReport getWorkReport();
/**
* Return all {@link WorkReportLine} associated with current {@link WorkReport}
*
* @return
*/
List<WorkReportLine> getWorkReportLines();
/**
* Get all {@link WorkReport} elements
@ -108,20 +110,17 @@ public interface IWorkReportModel {
boolean isEditing();
/**
* Returns distinguished code for {@link OrderElement}
* Makes some operations needed before edit a {@link WorkReport}.
*
* @param orderElement
* @return
* @param workReport
* The object to be edited
*/
String getDistinguishedCode(OrderElement orderElement)
throws InstanceNotFoundException;
void initEdit(WorkReport workReport);
/**
* Add new {@link WorkReportLine} to {@link WorkReport}
*
* @return
* Makes some operations needed before create a new {@link WorkReport}.
*/
WorkReportLine addWorkReportLine();
void initCreate(WorkReportType workReportType);
/**
* Removes {@link WorkReport}
@ -138,9 +137,10 @@ public interface IWorkReportModel {
void removeWorkReportLine(WorkReportLine workReportLine);
/**
* Return all {@link WorkReportLine} associated with current {@link WorkReport}
* Stores the current {@link WorkReport}.
*
* @return
* @throws ValidationException
* If validation fails
*/
List<WorkReportLine> getWorkReportLines();
void confirmSave() throws ValidationException;
}

View file

@ -24,7 +24,6 @@ import static org.navalplanner.web.I18nHelper._;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -58,7 +57,6 @@ import org.zkoss.zul.Button;
import org.zkoss.zul.Comboitem;
import org.zkoss.zul.Datebox;
import org.zkoss.zul.Intbox;
import org.zkoss.zul.ListModel;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listcell;
import org.zkoss.zul.Listhead;
@ -66,7 +64,6 @@ import org.zkoss.zul.Listheader;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.ListitemRenderer;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.SimpleListModel;
import org.zkoss.zul.Textbox;
import org.zkoss.zul.api.Window;
@ -166,7 +163,7 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
public boolean save() {
try {
workReportModel.save();
workReportModel.confirmSave();
messagesForUser.showMessage(Level.INFO,
_("Work report saved"));
return true;
@ -302,14 +299,14 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
}
public void goToCreateForm(WorkReportType workReportType) {
workReportModel.prepareForCreate(workReportType);
workReportModel.initCreate(workReportType);
prepareWorkReportList();
getVisibility().showOnly(createWindow);
Util.reloadBindings(createWindow);
}
public void goToEditForm(WorkReport workReport) {
workReportModel.prepareEditFor(workReport);
workReportModel.initEdit(workReport);
prepareWorkReportList();
getVisibility().showOnly(createWindow);
Util.reloadBindings(createWindow);

View file

@ -73,7 +73,7 @@ public class WorkReportModel implements IWorkReportModel {
@Override
@Transactional(readOnly = true)
public void prepareForCreate(WorkReportType workReportType) {
public void initCreate(WorkReportType workReportType) {
editing = false;
workReport = WorkReport.create();
workReport.setWorkReportType(workReportType);
@ -81,7 +81,7 @@ public class WorkReportModel implements IWorkReportModel {
@Override
@Transactional(readOnly = true)
public void prepareEditFor(WorkReport workReport) {
public void initEdit(WorkReport workReport) {
editing = true;
Validate.notNull(workReport);
this.workReport = getFromDB(workReport);
@ -137,7 +137,7 @@ public class WorkReportModel implements IWorkReportModel {
@Override
@Transactional
public void save() throws ValidationException {
public void confirmSave() throws ValidationException {
workReportDAO.save(workReport);
}