From c0a3ec1392e093adee0a14b235a035678b6f9a51 Mon Sep 17 00:00:00 2001 From: Susana Montes Pedreira Date: Fri, 4 Nov 2011 13:49:11 +0100 Subject: [PATCH] Improve ComunicationType enum and include the translate method. FEA: ItEr75S28CustomerIncommingCommunicationsLists --- .../entities/ComunicationType.java | 19 ++++++++++++++++++- .../entities/CustomerComunication.java | 3 ++- .../CustomerComunicationCRUDController.java | 11 ++++------- .../impl/SubcontractServiceREST.java | 2 +- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/libreplan-business/src/main/java/org/libreplan/business/externalcompanies/entities/ComunicationType.java b/libreplan-business/src/main/java/org/libreplan/business/externalcompanies/entities/ComunicationType.java index ff95d30e6..f53bb5fb4 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/externalcompanies/entities/ComunicationType.java +++ b/libreplan-business/src/main/java/org/libreplan/business/externalcompanies/entities/ComunicationType.java @@ -21,11 +21,28 @@ package org.libreplan.business.externalcompanies.entities; +import static org.libreplan.business.i18n.I18nHelper._; + /** * Enum for specified the type of {@link CustomerComunication} * * @author Susana Montes Pedreira */ public enum ComunicationType { - New_Project + + NEW_PROJECT(_("New project")); + + private String description; + + private ComunicationType(String description) { + this.description = description; + } + + public String toString() { + return this.description; + } + + public static ComunicationType getDefault() { + return NEW_PROJECT; + } } diff --git a/libreplan-business/src/main/java/org/libreplan/business/externalcompanies/entities/CustomerComunication.java b/libreplan-business/src/main/java/org/libreplan/business/externalcompanies/entities/CustomerComunication.java index 3f884dcf1..ee598dbbb 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/externalcompanies/entities/CustomerComunication.java +++ b/libreplan-business/src/main/java/org/libreplan/business/externalcompanies/entities/CustomerComunication.java @@ -63,7 +63,8 @@ public class CustomerComunication extends BaseEntity{ } public static CustomerComunication createTodayNewProject(Date deadline) { - return (CustomerComunication) create(new CustomerComunication(deadline, new Date(), ComunicationType.New_Project)); + return (CustomerComunication) create(new CustomerComunication(deadline, + new Date(), ComunicationType.NEW_PROJECT)); } protected CustomerComunication(Date deadline, Date comunicationDate, ComunicationType comunicationType) { diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/subcontract/CustomerComunicationCRUDController.java b/libreplan-webapp/src/main/java/org/libreplan/web/subcontract/CustomerComunicationCRUDController.java index 74688fe94..1f5331211 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/subcontract/CustomerComunicationCRUDController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/subcontract/CustomerComunicationCRUDController.java @@ -31,14 +31,12 @@ import javax.annotation.Resource; import org.apache.commons.logging.LogFactory; import org.libreplan.business.common.exceptions.ValidationException; +import org.libreplan.business.externalcompanies.entities.ComunicationType; import org.libreplan.business.externalcompanies.entities.CustomerComunication; -import org.libreplan.business.materials.entities.MaterialStatusEnum; import org.libreplan.business.orders.entities.Order; -import org.libreplan.business.workreports.entities.PositionInWorkReportEnum; import org.libreplan.web.common.IMessagesForUser; import org.libreplan.web.common.MessagesForUser; import org.libreplan.web.planner.tabs.IGlobalViewEntryPoints; -import org.zkoss.ganttz.timetracker.zoom.ZoomLevel; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; @@ -48,8 +46,6 @@ import org.zkoss.zul.Button; import org.zkoss.zul.Checkbox; import org.zkoss.zul.Grid; import org.zkoss.zul.Label; -import org.zkoss.zul.ListModel; -import org.zkoss.zul.Listbox; import org.zkoss.zul.Row; import org.zkoss.zul.RowRenderer; import org.zkoss.zul.SimpleListModel; @@ -134,8 +130,9 @@ public class CustomerComunicationCRUDController extends GenericForwardComposer { CustomerComunication customerComunication = (CustomerComunication) data; row.setValue(customerComunication); - appendLabel(row, customerComunication.getComunicationType() - .toString()); + final ComunicationType type = customerComunication.getComunicationType(); + appendLabel(row, type.toString()); + appendLabel(row, customerComunication.getOrder().getName()); appendLabel(row, toString(customerComunication.getDeadline())); appendLabel(row, customerComunication.getOrder().getCode()); diff --git a/libreplan-webapp/src/main/java/org/libreplan/ws/subcontract/impl/SubcontractServiceREST.java b/libreplan-webapp/src/main/java/org/libreplan/ws/subcontract/impl/SubcontractServiceREST.java index c7791d84c..f724a4a77 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/ws/subcontract/impl/SubcontractServiceREST.java +++ b/libreplan-webapp/src/main/java/org/libreplan/ws/subcontract/impl/SubcontractServiceREST.java @@ -325,7 +325,7 @@ public class SubcontractServiceREST implements ISubcontractService { Date comunicationDate = new Date(); CustomerComunication customerComunication = CustomerComunication .create(deadline, comunicationDate, - ComunicationType.New_Project, order); + ComunicationType.NEW_PROJECT, order); customerComunicationDAO.save(customerComunication); } }