diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/orders/OrderCRUDController.java b/libreplan-webapp/src/main/java/org/libreplan/web/orders/OrderCRUDController.java index 000382f69..cf1331fda 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/orders/OrderCRUDController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/orders/OrderCRUDController.java @@ -36,8 +36,13 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.LogFactory; import org.hibernate.validator.InvalidValue; import org.libreplan.business.calendars.entities.BaseCalendar; +import org.libreplan.business.common.Registry; +import org.libreplan.business.common.exceptions.InstanceNotFoundException; import org.libreplan.business.common.exceptions.ValidationException; import org.libreplan.business.externalcompanies.entities.ExternalCompany; +import org.libreplan.business.materials.daos.IMaterialCategoryDAO; +import org.libreplan.business.materials.entities.MaterialCategory; +import org.libreplan.business.orders.daos.IOrderDAO; import org.libreplan.business.orders.entities.HoursGroup; import org.libreplan.business.orders.entities.Order; import org.libreplan.business.orders.entities.Order.SchedulingMode; @@ -217,6 +222,9 @@ public class OrderCRUDController extends GenericForwardComposer { private ProjectDetailsController projectDetailsController; + @Autowired + private IOrderDAO orderDAO; + @Override public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); @@ -1473,4 +1481,30 @@ public class OrderCRUDController extends GenericForwardComposer { } } + public void chekValidProjectName(Textbox textbox) { + try { + Order found = orderDAO.findByNameAnotherTransaction(textbox + .getValue()); + if ((found != null) && (!found.getId().equals(getOrder().getId()))) { + throw new WrongValueException(textbox, + _("project name already being used")); + } + } catch (InstanceNotFoundException e) { + return; + } + } + + public void chekValidProjectCode(Textbox textbox) { + try { + Order found = orderDAO.findByCodeAnotherTransaction(textbox + .getValue()); + if ((found != null) && (!found.getId().equals(getOrder().getId()))) { + throw new WrongValueException(textbox, + _("code already being used")); + } + } catch (InstanceNotFoundException e) { + return; + } + } + } diff --git a/libreplan-webapp/src/main/webapp/orders/_edition.zul b/libreplan-webapp/src/main/webapp/orders/_edition.zul index 8519608da..c8c2dabc3 100644 --- a/libreplan-webapp/src/main/webapp/orders/_edition.zul +++ b/libreplan-webapp/src/main/webapp/orders/_edition.zul @@ -70,13 +70,17 @@