From fbdaf8f31fdea51f9ccbfa647729a040fda0228f Mon Sep 17 00:00:00 2001 From: Vova Perebykivskyi Date: Tue, 21 Jun 2016 16:14:09 +0300 Subject: [PATCH] Add start/end date constraints. Update NEWS file. Resolve minor errors. --- NEWS.rst | 38 ++++++++++++ .../src/main/resources/db.changelog-1.4.xml | 5 +- .../business/common/entities/Limits.hbm.xml | 4 +- .../orders/DetailsOrderElementController.java | 59 +++++++++++++++--- .../web/orders/ProjectDetailsController.java | 62 ++++++++++--------- .../src/main/resources/i18n/keys.pot | 7 ++- .../webapp/orders/_orderElementDetails.zul | 6 +- 7 files changed, 136 insertions(+), 45 deletions(-) diff --git a/NEWS.rst b/NEWS.rst index 8896311bb..76d23a74e 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -93,6 +93,44 @@ Changes * Code refactoring +Version 1.5.0 (? 2016) +--------------------------- + +Summary +~~~~~~~ + +* Bug fixing +* Email notification feature +* Risk and Issue Log feature +* Documents feature +* Global Dashboard feature + +Contributors +~~~~~~~~~~~~ + +Thanks to all the contributors to this new version: + +* Jeroen Baten +* Vova Perebykivkyi +* Bodgan Bodnarjuk +* Misha Gozda + +Changes +~~~~~~~ + +* Add Email notification feature (notification + template) +* Add new strings to i18n +* Add Risk&Issue Log feature +* Add Documents uploading/downloading feature +* Add test for documents feature +* Changes to LibrePlan version check +* Add Global Dashboard page + +* Update MPXJ library + +* Code refactoring + + Version 1.4.2 (2015) --------------------------- diff --git a/libreplan-business/src/main/resources/db.changelog-1.4.xml b/libreplan-business/src/main/resources/db.changelog-1.4.xml index 1ee33aa9b..160694554 100644 --- a/libreplan-business/src/main/resources/db.changelog-1.4.xml +++ b/libreplan-business/src/main/resources/db.changelog-1.4.xml @@ -24,8 +24,7 @@ - + @@ -43,7 +42,7 @@ - + diff --git a/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Limits.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Limits.hbm.xml index 051a069d5..4511d7715 100644 --- a/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Limits.hbm.xml +++ b/libreplan-business/src/main/resources/org/libreplan/business/common/entities/Limits.hbm.xml @@ -2,9 +2,9 @@ - + - + diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/orders/DetailsOrderElementController.java b/libreplan-webapp/src/main/java/org/libreplan/web/orders/DetailsOrderElementController.java index 07e5a3ca5..ac485c4b4 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/orders/DetailsOrderElementController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/orders/DetailsOrderElementController.java @@ -24,25 +24,33 @@ package org.libreplan.web.orders; import org.libreplan.business.orders.entities.OrderElement; import org.libreplan.web.common.Util; import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.WrongValueException; import org.zkoss.zk.ui.util.GenericForwardComposer; +import org.zkoss.zul.Constraint; import org.zkoss.zul.api.Datebox; +import java.util.Date; + +import static org.libreplan.web.I18nHelper._; + /** - * Controller for {@link OrderElement} details + * Controller for {@link OrderElement} details. * * @author Diego Pino García - * + * @author Vova Perebykivskyi */ -public class DetailsOrderElementController extends - GenericForwardComposer { +public class DetailsOrderElementController extends GenericForwardComposer { private IOrderElementModel orderElementModel; + private Datebox initDate; + private Datebox deadline; @Override public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); + // TODO resolve deprecated comp.setVariable("detailsController", this, true); } @@ -89,10 +97,45 @@ public class DetailsOrderElementController extends return true; } OrderElement orderElement = orderElementModel.getOrderElement(); - if (orderElement == null) { - return false; - } - return orderElement.isJiraIssue(); + + return orderElement != null && orderElement.isJiraIssue(); + } + + public Constraint checkConstraintStartDate() { + return new Constraint() { + @Override + public void validate(Component comp, Object value) throws WrongValueException { + Date startDate = (Date) value; + Date year2010 = new Date(1262296800000L); + + boolean startBefore2010 = (startDate != null) && startDate.before(year2010); + + if ( startBefore2010 ) { + initDate.setValue(null); + getOrderElement().setInitDate(null); + throw new WrongValueException(comp, _("Must be after 2010!")); + } + } + }; + } + + public Constraint checkConstraintFinishDate() { + return new Constraint() { + @Override + public void validate(Component comp, Object value) throws WrongValueException { + Date finishDate = (Date) value; + + boolean deadlineBeforeStart = (finishDate != null) && + (initDate.getValue() != null) && + (finishDate.compareTo(initDate.getValue()) < 0); + + if ( deadlineBeforeStart ) { + deadline.setValue(null); + getOrderElement().setDeadline(null); + throw new WrongValueException(comp, _("must be after starting date")); + } + } + }; } } \ No newline at end of file diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/orders/ProjectDetailsController.java b/libreplan-webapp/src/main/java/org/libreplan/web/orders/ProjectDetailsController.java index 844179e52..22174fc73 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/orders/ProjectDetailsController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/orders/ProjectDetailsController.java @@ -27,8 +27,6 @@ import java.util.Date; import java.util.HashMap; import java.util.List; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.joda.time.LocalDate; import org.libreplan.business.calendars.entities.BaseCalendar; import org.libreplan.business.externalcompanies.entities.ExternalCompany; @@ -38,7 +36,6 @@ import org.libreplan.business.templates.entities.OrderTemplate; import org.libreplan.web.common.ConstraintChecker; import org.libreplan.web.common.Util; import org.libreplan.web.common.components.bandboxsearch.BandboxSearch; -import org.libreplan.web.planner.consolidations.AdvanceConsolidationController; import org.libreplan.web.planner.tabs.MultipleTabsPlannerController; import org.springframework.beans.factory.annotation.Autowired; import org.zkoss.zk.ui.Component; @@ -56,17 +53,15 @@ import org.zkoss.zul.Textbox; import org.zkoss.zul.Window; /** - * Controller for the creation of an {@link order} with its principal - * properties. + * Controller for the creation of an {@link Order} with its principal properties. * * @author Susana Montes Pedreira * @author Lorenzo Tilve Álvaro + * @author Vova Perebykivskyi */ public class ProjectDetailsController extends GenericForwardComposer { - private static final Log LOG = LogFactory.getLog(AdvanceConsolidationController.class); - private OrderCRUDController orderController; private Grid gridProjectDetails; @@ -96,8 +91,8 @@ public class ProjectDetailsController extends GenericForwardComposer { public ProjectDetailsController() { - Window window = (Window) Executions.createComponents("/orders/_projectDetails.zul", null, - new HashMap()); + Window window = (Window) + Executions.createComponents("/orders/_projectDetails.zul", null, new HashMap()); try { doAfterCompose(window); } catch (Exception e) { @@ -109,6 +104,7 @@ public class ProjectDetailsController extends GenericForwardComposer { public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); window = (Window) comp; + // TODO resolve deprecated window.setVariable("projectController", this, true); } @@ -122,9 +118,7 @@ public class ProjectDetailsController extends GenericForwardComposer { Util.createBindingsFor(gridProjectDetails); Util.reloadBindings(gridProjectDetails); window.doModal(); - } catch (SuspendNotAllowedException e) { - throw new RuntimeException(e); - } catch (InterruptedException e) { + } catch (SuspendNotAllowedException | InterruptedException e) { throw new RuntimeException(e); } } @@ -170,8 +164,7 @@ public class ProjectDetailsController extends GenericForwardComposer { } private void showWrongName() { - throw new WrongValueException(txtName, - _("project name already being used")); + throw new WrongValueException(txtName, _("project name already being used")); } private void close() { @@ -210,8 +203,8 @@ public class ProjectDetailsController extends GenericForwardComposer { private void clearProperties() { Order order = orderController.getOrder(); order.setName(null); - // reset the code autogenerated property - if (isCodeAutogeneratedInit) { + /* Reset the code autogenerated property */ + if ( isCodeAutogeneratedInit ) { order.setCodeAutogenerated(true); } else { @@ -227,15 +220,17 @@ public class ProjectDetailsController extends GenericForwardComposer { public Constraint checkConstraintFinishDate() { return new Constraint() { @Override - public void validate(Component comp, Object value) - throws WrongValueException { + public void validate(Component comp, Object value) throws WrongValueException { Date finishDate = (Date) value; - if ((finishDate != null) && (initDate.getValue() != null) - && (finishDate.compareTo(initDate.getValue()) < 0)) { + + boolean deadlineBeforeStart = (finishDate != null) && + (initDate.getValue() != null) && + (finishDate.compareTo(initDate.getValue()) < 0); + + if ( deadlineBeforeStart ) { deadline.setValue(null); getOrder().setDeadline(null); - throw new WrongValueException(comp, - _("must be after start date")); + throw new WrongValueException(comp, _("must be after start date")); } } }; @@ -244,15 +239,26 @@ public class ProjectDetailsController extends GenericForwardComposer { public Constraint checkConstraintStartDate() { return new Constraint() { @Override - public void validate(Component comp, Object value) - throws WrongValueException { + public void validate(Component comp, Object value) throws WrongValueException { Date startDate = (Date) value; - if ((startDate != null) && (deadline.getValue() != null) - && (startDate.compareTo(deadline.getValue()) > 0)) { + + boolean startAfterDeadline = (startDate != null) && + (deadline.getValue() != null) && + (startDate.compareTo(deadline.getValue()) > 0); + + if ( startAfterDeadline ) { initDate.setValue(null); getOrder().setInitDate(null); - throw new WrongValueException(comp, - _("must be lower than end date")); + throw new WrongValueException(comp, _("must be lower than end date")); + } + + Date year2010 = new Date(1262296800000L); + boolean startBefore2010 = (startDate != null) && startDate.before(year2010); + + if ( startBefore2010 ) { + initDate.setValue(null); + getOrder().setInitDate(null); + throw new WrongValueException(comp, _("Must be after 2010!")); } } }; diff --git a/libreplan-webapp/src/main/resources/i18n/keys.pot b/libreplan-webapp/src/main/resources/i18n/keys.pot index 5ff1fbcb8..4f984ebee 100644 --- a/libreplan-webapp/src/main/resources/i18n/keys.pot +++ b/libreplan-webapp/src/main/resources/i18n/keys.pot @@ -9411,8 +9411,11 @@ msgstr "" msgid "Email: timesheet data missing" msgstr "" - - #: libreplan-webapp/src/main/java/org/libreplan/web/planner/taskedition/TaskPropertiesController.java:804 msgid "You cannot email user twice with the same info" +msgstr "" + +#: libreplan-webapp/src/main/java/org/libreplan/web/orders/ProjectDetailsController.java:266 +#: libreplan-webapp/src/main/java/org/libreplan/web/orders/DetailsOrderElement.java:110 +msgid "Must be after 2010!" msgstr "" \ No newline at end of file diff --git a/libreplan-webapp/src/main/webapp/orders/_orderElementDetails.zul b/libreplan-webapp/src/main/webapp/orders/_orderElementDetails.zul index b575ab383..61d966636 100644 --- a/libreplan-webapp/src/main/webapp/orders/_orderElementDetails.zul +++ b/libreplan-webapp/src/main/webapp/orders/_orderElementDetails.zul @@ -45,14 +45,16 @@