From acbb41cddfa3f89a7613866f67e1e8111233885d Mon Sep 17 00:00:00 2001 From: Vova Perebykivskyi Date: Wed, 9 Nov 2016 18:03:47 +0200 Subject: [PATCH 1/4] Changes to EmailSending feature. Code refactoring. --- .../business/common/daos/ILimitsDAO.java | 2 +- .../business/common/daos/LimitsDAO.java | 16 ++++-- .../business/common/entities/Limits.java | 4 +- .../email/daos/EmailNotificationDAO.java | 10 ++-- .../business/email/daos/EmailTemplateDAO.java | 7 ++- .../email/daos/IEmailNotificationDAO.java | 2 +- .../email/daos/IEmailTemplateDAO.java | 2 +- .../email/entities/EmailNotification.java | 7 ++- .../email/entities/EmailTemplate.java | 6 +- .../email/entities/EmailTemplateEnum.java | 4 +- .../business/orders/daos/IOrderFileDAO.java | 2 +- .../business/orders/daos/OrderFileDAO.java | 7 ++- .../business/orders/entities/OrderFile.java | 4 +- .../resources/daos/IResourcesSearcher.java | 56 +++++++++---------- .../notifications/IEmailNotificationJob.java | 2 +- .../jobs/SendEmailOnMilestoneReachedJob.java | 4 +- ...SendEmailOnResourceRemovedFromTaskJob.java | 4 +- .../SendEmailOnTaskAssignedToResourceJob.java | 2 +- .../jobs/SendEmailOnTaskShouldFinishJob.java | 2 +- .../jobs/SendEmailOnTaskShouldStartJob.java | 2 +- .../SendEmailOnTimesheetDataMissingJob.java | 2 +- .../SendEmailOnMilestoneReached.java | 11 ++-- .../SendEmailOnResourceRemovedFromTask.java | 8 ++- .../SendEmailOnTaskAssignedToResource.java | 2 +- .../SendEmailOnTaskShouldFinish.java | 2 + .../SendEmailOnTimesheetDataMissing.java | 13 +++-- .../web/email/EmailTemplateController.java | 25 ++------- .../web/email/EmailTemplateModel.java | 3 +- .../web/email/IEmailTemplateModel.java | 2 +- .../web/orders/files/OrderFileModel.java | 3 +- .../orders/files/OrderFilesController.java | 35 ++++++++---- ...ibreplan-webapp-spring-security-config.xml | 2 +- .../libreplan/web/orders/OrderFilesTest.java | 2 +- 33 files changed, 144 insertions(+), 111 deletions(-) diff --git a/libreplan-business/src/main/java/org/libreplan/business/common/daos/ILimitsDAO.java b/libreplan-business/src/main/java/org/libreplan/business/common/daos/ILimitsDAO.java index ebb039636..e3e27eb62 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/common/daos/ILimitsDAO.java +++ b/libreplan-business/src/main/java/org/libreplan/business/common/daos/ILimitsDAO.java @@ -27,7 +27,7 @@ import java.util.List; * DAO interface for the Limits entity. * Contract for {@link LimitsDAO}. * - * @author Created by Vova Perebykivskyi on 17.12.2015. + * @author Vova Perebykivskyi */ public interface ILimitsDAO extends IGenericDAO { diff --git a/libreplan-business/src/main/java/org/libreplan/business/common/daos/LimitsDAO.java b/libreplan-business/src/main/java/org/libreplan/business/common/daos/LimitsDAO.java index 484dc8669..80fd3bb45 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/common/daos/LimitsDAO.java +++ b/libreplan-business/src/main/java/org/libreplan/business/common/daos/LimitsDAO.java @@ -27,7 +27,7 @@ import java.util.List; /** * DAO for {@link Limits}. * - * @author Created by Vova Perebykivskyi on 24.09.2015. + * @author Vova Perebykivskyi */ @Repository @@ -41,16 +41,22 @@ public class LimitsDAO extends GenericDAOHibernate implements ILim @Override public Limits getUsersType() { List list = list(Limits.class); - for (Limits item : list) - if (item.getType().equals("users")) return item; + for (Limits item : list) { + if ("users".equals(item.getType())) { + return item; + } + } return null; } @Override public Limits getResourcesType() { List list = list(Limits.class); - for (Limits item : list) - if (item.getType().equals("workers+machines")) return item; + for (Limits item : list) { + if ("workers+machines".equals(item.getType())) { + return item; + } + } return null; } } diff --git a/libreplan-business/src/main/java/org/libreplan/business/common/entities/Limits.java b/libreplan-business/src/main/java/org/libreplan/business/common/entities/Limits.java index 3b76e2cac..0367a72c6 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/common/entities/Limits.java +++ b/libreplan-business/src/main/java/org/libreplan/business/common/entities/Limits.java @@ -26,7 +26,7 @@ import org.libreplan.business.common.BaseEntity; * This class is intended to work as a Hibernate component. * It represents the limit that can be modified only in database. * - * @author Created by Vova Perebykivskyi on 17.12.2015. + * @author Vova Perebykivskyi */ public class Limits extends BaseEntity { @@ -38,6 +38,7 @@ public class Limits extends BaseEntity { public String getType() { return type; } + public void setType(String type) { this.type = type; } @@ -45,6 +46,7 @@ public class Limits extends BaseEntity { public Integer getValue() { return value; } + public void setValue(Integer value) { this.value = value; } diff --git a/libreplan-business/src/main/java/org/libreplan/business/email/daos/EmailNotificationDAO.java b/libreplan-business/src/main/java/org/libreplan/business/email/daos/EmailNotificationDAO.java index 40d154307..109ef16bb 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/email/daos/EmailNotificationDAO.java +++ b/libreplan-business/src/main/java/org/libreplan/business/email/daos/EmailNotificationDAO.java @@ -28,9 +28,9 @@ import org.springframework.stereotype.Repository; import java.util.List; /** - * Dao for {@link EmailNotification} + * DAO for {@link EmailNotification}. * - * @author Created by Vova Perebykivskyi on 19.10.2015. + * @author Vova Perebykivskyi */ @Repository public class EmailNotificationDAO @@ -54,11 +54,11 @@ public class EmailNotificationDAO public boolean deleteAll() { List notifications = list(EmailNotification.class); - for (Object item : notifications){ + for (Object item : notifications) { getSession().delete(item); } - return list(EmailNotification.class).size() == 0; + return list(EmailNotification.class).isEmpty(); } @Override @@ -76,7 +76,7 @@ public class EmailNotificationDAO .createCriteria(EmailNotification.class) .add(Restrictions.eq("type", enumeration.ordinal())) .list() - .size() == 0; + .isEmpty(); } @Override diff --git a/libreplan-business/src/main/java/org/libreplan/business/email/daos/EmailTemplateDAO.java b/libreplan-business/src/main/java/org/libreplan/business/email/daos/EmailTemplateDAO.java index 976d31444..d0cdd0887 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/email/daos/EmailTemplateDAO.java +++ b/libreplan-business/src/main/java/org/libreplan/business/email/daos/EmailTemplateDAO.java @@ -33,10 +33,10 @@ import java.util.List; /** * DAO for {@link EmailTemplate} * - * @author Created by Vova Perebykivskyi on 24.09.2015. + * @author Vova Perebykivskyi */ @Repository -public class EmailTemplateDAO extends GenericDAOHibernate implements IEmailTemplateDAO{ +public class EmailTemplateDAO extends GenericDAOHibernate implements IEmailTemplateDAO { @Override @Transactional(readOnly = true) @@ -68,6 +68,7 @@ public class EmailTemplateDAO extends GenericDAOHibernate i public void delete(EmailTemplate entity) { try { remove(entity.getId()); - } catch (InstanceNotFoundException ignored) {} + } catch (InstanceNotFoundException ignored) { + } } } diff --git a/libreplan-business/src/main/java/org/libreplan/business/email/daos/IEmailNotificationDAO.java b/libreplan-business/src/main/java/org/libreplan/business/email/daos/IEmailNotificationDAO.java index 9cc28dc5a..92a32c886 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/email/daos/IEmailNotificationDAO.java +++ b/libreplan-business/src/main/java/org/libreplan/business/email/daos/IEmailNotificationDAO.java @@ -28,7 +28,7 @@ import java.util.List; /** * Contract for {@link EmailNotificationDAO} * - * @author Created by Vova Perebykivskyi on 19.10.2015. + * @author Vova Perebykivskyi */ public interface IEmailNotificationDAO extends IGenericDAO { diff --git a/libreplan-business/src/main/java/org/libreplan/business/email/daos/IEmailTemplateDAO.java b/libreplan-business/src/main/java/org/libreplan/business/email/daos/IEmailTemplateDAO.java index 953111007..0a2c239de 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/email/daos/IEmailTemplateDAO.java +++ b/libreplan-business/src/main/java/org/libreplan/business/email/daos/IEmailTemplateDAO.java @@ -30,7 +30,7 @@ import java.util.List; * DAO interface for the EmailTemplate entity. * Contract for {@link EmailTemplateDAO}. * - * @author Created by Vova Perebykivskyi on 29.09.2015. + * @author Vova Perebykivskyi */ public interface IEmailTemplateDAO extends IGenericDAO{ diff --git a/libreplan-business/src/main/java/org/libreplan/business/email/entities/EmailNotification.java b/libreplan-business/src/main/java/org/libreplan/business/email/entities/EmailNotification.java index f17415cca..bdce3f013 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/email/entities/EmailNotification.java +++ b/libreplan-business/src/main/java/org/libreplan/business/email/entities/EmailNotification.java @@ -31,7 +31,7 @@ import java.util.Date; * This class is intended to work as a Hibernate component. * It represents the Email notification to be send to user. * - * @author Created by Vova Perebykivskyi on 19.10.2015. + * @author Vova Perebykivskyi */ public class EmailNotification extends BaseEntity { @@ -49,6 +49,7 @@ public class EmailNotification extends BaseEntity { public EmailTemplateEnum getType() { return type; } + public void setType(EmailTemplateEnum type) { this.type = type; } @@ -56,6 +57,7 @@ public class EmailNotification extends BaseEntity { public Date getUpdated() { return updated; } + public void setUpdated(Date updated) { this.updated = updated; } @@ -63,6 +65,7 @@ public class EmailNotification extends BaseEntity { public Resource getResource() { return resource; } + public void setResource(Resource resource) { this.resource = resource; } @@ -70,6 +73,7 @@ public class EmailNotification extends BaseEntity { public TaskElement getTask() { return task; } + public void setTask(TaskElement task) { this.task = task; } @@ -77,6 +81,7 @@ public class EmailNotification extends BaseEntity { public TaskElement getProject() { return project; } + public void setProject(TaskElement project) { this.project = project; } diff --git a/libreplan-business/src/main/java/org/libreplan/business/email/entities/EmailTemplate.java b/libreplan-business/src/main/java/org/libreplan/business/email/entities/EmailTemplate.java index 68905c002..1315ed989 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/email/entities/EmailTemplate.java +++ b/libreplan-business/src/main/java/org/libreplan/business/email/entities/EmailTemplate.java @@ -27,7 +27,7 @@ import org.libreplan.business.settings.entities.Language; * This class is intended to work as a Hibernate component. * It represents the E-mail template to be modified by admin and send to user. * - * @author Created by Vova Perebykivskyi on 29.09.2015. + * @author Vova Perebykivskyi */ public class EmailTemplate extends BaseEntity { @@ -42,6 +42,7 @@ public class EmailTemplate extends BaseEntity { public EmailTemplateEnum getType() { return type; } + public void setType(EmailTemplateEnum type) { this.type = type; } @@ -49,6 +50,7 @@ public class EmailTemplate extends BaseEntity { public Language getLanguage() { return language; } + public void setLanguage(Language language) { this.language = language; } @@ -56,6 +58,7 @@ public class EmailTemplate extends BaseEntity { public String getContent() { return content != null ? content : ""; } + public void setContent(String content) { this.content = content; } @@ -63,6 +66,7 @@ public class EmailTemplate extends BaseEntity { public String getSubject() { return subject != null ? subject : ""; } + public void setSubject(String subject) { this.subject = subject; } diff --git a/libreplan-business/src/main/java/org/libreplan/business/email/entities/EmailTemplateEnum.java b/libreplan-business/src/main/java/org/libreplan/business/email/entities/EmailTemplateEnum.java index 9cd69bdb5..60da21c66 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/email/entities/EmailTemplateEnum.java +++ b/libreplan-business/src/main/java/org/libreplan/business/email/entities/EmailTemplateEnum.java @@ -24,10 +24,10 @@ import static org.libreplan.business.i18n.I18nHelper._; /** * Available E-mail templates. * - * @author Created by Vova Perebykivskyi on 28.09.2015. - * * TEMPLATE_N(_("Template N")) - for i18n * TEMPLATE_A("Template A") - for general use (no internationalizing) + * + * @author Vova Perebykivskyi */ public enum EmailTemplateEnum { diff --git a/libreplan-business/src/main/java/org/libreplan/business/orders/daos/IOrderFileDAO.java b/libreplan-business/src/main/java/org/libreplan/business/orders/daos/IOrderFileDAO.java index 0b60df2da..cd6bff4e2 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/orders/daos/IOrderFileDAO.java +++ b/libreplan-business/src/main/java/org/libreplan/business/orders/daos/IOrderFileDAO.java @@ -26,7 +26,7 @@ import org.libreplan.business.orders.entities.OrderFile; import java.util.List; /** - * @author Created by Vova Perebykivskyi on 12.24.2015. + * @author Vova Perebykivskyi */ public interface IOrderFileDAO extends IGenericDAO { diff --git a/libreplan-business/src/main/java/org/libreplan/business/orders/daos/OrderFileDAO.java b/libreplan-business/src/main/java/org/libreplan/business/orders/daos/OrderFileDAO.java index a0bc8bdb0..99b4ab9c5 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/orders/daos/OrderFileDAO.java +++ b/libreplan-business/src/main/java/org/libreplan/business/orders/daos/OrderFileDAO.java @@ -29,7 +29,9 @@ import org.springframework.stereotype.Repository; import java.util.List; /** - * @author Created by Vova Perebykivskyi on 12.24.2015. + * DAO for {@link OrderFile}. + * + * @author Vova Perebykivskyi */ @Repository @@ -44,7 +46,8 @@ public class OrderFileDAO extends GenericDAOHibernate implement public void delete(OrderFile file) { try { remove(file.getId()); - } catch (InstanceNotFoundException ignored) {} + } catch (InstanceNotFoundException ignored) { + } } @Override diff --git a/libreplan-business/src/main/java/org/libreplan/business/orders/entities/OrderFile.java b/libreplan-business/src/main/java/org/libreplan/business/orders/entities/OrderFile.java index efa3b3bae..aacae5c3e 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/orders/entities/OrderFile.java +++ b/libreplan-business/src/main/java/org/libreplan/business/orders/entities/OrderFile.java @@ -27,9 +27,9 @@ import java.util.Date; /** * OrderFile entity representing table: files. * This class is intended to work as a Hibernate component. - * It represents the LibrePlan File to be stored in customer`s HDD. + * It represents the LibrePlan File to be stored in customer`s data storage. * - * @author Created by Vova Perebykivskyi on 25.12.2015. + * @author Vova Perebykivskyi */ public class OrderFile extends BaseEntity { diff --git a/libreplan-business/src/main/java/org/libreplan/business/resources/daos/IResourcesSearcher.java b/libreplan-business/src/main/java/org/libreplan/business/resources/daos/IResourcesSearcher.java index eea7d0ac8..536e3fd11 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/resources/daos/IResourcesSearcher.java +++ b/libreplan-business/src/main/java/org/libreplan/business/resources/daos/IResourcesSearcher.java @@ -35,17 +35,17 @@ import org.libreplan.business.resources.entities.ResourceType; import org.libreplan.business.resources.entities.Worker; /** - * Conversation for worker search + * Conversation for worker search. * * @author Diego Pino Garcia */ public interface IResourcesSearcher { - public interface IResourcesQuery { + interface IResourcesQuery { /** - * Restrict the result to resources that have name as a substring. The - * match is case insensitive. + * Restrict the result to resources that have name as a substring. + * The match is case insensitive. * * @param name * @return this same object in order to cascade calls @@ -53,8 +53,7 @@ public interface IResourcesSearcher { IResourcesQuery byName(String name); /** - * Restrict the result to a list of {@link Resource} satisfying all - * criteria at some point in time + * Restrict the result to a list of {@link Resource} satisfying all criteria at some point in time. * * @param criteria * @return this same object in order to cascade calls @@ -62,9 +61,9 @@ public interface IResourcesSearcher { IResourcesQuery byCriteria(Collection criteria); /** - * Restrict resources to the ones having the provided type. By default - * if this method is not called, the resources are restricted to the - * type NON_LIMITING_RESOURCE. + * Restrict resources to the ones having the provided type. + * By default if this method is not called, the resources are restricted to the type NON_LIMITING_RESOURCE. + * * @param type * @return this same object in order to cascade calls */ @@ -73,48 +72,49 @@ public interface IResourcesSearcher { /** * Retrieve the list of resources that match the restrictions specified. * - * @return + * @return {@link List} */ List execute(); /** *

- * Gets all {@link Criterion} and groups then by {@link CriterionType} - * with the condition that the {@link CriterionType#getResource()} is of - * a type compatible for this query. + * Gets all {@link Criterion} and groups then by {@link CriterionType} with the condition + * that the {@link CriterionType#getResource()} is of a type compatible for this query. + * For example if this query has been created by {@link IResourcesSearcher#searchWorkers()} + * only the criteria with criterion type such its resource is {@link ResourceEnum#WORKER}. *

- * For example if this query has been created by - * {@link IResourcesSearcher#searchWorkers()} only the criteria with - * criterion type such its resource is {@link ResourceEnum.WORKER} + * * @return HashMap> */ Map> getCriteria(); } /** - * Do the search limited to workers + * Do the search limited to workers. * - * @return + * @return {@link IResourcesQuery} */ - public IResourcesQuery searchWorkers(); + IResourcesQuery searchWorkers(); /** - * Do the search limited to machines - * @return + * Do the search limited to machines. + * @return {@link IResourcesQuery} */ - public IResourcesQuery searchMachines(); + IResourcesQuery searchMachines(); /** - * Search machines or workers based on the value of resourceType + * Search machines or workers based on the value of resourceType. + * * @param resourceType - * @return + * @return {@link IResourcesQuery} */ - public IResourcesQuery searchBy(ResourceEnum resourceType); + IResourcesQuery searchBy(ResourceEnum resourceType); /** - * Search both resources and machines - * @return + * Search both resources and machines. + * + * @return {@link IResourcesQuery} */ - public IResourcesQuery searchBoth(); + IResourcesQuery searchBoth(); } diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/IEmailNotificationJob.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/IEmailNotificationJob.java index 9adfdf9fd..de96b3d7e 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/IEmailNotificationJob.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/IEmailNotificationJob.java @@ -24,7 +24,7 @@ import org.libreplan.business.email.entities.EmailNotification; /** * Sends E-mail to users with data that storing in notification_queue table. * - * @author Created by Vova Perebykivskyi on 13.10.2015. + * @author Vova Perebykivskyi */ public interface IEmailNotificationJob { diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnMilestoneReachedJob.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnMilestoneReachedJob.java index f5012ac30..eb585e3a5 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnMilestoneReachedJob.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnMilestoneReachedJob.java @@ -30,7 +30,9 @@ import org.springframework.scheduling.quartz.QuartzJobBean; * Sends E-mail to users with data that storing in notification_queue table * and that are treat to {@link org.libreplan.business.email.entities.EmailTemplateEnum#TEMPLATE_MILESTONE_REACHED} * - * @author Created by Vova Perebykivskyi on 20.01.2016. + * It is used! + * + * @author Vova Perebykivskyi */ public class SendEmailOnMilestoneReachedJob extends QuartzJobBean { diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnResourceRemovedFromTaskJob.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnResourceRemovedFromTaskJob.java index 4343c0d02..521801a36 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnResourceRemovedFromTaskJob.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnResourceRemovedFromTaskJob.java @@ -29,7 +29,9 @@ import org.springframework.scheduling.quartz.QuartzJobBean; * Sends E-mail to users with data that storing in notification_queue table and that are treat to * {@link org.libreplan.business.email.entities.EmailTemplateEnum#TEMPLATE_RESOURCE_REMOVED_FROM_TASK}. * - * @author Created by Vova Perebykivskyi on 20.01.2016. + * It is used! + * + * @author Vova Perebykivskyi */ public class SendEmailOnResourceRemovedFromTaskJob extends QuartzJobBean { diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskAssignedToResourceJob.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskAssignedToResourceJob.java index 5f7a417cd..2da2faec1 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskAssignedToResourceJob.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskAssignedToResourceJob.java @@ -30,7 +30,7 @@ import org.springframework.scheduling.quartz.QuartzJobBean; * Sends E-mail to users with data that storing in notification_queue table and that are treat to * {@link org.libreplan.business.email.entities.EmailTemplateEnum#TEMPLATE_TASK_ASSIGNED_TO_RESOURCE}. * - * @author Created by Vova Perebykivskyi on 13.10.2015. + * @author Vova Perebykivskyi */ public class SendEmailOnTaskAssignedToResourceJob extends QuartzJobBean { diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskShouldFinishJob.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskShouldFinishJob.java index e0d808d0a..279bb2046 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskShouldFinishJob.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskShouldFinishJob.java @@ -29,7 +29,7 @@ import org.springframework.scheduling.quartz.QuartzJobBean; * Sends E-mail to users with data that storing in notification_queue table and that are treat to * {@link org.libreplan.business.email.entities.EmailTemplateEnum#TEMPLATE_TODAY_TASK_SHOULD_FINISH}. * - * @author Created by Vova Perebykivskyi on 20.01.2016. + * @author Vova Perebykivskyi */ public class SendEmailOnTaskShouldFinishJob extends QuartzJobBean { diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskShouldStartJob.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskShouldStartJob.java index 34743d3a9..1c6e54994 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskShouldStartJob.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskShouldStartJob.java @@ -30,7 +30,7 @@ import org.springframework.scheduling.quartz.QuartzJobBean; * {@link org.libreplan.business.email.entities.EmailTemplateEnum#TEMPLATE_TODAY_TASK_SHOULD_START}. * * - * @author Created by Vova Perebykivskyi on 20.01.2016 + * @author Vova Perebykivskyi */ public class SendEmailOnTaskShouldStartJob extends QuartzJobBean { diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTimesheetDataMissingJob.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTimesheetDataMissingJob.java index 279f46971..066aed022 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTimesheetDataMissingJob.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTimesheetDataMissingJob.java @@ -29,7 +29,7 @@ import org.springframework.scheduling.quartz.QuartzJobBean; * Sends E-mail to users with data that storing in notification_queue table and that are treat to * {@link org.libreplan.business.email.entities.EmailTemplateEnum#TEMPLATE_ENTER_DATA_IN_TIMESHEET}. * - * @author Created by Vova Perebykivskyi on 20.01.2016. + * @author Vova Perebykivskyi */ public class SendEmailOnTimesheetDataMissingJob extends QuartzJobBean { diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnMilestoneReached.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnMilestoneReached.java index 51185efc6..7b25ed197 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnMilestoneReached.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnMilestoneReached.java @@ -50,7 +50,7 @@ import java.util.List; * Date will be send on current date equals to deadline date of {@link org.zkoss.ganttz.data.Milestone}. * But it will be only send to Manager (you can assign him in project properties). * - * @author Created by Vova Perebykivskyi on 20.01.2016. + * @author Vova Perebykivskyi */ @Component @@ -118,7 +118,10 @@ public class SendEmailOnMilestoneReached implements IEmailNotificationJob { e.printStackTrace(); } - if ( user.getWorker() != null && user.isInRole(UserRole.ROLE_EMAIL_MILESTONE_REACHED) ) { + boolean userHasNeededRoles = + user.isInRole(UserRole.ROLE_SUPERUSER) || user.isInRole(UserRole.ROLE_EMAIL_MILESTONE_REACHED); + + if ( user.getWorker() != null && userHasNeededRoles ) { emailNotificationModel.setResource(user.getWorker()); emailNotificationModel.setTask(item); emailNotificationModel.setProject(item.getParent()); @@ -127,14 +130,14 @@ public class SendEmailOnMilestoneReached implements IEmailNotificationJob { } public void checkMilestoneDate() { - List list = taskElementDAO.getTaskElementsWithMilestones(); + List milestones = taskElementDAO.getTaskElementsWithMilestones(); LocalDate date = new LocalDate(); int currentYear = date.getYear(); int currentMonth = date.getMonthOfYear(); int currentDay = date.getDayOfMonth(); - for (TaskElement item : list) { + for (TaskElement item : milestones) { if ( item.getDeadline() != null ) { LocalDate deadline = item.getDeadline(); diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnResourceRemovedFromTask.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnResourceRemovedFromTask.java index 5ca5f3ef9..1294e3ffb 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnResourceRemovedFromTask.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnResourceRemovedFromTask.java @@ -39,7 +39,7 @@ import java.util.List; * and that are treat to {@link EmailTemplateEnum#TEMPLATE_RESOURCE_REMOVED_FROM_TASK}. * Data will be send if resource has been removed from task (in resource allocation) * - * @author Created by Vova Perebykivskyi on 20.01.2016. + * @author Vova Perebykivskyi */ @Component @@ -65,9 +65,11 @@ public class SendEmailOnResourceRemovedFromTask implements IEmailNotificationJob List notifications = emailNotificationModel.getAllByType(EmailTemplateEnum.TEMPLATE_RESOURCE_REMOVED_FROM_TASK); - for (int i = 0; i < notifications.size(); i++) - if ( composeMessageForUser(notifications.get(i)) ) + for (int i = 0; i < notifications.size(); i++) { + if ( composeMessageForUser(notifications.get(i)) ) { deleteSingleNotification(notifications.get(i)); + } + } } } } diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnTaskAssignedToResource.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnTaskAssignedToResource.java index 7e8822cd2..0de010679 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnTaskAssignedToResource.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnTaskAssignedToResource.java @@ -41,7 +41,7 @@ import java.util.List; * and that are treat to {@link EmailTemplateEnum#TEMPLATE_ENTER_DATA_IN_TIMESHEET}. * Data will be send after user will be assigned to some task. * - * @author Created by Vova Perebykivskyi on 13.10.2015. + * @author Vova Perebykivskyi */ @Component @Scope(BeanDefinition.SCOPE_PROTOTYPE) diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnTaskShouldFinish.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnTaskShouldFinish.java index a914c859b..d2ba3a257 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnTaskShouldFinish.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnTaskShouldFinish.java @@ -98,6 +98,7 @@ public class SendEmailOnTaskShouldFinish implements IEmailNotificationJob { @Transactional public void taskShouldFinish() { // TODO resolve deprecated + // Check if current date equals with item date Date date = new Date(); int currentYear = date.getYear(); @@ -114,6 +115,7 @@ public class SendEmailOnTaskShouldFinish implements IEmailNotificationJob { if ( currentYear == endYear && currentMonth == endMonth && currentDay == endDay ) { + // Get all resources for current task and send them email notification sendEmailNotificationAboutTaskShouldFinish(item); } diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnTimesheetDataMissing.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnTimesheetDataMissing.java index 1768eec32..f2cfa0e44 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnTimesheetDataMissing.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnTimesheetDataMissing.java @@ -63,7 +63,7 @@ import java.util.List; * and that are treat to {@link EmailTemplateEnum#TEMPLATE_ENTER_DATA_IN_TIMESHEET} * Data will be send for bound users with empty timesheet lines. * - * @author Created by Vova Perebykivskyi on 20.01.2016. + * @author Vova Perebykivskyi */ @Component @@ -99,9 +99,11 @@ public class SendEmailOnTimesheetDataMissing implements IEmailNotificationJob { List notifications = emailNotificationModel.getAllByType(EmailTemplateEnum.TEMPLATE_ENTER_DATA_IN_TIMESHEET); - for (int i = 0; i < notifications.size(); i++) - if ( composeMessageForUser(notifications.get(i)) ) + for (int i = 0; i < notifications.size(); i++) { + if ( composeMessageForUser(notifications.get(i)) ) { deleteSingleNotification(notifications.get(i)); + } + } } } } @@ -111,7 +113,7 @@ public class SendEmailOnTimesheetDataMissing implements IEmailNotificationJob { return composeMessage.composeMessageForUser(notification); } - private void deleteSingleNotification(EmailNotification notification){ + private void deleteSingleNotification(EmailNotification notification) { emailNotificationModel.deleteById(notification); } @@ -205,8 +207,7 @@ public class SendEmailOnTimesheetDataMissing implements IEmailNotificationJob { private PersonalTimesheetsPeriodicityEnum getPersonalTimesheetsPeriodicity() { return configurationDAO.getConfiguration().getPersonalTimesheetsPeriodicity(); } - private WorkReport getWorkReport(Resource resource, LocalDate date, - PersonalTimesheetsPeriodicityEnum periodicity) { + private WorkReport getWorkReport(Resource resource, LocalDate date, PersonalTimesheetsPeriodicityEnum periodicity) { WorkReport workReport = workReportDAO.getPersonalTimesheetWorkReport(resource, date, periodicity); forceLoad(workReport); diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailTemplateController.java b/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailTemplateController.java index c9b0cf5c2..d254bee70 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailTemplateController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailTemplateController.java @@ -19,18 +19,13 @@ package org.libreplan.web.email; -import org.libreplan.business.common.exceptions.InstanceNotFoundException; import org.libreplan.business.common.exceptions.ValidationException; import org.libreplan.business.settings.entities.Language; import org.libreplan.business.email.entities.EmailTemplateEnum; -import org.libreplan.business.users.daos.IUserDAO; -import org.libreplan.business.users.entities.User; import org.libreplan.web.common.IMessagesForUser; import org.libreplan.web.common.Level; import org.libreplan.web.common.MessagesForUser; -import org.libreplan.web.security.SecurityUtils; -import org.springframework.transaction.annotation.Transactional; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Executions; @@ -50,15 +45,11 @@ import static org.libreplan.web.I18nHelper._; /** * Controller for page Edit email templates. * - * @author Created by Vova Perebykivskyi on 25.09.2015. + * @author Vova Perebykivskyi */ public class EmailTemplateController extends GenericForwardComposer { - private IUserDAO userDAO; - - private User user; - private IEmailTemplateModel emailTemplateModel; private IMessagesForUser messages; @@ -77,8 +68,9 @@ public class EmailTemplateController extends GenericForwardComposer { public EmailTemplateController() { - userDAO = (IUserDAO) SpringUtil.getBean("userDAO"); - emailTemplateModel = (IEmailTemplateModel) SpringUtil.getBean("emailTemplateModel"); + if ( emailTemplateModel == null ) { + emailTemplateModel = (IEmailTemplateModel) SpringUtil.getBean("emailTemplateModel"); + } } @Override @@ -91,7 +83,6 @@ public class EmailTemplateController extends GenericForwardComposer { * Set default template and language for user. * And content and subject for that language & template. */ - setUser(); setSelectedLanguage(Language.ENGLISH_LANGUAGE); getContentDataBySelectedLanguage(); @@ -226,12 +217,4 @@ public class EmailTemplateController extends GenericForwardComposer { subjectTextbox.setValue(emailTemplateModel.getSubject(getSelectedLanguage(), getSelectedEmailTemplateEnum())); } - @Transactional - private void setUser() { - try { - user = userDAO.findByLoginName(SecurityUtils.getSessionUserLoginName()); - } catch (InstanceNotFoundException e) { - throw new RuntimeException(e); - } - } } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailTemplateModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailTemplateModel.java index 87627f522..8cba28577 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailTemplateModel.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/email/EmailTemplateModel.java @@ -36,7 +36,7 @@ import java.util.List; /** * Model for operations related to {@link EmailTemplate}. * - * @author Created by Vova Perebykivskyi on 25.09.2015. + * @author Vova Perebykivskyi */ @Service @Scope(BeanDefinition.SCOPE_PROTOTYPE) @@ -142,6 +142,7 @@ public class EmailTemplateModel implements IEmailTemplateModel { return template != null ? template.getSubject() : ""; } + @Override public EmailTemplate getEmailTemplateByTypeAndLanguage(EmailTemplateEnum type, Language language) { return emailTemplateDAO.findByTypeAndLanguage(type, language); } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/email/IEmailTemplateModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/email/IEmailTemplateModel.java index 3c4f9b9b2..849d29f67 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/email/IEmailTemplateModel.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/email/IEmailTemplateModel.java @@ -28,7 +28,7 @@ import java.util.List; /** * Contract for {@link EmailTemplate}. * - * @author Created by Vova Perebykivskyi on 28.09.2015. + * @author Vova Perebykivskyi */ public interface IEmailTemplateModel { diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/orders/files/OrderFileModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/orders/files/OrderFileModel.java index 7e074bcfa..8f33afc5b 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/orders/files/OrderFileModel.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/orders/files/OrderFileModel.java @@ -14,7 +14,7 @@ import java.util.Date; import java.util.List; /** - * @author Created by Vova Perebykivskyi on 12.24.2015. + * @author Vova Perebykivskyi */ @Service @@ -80,6 +80,7 @@ public class OrderFileModel implements IOrderFileModel { return fileDAO.findByParent(parent); } + @Override public OrderFile getOrderFile() { return orderFile; } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/orders/files/OrderFilesController.java b/libreplan-webapp/src/main/java/org/libreplan/web/orders/files/OrderFilesController.java index 794b2f5ab..55416127b 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/orders/files/OrderFilesController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/orders/files/OrderFilesController.java @@ -62,7 +62,7 @@ import static org.libreplan.web.I18nHelper._; /** * Controller for managing Order files. * - * @author Created by Vova Perebykivskyi on 12.24.2015. + * @author Vova Perebykivskyi */ public class OrderFilesController extends GenericForwardComposer { @@ -82,10 +82,21 @@ public class OrderFilesController extends GenericForwardComposer { private Listbox filesList; public OrderFilesController() { - configurationModel = (IConfigurationModel) SpringUtil.getBean("configurationModel"); - userDAO = (IUserDAO) SpringUtil.getBean("userDAO"); - orderElementModel = (IOrderElementModel) SpringUtil.getBean("orderElementModel"); - orderFileModel = (IOrderFileModel) SpringUtil.getBean("orderFileModel"); + if ( configurationModel == null ) { + configurationModel = (IConfigurationModel) SpringUtil.getBean("configurationModel"); + } + + if ( userDAO == null ) { + userDAO = (IUserDAO) SpringUtil.getBean("userDAO"); + } + + if ( orderElementModel == null ) { + orderElementModel = (IOrderElementModel) SpringUtil.getBean("orderElementModel"); + } + + if ( orderFileModel == null ) { + orderFileModel = (IOrderFileModel) SpringUtil.getBean("orderFileModel"); + } } @Override @@ -99,8 +110,10 @@ public class OrderFilesController extends GenericForwardComposer { configurationModel.init(); File repositoryDirectory = null; - if ( configurationModel.getRepositoryLocation() != null ) + + if ( configurationModel.getRepositoryLocation() != null ) { repositoryDirectory = new File(configurationModel.getRepositoryLocation()); + } return repositoryDirectory != null && repositoryDirectory.exists(); } @@ -185,7 +198,7 @@ public class OrderFilesController extends GenericForwardComposer { boolean deleted = fileToDelete.delete(); - if ( deleted ){ + if ( deleted ) { orderFileModel.delete(file); messages.clearMessages(); @@ -239,8 +252,9 @@ public class OrderFilesController extends GenericForwardComposer { if ( inputStream != null ) { byte[] buffer = new byte[1024]; - for ( int count; (count = inputStream.read(buffer)) != -1; ) + for ( int count; (count = inputStream.read(buffer)) != -1; ) { outputStream.write(buffer, 0, count); + } } outputStream.flush(); @@ -283,14 +297,15 @@ public class OrderFilesController extends GenericForwardComposer { public void openWindow(IOrderElementModel orderElementModel) { setOrderElementModel(orderElementModel); - if ( isRepositoryExists() ) + if ( isRepositoryExists() ) { updateListbox(); + } } /** * Listbox is updating after re set the model for it. */ - private void updateListbox(){ + private void updateListbox() { OrderElement currentOrder = orderElementModel.getOrderElement(); filesList.setModel(new ListModelList<>(orderFileModel.findByParent(currentOrder))); } diff --git a/libreplan-webapp/src/main/resources/libreplan-webapp-spring-security-config.xml b/libreplan-webapp/src/main/resources/libreplan-webapp-spring-security-config.xml index b43dc8104..48687b160 100644 --- a/libreplan-webapp/src/main/resources/libreplan-webapp-spring-security-config.xml +++ b/libreplan-webapp/src/main/resources/libreplan-webapp-spring-security-config.xml @@ -17,7 +17,7 @@ - + diff --git a/libreplan-webapp/src/test/java/org/libreplan/web/orders/OrderFilesTest.java b/libreplan-webapp/src/test/java/org/libreplan/web/orders/OrderFilesTest.java index e876799b7..67d4c95d9 100644 --- a/libreplan-webapp/src/test/java/org/libreplan/web/orders/OrderFilesTest.java +++ b/libreplan-webapp/src/test/java/org/libreplan/web/orders/OrderFilesTest.java @@ -53,7 +53,7 @@ import java.util.Date; /** * Tests for {@link OrderFile}. * - * @author Created by Vova Perebykivskyi on 11.01.2016. + * @author Vova Perebykivskyi */ @RunWith(SpringJUnit4ClassRunner.class) From 5a7c972d473e51b9a883ca0e1d7aa046973df3ab Mon Sep 17 00:00:00 2001 From: Vova Perebykivskyi Date: Wed, 9 Nov 2016 18:31:42 +0200 Subject: [PATCH 2/4] Code refactoring. --- .../libreplan/business/common/entities/JobClassNameEnum.java | 1 + .../notifications/jobs/SendEmailOnMilestoneReachedJob.java | 5 +++-- .../jobs/SendEmailOnResourceRemovedFromTaskJob.java | 3 ++- .../jobs/SendEmailOnTaskAssignedToResourceJob.java | 4 +++- .../notifications/jobs/SendEmailOnTaskShouldFinishJob.java | 3 +++ .../notifications/jobs/SendEmailOnTaskShouldStartJob.java | 2 ++ .../jobs/SendEmailOnTimesheetDataMissingJob.java | 3 +++ .../realization/SendEmailOnTaskShouldFinish.java | 2 +- .../resources/libreplan-webapp-spring-security-config.xml | 2 +- 9 files changed, 19 insertions(+), 6 deletions(-) diff --git a/libreplan-business/src/main/java/org/libreplan/business/common/entities/JobClassNameEnum.java b/libreplan-business/src/main/java/org/libreplan/business/common/entities/JobClassNameEnum.java index 64a4dec6c..d70a0c126 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/common/entities/JobClassNameEnum.java +++ b/libreplan-business/src/main/java/org/libreplan/business/common/entities/JobClassNameEnum.java @@ -40,6 +40,7 @@ public enum JobClassNameEnum { SEND_EMAIL_TIMESHEET_DATA_MISSING("org.libreplan.importers.notifications.jobs", "SendEmailOnTimesheetDataMissingJob"); private String packageName; + private String name; JobClassNameEnum(String packageName, String name) { diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnMilestoneReachedJob.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnMilestoneReachedJob.java index eb585e3a5..58090d415 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnMilestoneReachedJob.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnMilestoneReachedJob.java @@ -28,12 +28,13 @@ import org.springframework.scheduling.quartz.QuartzJobBean; /** * Sends E-mail to users with data that storing in notification_queue table - * and that are treat to {@link org.libreplan.business.email.entities.EmailTemplateEnum#TEMPLATE_MILESTONE_REACHED} + * and that are treat to {@link org.libreplan.business.email.entities.EmailTemplateEnum#TEMPLATE_MILESTONE_REACHED}. * - * It is used! + * It is used in {@link org.libreplan.web.common.JobSchedulerModel}. * * @author Vova Perebykivskyi */ +@SuppressWarnings("unused") public class SendEmailOnMilestoneReachedJob extends QuartzJobBean { @Override diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnResourceRemovedFromTaskJob.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnResourceRemovedFromTaskJob.java index 521801a36..295f44084 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnResourceRemovedFromTaskJob.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnResourceRemovedFromTaskJob.java @@ -29,10 +29,11 @@ import org.springframework.scheduling.quartz.QuartzJobBean; * Sends E-mail to users with data that storing in notification_queue table and that are treat to * {@link org.libreplan.business.email.entities.EmailTemplateEnum#TEMPLATE_RESOURCE_REMOVED_FROM_TASK}. * - * It is used! + * It is used in {@link org.libreplan.web.common.JobSchedulerModel}. * * @author Vova Perebykivskyi */ +@SuppressWarnings("unused") public class SendEmailOnResourceRemovedFromTaskJob extends QuartzJobBean { @Override diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskAssignedToResourceJob.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskAssignedToResourceJob.java index 2da2faec1..369539c44 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskAssignedToResourceJob.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskAssignedToResourceJob.java @@ -30,9 +30,11 @@ import org.springframework.scheduling.quartz.QuartzJobBean; * Sends E-mail to users with data that storing in notification_queue table and that are treat to * {@link org.libreplan.business.email.entities.EmailTemplateEnum#TEMPLATE_TASK_ASSIGNED_TO_RESOURCE}. * + * It is used in {@link org.libreplan.web.common.JobSchedulerModel}. + * * @author Vova Perebykivskyi */ - +@SuppressWarnings("unused") public class SendEmailOnTaskAssignedToResourceJob extends QuartzJobBean { @Override diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskShouldFinishJob.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskShouldFinishJob.java index 279bb2046..587aa3557 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskShouldFinishJob.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskShouldFinishJob.java @@ -29,8 +29,11 @@ import org.springframework.scheduling.quartz.QuartzJobBean; * Sends E-mail to users with data that storing in notification_queue table and that are treat to * {@link org.libreplan.business.email.entities.EmailTemplateEnum#TEMPLATE_TODAY_TASK_SHOULD_FINISH}. * + * It is used in {@link org.libreplan.web.common.JobSchedulerModel}. + * * @author Vova Perebykivskyi */ +@SuppressWarnings("unused") public class SendEmailOnTaskShouldFinishJob extends QuartzJobBean { @Override diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskShouldStartJob.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskShouldStartJob.java index 1c6e54994..b7b7b8407 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskShouldStartJob.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTaskShouldStartJob.java @@ -29,9 +29,11 @@ import org.springframework.scheduling.quartz.QuartzJobBean; * Sends E-mail to users with data that storing in notification_queue table and that are treat to * {@link org.libreplan.business.email.entities.EmailTemplateEnum#TEMPLATE_TODAY_TASK_SHOULD_START}. * + * It is used in {@link org.libreplan.web.common.JobSchedulerModel}. * * @author Vova Perebykivskyi */ +@SuppressWarnings("unused") public class SendEmailOnTaskShouldStartJob extends QuartzJobBean { @Override diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTimesheetDataMissingJob.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTimesheetDataMissingJob.java index 066aed022..887a891b2 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTimesheetDataMissingJob.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/jobs/SendEmailOnTimesheetDataMissingJob.java @@ -29,8 +29,11 @@ import org.springframework.scheduling.quartz.QuartzJobBean; * Sends E-mail to users with data that storing in notification_queue table and that are treat to * {@link org.libreplan.business.email.entities.EmailTemplateEnum#TEMPLATE_ENTER_DATA_IN_TIMESHEET}. * + * It is used in {@link org.libreplan.web.common.JobSchedulerModel}. + * * @author Vova Perebykivskyi */ +@SuppressWarnings("unused") public class SendEmailOnTimesheetDataMissingJob extends QuartzJobBean { @Override diff --git a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnTaskShouldFinish.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnTaskShouldFinish.java index 4ed0d1132..de57411a7 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnTaskShouldFinish.java +++ b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnTaskShouldFinish.java @@ -112,7 +112,7 @@ public class SendEmailOnTaskShouldFinish implements IEmailNotificationJob { DateTimeComparator dateTimeComparator = DateTimeComparator.getDateOnlyInstance(); List tasks = taskElementDAO.getTaskElementsWithParentsWithoutMilestones(); - for (TaskElement item : tasks){ + for (TaskElement item : tasks) { DateTime endDate = new DateTime(item.getEndDate()); if ( dateTimeComparator.compare(currentDate, endDate) == 0 ) { diff --git a/libreplan-webapp/src/main/resources/libreplan-webapp-spring-security-config.xml b/libreplan-webapp/src/main/resources/libreplan-webapp-spring-security-config.xml index 48687b160..f74420fd5 100644 --- a/libreplan-webapp/src/main/resources/libreplan-webapp-spring-security-config.xml +++ b/libreplan-webapp/src/main/resources/libreplan-webapp-spring-security-config.xml @@ -17,7 +17,7 @@ - + From 46b5997e620234d7682e5856cdf71e11b2d9c55f Mon Sep 17 00:00:00 2001 From: Vova Perebykivskyi Date: Tue, 15 Nov 2016 11:13:21 +0200 Subject: [PATCH 3/4] Remove slf4j-jdk14 dependency. Set default config for ExpensesSheet entities obviously in ehcache.xml. Add log4j loggers. Minor changes to documentation / i18n. Code refactoring. --- HACKING.rst | 71 ++- doc/src/user/en/01-introducion.rst | 27 +- doc/src/user/en/02-criterios.rst | 14 +- doc/src/user/en/03-calendarios.rst | 66 ++- doc/src/user/en/04-avances.rst | 43 +- doc/src/user/en/05-recursos.rst | 2 +- doc/src/user/en/06-pedidos.rst | 51 ++- doc/src/user/en/07-planificacion.rst | 19 +- doc/src/user/en/10-etiquetas.rst | 18 +- doc/src/user/en/11-materiales.rst | 5 +- doc/src/user/en/12-formularios-calidad.rst | 5 +- doc/src/user/en/14-custos.rst | 6 +- doc/src/user/en/17-project-dashboard.rst | 2 +- doc/src/user/en/18-connectors.rst | 6 +- doc/src/user/en/19-scheduler.rst | 7 +- doc/src/user/en/20-acerca-de.rst | 16 +- .../org/zkoss/ganttz/MilestoneComponent.java | 3 +- .../main/java/org/zkoss/ganttz/Planner.java | 61 ++- .../ganttz/adapters/PlannerConfiguration.java | 26 +- .../java/org/zkoss/ganttz/util/Emitter.java | 13 +- .../resources/web/js/ganttz/GanttPanel.js | 6 +- .../timetracker/OnColumnsRowRendererTest.java | 13 +- .../expensesheet/entities/ExpenseSheet.java | 27 +- .../entities/ExpenseSheetLine.java | 23 +- .../src/main/resources/ehcache.xml | 17 + .../business/advance/entities/Advance.hbm.xml | 3 +- .../entities/ExpenseSheets.hbm.xml | 7 +- .../business/logs/entities/Logs.hbm.xml | 5 +- .../calendars/entities/BaseCalendarTest.java | 412 +++++++----------- .../src/test/resources/log4j.properties | 1 + libreplan-webapp/pom.xml | 5 + .../libreplan/web/LoggingConfiguration.java | 44 +- .../entrypoints/EntryPointsHandler.java | 126 +++--- .../ExpenseSheetCRUDController.java | 68 +-- .../web/planner/chart/LoadChartFiller.java | 17 +- .../chart/StandardLoadChartFiller.java | 36 +- .../planner/company/CompanyPlanningModel.java | 109 +++-- .../web/planner/order/OrderPlanningModel.java | 174 ++++---- .../planner/tabs/ResourcesLoadTabCreator.java | 4 +- .../org/libreplan/web/print/CutyPrint.java | 202 ++++----- .../resourceload/ResourceLoadController.java | 34 +- .../users/dashboard/PersonalTimesheetDTO.java | 33 +- .../src/main/resources/i18n/ca.po | 9 +- .../src/main/resources/i18n/cs.po | 9 +- .../src/main/resources/i18n/de.po | 9 +- .../src/main/resources/i18n/pl.po | 9 +- .../src/main/resources/i18n/pt.po | 9 +- .../src/main/resources/i18n/ru.po | 9 +- .../src/main/resources/i18n/zh.po | 9 +- libreplan-webapp/src/main/resources/log4j.xml | 175 ++++---- .../src/main/webapp/WEB-INF/web.xml | 4 +- .../src/main/webapp/WEB-INF/zk.xml | 4 +- .../webapp/resourceload/_resourceload.zul | 11 +- pom.xml | 48 +- 54 files changed, 1066 insertions(+), 1066 deletions(-) diff --git a/HACKING.rst b/HACKING.rst index 265e29f96..786d37b78 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -1,8 +1,8 @@ Hacking ======= -This is a guide about how to start hacking on *LibrePlan* project. If you want -more information about *LibrePlan* development you should visit the wiki +This is a guide about how to start hacking on *LibrePlan* project. +If you want more information about *LibrePlan* development you should visit the wiki available at: http://wiki.libreplan.org/. .. contents:: @@ -15,13 +15,13 @@ Compilation requirements Needed to clone source code repository -* *Maven 2* - Java software project management and comprehension tool +* *Maven 3* - Java software project management and comprehension tool Needed to build and compile the project -* *JDK 6* - Java Development Kit +* *JDK 8* - Java Development Kit - Project depends on Java 6 and JDK is needed in order to compile it + Project depends on Java 8 and JDK is needed in order to compile it * *PostgreSQL* - Object-relational SQL database @@ -56,7 +56,7 @@ Debian/Ubuntu * Install requirements:: - # apt-get install git-core maven2 openjdk-6-jdk postgresql postgresql-client python-docutils make gettext cutycapt + # apt-get install git-core maven openjdk-8-jdk postgresql postgresql-client python-docutils make gettext cutycapt * Connect to database:: @@ -72,7 +72,7 @@ Debian/Ubuntu * Download source code:: - $ git clone git://github.com/Igalia/libreplan.git + $ git clone git://github.com/LibrePlan/libreplan.git * Compile project:: @@ -84,18 +84,18 @@ Debian/Ubuntu $ cd libreplan-webapp/ $ mvn jetty:run -* Go to http://localhost:8080/libreplan-webapp/ +* Go to http://localhost:8080/ Fedora ~~~~~~ * Install requirements:: - # yum install git maven java-1.7.0-openjdk-devel postgresql postgresql-server python-docutils make gettext gnu-free-fonts-compat + # yum install git maven java-1.8.0-openjdk-devel postgresql postgresql-server python-docutils make gettext gnu-free-fonts-compat .. WARNING:: Use the following command in Fedora 16 or below:: - # yum install git maven java-1.6.0-openjdk postgresql postgresql-server python-docutils make gettext gnu-free-fonts-compat + # yum install git maven java-1.8.0-openjdk postgresql postgresql-server python-docutils make gettext gnu-free-fonts-compat * Start database service:: @@ -133,7 +133,7 @@ Fedora * Download source code:: - $ git clone git://github.com/Igalia/libreplan.git + $ git clone git://github.com/LibrePlan/libreplan.git * Compile project:: @@ -145,26 +145,26 @@ Fedora $ cd libreplan-webapp/ $ mvn jetty:run -* Go to http://localhost:8080/libreplan-webapp/ +* Go to http://localhost:8080/ openSUSE ~~~~~~~~ * Install requirements:: - # zypper install git-core java-1_6_0-openjdk-devel postgresql-server postgresql docutils make gettext-tools + # zypper install git-core java-1_8_0-openjdk-devel postgresql-server postgresql docutils make gettext-tools * Install Maven:: # cd /opt/ - # wget http://www.apache.org/dist//maven/binaries/apache-maven-2.2.1-bin.tar.gz - # tar -xzvf apache-maven-2.2.1-bin.tar.gz + # wget http://www.apache.org/dist//maven/binaries/apache-maven-3.0.5-bin.tar.gz + # tar -xzvf apache-maven-3.0.5-bin.tar.gz Edit ``/etc/bash.bashrc.local`` and add the following lines:: - export M2_HOME=/opt/apache-maven-2.2.1 - export M2=$M2_HOME/bin - export PATH=$M2:$PATH + export M2_HOME=/opt/apache-maven-3.0.5 + export MVN=$M2_HOME/bin + export PATH=$MVN:$PATH * Start database service:: @@ -194,7 +194,7 @@ openSUSE * Download source code:: - $ git clone git://github.com/Igalia/libreplan.git + $ git clone git://github.com/LibrePlan/libreplan.git * Compile project:: @@ -206,31 +206,31 @@ openSUSE $ cd libreplan-webapp/ $ mvn jetty:run -* Go to http://localhost:8080/libreplan-webapp/ +* Go to http://localhost:8080/ Microsoft Windows -~~~~~~~~ +~~~~~~~~~~~~~~~~~ -* Download and install latest Java Development Kit 7uXX (JDK7uXX):: +* Download and install latest Java Development Kit 8uXX (JDK8uXX):: - # http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html + # http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html * Download and install latest PostgreSQL database:: # http://www.enterprisedb.com/products-services-training/pgdownload#windows -* Download and install Apache Tomcat 6:: +* Download and install Apache Tomcat 8:: - # http://tomcat.apache.org/download-60.cgi + # http://tomcat.apache.org/download-80.cgi # Note: in JDK folder there is JRE folder * Set up JDBC41 PostgreSQL Driver:: # Download latest driver: https://jdbc.postgresql.org/download.html - # Copy downloaded *.jar file to JRE location: (e.g. C:\Program Files\Java\jre7\lib\ext) - # Copy downloaded *.jar file to JAVA_HOME location: (e.g. C:\Program Files\Java\jdk1.7.0_80\jre\lib\ext) - # Put downloaded *.jar file to Tomcat lib location: (e.g. C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib) + # Copy downloaded *.jar file to JRE location: (e.g. C:\Program Files\Java\jre8\lib\ext) + # Copy downloaded *.jar file to JAVA_HOME location: (e.g. C:\Program Files\Java\jdk1.8.0_111\jre\lib\ext) + # Put downloaded *.jar file to Tomcat lib location: (e.g. C:\Program Files\Apache Software Foundation\Tomcat 8.0\lib) * Create database:: @@ -272,7 +272,7 @@ Microsoft Windows * Configure Apache Tomcat Server -* Go to (e.g. C:/Program Files/Apache Software Foundation/Tomcat 6.0/conf/Catalina/localhost/) +* Go to (e.g. C:/Program Files/Apache Software Foundation/Tomcat 8.0/conf/Catalina/localhost/) and create there libreplan.xml file with this lines of code:: @@ -295,7 +295,7 @@ Microsoft Windows * Set JAVA_HOME environment variable:: - # You need to set it to your JDK installed directory (e.g. C:\Program Files\Java\jdk1.7.0_80) + # You need to set it to your JDK installed directory (e.g. C:\Program Files\Java\jdk1.8.0_111) * Add path of unpacked distributions bin directory of Maven to 'Path' environment variable @@ -310,12 +310,12 @@ Microsoft Windows * Get *.war file from project folder (e.g ../libreplan/libreplan-webapp/target/libreplan-webapp.war) * Rename it to libreplan.war - * Put your libreplan.war file to Apache Tomcat webapps folder (e.g. C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\) + * Put your libreplan.war file to Apache Tomcat webapps folder (e.g. C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\) * Start Apache Tomcat server - # Possible location: C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin\Tomcat6.exe + # Possible location: C:\Program Files\Apache Software Foundation\Tomcat 8.0\bin\Tomcat8.exe -* Go to http://localhost:8080/libreplan-webapp/ +* Go to http://localhost:8080/ CutyCapt compilation @@ -398,9 +398,8 @@ LibrePlan documentation generation ---------------------------------- In the doc/src folder you'll find several types of documentation -available: technical documentation, user manual, some training -documentation and training exercises. This documentation is available -in several languages. +available: technical documentation, user manual, some training documentation and training exercises. +This documentation is available in several languages. The supported outputs are HTML and PDF. diff --git a/doc/src/user/en/01-introducion.rst b/doc/src/user/en/01-introducion.rst index 18e91a273..9dc232ba1 100644 --- a/doc/src/user/en/01-introducion.rst +++ b/doc/src/user/en/01-introducion.rst @@ -1,5 +1,5 @@ Introduction -############# +############ .. contents:: @@ -17,7 +17,8 @@ For any specific information you may need about this software, please contact th Company overview and view management ==================================================== -As can be seen in the program's main screen (shot given previously) and the company overview, users can see the list of planned projects to find out about the company's overall situation in relation to orders and the use of resources. The company overview contains 3 views: +As can be seen in the program's main screen (shot given previously) and the company overview, users can see the list of planned projects +to find out about the company's overall situation in relation to orders and the use of resources. The company overview contains 3 views: * Planning view: View that combines two points of view: @@ -39,7 +40,8 @@ As can be seen in the program's main screen (shot given previously) and the comp Work Breakdown Structure -The view management commented on previously for the company overview is very similar to the management planned for a single project. A project can be accessed in several ways: +The view management commented on previously for the company overview is very similar to the management planned for a single project. +A project can be accessed in several ways: * By right clicking on the Gantt chart for the order and then selecting *Plan*. * By accessing the order list and clicking on the icon for the Gantt diagrams. @@ -80,10 +82,10 @@ On top of the functions offered by the program, there are other features that ma * History management: The program does not erase information, it only makes it invalid, so users can check older information using date filters. Usability conventions -========================== +===================== Information about forms ---------------------------------- +----------------------- Before describing the various functions associated with the most important modules, we need to give a general explanation on how to browse and the forms. Essentially, there are 3 kinds of editing forms: @@ -102,13 +104,18 @@ Standard icons and buttons * Search: The magnifying glass is the icon that indicates that the text entry to the left is intended for searching for elements. Tabs --------- -The program will have content editing and administration forms, which will be represented by graphic components based on tabs. This method is used to organise information from a comprehensive form into different sections that can be accessed by clicking on the names of the different tabs, the others keeping their status. In all cases, the save and cancel options affect the group of sub-forms on the different tabs. +---- +The program will have content editing and administration forms, which will be represented by graphic components based on tabs. +This method is used to organise information from a comprehensive form into different sections that can be accessed by clicking on the +names of the different tabs, the others keeping their status. In all cases, the save and cancel options affect the group of sub-forms on +the different tabs. Explicit actions and context help --------------------------------------- +--------------------------------- The program contains components that provide additional descriptions about the element when hovering over them for one second. -The actions the user may carry out in the program are stated on the button tabs and in the help texts about them, the browsing menu options and the options on the context menus that open out when right clicking on the planner area. -Furthermore, short cuts are given for the main operations by double clicking the listed elements or by associating key events with cursors and the enter key, which is how to add elements when moving through the forms. +The actions the user may carry out in the program are stated on the button tabs and in the help texts about them, the browsing menu +options and the options on the context menus that open out when right clicking on the planner area. +Furthermore, short cuts are given for the main operations by double clicking the listed elements or by associating key events with +cursors and the enter key, which is how to add elements when moving through the forms. diff --git a/doc/src/user/en/02-criterios.rst b/doc/src/user/en/02-criterios.rst index e39a1b7cc..0e71fddd3 100644 --- a/doc/src/user/en/02-criterios.rst +++ b/doc/src/user/en/02-criterios.rst @@ -1,9 +1,14 @@ Criteria -######### +######## .. contents:: -Criteria are elements that are used in the program to categorise resources and tasks. Tasks need criteria and the resources fulfil them. The following sequence is an example of how to use criteria: A resource is designated the criterion of "welder" (that is the resource fulfils the "welder" category) and a task requires the "welder" criterion to be carried out. As a result, when resources are allocated to tasks, workers with the "welder" criterion are used when allocating resources generically (not applicable to specific allocation). See the chapter on allocating resources to find out more about the different kinds of allocation. +Criteria are elements that are used in the program to categorise resources and tasks. Tasks need criteria and the resources fulfil them. +The following sequence is an example of how to use criteria: +A resource is designated the criterion of "welder" (that is the resource fulfils the "welder" category) and a task requires the "welder" +criterion to be carried out. As a result, when resources are allocated to tasks, workers with the "welder" +criterion are used when allocating resources generically (not applicable to specific allocation). +See the chapter on allocating resources to find out more about the different kinds of allocation. Several operations can be carried out with criteria in the program: @@ -12,11 +17,12 @@ Several operations can be carried out with criteria in the program: * Allocation of criteria to tasks. * Filtering entities according to criteria. Tasks and order items can be filtered according to criteria to carry out operations in the program. -Only the first function out of the three described above will be explained in this section. The two kinds of allocation will be dealt with later, the allocation of resources in the chapter on "Resource management" and the filtering function in the chapter on "Task planning". +Only the first function out of the three described above will be explained in this section. The two kinds of allocation will be dealt with later, +the allocation of resources in the chapter on "Resource management" and the filtering function in the chapter on "Task planning". Criteria administration -=========================== +======================= Criteria administration can be accessed from the administration menu: .. figure:: images/menu.png diff --git a/doc/src/user/en/03-calendarios.rst b/doc/src/user/en/03-calendarios.rst index db84965ca..f9706a211 100644 --- a/doc/src/user/en/03-calendarios.rst +++ b/doc/src/user/en/03-calendarios.rst @@ -1,11 +1,13 @@ Calendars -########### +######### .. contents:: -Calendars are the program entities that determine the load capacity of different resources. A calendar consists of a series of days in the year with each day divided into available working hours. +Calendars are the program entities that determine the load capacity of different resources. +A calendar consists of a series of days in the year with each day divided into available working hours. -For example, a public holiday may have 0 hours available and, if the working hours in a workday are 8, this is the number of hours that is designated as available time for that day. +For example, a public holiday may have 0 hours available and, if the working hours in a workday are 8, +this is the number of hours that is designated as available time for that day. There are two ways of informing the system of how many working hours there are in a day: @@ -13,9 +15,11 @@ There are two ways of informing the system of how many working hours there are i * According to exceptions. For example, 10 working hours on Monday 30 January. Administration of calendars -============================= +=========================== -The calendar system is hierarchical, meaning that base calendars or calendars based on them can be created, thus maintaining a tree structure. A calendar based on a calendar from a higher level of the tree will take on the daily duties and exceptions, providing that they have not been explicitly modified for the new calendar. The following concepts must be understood to manage calendars: +The calendar system is hierarchical, meaning that base calendars or calendars based on them can be created, thus maintaining a tree structure. +A calendar based on a calendar from a higher level of the tree will take on the daily duties and exceptions, providing that they have not +been explicitly modified for the new calendar. The following concepts must be understood to manage calendars: * Each day is independent in itself and each year has different days. For example, if 8 December 2009 is a public holiday, this does not mean that 2010 already has 8 December marked as a public holiday. * Working days are based on weekdays. For example, if it is normal to work 8 hours on Mondays, all the Mondays from all the weeks in the different years will have 8 hours available. @@ -34,9 +38,10 @@ The administration of calendars can be accessed from the procedures on the "Admi 4. Editing an existing calendar. Creating a new calendar -------------------------------- +----------------------- -In order to create a new calendar, users need to click the "Create" button. The system then shows a form where users can carry out the following procedures: +In order to create a new calendar, users need to click the "Create" button. +The system then shows a form where users can carry out the following procedures: * Choosing the tab they want to work on. @@ -56,7 +61,8 @@ In order to create a new calendar, users need to click the "Create" button. The * Distribute different weekly hours for the future. * Delete previous hour distribution lists. -With these procedures, users of the program can fully personalise the calendars according to their needs. Users need to click the "Save" button to store changes made to the form. +With these procedures, users of the program can fully personalise the calendars according to their needs. +Users need to click the "Save" button to store changes made to the form. .. figure:: images/calendar-edition.png :scale: 50 @@ -71,11 +77,17 @@ With these procedures, users of the program can fully personalise the calendars Creating derived calendars ---------------------------------- -A derived calendar is a calendar created from another existing one. For example, it has all the features of the original one, but users can change it to contain other options. +A derived calendar is a calendar created from another existing one. For example, it has all the features of the original one, +but users can change it to contain other options. -An example of using derived calendars is when there is a general calendar for Spain, and the creation of a derived calendar to include public holidays in Galicia in additional to the ones defined in the general calendar. +An example of using derived calendars is when there is a general calendar for Spain, and the creation of a derived calendar +to include public holidays in Galicia in additional to the ones defined in the general calendar. -It is important to point out that any change made to the original calendar is made directly to the derived calendar, providing that a specific exception against this was not defined. For example, the calendar for Spain has an 8-hour working day on 17 May, but the calendar for Galicia (a derived calendar) has no working hours on the very same day, as it is a public holiday. If the Spanish calendar was changed to have 4 hours available per day for the week of 17 May, the Galician calendar would also change to have 4 hours available for every day on the same week, except 17 May, which would have no working hours for the reason stated above. +It is important to point out that any change made to the original calendar is made directly to the derived calendar, + providing that a specific exception against this was not defined. For example, the calendar for Spain has an 8-hour working day on 17 May, + but the calendar for Galicia (a derived calendar) has no working hours on the very same day, as it is a public holiday. + If the Spanish calendar was changed to have 4 hours available per day for the week of 17 May, the Galician calendar would also + change to have 4 hours available for every day on the same week, except 17 May, which would have no working hours for the reason stated above. .. figure:: images/calendar-create-derived.png :scale: 50 @@ -90,13 +102,16 @@ To create a derived calendar in the program, it is necessary to: * Once this procedure has been carried out, the system shows an editing form with the same characteristics as the forms used to create forms from scratch, with the difference that the proposed exceptions and the hours per weekday are based on the original calendar. Creating a calendar by copying ------------------------------------ +------------------------------ -A copied calendar is a calendar created as an exact copy of another existing one. For example, it has all the features of the original one, but users can also change it to contain other options. +A copied calendar is a calendar created as an exact copy of another existing one. For example, it has all the features of the original one, +but users can also change it to contain other options. -The difference between a copied and a derived calendar is based on the changes in the original. In relation to copies, if the original is modified, the copy is not affected. However, derived calendars are affected by changes made to the original. +The difference between a copied and a derived calendar is based on the changes in the original. In relation to copies, if the original +is modified, the copy is not affected. However, derived calendars are affected by changes made to the original. -An example of using a copied calendar is having a calendar for "Pontevedra" and needing a calendar for "A Coruña", for which most of the features would be the same. However, changes on one calendar should not be reflected in the other. +An example of using a copied calendar is having a calendar for "Pontevedra" and needing a calendar for "A Coruña", for which most of +the features would be the same. However, changes on one calendar should not be reflected in the other. To create a copied calendar in the program, it is necessary to do the following: @@ -106,9 +121,10 @@ To create a copied calendar in the program, it is necessary to do the following: * Once this procedure has been carried out, the system shows an editing form with the same characteristics as the forms used to create forms from scratch, with the difference that the proposed exceptions and the hours per weekday are based on the original calendar. Default calendar ----------------------- +---------------- -One of the existing calendars in the system can be marked as the default calendar. This calendar is the one that will be designated to any entity in the system that is managed with calendars. +One of the existing calendars in the system can be marked as the default calendar. +This calendar is the one that will be designated to any entity in the system that is managed with calendars. The following must be carried out to set up a default calendar: @@ -123,16 +139,19 @@ The following must be carried out to set up a default calendar: Creating a default calendar Assigning a calendar to resources ------------------------------------ +--------------------------------- -Resources can only be activated, i.e. available working hours, if they have an assigned calendar with a valid activation period. If no calendar is assigned to resources, the default calendar is assigned with an activation period that begins on the start date and does not have an expiry date. +Resources can only be activated, i.e. available working hours, if they have an assigned calendar with a valid activation period. +If no calendar is assigned to resources, the default calendar is assigned with an activation period that begins on the start +date and does not have an expiry date. .. figure:: images/resource-calendar.png :scale: 50 Calendar of resources -However, users can delete the calendar that has been previously assigned to a resource and create a new calendar based on one that already exists. Consequently, resources can be fully personalised in relation to calendars. +However, users can delete the calendar that has been previously assigned to a resource and create a new calendar based on one that already exists. +Consequently, resources can be fully personalised in relation to calendars. The following steps have to be carried out to assign a calendar: @@ -155,7 +174,7 @@ The following steps have to be carried out to assign a calendar: Assigning new calendars to resources Assigning calendars to orders ----------------------------------- +----------------------------- Projects can have a different calendar to the default calendar. Users need to do the following to change the calendar for the order: @@ -166,8 +185,9 @@ Projects can have a different calendar to the default calendar. Users need to do * Click "Save" or "Save and continue". Assigning calendars to tasks ----------------------------------- -In the same way that calendars can be assigned to resources or orders, users can carry out the same procedure for planned tasks. This procedure allows specific calendars to be defined for specific stages of a project. To carry out this procedure, it is necessary to: +---------------------------- +In the same way that calendars can be assigned to resources or orders, users can carry out the same procedure for planned tasks. +This procedure allows specific calendars to be defined for specific stages of a project. To carry out this procedure, it is necessary to: * Access the planning of a project. * Right click the task to which a calendar is to be assigned. diff --git a/doc/src/user/en/04-avances.rst b/doc/src/user/en/04-avances.rst index 1dfa35db4..9f02d350c 100644 --- a/doc/src/user/en/04-avances.rst +++ b/doc/src/user/en/04-avances.rst @@ -1,27 +1,39 @@ Progress -######### +######## .. contents:: -The progress of a project shows the degree to which the estimated time of completion of the project is being fulfilled, and the progress of a task indicates the degree to which it is being fulfilled in terms of estimated completion. +The progress of a project shows the degree to which the estimated time of completion of the project is being fulfilled, +and the progress of a task indicates the degree to which it is being fulfilled in terms of estimated completion. -In general, progress cannot be measured automatically; a member of staff with experience or a checklist has to determine the degree of completion of a task or project. +In general, progress cannot be measured automatically; a member of staff with experience or a checklist has to determine the degree +of completion of a task or project. -It should be noted that there is a significant difference between the use of hours assigned to a task or project and the degree of progress of that task or project. While the number of used hours may be more or less than they should be, the project may be behind or ahead of its estimated completion on the day that is being monitored. Several possible situations may arise due to these two measurements: +It should be noted that there is a significant difference between the use of hours assigned to a task or project and the degree +of progress of that task or project. While the number of used hours may be more or less than they should be, the project may be behind +or ahead of its estimated completion on the day that is being monitored. Several possible situations may arise due to these two measurements: * Less hours are consumed than expected for the element that is to be measured and, at the same time, the project is more behind than expected because progress is lower than estimated for the day that is being monitored. * Less hours are consumed than expected for the element that is to be measured and, at the same time, the project is more ahead than expected because progress is lower than estimated for the day that is being monitored. * More hours are consumed than expected and, at the same time, the project is more behind than expected because progress is lower than estimated for the day that is being monitored. * More hours are consumed than expected and, at the same time, the project is more ahead than expected because progress is lower than expected for the day that is being monitored. -It is possible to compare these possible situations from the planning itself by using information relating to the degree of progress made and also the degree to which the hours have been used. This chapter will deal with the entering of information in order to carry out the monitoring of progress. +It is possible to compare these possible situations from the planning itself by using information relating to the degree of progress +made and also the degree to which the hours have been used. This chapter will deal with the entering of information in order to carry out +the monitoring of progress. -The philosophy of the project for monitoring progress is based on the users stating how far they want to monitor the progress of their projects. As a result, if users want to monitor orders, they only have to enter information for level-1 elements. If they want monitoring to be more precise in relation to tasks, they have to enter information about progress at lower levels, and it is the system that transmits all of the data upwards in the hierarchy. +The philosophy of the project for monitoring progress is based on the users stating how far they want to monitor the progress of their projects. +As a result, if users want to monitor orders, they only have to enter information for level-1 elements. If they want monitoring to be more precise +in relation to tasks, they have to enter information about progress at lower levels, and it is the system that transmits all of the data upwards +in the hierarchy. Managing types of progress ========================== -All companies have different needs when monitoring project progress, specifically the tasks they consist of. It was therefore necessary to consider the existence of entities in the system called “types of progress”. Users can register the different types of progress in the system to measure a task's progress. For example, a task can be measured in percentage terms, but at the same time, this percentage progress can be translated to progress in *Tonnes* on the agreed amount with the client. +All companies have different needs when monitoring project progress, specifically the tasks they consist of. It was therefore necessary +to consider the existence of entities in the system called “types of progress”. Users can register the different types of progress in the system +to measure a task's progress. For example, a task can be measured in percentage terms, but at the same time, this percentage progress can be +translated to progress in *Tonnes* on the agreed amount with the client. A type of progress is given a name, a maximum value and a precision value: @@ -56,14 +68,17 @@ Users can create new types of progress in the following way: * Maximum value accepted by the type of progress. * Precision value for the type of progress. -Entering progress based on t -====================================== +Entering progress based on type +=============================== -Entering progress is done on order elements, but it can also be done using a short cut from the planning tasks. The decision on what type of progress users want to associate with each order element is their own responsibility. +Entering progress is done on order elements, but it can also be done using a short cut from the planning tasks. +The decision on what type of progress users want to associate with each order element is their own responsibility. Users can enter a unique and default type of progress for the whole order. -Before carrying out progress measurements, users need to associate the chosen type with the order. For example, progress in percentage terms to measure progress made on the entire task or an agreed progress rate if progress measurements agreed with the client are to be entered in the future. +Before carrying out progress measurements, users need to associate the chosen type with the order. +For example, progress in percentage terms to measure progress made on the entire task or an agreed progress rate if progress +measurements agreed with the client are to be entered in the future. .. figure:: images/avance.png :scale: 40 @@ -81,9 +96,11 @@ The following must be done to enter progress measurements: Comparison of progress with an order element -================================================= +============================================ -Users can compare graphically how much progress is being made on the orders with the measurements taken. All types of progress have a column with a check button (called "Show"). When this is marked, the progress chart of measurements taken is shown on the order element. +Users can compare graphically how much progress is being made on the orders with the measurements taken. +All types of progress have a column with a check button (called "Show"). +When this is marked, the progress chart of measurements taken is shown on the order element. .. figure:: images/contraste-avance.png :scale: 40 diff --git a/doc/src/user/en/05-recursos.rst b/doc/src/user/en/05-recursos.rst index 663ae93cf..c3d013f36 100644 --- a/doc/src/user/en/05-recursos.rst +++ b/doc/src/user/en/05-recursos.rst @@ -31,7 +31,7 @@ Users can create, edit and invalidate (never delete definitively) workers from t * List of machines: Machines will be shown in lists and will be numbered. This is where their details can be managed. Management of workers -======================== +===================== The management of workers is carried out by going to the "Resources" tab and then the feature "List of workers". Users can edit all of the workers on the resource list by clicking the standard editing icon. diff --git a/doc/src/user/en/06-pedidos.rst b/doc/src/user/en/06-pedidos.rst index 62467674c..280d14581 100644 --- a/doc/src/user/en/06-pedidos.rst +++ b/doc/src/user/en/06-pedidos.rst @@ -1,19 +1,23 @@ Orders and order elements -############################## +######################### .. contents:: Orders describe the work to be carried out by the users who use the program. Each order corresponds with the projects that the companies are going to offer their clients. -An order consists of one or several order lines. Each order line corresponds with the planning the works on the order should follow when being implemented. Order lines are organised hierarchically without any limitations on depth. The fact that order lines are organised hierarchically shows how several inheritable features work, such as labels. +An order consists of one or several order lines. +Each order line corresponds with the planning the works on the order should follow when being implemented. +Order lines are organised hierarchically without any limitations on depth. +The fact that order lines are organised hierarchically shows how several inheritable features work, such as labels. The following sections will describe the operations that users can carry out with orders and order lines. Order -====== +===== -An order is a project or work that a client requests from a company. The order for the planned works identifies the project in the company. The difference with comprehensive management programs such as "LibrePlan" is that they only need to use certain order details. These details are: +An order is a project or work that a client requests from a company. The order for the planned works identifies the project in the company. +The difference with comprehensive management programs such as "LibrePlan" is that they only need to use certain order details. These details are: * Order name * Order code @@ -128,7 +132,8 @@ Users can access the following tabs from the editing order option: Editing order elements ============================== -Editing order elements is carried out from the "Order element list" tab by clicking the editing icon, which shows a new screen from which the user can carry out the following: +Editing order elements is carried out from the "Order element list" tab by clicking the editing icon, which shows a new screen +from which the user can carry out the following: * Edit information about the order element. * View hours attributed to order elements. @@ -141,7 +146,7 @@ Editing order elements is carried out from the "Order element list" tab by click The following subsections describe each one of the operations in depth. Editing information about the order element ------------------------------------------------- +------------------------------------------- Editing information about the order element includes the editing of the following details: @@ -161,7 +166,8 @@ Editing information about the order element includes the editing of the followin Viewing hours attributed to order elements ------------------------------------------------------ -The "Assigned hours" tab enables users to view the work reports associated with an order element and also how many of the estimated hours have already been carried out. +The "Assigned hours" tab enables users to view the work reports associated with an order element and also how many of the estimated hours have +already been carried out. .. figure:: images/order-element-hours.png :scale: 50 @@ -174,16 +180,19 @@ The screen is divided into two parts: * Use of estimated hours: The system calculates the total number of hours devoted to a task and compares them with the estimated hours. Managing progress of order elements ---------------------------------------------- +----------------------------------- Entering types of progress and the management of order element progress has been described in the "Progress" chapter. Managing order labels ------------------------------- +--------------------- -Labels, as described in the chapter on labels, enable users to categorise order elements. Consequently, users can group planning or order information based on them. +Labels, as described in the chapter on labels, enable users to categorise order elements. +Consequently, users can group planning or order information based on them. -Users can assign labels directly to an order element or even to a previous order element in the hierarchy. From the moment a label from one of the two previous methods is assigned, the order element and the related planning task are associated with the label, and used for subsequent filtering. +Users can assign labels directly to an order element or even to a previous order element in the hierarchy. +From the moment a label from one of the two previous methods is assigned, the order element and the related planning task are associated with the label, +and used for subsequent filtering. .. figure:: images/order-element-tags.png :scale: 50 @@ -199,14 +208,16 @@ As can be seen in the image, users can carry out the following procedures from t Managing criteria required by the order element and hour groups --------------------------------------------------------------------------------- +--------------------------------------------------------------- Both an order and an order element can be assigned criteria that need to be fulfilled for it to be carried out. Criteria can be direct or indirect: * Direct criteria: These are assigned directly to the order element. They are criteria that are required by the hour groups on the order element. * Indirect criteria: These are assigned on order elements that are higher in the hierarchy and are inherited by the element that is being edited. -Apart from the required criterion, one or various hour groups that are part of the order element can be defined. It all depends on whether the order element contains other order elements as child nodes or if it is a leaf node. In the first case the information about hours and hour groups can only be viewed, but leaf nodes can be edited. The latter case works as follows: +Apart from the required criterion, one or various hour groups that are part of the order element can be defined. +It all depends on whether the order element contains other order elements as child nodes or if it is a leaf node. +In the first case the information about hours and hour groups can only be viewed, but leaf nodes can be edited. The latter case works as follows: * The system creates an hour group by default, which is associated to the order element. The details that can be modified for an hour group are: @@ -225,7 +236,8 @@ Apart from the required criterion, one or various hour groups that are part of t Managing materials ------------------------ -Materials are managed in the projects as a list associated with each order line or an order in general. The list of materials is made up of the following fields: +Materials are managed in the projects as a list associated with each order line or an order in general. +The list of materials is made up of the following fields: * Code * Date @@ -262,19 +274,22 @@ Working with materials is carried out as follows: * Users select the units, status and date of assigned materials. -For subsequent monitoring of materials, it is possible to change the status of a unit group of the received material. This procedure is carried out as follows: +For subsequent monitoring of materials, it is possible to change the status of a unit group of the received material. +This procedure is carried out as follows: * Users click the "Divide" button on the list of materials to the right of each row. * Users select the number of units they want the row to be divided into. * The program shows two rows with the material divided. * Users change the status of the row containing the material. -The advantage of using this dividing tool is the possibility of receiving partial deliveries of material without having to wait to receive it all in order to mark it as received. +The advantage of using this dividing tool is the possibility of receiving partial deliveries of material without having to wait +to receive it all in order to mark it as received. Managing quality forms ------------------------------------- +---------------------- -Some order elements must certify that certain tasks have been carried out in order for them to be marked as complete. This is why the program has quality forms, which consist of a list of questions that can be considered important if they are answered positively. +Some order elements must certify that certain tasks have been carried out in order for them to be marked as complete. +This is why the program has quality forms, which consist of a list of questions that can be considered important if they are answered positively. It is important to mention that a quality form has to be created previously so that it can be assigned to an order element. diff --git a/doc/src/user/en/07-planificacion.rst b/doc/src/user/en/07-planificacion.rst index f5d1499b4..3eca4c8e7 100644 --- a/doc/src/user/en/07-planificacion.rst +++ b/doc/src/user/en/07-planificacion.rst @@ -1,5 +1,5 @@ Task planning -####################### +############# .. _planificacion: .. contents:: @@ -8,14 +8,17 @@ Task planning Task planning ============= -Planning in "LibrePlan" is a process that has been described throughout all of the chapters of the user guide, the chapters on orders and the assigning of resources being particularly important in this respect. This chapter describes basic planning procedures after the order and the Gantt charts have been configured properly. +Planning in "LibrePlan" is a process that has been described throughout all of the chapters of the user guide, +the chapters on orders and the assigning of resources being particularly important in this respect. +This chapter describes basic planning procedures after the order and the Gantt charts have been configured properly. .. figure:: images/planning-view.png :scale: 35 Work planning view -As with the company overview, the project planning view is divided into several views based on the information it is analysing. The views of a specific project are: +As with the company overview, the project planning view is divided into several views based on the information it is analysing. +The views of a specific project are: * Planning view * Resource load view @@ -23,7 +26,7 @@ As with the company overview, the project planning view is divided into several * Advanced assignment view Planning view ----------------------- +------------- The planning view combines three different views: * Project planning. Project planning can be viewed in the upper right-hand part of the program. It represents the planning in a Gantt chart. This is the view where users can temporarily move tasks, assign dependencies among them, define milestones and establish restrictions. @@ -73,8 +76,10 @@ The planning view also offers several procedures that ultimately function as vie * Print: Enabling users to print the Gantt chart being viewed at that moment. Resource load view --------------------------- -The resource load view provides a list of resources that contains a list of tasks or criteria that generate workloads. Each task or criterion is shown as a Gantt chart so that the start and end date of the load can be seen. A different colour is shown depending on whether the resource has a load that is higher or lower than 100%: +------------------ +The resource load view provides a list of resources that contains a list of tasks or criteria that generate workloads. +Each task or criterion is shown as a Gantt chart so that the start and end date of the load can be seen. +A different colour is shown depending on whether the resource has a load that is higher or lower than 100%: * Green: load lower than 100% * Orange: 100% load @@ -93,7 +98,7 @@ The order list view allows users to go to the order editing and deleting options Advanced assignment view ----------------------------- +------------------------ The advanced assignment view is explained in depth in the "Resource assignment" chapter. diff --git a/doc/src/user/en/10-etiquetas.rst b/doc/src/user/en/10-etiquetas.rst index bd2fdcda2..644cb1b3e 100644 --- a/doc/src/user/en/10-etiquetas.rst +++ b/doc/src/user/en/10-etiquetas.rst @@ -1,21 +1,23 @@ Tags -######### +#### .. contents:: Tags are entities used in the program to conceptually organise tasks or order elements. -Tags are categorised according to tag type. A tag can only belong to one tag type, however, users can create many similar tags belonging to different tag types. +Tags are categorised according to tag type. A tag can only belong to one tag type, however, +users can create many similar tags belonging to different tag types. Tag types -=========== +========= Tag types are used to group the types of tag that users want to manage in the program. Here are some examples of possible tag types: i. Client: Users may be interested in tagging tasks, orders or order elements in relation to the client who requests them. ii. Area: Users may be interested in tagging tasks, orders or order elements in relation to the areas in which they are carried out. -The administration of tag types is managed from the "Administration" menu option. This is where users can edit tag types, create new tag types and add tags to tag types. Users can access the list of tags from this option. +The administration of tag types is managed from the "Administration" menu option. +This is where users can edit tag types, create new tag types and add tags to tag types. Users can access the list of tags from this option. .. figure:: images/tag-types-list.png :scale: 50 @@ -28,7 +30,9 @@ i. Create a new tag type. ii. Edit an existing tag type. iii. Delete a tag type with all of its tags. -Editing and creating tags share the same form. From this form, the user can assign a name to the tag type, create or delete tags and store the changes. The procedure is as follows: +Editing and creating tags share the same form. +From this form, the user can assign a name to the tag type, create or delete tags and store the changes. +The procedure is as follows: i. Select a tag to edit or click the create button for a new one. ii. The system shows a form with a text entry for the name and a list of text entries with existing and assigned tags. @@ -46,7 +50,9 @@ vii. Users click "Save" or "Save and continue" to continue editing the form. Tags ==== -Tags are entities that belong to a tag type. These entities can be assigned to order elements. Assigning a tag to an order element means that all the elements descending from this element will inherit the tag to which they belong. Having an assigned tag means that these entities are filtered where searches can be carried out: +Tags are entities that belong to a tag type. These entities can be assigned to order elements. +Assigning a tag to an order element means that all the elements descending from this element will inherit the tag to which they belong. +Having an assigned tag means that these entities are filtered where searches can be carried out: i. Search for tasks in the Gantt chart. ii. Search for order elements in the list of order elements. diff --git a/doc/src/user/en/11-materiales.rst b/doc/src/user/en/11-materiales.rst index 1953780ca..4613579a4 100644 --- a/doc/src/user/en/11-materiales.rst +++ b/doc/src/user/en/11-materiales.rst @@ -1,5 +1,5 @@ Materials -########## +######### .. _materiales: .. contents:: @@ -9,7 +9,8 @@ Administration of materials Users can manage a basic database of materials, organised by categories. -The categories are containers that can be assigned specific materials and also more categories. They are stored in a tree structure as the materials can belong to leaf or intermediary categories. +The categories are containers that can be assigned specific materials and also more categories. +They are stored in a tree structure as the materials can belong to leaf or intermediary categories. Users have to do the following to manage categories: diff --git a/doc/src/user/en/12-formularios-calidad.rst b/doc/src/user/en/12-formularios-calidad.rst index 3a6e0b5f5..662eb8c58 100644 --- a/doc/src/user/en/12-formularios-calidad.rst +++ b/doc/src/user/en/12-formularios-calidad.rst @@ -1,5 +1,5 @@ Quality forms -###################### +############# .. _calidad: .. contents:: @@ -8,7 +8,8 @@ Quality forms Administration of quality forms =============================== -Quality forms consist of a list of questions or sentences that indicate the tasks or processes that should have been completed so that a task can be marked as complete by the company. These forms consist of the following fields: +Quality forms consist of a list of questions or sentences that indicate the tasks or processes that should have been +completed so that a task can be marked as complete by the company. These forms consist of the following fields: * Name * Description diff --git a/doc/src/user/en/14-custos.rst b/doc/src/user/en/14-custos.rst index f7d237f3c..b3182b878 100644 --- a/doc/src/user/en/14-custos.rst +++ b/doc/src/user/en/14-custos.rst @@ -1,5 +1,5 @@ Cost management -################# +############### .. _costes: .. contents:: @@ -25,7 +25,7 @@ Cost management allows users to estimate the costs of resources used in a projec Managing hour types worked ------------------------------------------- +-------------------------- Users need to carry out the following steps to register hour types worked: @@ -55,7 +55,7 @@ Users need to carry out the following steps to register hour types worked: * Click "Save" or "Save and continue". Cost categories -------------------- +--------------- Users need to carry out the following steps to register cost categories: diff --git a/doc/src/user/en/17-project-dashboard.rst b/doc/src/user/en/17-project-dashboard.rst index 4d74d9768..950d78e2f 100644 --- a/doc/src/user/en/17-project-dashboard.rst +++ b/doc/src/user/en/17-project-dashboard.rst @@ -119,7 +119,7 @@ overload)**. * > 0 is bad, meaning that the resources are overloaded. Availability ratio -------------------- +------------------ It sums up the capacity that is free in the resources currently allocated to the project. Therefore it is a measurement of the resource availability to receive more allocations without diff --git a/doc/src/user/en/18-connectors.rst b/doc/src/user/en/18-connectors.rst index ca302cb57..dacde434b 100644 --- a/doc/src/user/en/18-connectors.rst +++ b/doc/src/user/en/18-connectors.rst @@ -1,5 +1,5 @@ Connectors -################## +########## .. contents:: @@ -214,7 +214,7 @@ not available for that ``total duration``. But in Libreplan if the worker is on The Tim connector also takes care of this translation. E-mail connector -============== +================ E-mail is a method of exchanging digital messages from an author to one or more recipients. @@ -273,4 +273,4 @@ gathering data and sending it to user`s e-mail. See also the Scheduler manual. .. NOTE:: -The success or failure information would be displayed in pop-up window. \ No newline at end of file + The success or failure information would be displayed in pop-up window. diff --git a/doc/src/user/en/19-scheduler.rst b/doc/src/user/en/19-scheduler.rst index 9fe39d041..299225045 100644 --- a/doc/src/user/en/19-scheduler.rst +++ b/doc/src/user/en/19-scheduler.rst @@ -1,5 +1,5 @@ Scheduler -################## +######### .. contents:: @@ -44,7 +44,7 @@ The ``job scheduling list`` view allows users to * start a process manually Add or Edit Job -================= +=============== From the ``job scheduling list`` view, click * ``Create`` button to add a new Job or @@ -83,5 +83,4 @@ will be shown. Start Job Manually ================== As an alternative to wait until the Job is run as scheduled by the scheduler, you can click this button to start the -process directly. Afterwards the success/failure info will be shown in ``pop-up window``. - +process directly. Afterwards the success/failure info will be shown in ``pop-up window``. \ No newline at end of file diff --git a/doc/src/user/en/20-acerca-de.rst b/doc/src/user/en/20-acerca-de.rst index 864e5c915..5ba9afeb4 100644 --- a/doc/src/user/en/20-acerca-de.rst +++ b/doc/src/user/en/20-acerca-de.rst @@ -1,5 +1,5 @@ About -################# +##### .. _acercade: .. contents:: @@ -21,7 +21,7 @@ S.L. Licence -======== +======= This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -38,7 +38,7 @@ along with this program. If not, see . Written by -================ +========== LibrePlan Team -------------- @@ -109,15 +109,19 @@ Contributors Public funding -================================ +============== -Inside the global scope that LibrePlan is designed for regarding planning management, a project was developed to solve some common polanning problems. This project is partially financed by Xunta de Galicia, Ministerio de Industria, Turismo e Comercio, and by the European Union, Fondo Europeo de Desenvolvemento Rexional. +Inside the global scope that LibrePlan is designed for regarding planning management, +a project was developed to solve some common planning problems. +This project is partially financed by Xunta de Galicia, Ministerio de Industria, Turismo e Comercio, and by the European Union, +Fondo Europeo de Desenvolvemento Rexional. .. figure:: images/logos.png + :scale: 100 This project was part of Plan Avanza: .. figure:: images/avanza.png -:scale: 100 +:scale: 100 diff --git a/ganttzk/src/main/java/org/zkoss/ganttz/MilestoneComponent.java b/ganttzk/src/main/java/org/zkoss/ganttz/MilestoneComponent.java index 00423ec23..ecb18729f 100644 --- a/ganttzk/src/main/java/org/zkoss/ganttz/MilestoneComponent.java +++ b/ganttzk/src/main/java/org/zkoss/ganttz/MilestoneComponent.java @@ -29,8 +29,7 @@ import org.zkoss.ganttz.data.Task; */ public class MilestoneComponent extends TaskComponent { - public MilestoneComponent(Task task, - IDisabilityConfiguration disabilityConfiguration) { + public MilestoneComponent(Task task, IDisabilityConfiguration disabilityConfiguration) { super(task, disabilityConfiguration); } diff --git a/ganttzk/src/main/java/org/zkoss/ganttz/Planner.java b/ganttzk/src/main/java/org/zkoss/ganttz/Planner.java index 771cbe4f4..568d08154 100644 --- a/ganttzk/src/main/java/org/zkoss/ganttz/Planner.java +++ b/ganttzk/src/main/java/org/zkoss/ganttz/Planner.java @@ -74,12 +74,10 @@ import org.zkoss.zul.Combobox; public class Planner extends HtmlMacroComponent { + private static final String PLANNER_COMMAND = "planner-command"; + private static final Log PROFILING_LOG = ProfilingLogFactory.getLog(Planner.class); - private static int PIXELS_PER_TASK_LEVEL = 21; - - private static int PIXELS_PER_CHARACTER = 5; - private String EXPAND_ALL_BUTTON = "expandAll"; private GanttZKDiagramGraph diagramGraph; @@ -120,8 +118,7 @@ public class Planner extends HtmlMacroComponent { private Listbox listZoomLevels = null; - private WeakReferencedListeners chartVisibilityListeners = - WeakReferencedListeners.create(); + private WeakReferencedListeners chartVisibilityListeners = WeakReferencedListeners.create(); private IGraphChangeListener showCriticalPathOnChange = new IGraphChangeListener() { @Override @@ -163,7 +160,8 @@ public class Planner extends HtmlMacroComponent { private boolean visibleChart; - public Planner() {} + public Planner() { + } public static boolean guessContainersExpandedByDefaultGivenPrintParameters(Map printParameters) { return guessContainersExpandedByDefault(convertToURLParameters(printParameters)); @@ -180,30 +178,22 @@ public class Planner extends HtmlMacroComponent { public static boolean guessContainersExpandedByDefault(Map queryURLParameters) { String[] values = queryURLParameters.get("expanded"); - return values != null && toLowercaseSet(values).contains("all"); - } public static boolean guessShowAdvancesByDefault(Map queryURLParameters) { String[] values = queryURLParameters.get("advances"); - return values != null && toLowercaseSet(values).contains("all"); - } public static boolean guessShowReportedHoursByDefault(Map queryURLParameters) { String[] values = queryURLParameters.get("reportedHours"); - return values != null && toLowercaseSet(values).contains("all"); - } public static boolean guessShowMoneyCostBarByDefault(Map queryURLParameters) { String[] values = queryURLParameters.get("moneyCostBar"); - return values != null && toLowercaseSet(values).contains("all"); - } private static Set toLowercaseSet(String[] values) { @@ -233,6 +223,8 @@ public class Planner extends HtmlMacroComponent { IDomainAndBeansMapper mapper = getContext().getMapper(); int widest = 0; + int pixelsPerTaskLevel = 21; + int pixelsPerCharacter = 5; for (Task task : tasks) { int numberOfAncestors = mapper.findPositionFor(task).getAncestors().size(); @@ -240,7 +232,7 @@ public class Planner extends HtmlMacroComponent { widest = Math.max( widest, - numberOfCharacters * PIXELS_PER_CHARACTER + numberOfAncestors * PIXELS_PER_TASK_LEVEL); + numberOfCharacters * pixelsPerCharacter + numberOfAncestors * pixelsPerTaskLevel); if ( expand && !task.isLeaf() ) { widest = Math.max(widest, calculateMinimumWidthForTaskNameColumn(expand, task.getTasks())); @@ -451,7 +443,7 @@ public class Planner extends HtmlMacroComponent { + (System.currentTimeMillis() - timeSetupingAndAddingComponents) + " ms"); setAuService(new AuService() { - public boolean service(AuRequest request, boolean everError){ + public boolean service(AuRequest request, boolean everError) { String command = request.getCommand(); int zoomindex; int scrollLeft; @@ -493,6 +485,7 @@ public class Planner extends HtmlMacroComponent { private List> contextualize(FunctionalityExposedForExtensions context, List> commands) { + List> result = new ArrayList<>(); for (ICommandOnTask c : commands) { result.add(contextualize(context, c)); @@ -551,11 +544,11 @@ public class Planner extends HtmlMacroComponent { @SuppressWarnings("unchecked") private void insertGlobalCommands() { - Component commontoolbar = getCommonCommandsInsertionPoint(); + Component commonToolbar = getCommonCommandsInsertionPoint(); Component plannerToolbar = getSpecificCommandsInsertionPoint(); if ( !contextualizedGlobalCommands.isEmpty() ) { - commontoolbar.getChildren().removeAll(commontoolbar.getChildren()); + commonToolbar.getChildren().removeAll(commonToolbar.getChildren()); } for (CommandContextualized c : contextualizedGlobalCommands) { @@ -569,7 +562,7 @@ public class Planner extends HtmlMacroComponent { plannerToolbar.appendChild(c.toButton()); } } else { - commontoolbar.appendChild(c.toButton()); + commonToolbar.appendChild(c.toButton()); } } @@ -616,12 +609,12 @@ public class Planner extends HtmlMacroComponent { if ( isShowingCriticalPath ) { context.hideCriticalPath(); diagramGraph.removePostGraphChangeListener(showCriticalPathOnChange); - showCriticalPathButton.setSclass("planner-command"); + showCriticalPathButton.setSclass(PLANNER_COMMAND); showCriticalPathButton.setTooltiptext(_("Show critical path")); } else { context.showCriticalPath(); diagramGraph.addPostGraphChangeListener(showCriticalPathOnChange); - showCriticalPathButton.setSclass("planner-command clicked"); + showCriticalPathButton.setSclass(PLANNER_COMMAND + " clicked"); showCriticalPathButton.setTooltiptext(_("Hide critical path")); } @@ -643,7 +636,7 @@ public class Planner extends HtmlMacroComponent { if ( isShowingAdvances ) { context.hideAdvances(); diagramGraph.removePostGraphChangeListener(showAdvanceOnChange); - showAdvancesButton.setSclass("planner-command"); + showAdvancesButton.setSclass(PLANNER_COMMAND); showAdvancesButton.setTooltiptext(_("Show progress")); if ( progressTypesCombo.getItemCount() > 0 ) { @@ -652,7 +645,7 @@ public class Planner extends HtmlMacroComponent { } else { context.showAdvances(); diagramGraph.addPostGraphChangeListener(showAdvanceOnChange); - showAdvancesButton.setSclass("planner-command clicked"); + showAdvancesButton.setSclass(PLANNER_COMMAND + " clicked"); showAdvancesButton.setTooltiptext(_("Hide progress")); } @@ -667,12 +660,12 @@ public class Planner extends HtmlMacroComponent { if ( isShowingReportedHours ) { context.hideReportedHours(); diagramGraph.removePostGraphChangeListener(showReportedHoursOnChange); - showReportedHoursButton.setSclass("planner-command"); + showReportedHoursButton.setSclass(PLANNER_COMMAND); showReportedHoursButton.setTooltiptext(_("Show reported hours")); } else { context.showReportedHours(); diagramGraph.addPostGraphChangeListener(showReportedHoursOnChange); - showReportedHoursButton.setSclass("planner-command clicked"); + showReportedHoursButton.setSclass(PLANNER_COMMAND + " clicked"); showReportedHoursButton.setTooltiptext(_("Hide reported hours")); } @@ -686,12 +679,12 @@ public class Planner extends HtmlMacroComponent { if ( isShowingMoneyCostBar ) { context.hideMoneyCostBar(); diagramGraph.removePostGraphChangeListener(showMoneyCostBarOnChange); - showMoneyCostBarButton.setSclass("planner-command"); + showMoneyCostBarButton.setSclass(PLANNER_COMMAND); showMoneyCostBarButton.setTooltiptext(_("Show money cost bar")); } else { context.showMoneyCostBar(); diagramGraph.addPostGraphChangeListener(showMoneyCostBarOnChange); - showMoneyCostBarButton.setSclass("planner-command clicked"); + showMoneyCostBarButton.setSclass(PLANNER_COMMAND + " clicked"); showMoneyCostBarButton.setTooltiptext(_("Hide money cost bar")); } @@ -792,10 +785,10 @@ public class Planner extends HtmlMacroComponent { if ( isExpandAll ) { context.collapseAll(); - expandAllButton.setSclass("planner-command"); + expandAllButton.setSclass(PLANNER_COMMAND); } else { context.expandAll(); - expandAllButton.setSclass("planner-command clicked"); + expandAllButton.setSclass(PLANNER_COMMAND + " clicked"); } } @@ -806,7 +799,7 @@ public class Planner extends HtmlMacroComponent { Button expandAllButton = (Button) getFellow(EXPAND_ALL_BUTTON); if ( disabilityConfiguration.isExpandAllEnabled() ) { context.expandAll(); - expandAllButton.setSclass("planner-command clicked"); + expandAllButton.setSclass(PLANNER_COMMAND + " clicked"); } } @@ -841,10 +834,10 @@ public class Planner extends HtmlMacroComponent { if ( disabilityConfiguration.isFlattenTreeEnabled() ) { if (isFlattenTree) { predicate.setFilterContainers(false); - flattenTreeButton.setSclass("planner-command"); + flattenTreeButton.setSclass(PLANNER_COMMAND); } else { predicate.setFilterContainers(true); - flattenTreeButton.setSclass("planner-command clicked"); + flattenTreeButton.setSclass(PLANNER_COMMAND + " clicked"); } setTaskListPredicate(predicate); @@ -906,7 +899,6 @@ public class Planner extends HtmlMacroComponent { return c.toButton(); } } - return null; } @@ -941,7 +933,6 @@ public class Planner extends HtmlMacroComponent { } } } - return null; } diff --git a/ganttzk/src/main/java/org/zkoss/ganttz/adapters/PlannerConfiguration.java b/ganttzk/src/main/java/org/zkoss/ganttz/adapters/PlannerConfiguration.java index 47a5fc473..e13f5bb88 100644 --- a/ganttzk/src/main/java/org/zkoss/ganttz/adapters/PlannerConfiguration.java +++ b/ganttzk/src/main/java/org/zkoss/ganttz/adapters/PlannerConfiguration.java @@ -52,12 +52,14 @@ import org.zkoss.zk.ui.Component; */ public class PlannerConfiguration implements IDisabilityConfiguration { + private static final String PRINT_NOT_SUPPORTED = "print not supported"; + public interface IPrintAction { void doPrint(); void doPrint(Map parameters); - void doPrint(HashMap parameters, Planner planner); + void doPrint(Map parameters, Planner planner); } public interface IReloadChartListener { @@ -290,11 +292,9 @@ public class PlannerConfiguration implements IDisabilityConfiguration { } public static List> getStartConstraintsGiven(GanttDate notBeforeThan) { - if ( notBeforeThan != null ) { - return Collections.singletonList(biggerOrEqualThan(notBeforeThan)); - } - - return Collections.emptyList(); + return notBeforeThan != null + ? Collections.singletonList(biggerOrEqualThan(notBeforeThan)) + : Collections.emptyList(); } public List> getStartConstraints() { @@ -302,11 +302,9 @@ public class PlannerConfiguration implements IDisabilityConfiguration { } public static List> getEndConstraintsGiven(GanttDate notAfterThan) { - if ( notAfterThan != null ) { - return Collections.singletonList(lessOrEqualThan(notAfterThan)); - } - - return Collections.emptyList(); + return notAfterThan != null + ? Collections.singletonList(lessOrEqualThan(notAfterThan)) + : Collections.emptyList(); } public List> getEndConstraints() { @@ -430,21 +428,21 @@ public class PlannerConfiguration implements IDisabilityConfiguration { public void print() { if ( !isPrintEnabled() ) { - throw new UnsupportedOperationException("print not supported"); + throw new UnsupportedOperationException(PRINT_NOT_SUPPORTED); } printAction.doPrint(); } public void print(Map parameters) { if ( !isPrintEnabled() ) { - throw new UnsupportedOperationException("print not supported"); + throw new UnsupportedOperationException(PRINT_NOT_SUPPORTED); } printAction.doPrint(parameters); } public void print(HashMap parameters, Planner planner) { if ( !isPrintEnabled() ) { - throw new UnsupportedOperationException("print not supported"); + throw new UnsupportedOperationException(PRINT_NOT_SUPPORTED); } printAction.doPrint(parameters, planner); } diff --git a/ganttzk/src/main/java/org/zkoss/ganttz/util/Emitter.java b/ganttzk/src/main/java/org/zkoss/ganttz/util/Emitter.java index b671502f2..b9271983b 100644 --- a/ganttzk/src/main/java/org/zkoss/ganttz/util/Emitter.java +++ b/ganttzk/src/main/java/org/zkoss/ganttz/util/Emitter.java @@ -23,28 +23,27 @@ import java.util.ArrayList; import java.util.List; /** - * * @author Óscar González Fernández */ public class Emitter { public interface IEmissionListener { - public void newEmission(T value); + void newEmission(T value); } private T lastValue; - private List> listeners = new ArrayList>(); - - public static Emitter withInitial(T initialValue) { - return new Emitter(initialValue); - } + private List> listeners = new ArrayList<>(); private Emitter(T initialValue) { this.lastValue = initialValue; } + public static Emitter withInitial(T initialValue) { + return new Emitter<>(initialValue); + } + public T getLastValue() { return lastValue; } diff --git a/ganttzk/src/main/resources/web/js/ganttz/GanttPanel.js b/ganttzk/src/main/resources/web/js/ganttz/GanttPanel.js index b9104f65a..1e1b9dcb3 100644 --- a/ganttzk/src/main/resources/web/js/ganttz/GanttPanel.js +++ b/ganttzk/src/main/resources/web/js/ganttz/GanttPanel.js @@ -64,7 +64,7 @@ ganttz.GanttPanel = zk.$extends( /* * The canvas is inserted in the DOM after this component, so it's not available right now. * It is queried instead. - * Using throttle to not re-query it constantly + * Using throttle to not re-query it constantly. */ _getTimeplotContainer: common.Common.throttle(500, function() { return jq('canvas.timeplot-canvas').parent(); @@ -81,7 +81,7 @@ ganttz.GanttPanel = zk.$extends( jq('#ganttpanel_inner_scroller_y').height(px); }, - reScrollX : function(px){ + reScrollX : function(px) { jq('#ganttpanel_inner_scroller_x').width(px); } }, @@ -90,7 +90,7 @@ ganttz.GanttPanel = zk.$extends( return this._instance; }, - setInstance : function(instance){ + setInstance : function(instance) { this._instance = instance; } }); diff --git a/ganttzk/src/test/java/org/zkoss/ganttz/timetracker/OnColumnsRowRendererTest.java b/ganttzk/src/test/java/org/zkoss/ganttz/timetracker/OnColumnsRowRendererTest.java index b45d4a8fa..80d4883bb 100644 --- a/ganttzk/src/test/java/org/zkoss/ganttz/timetracker/OnColumnsRowRendererTest.java +++ b/ganttzk/src/test/java/org/zkoss/ganttz/timetracker/OnColumnsRowRendererTest.java @@ -43,7 +43,8 @@ import org.zkoss.zul.Label; public class OnColumnsRowRendererTest { - private static class Data {} + private static class Data { + } private static class CellRenderer implements ICellForDetailItemRenderer { @Override @@ -103,27 +104,27 @@ public class OnColumnsRowRendererTest { @Test(expected = NullPointerException.class) public void itNeedsTheTypeAsClass() { - OnColumnsRowRenderer.create(null, createStub(), new ArrayList()); + OnColumnsRowRenderer.create(null, createStub(), new ArrayList<>()); } @Test public void itCanHaveEmptyDetailItems() { - OnColumnsRowRenderer.create(Data.class, createStub(), new ArrayList()); + OnColumnsRowRenderer.create(Data.class, createStub(), new ArrayList<>()); } @Test public void itCanInferTheGenericType() { - OnColumnsRowRenderer.create(new CellRenderer(), new ArrayList()); + OnColumnsRowRenderer.create(new CellRenderer(), new ArrayList<>()); } @Test(expected = IllegalArgumentException.class) public void ifComesFromRawTypeIsNotInferrable() { - OnColumnsRowRenderer.create(createStub(), new ArrayList()); + OnColumnsRowRenderer.create(createStub(), new ArrayList<>()); } @Test(expected = IllegalArgumentException.class) public void ifItNotShowsTheActualTypeIsNotInferrable() { - OnColumnsRowRenderer.create(new CellRendererNotInferable(), new ArrayList()); + OnColumnsRowRenderer.create(new CellRendererNotInferable(), new ArrayList<>()); } @SuppressWarnings("serial") diff --git a/libreplan-business/src/main/java/org/libreplan/business/expensesheet/entities/ExpenseSheet.java b/libreplan-business/src/main/java/org/libreplan/business/expensesheet/entities/ExpenseSheet.java index 19d47f165..1aff5e2e8 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/expensesheet/entities/ExpenseSheet.java +++ b/libreplan-business/src/main/java/org/libreplan/business/expensesheet/entities/ExpenseSheet.java @@ -40,7 +40,7 @@ import org.libreplan.business.expensesheet.daos.IExpenseSheetDAO; import org.libreplan.business.resources.entities.Resource; /** - * ExpenseSheet Entity + * ExpenseSheet Entity. * * @author Susana Montes Pedreira */ @@ -57,8 +57,7 @@ public class ExpenseSheet extends IntegrationEntity implements IHumanIdentifiabl private boolean personal = false; @Valid - private SortedSet expenseSheetLines = new TreeSet<>( - new ExpenseSheetLineComparator()); + private SortedSet expenseSheetLines = new TreeSet<>(new ExpenseSheetLineComparator()); private Integer lastExpenseSheetLineSequenceCode = 0; @@ -78,8 +77,7 @@ public class ExpenseSheet extends IntegrationEntity implements IHumanIdentifiabl return create(new ExpenseSheet()); } - public static ExpenseSheet create(LocalDate firstExpense, LocalDate lastExpense, - BigDecimal total) { + public static ExpenseSheet create(LocalDate firstExpense, LocalDate lastExpense, BigDecimal total) { return create(new ExpenseSheet(firstExpense, lastExpense, total)); } @@ -120,6 +118,7 @@ public class ExpenseSheet extends IntegrationEntity implements IHumanIdentifiabl return Collections.unmodifiableSortedSet(expenseSheetLines); } + /** Field setter of entity, do not remove! */ public void setLastExpenseSheetLineSequenceCode(Integer lastExpenseSheetLineSequenceCode) { this.lastExpenseSheetLineSequenceCode = lastExpenseSheetLineSequenceCode; } @@ -144,11 +143,9 @@ public class ExpenseSheet extends IntegrationEntity implements IHumanIdentifiabl public void generateExpenseSheetLineCodes(int numberOfDigits) { for (ExpenseSheetLine line : this.getExpenseSheetLines()) { - if ((line.getCode() == null) || (line.getCode().isEmpty()) - || (!line.getCode().startsWith(this.getCode()))) { + if ((line.getCode() == null) || (line.getCode().isEmpty()) || (!line.getCode().startsWith(this.getCode()))) { this.incrementLastExpenseSheetLineSequenceCode(); - String lineCode = EntitySequence.formatValue(numberOfDigits, - this.getLastExpenseSheetLineSequenceCode()); + String lineCode = EntitySequence.formatValue(numberOfDigits, this.getLastExpenseSheetLineSequenceCode()); line.setCode(this.getCode() + EntitySequence.CODE_SEPARATOR_CHILDREN + lineCode); } } @@ -161,8 +158,7 @@ public class ExpenseSheet extends IntegrationEntity implements IHumanIdentifiabl lastExpenseSheetLineSequenceCode++; } - public void keepSortedExpenseSheetLines(ExpenseSheetLine expenseSheetLine, - LocalDate newDate) { + public void keepSortedExpenseSheetLines(ExpenseSheetLine expenseSheetLine, LocalDate newDate) { this.expenseSheetLines.remove(expenseSheetLine); expenseSheetLine.setDate(newDate); this.expenseSheetLines.add(expenseSheetLine); @@ -210,12 +206,10 @@ public class ExpenseSheet extends IntegrationEntity implements IHumanIdentifiabl return getCode() + (description != null ? description : ""); } - public ExpenseSheetLine getExpenseSheetLineByCode(String code) - throws ValidationException { + public ExpenseSheetLine getExpenseSheetLineByCode(String code) throws ValidationException { if (StringUtils.isBlank(code)) { - throw new ValidationException( - "missing the code with which find the expense sheet line"); + throw new ValidationException("missing the code with which find the expense sheet line"); } for (ExpenseSheetLine l : this.expenseSheetLines) { @@ -252,8 +246,7 @@ public class ExpenseSheet extends IntegrationEntity implements IHumanIdentifiabl for (ExpenseSheetLine line : expenseSheetLines) { Resource resourceLine = line.getResource(); - if ((resourceLine == null) - || (!resourceLine.getId().equals(resource.getId()))) { + if ((resourceLine == null) || (!resourceLine.getId().equals(resource.getId()))) { return false; } } diff --git a/libreplan-business/src/main/java/org/libreplan/business/expensesheet/entities/ExpenseSheetLine.java b/libreplan-business/src/main/java/org/libreplan/business/expensesheet/entities/ExpenseSheetLine.java index fa9ceb454..0e46acd4a 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/expensesheet/entities/ExpenseSheetLine.java +++ b/libreplan-business/src/main/java/org/libreplan/business/expensesheet/entities/ExpenseSheetLine.java @@ -31,7 +31,7 @@ import org.libreplan.business.orders.entities.OrderElement; import org.libreplan.business.resources.entities.Resource; /** - * ExpenseSheetLine Entity + * ExpenseSheetLine Entity. * * @author Susana Montes Pedreira */ @@ -53,19 +53,16 @@ public class ExpenseSheetLine extends IntegrationEntity { * Constructor for Hibernate. Do not use! */ protected ExpenseSheetLine() { - } - private ExpenseSheetLine(BigDecimal value, String concept, LocalDate date, - OrderElement orderElement) { + private ExpenseSheetLine(BigDecimal value, String concept, LocalDate date, OrderElement orderElement) { this.orderElement = orderElement; this.concept = concept; this.value = value; this.setDate(date); } - public static ExpenseSheetLine create(BigDecimal value, String concept, LocalDate date, - OrderElement orderElement) { + public static ExpenseSheetLine create(BigDecimal value, String concept, LocalDate date, OrderElement orderElement) { return create(new ExpenseSheetLine(value, concept, date, orderElement)); } @@ -80,13 +77,10 @@ public class ExpenseSheetLine extends IntegrationEntity { } private boolean isDifferent(BigDecimal value) { - if (this.value == null && value == null) { + if ( this.value == null && value == null ) { return false; } - if (this.value != null && value != null) { - return (this.value.compareTo(value) != 0); - } - return true; + return !(this.value != null && value != null) || this.value.compareTo(value) != 0; } @Min(message = "value must be greater or equal than 0", value = 0) @@ -134,13 +128,10 @@ public class ExpenseSheetLine extends IntegrationEntity { } private boolean isDifferent(LocalDate date) { - if (this.date == null && date == null) { + if ( this.date == null && date == null ) { return false; } - if (this.date != null && date != null) { - return (this.date.compareTo(date) != 0); - } - return true; + return !(this.date != null && date != null) || this.date.compareTo(date) != 0; } @NotNull(message = "date not specified") diff --git a/libreplan-business/src/main/resources/ehcache.xml b/libreplan-business/src/main/resources/ehcache.xml index b954dfede..793dc4586 100644 --- a/libreplan-business/src/main/resources/ehcache.xml +++ b/libreplan-business/src/main/resources/ehcache.xml @@ -124,4 +124,21 @@ timeToLiveSeconds="1800" overflowToDisk="false" /> + + + + + diff --git a/libreplan-business/src/main/resources/org/libreplan/business/advance/entities/Advance.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/advance/entities/Advance.hbm.xml index ecc6a5070..1f6a5854f 100644 --- a/libreplan-business/src/main/resources/org/libreplan/business/advance/entities/Advance.hbm.xml +++ b/libreplan-business/src/main/resources/org/libreplan/business/advance/entities/Advance.hbm.xml @@ -1,6 +1,5 @@ - + diff --git a/libreplan-business/src/main/resources/org/libreplan/business/expensesheets/entities/ExpenseSheets.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/expensesheets/entities/ExpenseSheets.hbm.xml index 5c1ac9aa5..fc253cc86 100644 --- a/libreplan-business/src/main/resources/org/libreplan/business/expensesheets/entities/ExpenseSheets.hbm.xml +++ b/libreplan-business/src/main/resources/org/libreplan/business/expensesheets/entities/ExpenseSheets.hbm.xml @@ -1,12 +1,13 @@ - + + + 100 @@ -33,7 +34,9 @@ + + 100 diff --git a/libreplan-business/src/main/resources/org/libreplan/business/logs/entities/Logs.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/logs/entities/Logs.hbm.xml index ff76b1619..66b2ec698 100644 --- a/libreplan-business/src/main/resources/org/libreplan/business/logs/entities/Logs.hbm.xml +++ b/libreplan-business/src/main/resources/org/libreplan/business/logs/entities/Logs.hbm.xml @@ -1,10 +1,10 @@ - + + 100 @@ -58,6 +58,7 @@ + 100 diff --git a/libreplan-business/src/test/java/org/libreplan/business/test/calendars/entities/BaseCalendarTest.java b/libreplan-business/src/test/java/org/libreplan/business/test/calendars/entities/BaseCalendarTest.java index b7463ac01..5f58ac897 100644 --- a/libreplan-business/src/test/java/org/libreplan/business/test/calendars/entities/BaseCalendarTest.java +++ b/libreplan-business/src/test/java/org/libreplan/business/test/calendars/entities/BaseCalendarTest.java @@ -49,36 +49,35 @@ import org.libreplan.business.workingday.ResourcesPerDay; /** * Tests for {@link BaseCalendar}. + * * @author Manuel Rego Casasnovas */ public class BaseCalendarTest { - public static final LocalDate JUNE_NEXT_YEAR = new LocalDate( - (new LocalDate()) - .getYear(), 6, 1).plusYears(1); + private static final LocalDate JUNE_NEXT_YEAR = new LocalDate((new LocalDate()).getYear(), 6, 1).plusYears(1); - public static final LocalDate MONDAY_LOCAL_DATE = JUNE_NEXT_YEAR - .dayOfWeek().withMinimumValue(); - public static final LocalDate TUESDAY_LOCAL_DATE = MONDAY_LOCAL_DATE - .plusDays(1); - public static final LocalDate WEDNESDAY_LOCAL_DATE = MONDAY_LOCAL_DATE - .plusDays(2); - public static final LocalDate THURSDAY_LOCAL_DATE = MONDAY_LOCAL_DATE - .plusDays(3); - public static final LocalDate FRIDAY_LOCAL_DATE = MONDAY_LOCAL_DATE - .plusDays(4); - public static final LocalDate SATURDAY_LOCAL_DATE = MONDAY_LOCAL_DATE - .plusDays(5); - public static final LocalDate SUNDAY_LOCAL_DATE = MONDAY_LOCAL_DATE - .plusDays(6); + private static final LocalDate MONDAY_LOCAL_DATE = JUNE_NEXT_YEAR.dayOfWeek().withMinimumValue(); + + private static final LocalDate TUESDAY_LOCAL_DATE = MONDAY_LOCAL_DATE.plusDays(1); + + private static final LocalDate WEDNESDAY_LOCAL_DATE = MONDAY_LOCAL_DATE.plusDays(2); + + private static final LocalDate THURSDAY_LOCAL_DATE = MONDAY_LOCAL_DATE.plusDays(3); + + private static final LocalDate FRIDAY_LOCAL_DATE = MONDAY_LOCAL_DATE.plusDays(4); + + private static final LocalDate SATURDAY_LOCAL_DATE = MONDAY_LOCAL_DATE.plusDays(5); + + private static final LocalDate SUNDAY_LOCAL_DATE = MONDAY_LOCAL_DATE.plusDays(6); private static final LocalDate[] DAYS_OF_A_WEEK_EXAMPLE = { - MONDAY_LOCAL_DATE, TUESDAY_LOCAL_DATE, WEDNESDAY_LOCAL_DATE, - THURSDAY_LOCAL_DATE, FRIDAY_LOCAL_DATE, SATURDAY_LOCAL_DATE, - SUNDAY_LOCAL_DATE }; + MONDAY_LOCAL_DATE, TUESDAY_LOCAL_DATE, + WEDNESDAY_LOCAL_DATE, THURSDAY_LOCAL_DATE, + FRIDAY_LOCAL_DATE, SATURDAY_LOCAL_DATE, + SUNDAY_LOCAL_DATE + }; - public static final LocalDate CHRISTMAS_DAY_LOCAL_DATE = new LocalDate( - JUNE_NEXT_YEAR.getYear(), 12, 25); + public static final LocalDate CHRISTMAS_DAY_LOCAL_DATE = new LocalDate(JUNE_NEXT_YEAR.getYear(), 12, 25); public static BaseCalendar createBasicCalendar() { BaseCalendar calendar = BaseCalendar.create(); @@ -98,10 +97,10 @@ public class BaseCalendarTest { } /** - * Creates a {@link Capacity} with normal {@link EffortDuration} and no - * extra hours limit + * Creates a {@link Capacity} with normal {@link EffortDuration} and no extra hours limit. + * * @param effort - * @return + * @return {@link Capacity} */ private static Capacity withNormalDuration(EffortDuration effort) { return Capacity.create(effort).overAssignableWithoutLimit(); @@ -114,15 +113,13 @@ public class BaseCalendarTest { } public static CalendarExceptionType createCalendarExceptionType() { - CalendarExceptionType result = CalendarExceptionType.create("TEST", - CalendarExceptionTypeColor.DEFAULT, true); - return result; + return CalendarExceptionType.create("TEST", CalendarExceptionTypeColor.DEFAULT, true); } public static void addChristmasAsExceptionDay(BaseCalendar calendar) { - CalendarException christmasDay = CalendarException.create( - CHRISTMAS_DAY_LOCAL_DATE, EffortDuration.zero(), - createCalendarExceptionType()); + + CalendarException christmasDay = + CalendarException.create(CHRISTMAS_DAY_LOCAL_DATE, EffortDuration.zero(), createCalendarExceptionType()); calendar.addExceptionDay(christmasDay); } @@ -152,7 +149,7 @@ public class BaseCalendarTest { assertFalse(calendar.onlyGivesZeroHours()); } - public static BaseCalendar createChristmasCalendar() { + private static BaseCalendar createChristmasCalendar() { BaseCalendar calendar = createBasicCalendar(); addChristmasAsExceptionDay(calendar); return calendar; @@ -162,12 +159,10 @@ public class BaseCalendarTest { public void testCapacityOnBasic() { BaseCalendar calendar = createBasicCalendar(); - EffortDuration wednesdayHours = calendar - .getCapacityOn(wholeDay(WEDNESDAY_LOCAL_DATE)); + EffortDuration wednesdayHours = calendar.getCapacityOn(wholeDay(WEDNESDAY_LOCAL_DATE)); assertThat(wednesdayHours, equalTo(hours(8))); - EffortDuration sundayHours = calendar - .getCapacityOn(wholeDay(SUNDAY_LOCAL_DATE)); + EffortDuration sundayHours = calendar.getCapacityOn(wholeDay(SUNDAY_LOCAL_DATE)); assertThat(sundayHours, equalTo(zero())); } @@ -181,8 +176,7 @@ public class BaseCalendarTest { public void testCapacityOnChristmas() { BaseCalendar calendar = createChristmasCalendar(); - EffortDuration duration = calendar - .getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE)); + EffortDuration duration = calendar.getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE)); assertThat(duration, equalTo(EffortDuration.zero())); } @@ -198,12 +192,10 @@ public class BaseCalendarTest { public void testCapacityOnDerivedBasicCalendar() { BaseCalendar calendar = createBasicCalendar().newDerivedCalendar(); - EffortDuration wednesdayHours = calendar - .getCapacityOn(wholeDay(WEDNESDAY_LOCAL_DATE)); + EffortDuration wednesdayHours = calendar.getCapacityOn(wholeDay(WEDNESDAY_LOCAL_DATE)); assertThat(wednesdayHours, equalTo(hours(8))); - EffortDuration sundayHours = calendar - .getCapacityOn(wholeDay(SUNDAY_LOCAL_DATE)); + EffortDuration sundayHours = calendar.getCapacityOn(wholeDay(SUNDAY_LOCAL_DATE)); assertThat(sundayHours, equalTo(zero())); } @@ -211,8 +203,7 @@ public class BaseCalendarTest { public void testCapacityOnDerivedChristmasCalendar() { BaseCalendar calendar = createChristmasCalendar().newDerivedCalendar(); - EffortDuration hours = calendar - .getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE)); + EffortDuration hours = calendar.getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE)); assertThat(hours, equalTo(EffortDuration.zero())); } @@ -220,20 +211,16 @@ public class BaseCalendarTest { public void testCapacityOnDerivedBasicCalendarWithException() { BaseCalendar calendar = createBasicCalendar().newDerivedCalendar(); - CalendarException day = CalendarException.create(WEDNESDAY_LOCAL_DATE, - hours(4), createCalendarExceptionType()); + CalendarException day = CalendarException.create(WEDNESDAY_LOCAL_DATE, hours(4), createCalendarExceptionType()); calendar.addExceptionDay(day); - EffortDuration mondayHours = calendar - .getCapacityOn(wholeDay(MONDAY_LOCAL_DATE)); + EffortDuration mondayHours = calendar.getCapacityOn(wholeDay(MONDAY_LOCAL_DATE)); assertThat(mondayHours, equalTo(hours(8))); - EffortDuration wednesdayHours = calendar - .getCapacityOn(wholeDay(WEDNESDAY_LOCAL_DATE)); + EffortDuration wednesdayHours = calendar.getCapacityOn(wholeDay(WEDNESDAY_LOCAL_DATE)); assertThat(wednesdayHours, equalTo(hours(4))); - EffortDuration sundayHours = calendar - .getCapacityOn(wholeDay(SUNDAY_LOCAL_DATE)); + EffortDuration sundayHours = calendar.getCapacityOn(wholeDay(SUNDAY_LOCAL_DATE)); assertThat(sundayHours, equalTo(zero())); } @@ -241,13 +228,10 @@ public class BaseCalendarTest { public void testCapacityOnDerivedChristmasCalendarRedefiningExceptionDay() { BaseCalendar calendar = createChristmasCalendar().newDerivedCalendar(); - CalendarException day = CalendarException.create( - CHRISTMAS_DAY_LOCAL_DATE, hours(4), - createCalendarExceptionType()); + CalendarException day = CalendarException.create(CHRISTMAS_DAY_LOCAL_DATE, hours(4), createCalendarExceptionType()); calendar.addExceptionDay(day); - EffortDuration hours = calendar - .getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE)); + EffortDuration hours = calendar.getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE)); assertThat(hours, equalTo(hours(4))); } @@ -255,15 +239,13 @@ public class BaseCalendarTest { public void testCapacityOnInterval() { BaseCalendar calendar = createBasicCalendar(); - int mondayToWednesdayHours = calendar.getWorkableHours( - MONDAY_LOCAL_DATE, WEDNESDAY_LOCAL_DATE); + int mondayToWednesdayHours = calendar.getWorkableHours(MONDAY_LOCAL_DATE, WEDNESDAY_LOCAL_DATE); assertThat(mondayToWednesdayHours, equalTo(24)); } @Test public void testCapacityOnPerWeek() { BaseCalendar calendar = createBasicCalendar(); - int weekHours = calendar.getWorkableHoursPerWeek(WEDNESDAY_LOCAL_DATE); assertThat(weekHours, equalTo(40)); } @@ -272,12 +254,10 @@ public class BaseCalendarTest { public void testAddTwoExceptionDaysInTheSameDate() { BaseCalendar calendar = createBasicCalendar(); - CalendarException day = CalendarException.create(MONDAY_LOCAL_DATE, - hours(8), createCalendarExceptionType()); + CalendarException day = CalendarException.create(MONDAY_LOCAL_DATE, hours(8), createCalendarExceptionType()); calendar.addExceptionDay(day); - CalendarException day2 = CalendarException.create(MONDAY_LOCAL_DATE, - hours(4), createCalendarExceptionType()); + CalendarException day2 = CalendarException.create(MONDAY_LOCAL_DATE, hours(4), createCalendarExceptionType()); calendar.addExceptionDay(day2); } @@ -285,7 +265,6 @@ public class BaseCalendarTest { public void testCreateNewVersion() { BaseCalendar calendar = createBasicCalendar(); calendar.newVersion((new LocalDate()).plusDays(1)); - assertThat(calendar.getCalendarDataVersions().size(), equalTo(2)); } @@ -325,18 +304,13 @@ public class BaseCalendarTest { calendar.setCapacityAt(Days.WEDNESDAY, withNormalDuration(hours(4))); calendar.setCapacityAt(Days.SUNDAY, withNormalDuration(hours(4))); - assertThat(calendar.getCapacityOn(wholeDay(WEDNESDAY_LOCAL_DATE)), - equalTo(hours(4))); + assertThat(calendar.getCapacityOn(wholeDay(WEDNESDAY_LOCAL_DATE)), equalTo(hours(4))); - assertThat(calendar.getCapacityOn(wholeDay(WEDNESDAY_LOCAL_DATE - .minusWeeks(1))), equalTo(hours(8))); + assertThat(calendar.getCapacityOn(wholeDay(WEDNESDAY_LOCAL_DATE.minusWeeks(1))), equalTo(hours(8))); - assertThat(calendar.getCapacityOn(wholeDay(SUNDAY_LOCAL_DATE)), - equalTo(hours(4))); + assertThat(calendar.getCapacityOn(wholeDay(SUNDAY_LOCAL_DATE)), equalTo(hours(4))); - assertThat(calendar.getCapacityOn(wholeDay(SUNDAY_LOCAL_DATE - .minusWeeks(1))), - equalTo(zero())); + assertThat(calendar.getCapacityOn(wholeDay(SUNDAY_LOCAL_DATE.minusWeeks(1))), equalTo(zero())); } @Test @@ -347,19 +321,13 @@ public class BaseCalendarTest { calendar.setCapacityAt(Days.MONDAY, withNormalDuration(hours(1))); calendar.setCapacityAt(Days.SUNDAY, withNormalDuration(hours(2))); - assertThat(calendar.getCapacityOn(wholeDay(MONDAY_LOCAL_DATE)), - equalTo(hours(1))); + assertThat(calendar.getCapacityOn(wholeDay(MONDAY_LOCAL_DATE)), equalTo(hours(1))); - assertThat(calendar.getCapacityOn(wholeDay(SUNDAY_LOCAL_DATE)), - equalTo(hours(2))); + assertThat(calendar.getCapacityOn(wholeDay(SUNDAY_LOCAL_DATE)), equalTo(hours(2))); - assertThat(calendar.getCapacityOn(wholeDay(MONDAY_LOCAL_DATE - .minusWeeks(1))), - equalTo(hours(8))); + assertThat(calendar.getCapacityOn(wholeDay(MONDAY_LOCAL_DATE.minusWeeks(1))), equalTo(hours(8))); - assertThat(calendar.getCapacityOn(wholeDay(MONDAY_LOCAL_DATE - .minusDays(1))), - equalTo(zero())); + assertThat(calendar.getCapacityOn(wholeDay(MONDAY_LOCAL_DATE.minusDays(1))), equalTo(zero())); } @Test @@ -374,7 +342,6 @@ public class BaseCalendarTest { @Test(expected = IllegalArgumentException.class) public void testRemoveExceptionDayDerivedCalendar() { BaseCalendar calendar = createChristmasCalendar().newDerivedCalendar(); - calendar.removeExceptionDay(CHRISTMAS_DAY_LOCAL_DATE); } @@ -391,23 +358,23 @@ public class BaseCalendarTest { @Test public void testCapacityOnNewVersionFromChristmasCalendar() { BaseCalendar calendar = createChristmasCalendar(); + CalendarException day = CalendarException.create( - CHRISTMAS_DAY_LOCAL_DATE.plusYears(1), EffortDuration.zero(), - createCalendarExceptionType()); + CHRISTMAS_DAY_LOCAL_DATE.plusYears(1), EffortDuration.zero(), createCalendarExceptionType()); + calendar.addExceptionDay(day); calendar.newVersion(CHRISTMAS_DAY_LOCAL_DATE.plusDays(1)); CalendarExceptionType type = createCalendarExceptionType(); - calendar.updateExceptionDay(CHRISTMAS_DAY_LOCAL_DATE.plusYears(1), - Capacity.create(hours(8)).withAllowedExtraEffort( - type.getCapacity().getAllowedExtraEffort()), type); - assertThat(calendar.getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE - .plusYears(1))), equalTo(hours(8))); + calendar.updateExceptionDay( + CHRISTMAS_DAY_LOCAL_DATE.plusYears(1), + Capacity.create(hours(8)).withAllowedExtraEffort(type.getCapacity().getAllowedExtraEffort()), + type); - assertThat(calendar.getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE)), - equalTo(zero())); + assertThat(calendar.getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE.plusYears(1))), equalTo(hours(8))); + assertThat(calendar.getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE)), equalTo(zero())); } public static void setHoursForAllDays(BaseCalendar calendar, Integer hours) { @@ -428,14 +395,11 @@ public class BaseCalendarTest { calendar.newVersion(FRIDAY_LOCAL_DATE); setHoursForAllDays(calendar, 2); - assertThat(calendar.getCapacityOn(wholeDay(MONDAY_LOCAL_DATE)), - equalTo(hours(8))); + assertThat(calendar.getCapacityOn(wholeDay(MONDAY_LOCAL_DATE)), equalTo(hours(8))); - assertThat(calendar.getCapacityOn(wholeDay(WEDNESDAY_LOCAL_DATE)), - equalTo(hours(4))); + assertThat(calendar.getCapacityOn(wholeDay(WEDNESDAY_LOCAL_DATE)), equalTo(hours(4))); - assertThat(calendar.getCapacityOn(wholeDay(FRIDAY_LOCAL_DATE)), - equalTo(hours(2))); + assertThat(calendar.getCapacityOn(wholeDay(FRIDAY_LOCAL_DATE)), equalTo(hours(2))); } @@ -449,36 +413,29 @@ public class BaseCalendarTest { calendar.newVersion(WEDNESDAY_LOCAL_DATE); setHoursForAllDays(calendar, 2); - assertThat(baseCalendar.getCapacityOn(wholeDay(MONDAY_LOCAL_DATE)), - equalTo(hours(8))); + assertThat(baseCalendar.getCapacityOn(wholeDay(MONDAY_LOCAL_DATE)), equalTo(hours(8))); - assertThat(calendar.getCapacityOn(wholeDay(MONDAY_LOCAL_DATE)), - equalTo(hours(4))); + assertThat(calendar.getCapacityOn(wholeDay(MONDAY_LOCAL_DATE)), equalTo(hours(4))); - assertThat(baseCalendar.getCapacityOn(wholeDay(FRIDAY_LOCAL_DATE)), - equalTo(hours(8))); + assertThat(baseCalendar.getCapacityOn(wholeDay(FRIDAY_LOCAL_DATE)), equalTo(hours(8))); - assertThat(calendar.getCapacityOn(wholeDay(FRIDAY_LOCAL_DATE)), - equalTo(hours(2))); + assertThat(calendar.getCapacityOn(wholeDay(FRIDAY_LOCAL_DATE)), equalTo(hours(2))); - assertThat(calendar.getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE)), - equalTo(zero())); + assertThat(calendar.getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE)), equalTo(zero())); } @Test public void testAddExceptionToNewVersionCalendar() { BaseCalendar calendar = createBasicCalendar(); - calendar.newVersion(CHRISTMAS_DAY_LOCAL_DATE - .plusDays(1)); + calendar.newVersion(CHRISTMAS_DAY_LOCAL_DATE.plusDays(1)); CalendarException day = CalendarException.create( - CHRISTMAS_DAY_LOCAL_DATE, EffortDuration.zero(), - createCalendarExceptionType()); + CHRISTMAS_DAY_LOCAL_DATE, EffortDuration.zero(), createCalendarExceptionType()); + calendar.addExceptionDay(day); assertThat(calendar.getExceptions().size(), equalTo(1)); - assertThat(calendar.getExceptions().iterator().next().getDate(), - equalTo(CHRISTMAS_DAY_LOCAL_DATE)); + assertThat(calendar.getExceptions().iterator().next().getDate(), equalTo(CHRISTMAS_DAY_LOCAL_DATE)); } @Test @@ -489,8 +446,7 @@ public class BaseCalendarTest { private void thenForAllDaysReturnsZero() { for (LocalDate localDate : DAYS_OF_A_WEEK_EXAMPLE) { - assertThat(calendarFixture.getCapacityOn(wholeDay(localDate)), - equalTo(zero())); + assertThat(calendarFixture.getCapacityOn(wholeDay(localDate)), equalTo(zero())); } } @@ -534,15 +490,11 @@ public class BaseCalendarTest { BaseCalendar calendar = createChristmasCalendar(); BaseCalendar derived = calendar.newDerivedCalendar(); - assertThat(calendar.getExceptionDay(CHRISTMAS_DAY_LOCAL_DATE), - notNullValue()); - assertThat(derived.getExceptionDay(CHRISTMAS_DAY_LOCAL_DATE), - notNullValue()); + assertThat(calendar.getExceptionDay(CHRISTMAS_DAY_LOCAL_DATE), notNullValue()); + assertThat(derived.getExceptionDay(CHRISTMAS_DAY_LOCAL_DATE), notNullValue()); - assertThat(calendar.getOwnExceptionDay(CHRISTMAS_DAY_LOCAL_DATE), - notNullValue()); - assertThat(derived.getOwnExceptionDay(CHRISTMAS_DAY_LOCAL_DATE), - nullValue()); + assertThat(calendar.getOwnExceptionDay(CHRISTMAS_DAY_LOCAL_DATE), notNullValue()); + assertThat(derived.getOwnExceptionDay(CHRISTMAS_DAY_LOCAL_DATE), nullValue()); } @Test @@ -564,8 +516,7 @@ public class BaseCalendarTest { calendar.setParent(parent); assertThat(calendar.getParent(), equalTo(parent)); - assertThat(calendar.getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE)), - equalTo(zero())); + assertThat(calendar.getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE)), equalTo(zero())); } @Test @@ -574,8 +525,7 @@ public class BaseCalendarTest { BaseCalendar derived = calendar.newDerivedCalendar(); BaseCalendar copy = derived.newCopy(); - assertThat(copy.getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE)), - equalTo(zero())); + assertThat(copy.getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE)), equalTo(zero())); assertThat(copy.getParent(), equalTo(calendar)); assertThat(copy.getCalendarDataVersions().size(), equalTo(1)); } @@ -599,14 +549,11 @@ public class BaseCalendarTest { calendar.setParent(parent2); assertThat(calendar.getParent(), equalTo(parent2)); - assertThat(calendar.getParent(MONDAY_LOCAL_DATE), - equalTo(parent1)); + assertThat(calendar.getParent(MONDAY_LOCAL_DATE), equalTo(parent1)); - assertThat(calendar.getCapacityOn(wholeDay(MONDAY_LOCAL_DATE)), - equalTo(hours(8))); + assertThat(calendar.getCapacityOn(wholeDay(MONDAY_LOCAL_DATE)), equalTo(hours(8))); - assertThat(calendar.getCapacityOn(wholeDay(FRIDAY_LOCAL_DATE)), - equalTo(hours(4))); + assertThat(calendar.getCapacityOn(wholeDay(FRIDAY_LOCAL_DATE)), equalTo(hours(4))); } @Test @@ -614,16 +561,12 @@ public class BaseCalendarTest { BaseCalendar calendar = createBasicCalendar(); calendar.newVersion(WEDNESDAY_LOCAL_DATE); - calendar.addExceptionDay(CalendarException.create(MONDAY_LOCAL_DATE, - zero(), createCalendarExceptionType())); - calendar.addExceptionDay(CalendarException.create(FRIDAY_LOCAL_DATE, - zero(), createCalendarExceptionType())); + calendar.addExceptionDay(CalendarException.create(MONDAY_LOCAL_DATE, zero(), createCalendarExceptionType())); + calendar.addExceptionDay(CalendarException.create(FRIDAY_LOCAL_DATE, zero(), createCalendarExceptionType())); - assertThat(calendar.getCapacityOn(wholeDay(MONDAY_LOCAL_DATE)), - equalTo(zero())); + assertThat(calendar.getCapacityOn(wholeDay(MONDAY_LOCAL_DATE)), equalTo(zero())); - assertThat(calendar.getCapacityOn(wholeDay(FRIDAY_LOCAL_DATE)), - equalTo(zero())); + assertThat(calendar.getCapacityOn(wholeDay(FRIDAY_LOCAL_DATE)), equalTo(zero())); assertThat(calendar.getOwnExceptions().size(), equalTo(2)); } @@ -633,9 +576,7 @@ public class BaseCalendarTest { BaseCalendar calendar = createBasicCalendar(); LocalDate pastMonth = (new LocalDate()).minusMonths(1); - CalendarException exceptionDay = CalendarException.create(pastMonth, - zero(), - createCalendarExceptionType()); + CalendarException exceptionDay = CalendarException.create(pastMonth, zero(), createCalendarExceptionType()); calendar.addExceptionDay(exceptionDay); } @@ -645,8 +586,7 @@ public class BaseCalendarTest { BaseCalendar calendar = createBasicCalendar(); LocalDate pastMonth = (new LocalDate()).minusMonths(1); - CalendarException exceptionDay = CalendarException.create(pastMonth, - zero(), createCalendarExceptionType()); + CalendarException exceptionDay = CalendarException.create(pastMonth, zero(), createCalendarExceptionType()); calendar.addExceptionDay(exceptionDay); calendar.removeExceptionDay(pastMonth); @@ -669,23 +609,18 @@ public class BaseCalendarTest { LocalDate currentDate = new LocalDate(); calendar.newVersion(currentDate.plusWeeks(4)); - assertThat(calendar.getExpiringDate(currentDate), equalTo(currentDate - .plusWeeks(4))); - assertThat(calendar.getExpiringDate(currentDate.plusWeeks(4)), - nullValue()); + assertThat(calendar.getExpiringDate(currentDate), equalTo(currentDate.plusWeeks(4))); + assertThat(calendar.getExpiringDate(currentDate.plusWeeks(4)), nullValue()); calendar.setExpiringDate(currentDate.plusWeeks(2), currentDate); - assertThat(calendar.getExpiringDate(currentDate), equalTo(currentDate - .plusWeeks(2))); - assertThat(calendar.getExpiringDate(currentDate.plusWeeks(4)), - nullValue()); + assertThat(calendar.getExpiringDate(currentDate), equalTo(currentDate.plusWeeks(2))); + assertThat(calendar.getExpiringDate(currentDate.plusWeeks(4)), nullValue()); } @Test public void testAllowNewVersionOnCurrentDate() { BaseCalendar calendar = createBasicCalendar(); - calendar.newVersion(new LocalDate()); } @@ -705,15 +640,12 @@ public class BaseCalendarTest { calendar.newVersion(currentDate.plusWeeks(4)); assertThat(calendar.getValidFrom(currentDate), nullValue()); - assertThat(calendar.getValidFrom(currentDate.plusWeeks(4)), - equalTo(currentDate.plusWeeks(4))); + assertThat(calendar.getValidFrom(currentDate.plusWeeks(4)), equalTo(currentDate.plusWeeks(4))); - calendar.setValidFrom(currentDate.plusWeeks(2), currentDate - .plusWeeks(4)); + calendar.setValidFrom(currentDate.plusWeeks(2), currentDate.plusWeeks(4)); assertThat(calendar.getValidFrom(currentDate), nullValue()); - assertThat(calendar.getValidFrom(currentDate.plusWeeks(4)), - equalTo(currentDate.plusWeeks(2))); + assertThat(calendar.getValidFrom(currentDate.plusWeeks(4)), equalTo(currentDate.plusWeeks(2))); } @Test @@ -741,12 +673,10 @@ public class BaseCalendarTest { public void testGetNonWorkableDays() { BaseCalendar calendar = createBasicCalendar(); - Set nonWorkableDays = calendar.getNonWorkableDays( - MONDAY_LOCAL_DATE, WEDNESDAY_LOCAL_DATE); + Set nonWorkableDays = calendar.getNonWorkableDays(MONDAY_LOCAL_DATE, WEDNESDAY_LOCAL_DATE); assertTrue(nonWorkableDays.isEmpty()); - nonWorkableDays = calendar.getNonWorkableDays(MONDAY_LOCAL_DATE, - SUNDAY_LOCAL_DATE); + nonWorkableDays = calendar.getNonWorkableDays(MONDAY_LOCAL_DATE, SUNDAY_LOCAL_DATE); assertFalse(nonWorkableDays.isEmpty()); assertTrue(nonWorkableDays.contains(SATURDAY_LOCAL_DATE)); assertTrue(nonWorkableDays.contains(SUNDAY_LOCAL_DATE)); @@ -755,26 +685,28 @@ public class BaseCalendarTest { @Test public void aCalendarHasAMethodToConvertAnAmountOfResourcesPerDayToAEffortDuration() { BaseCalendar calendar = createBasicCalendar(); - assertThat(calendar.asDurationOn( - PartialDay.wholeDay(MONDAY_LOCAL_DATE), - ResourcesPerDay.amount(1)), equalTo(hours(8))); - assertThat(calendar.asDurationOn( - PartialDay.wholeDay(MONDAY_LOCAL_DATE), - ResourcesPerDay.amount(2)), equalTo(hours(16))); + + assertThat( + calendar.asDurationOn(PartialDay.wholeDay(MONDAY_LOCAL_DATE), ResourcesPerDay.amount(1)), + equalTo(hours(8))); + + assertThat( + calendar.asDurationOn(PartialDay.wholeDay(MONDAY_LOCAL_DATE), ResourcesPerDay.amount(2)), + equalTo(hours(16))); } @Test public void asDurationOnRespectsTheOverAssignablePropertyOfCalendarData() { BaseCalendar calendar = createBasicCalendar(); - calendar.setCapacityAt(Days.MONDAY, Capacity.create(hours(8)) - .overAssignableWithoutLimit()); + calendar.setCapacityAt(Days.MONDAY, Capacity.create(hours(8)).overAssignableWithoutLimit()); - assertThat(calendar.asDurationOn( - PartialDay.wholeDay(MONDAY_LOCAL_DATE), - ResourcesPerDay.amount(1)), equalTo(hours(8))); - assertThat(calendar.asDurationOn( - PartialDay.wholeDay(MONDAY_LOCAL_DATE), - ResourcesPerDay.amount(2)), equalTo(hours(16))); + assertThat( + calendar.asDurationOn(PartialDay.wholeDay(MONDAY_LOCAL_DATE), ResourcesPerDay.amount(1)), + equalTo(hours(8))); + + assertThat( + calendar.asDurationOn(PartialDay.wholeDay(MONDAY_LOCAL_DATE), ResourcesPerDay.amount(2)), + equalTo(hours(16))); } @Test(expected = NullPointerException.class) @@ -786,97 +718,95 @@ public class BaseCalendarTest { @Test public void getCapacityWithOvertimeOnReturnsTheCapacityForThatDay() { BaseCalendar calendar = createBasicCalendar(); - Capacity capacitySet = Capacity.create(hours(8)) - .overAssignableWithoutLimit(); + Capacity capacitySet = Capacity.create(hours(8)).overAssignableWithoutLimit(); calendar.setCapacityAt(Days.MONDAY, capacitySet); - assertThat(calendar.getCapacityWithOvertime(MONDAY_LOCAL_DATE), - equalTo(capacitySet)); + assertThat(calendar.getCapacityWithOvertime(MONDAY_LOCAL_DATE), equalTo(capacitySet)); } @Test public void asDurationOnRespectsTheNotOverAssignablePropertyOfCalendarData() { BaseCalendar calendar = createBasicCalendar(); - calendar.setCapacityAt(Days.MONDAY, Capacity.create(hours(8)) - .notOverAssignableWithoutLimit()); + calendar.setCapacityAt(Days.MONDAY, Capacity.create(hours(8)).notOverAssignableWithoutLimit()); - assertThat(calendar.asDurationOn( - PartialDay.wholeDay(MONDAY_LOCAL_DATE), - ResourcesPerDay.amount(1)), equalTo(hours(8))); - assertThat(calendar.asDurationOn( - PartialDay.wholeDay(MONDAY_LOCAL_DATE), - ResourcesPerDay.amount(2)), equalTo(hours(8))); + assertThat( + calendar.asDurationOn(PartialDay.wholeDay(MONDAY_LOCAL_DATE), ResourcesPerDay.amount(1)), + equalTo(hours(8))); + + assertThat( + calendar.asDurationOn(PartialDay.wholeDay(MONDAY_LOCAL_DATE), ResourcesPerDay.amount(2)), + equalTo(hours(8))); } @Test public void DurationOnRespectsTheExtraEffortPropertyOfCalendarData() { BaseCalendar calendar = createBasicCalendar(); - calendar.setCapacityAt(Days.MONDAY, Capacity.create(hours(8)) - .withAllowedExtraEffort(hours(2))); + calendar.setCapacityAt(Days.MONDAY, Capacity.create(hours(8)).withAllowedExtraEffort(hours(2))); - assertThat(calendar.asDurationOn( - PartialDay.wholeDay(MONDAY_LOCAL_DATE), - ResourcesPerDay.amount(1)), equalTo(hours(8))); - assertThat(calendar.asDurationOn( - PartialDay.wholeDay(MONDAY_LOCAL_DATE), - ResourcesPerDay.amount(2)), equalTo(hours(10))); + assertThat( + calendar.asDurationOn(PartialDay.wholeDay(MONDAY_LOCAL_DATE), ResourcesPerDay.amount(1)), + equalTo(hours(8))); + + assertThat( + calendar.asDurationOn(PartialDay.wholeDay(MONDAY_LOCAL_DATE), ResourcesPerDay.amount(2)), + equalTo(hours(10))); } - private void addExceptionOn(BaseCalendar calendar, LocalDate onDate, - Capacity capacity) { - calendar.addExceptionDay(CalendarException.create(onDate, capacity, - createCalendarExceptionType())); + private void addExceptionOn(BaseCalendar calendar, LocalDate onDate, Capacity capacity) { + calendar.addExceptionDay(CalendarException.create(onDate, capacity, createCalendarExceptionType())); } @Test public void asDurationOnRespectsAnOverAssignableCalendarException() { BaseCalendar calendar = createBasicCalendar(); - addExceptionOn(calendar, MONDAY_LOCAL_DATE, Capacity.create(hours(1)) - .overAssignableWithoutLimit()); + addExceptionOn(calendar, MONDAY_LOCAL_DATE, Capacity.create(hours(1)).overAssignableWithoutLimit()); - assertThat(calendar.asDurationOn( - PartialDay.wholeDay(MONDAY_LOCAL_DATE), - ResourcesPerDay.amount(1)), equalTo(hours(1))); - assertThat(calendar.asDurationOn( - PartialDay.wholeDay(MONDAY_LOCAL_DATE), - ResourcesPerDay.amount(2)), equalTo(hours(2))); + assertThat( + calendar.asDurationOn(PartialDay.wholeDay(MONDAY_LOCAL_DATE), ResourcesPerDay.amount(1)), + equalTo(hours(1))); + + assertThat( + calendar.asDurationOn(PartialDay.wholeDay(MONDAY_LOCAL_DATE), ResourcesPerDay.amount(2)), + equalTo(hours(2))); } @Test public void asDurationOnRespectsANotOverAssignableCalendarException() { BaseCalendar calendar = createBasicCalendar(); - addExceptionOn(calendar, MONDAY_LOCAL_DATE, Capacity.create(hours(1)) - .notOverAssignableWithoutLimit()); - assertThat(calendar.asDurationOn( - PartialDay.wholeDay(MONDAY_LOCAL_DATE), - ResourcesPerDay.amount(1)), equalTo(hours(1))); - assertThat(calendar.asDurationOn( - PartialDay.wholeDay(MONDAY_LOCAL_DATE), - ResourcesPerDay.amount(2)), equalTo(hours(1))); + addExceptionOn(calendar, MONDAY_LOCAL_DATE, Capacity.create(hours(1)).notOverAssignableWithoutLimit()); + + assertThat( + calendar.asDurationOn(PartialDay.wholeDay(MONDAY_LOCAL_DATE), ResourcesPerDay.amount(1)), + equalTo(hours(1))); + + assertThat( + calendar.asDurationOn(PartialDay.wholeDay(MONDAY_LOCAL_DATE), ResourcesPerDay.amount(2)), + equalTo(hours(1))); } @Test public void asDurationOnRespectsCapacityExtraEffort() { BaseCalendar calendar = createBasicCalendar(); - addExceptionOn(calendar, MONDAY_LOCAL_DATE, Capacity.create(hours(2)) - .withAllowedExtraEffort(hours(3))); - assertThat(calendar.asDurationOn( - PartialDay.wholeDay(MONDAY_LOCAL_DATE), - ResourcesPerDay.amount(1)), equalTo(hours(2))); - assertThat(calendar.asDurationOn( - PartialDay.wholeDay(MONDAY_LOCAL_DATE), - ResourcesPerDay.amount(2)), equalTo(hours(4))); - assertThat(calendar.asDurationOn( - PartialDay.wholeDay(MONDAY_LOCAL_DATE), - ResourcesPerDay.amount(3)), equalTo(hours(5))); + addExceptionOn(calendar, MONDAY_LOCAL_DATE, Capacity.create(hours(2)).withAllowedExtraEffort(hours(3))); + + assertThat( + calendar.asDurationOn(PartialDay.wholeDay(MONDAY_LOCAL_DATE), ResourcesPerDay.amount(1)), + equalTo(hours(2))); + + assertThat( + calendar.asDurationOn(PartialDay.wholeDay(MONDAY_LOCAL_DATE), ResourcesPerDay.amount(2)), + equalTo(hours(4))); + + assertThat( + calendar.asDurationOn(PartialDay.wholeDay(MONDAY_LOCAL_DATE), ResourcesPerDay.amount(3)), + equalTo(hours(5))); } @Test public void canWorkOnRespectsTheCapacityOfTheException() { BaseCalendar calendar = createBasicCalendar(); - addExceptionOn(calendar, MONDAY_LOCAL_DATE, Capacity.create(hours(0)) - .withAllowedExtraEffort(hours(0))); + addExceptionOn(calendar, MONDAY_LOCAL_DATE, Capacity.create(hours(0)).withAllowedExtraEffort(hours(0))); assertFalse(calendar.canWorkOn(MONDAY_LOCAL_DATE)); } @@ -884,8 +814,7 @@ public class BaseCalendarTest { @Test public void canWorkOnRespectsIsOverAssignable() { BaseCalendar calendar = createBasicCalendar(); - addExceptionOn(calendar, MONDAY_LOCAL_DATE, Capacity.create(hours(0)) - .overAssignableWithoutLimit()); + addExceptionOn(calendar, MONDAY_LOCAL_DATE, Capacity.create(hours(0)).overAssignableWithoutLimit()); assertTrue(calendar.canWorkOn(MONDAY_LOCAL_DATE)); } @@ -893,21 +822,18 @@ public class BaseCalendarTest { @Test public void canWorkOnRespectsCalendarData() { BaseCalendar calendar = createBasicCalendar(); - calendar.setCapacityAt(Days.MONDAY, Capacity.create(hours(0)) - .overAssignableWithoutLimit()); + calendar.setCapacityAt(Days.MONDAY, Capacity.create(hours(0)).overAssignableWithoutLimit()); assertTrue(calendar.canWorkOn(MONDAY_LOCAL_DATE)); - calendar.setCapacityAt(Days.MONDAY, Capacity.create(hours(0)) - .notOverAssignableWithoutLimit()); + calendar.setCapacityAt(Days.MONDAY, Capacity.create(hours(0)).notOverAssignableWithoutLimit()); assertFalse(calendar.canWorkOn(MONDAY_LOCAL_DATE)); } @Test public void theAvailabilityTimeLineTakesIntoAccountTheDaysItCannotWorkDueToCalendarData() { BaseCalendar calendar = createBasicCalendar(); - calendar.setCapacityAt(Days.MONDAY, Capacity.create(hours(0)) - .notOverAssignableWithoutLimit()); + calendar.setCapacityAt(Days.MONDAY, Capacity.create(hours(0)).notOverAssignableWithoutLimit()); AvailabilityTimeLine availability = calendar.getAvailability(); assertFalse(availability.isValid(MONDAY_LOCAL_DATE)); diff --git a/libreplan-business/src/test/resources/log4j.properties b/libreplan-business/src/test/resources/log4j.properties index 28d664592..346dc5657 100644 --- a/libreplan-business/src/test/resources/log4j.properties +++ b/libreplan-business/src/test/resources/log4j.properties @@ -1,5 +1,6 @@ # For JBoss: Avoid to setup Log4J outside $JBOSS_HOME/server/default/deploy/log4j.xml! # For all other servers: Comment out the Log4J listener in web.xml to activate Log4J. + log4j.rootLogger=INFO, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender diff --git a/libreplan-webapp/pom.xml b/libreplan-webapp/pom.xml index ebabd6182..bc8a9c8e5 100644 --- a/libreplan-webapp/pom.xml +++ b/libreplan-webapp/pom.xml @@ -354,6 +354,11 @@ zk + + org.zkoss.common + zcommon + + org.libreplan diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/LoggingConfiguration.java b/libreplan-webapp/src/main/java/org/libreplan/web/LoggingConfiguration.java index 94901cad8..8e3784060 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/LoggingConfiguration.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/LoggingConfiguration.java @@ -42,12 +42,14 @@ import org.apache.log4j.xml.DOMConfigurator; */ public class LoggingConfiguration implements ServletContextListener { - private static final String lineSeparator = System.getProperty("line.separator"); + private static final String LINE_SEPARATOR = System.getProperty("line.separator"); + + private static Pattern propertyPattern = Pattern.compile("\\$\\{\\s*(.+?)\\s*\\}"); @Override public void contextInitialized(ServletContextEvent sce) { if ( System.getProperty("libreplan-log-directory") != null ) { - // log4j will do the replacement automatically. + // log4j will do the replacement automatically return; } @@ -58,17 +60,13 @@ public class LoggingConfiguration implements ServletContextListener { new DOMConfigurator().doConfigure(newConfiguration, LogManager.getLoggerRepository()); } catch (IOException e) { e.printStackTrace(); - // let log4j be loaded without replacements + // Let log4j be loaded without replacements } } private String findLogDirectory(ServletContext servletContext) { File result = logDirectoryFile(servletContext); - if ( result != null ) { - return result.getAbsolutePath() + "/"; - } - - return ""; + return result != null ? result.getAbsolutePath() + "/" : ""; } private File logDirectoryFile(ServletContext servletContext) { @@ -85,11 +83,8 @@ public class LoggingConfiguration implements ServletContextListener { } File home = new File(System.getProperty("user.home")); - if ( home.canWrite() ) { - return tryToAppendApplicationName(home, applicationName); - } - return null; + return home.canWrite() ? tryToAppendApplicationName(home, applicationName) : null; } private File findTomcatLogDirectory() { @@ -98,29 +93,18 @@ public class LoggingConfiguration implements ServletContextListener { return null; } - File[] tomcatLogDirectories = file.listFiles(pathname -> { - return pathname.getName().contains("tomcat"); - }); + File[] tomcatLogDirectories = file.listFiles(pathname -> pathname.getName().contains("tomcat")); - if ( tomcatLogDirectories.length == 0 ) { - return null; - } - - return tomcatLogDirectories[0]; + return tomcatLogDirectories.length == 0 ? null : tomcatLogDirectories[0]; } private File tryToAppendApplicationName(File logDirectory, String applicationName) { File forApplication = new File(logDirectory, applicationName); - if ( forApplication.mkdir() || forApplication.canWrite() ) { - return forApplication; - } - - return logDirectory; + return forApplication.mkdir() || forApplication.canWrite() ? forApplication : logDirectory; } private boolean isTomcat(ServletContext servletContext) { String serverInfo = servletContext.getServerInfo(); - return serverInfo != null && serverInfo.contains("Tomcat"); } @@ -130,7 +114,6 @@ public class LoggingConfiguration implements ServletContextListener { return each; } } - return ""; } @@ -142,21 +125,18 @@ public class LoggingConfiguration implements ServletContextListener { return new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("log4j.xml"))); } - private String withReplacements(Map replacements, BufferedReader originalConfiguration) - throws IOException { + private String withReplacements(Map replacements, BufferedReader originalConfiguration) throws IOException { StringBuilder result = new StringBuilder(); String line; while ((line = originalConfiguration.readLine()) != null) { - result.append(doReplacement(replacements, line)).append(lineSeparator); + result.append(doReplacement(replacements, line)).append(LINE_SEPARATOR); } return result.toString(); } - private static Pattern propertyPattern = Pattern.compile("\\$\\{\\s*(.+?)\\s*\\}"); - private static String doReplacement(Map propertyReplacements, String line) { String result = line; diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/entrypoints/EntryPointsHandler.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/entrypoints/EntryPointsHandler.java index 71c308e4d..bb3445a60 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/common/entrypoints/EntryPointsHandler.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/entrypoints/EntryPointsHandler.java @@ -46,9 +46,9 @@ import org.zkoss.zk.ui.Page; import org.zkoss.zk.ui.event.BookmarkEvent; /** - * Handler for EntryPoints. In other way it is also wrapper for URL redirecting. + * Handler for EntryPoints. + * In other way it is also wrapper for URL redirecting. *
- * * @author Óscar González Fernández * @author Vova Perebykivskyi */ @@ -82,55 +82,6 @@ public class EntryPointsHandler { private static final ThreadLocal> linkCapturer = new ThreadLocal<>(); - public static void setupEntryPointsForThisRequest(HttpServletRequest request, Map entryPoints) { - request.setAttribute(MANUALLY_SET_PARAMS, entryPoints); - } - - public interface ICapture { - - void capture(); - } - - /** - * It capture the first redirect done via an {@link EntryPoint} in the - * provided {@link ICapture} and returns the path. - * - * @see #capturePaths(ICapture) - * @param redirects - * @throws IllegalStateException - * if no {@link EntryPoint} point call is done. - */ - public static String capturePath(ICapture redirects) { - List result = capturePaths(redirects); - if (result.isEmpty()) { - throw new IllegalStateException("a call to an entry point should be done"); - } - return result.get(0); - } - - /** - * It captures the redirects done via {@link EntryPoint} in the provided - * {@link ICapture} and returns the paths. - * - * @param redirects - * @return - */ - public static List capturePaths(ICapture redirects) { - linkCapturer.set(new ArrayList<>()); - try { - redirects.capture(); - List list = linkCapturer.get(); - - if (list == null) { - throw new RuntimeException(ICapture.class.getName() + " cannot be nested"); - } - - return Collections.unmodifiableList(list); - } finally { - linkCapturer.set(null); - } - } - public EntryPointsHandler(IConverterFactory converterFactory, IExecutorRetriever executorRetriever, Class interfaceDefiningEntryPoints) { @@ -157,6 +108,53 @@ public class EntryPointsHandler { } } + public static void setupEntryPointsForThisRequest(HttpServletRequest request, Map entryPoints) { + request.setAttribute(MANUALLY_SET_PARAMS, entryPoints); + } + + public interface ICapture { + + void capture(); + } + + /** + * It capture the first redirect done via an {@link EntryPoint} in the provided {@link ICapture} and returns the path. + * + * @see #capturePaths(ICapture) + * @param redirects + * @throws IllegalStateException + * if no {@link EntryPoint} point call is done. + */ + public static String capturePath(ICapture redirects) { + List result = capturePaths(redirects); + if (result.isEmpty()) { + throw new IllegalStateException("a call to an entry point should be done"); + } + return result.get(0); + } + + /** + * It captures the redirects done via {@link EntryPoint} in the provided {@link ICapture} and returns the paths. + * + * @param redirects + * @return {@link List} + */ + public static List capturePaths(ICapture redirects) { + linkCapturer.set(new ArrayList<>()); + try { + redirects.capture(); + List list = linkCapturer.get(); + + if (list == null) { + throw new RuntimeException(ICapture.class.getName() + " cannot be nested"); + } + + return Collections.unmodifiableList(list); + } finally { + linkCapturer.set(null); + } + } + public void doTransition(String methodName, Object... values) { if (!metadata.containsKey(methodName)) { LOG.error("Method " + methodName + @@ -173,7 +171,7 @@ public class EntryPointsHandler { return; } - if (isFlagedInThisRequest()) { + if ( isFlaggedInThisRequest()) { return; } flagAlreadyExecutedInThisRequest(); @@ -202,7 +200,7 @@ public class EntryPointsHandler { return getFragment(parameterNames, stringRepresentations); } - private boolean isFlagedInThisRequest() { + private boolean isFlaggedInThisRequest() { return getRequest().getAttribute(FLAG_ATTRIBUTE) == this; } @@ -227,9 +225,9 @@ public class EntryPointsHandler { * After migration from ZK 5 to ZK 8 it starts to throw 404 error on pages that were redirected with parameters. * Solution is to make question mark (?) symbol after page. * - * Before: http://localhost:8081/myaccount/personalTimesheet.zul;date=2016-07-08;resource=WORKER0004 + * Before: http://localhost:8080/myaccount/personalTimesheet.zul;date=2016-07-08;resource=WORKER0004 * - * After: http://localhost:8081/myaccount/personalTimesheet.zul?date=2016-07-08;resource=WORKER0004 + * After: http://localhost:8080/myaccount/personalTimesheet.zul?date=2016-07-08;resource=WORKER0004 */ private String buildRedirectURL(String fragment) { return page + "?" + stripPound(fragment); @@ -260,17 +258,13 @@ public class EntryPointsHandler { private static void callMethod(Object target, Method superclassMethod, Object[] params) { try { - Method method = target.getClass().getMethod( - superclassMethod.getName(), - superclassMethod.getParameterTypes()); - + Method method = target.getClass().getMethod(superclassMethod.getName(), superclassMethod.getParameterTypes()); method.invoke(target, params); } catch (Exception e) { throw new RuntimeException(e); } } - public boolean applyIfMatches(S controller) { HttpServletRequest request = getRequest(); @@ -288,7 +282,7 @@ public class EntryPointsHandler { } public boolean applyIfMatches(S controller, String fragment) { - if (isFlagedInThisRequest()) { + if ( isFlaggedInThisRequest()) { return false; } @@ -312,8 +306,9 @@ public class EntryPointsHandler { HashSet requiredParams = new HashSet<>(Arrays.asList(entryPointAnnotation.value())); if (matrixParamsNames.equals(requiredParams)) { - final Object[] arguments = retrieveArguments(matrixParams, - entryPointAnnotation, entryPointMetadata.method.getParameterTypes()); + + final Object[] arguments = + retrieveArguments(matrixParams, entryPointAnnotation, entryPointMetadata.method.getParameterTypes()); Util.executeIgnoringCreationOfBindings( () -> callMethod(controller, entryPointMetadata.method, arguments)); @@ -342,9 +337,8 @@ public class EntryPointsHandler { return !uri.startsWith(";") ? ";" + uri : uri; } - private Object[] retrieveArguments(Map matrixParams, - EntryPoint linkToStateAnnotation, - Class[] parameterTypes) { + private Object[] retrieveArguments( + Map matrixParams, EntryPoint linkToStateAnnotation, Class[] parameterTypes) { Object[] result = new Object[parameterTypes.length]; diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/expensesheet/ExpenseSheetCRUDController.java b/libreplan-webapp/src/main/java/org/libreplan/web/expensesheet/ExpenseSheetCRUDController.java index b875a0ed1..ba2831a87 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/expensesheet/ExpenseSheetCRUDController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/expensesheet/ExpenseSheetCRUDController.java @@ -75,6 +75,8 @@ public class ExpenseSheetCRUDController extends BaseCRUDController implements IExpenseSheetCRUDController { + private static final String NOT_EMPTY = "cannot be empty"; + private IExpenseSheetModel expenseSheetModel; /** @@ -102,8 +104,13 @@ public class ExpenseSheetCRUDController private boolean cancel = false; public ExpenseSheetCRUDController() { - expenseSheetModel = (IExpenseSheetModel) SpringUtil.getBean("expenseSheetModel"); - URLHandlerRegistry = (IURLHandlerRegistry) SpringUtil.getBean("URLHandlerRegistry"); + if ( expenseSheetModel == null ) { + expenseSheetModel = (IExpenseSheetModel) SpringUtil.getBean("expenseSheetModel"); + } + + if ( URLHandlerRegistry == null ) { + URLHandlerRegistry = (IURLHandlerRegistry) SpringUtil.getBean("URLHandlerRegistry"); + } } @Override @@ -185,11 +192,11 @@ public class ExpenseSheetCRUDController private boolean validateNewLine() { if (expenseSheetModel.getNewExpenseSheetLine().getDate() == null) { - throw new WrongValueException(this.dateboxExpenseDate, _("cannot be empty")); + throw new WrongValueException(this.dateboxExpenseDate, _(NOT_EMPTY)); } if (expenseSheetModel.getNewExpenseSheetLine().getOrderElement() == null) { - throw new WrongValueException(this.bandboxTasks, _("cannot be empty")); + throw new WrongValueException(this.bandboxTasks, _(NOT_EMPTY)); } BigDecimal value = expenseSheetModel.getNewExpenseSheetLine().getValue(); @@ -328,7 +335,7 @@ public class ExpenseSheetCRUDController } }); - dateboxExpense.setConstraint("no empty:" + _("cannot be empty")); + dateboxExpense.setConstraint("no empty:" + _(NOT_EMPTY)); row.appendChild(dateboxExpense); } @@ -344,6 +351,7 @@ public class ExpenseSheetCRUDController Listitem selectedItem = bandboxSearch.getSelectedItem(); setResourceInESL(selectedItem, expenseSheetLine); }; + bandboxSearch.setListboxEventListener(Events.ON_SELECT, eventListenerUpdateResource); bandboxSearch.setListboxEventListener(Events.ON_OK, eventListenerUpdateResource); bandboxSearch.setBandboxEventListener(Events.ON_CHANGING, eventListenerUpdateResource); @@ -361,7 +369,7 @@ public class ExpenseSheetCRUDController code.setValue(line.getCode()); } - code.addEventListener("onChange", (EventListener) event -> { + code.addEventListener("onChange", event -> { final ExpenseSheetLine line1 = row.getValue(); line1.setCode(code.getValue()); }); @@ -375,7 +383,7 @@ public class ExpenseSheetCRUDController delete.setHoverImage("/common/img/ico_borrar.png"); delete.setSclass("icono"); delete.setTooltiptext(_("Delete")); - delete.addEventListener(Events.ON_CLICK, (EventListener) event -> confirmRemove(row.getValue())); + delete.addEventListener(Events.ON_CLICK, event -> confirmRemove(row.getValue())); row.appendChild(delete); } @@ -418,17 +426,37 @@ public class ExpenseSheetCRUDController bandboxSearch.setListboxEventListener(Events.ON_SELECT, eventListenerUpdateOrderElement); bandboxSearch.setListboxEventListener(Events.ON_OK, eventListenerUpdateOrderElement); bandboxSearch.setBandboxEventListener(Events.ON_CHANGING, eventListenerUpdateOrderElement); - bandboxSearch.setBandboxConstraint("no empty:" + _("cannot be empty")); + bandboxSearch.setBandboxConstraint("no empty:" + _(NOT_EMPTY)); row.appendChild(bandboxSearch); } + private Constraint checkConstraintLineCodes(final ExpenseSheetLine line) { + return (comp, value) -> { + if (!getExpenseSheet().isCodeAutogenerated()) { + String code = (String) value; + + if (code == null || code.isEmpty()) { + throw new WrongValueException(comp, _("Code cannot be empty.")); + } else { + String oldCode = line.getCode(); + line.setCode(code); + + if (!getExpenseSheet().isNonRepeatedExpenseSheetLinesCodesConstraint()) { + line.setCode(oldCode); + throw new WrongValueException(comp, _("The code must be unique.")); + } + } + } + }; + } + private void setOrderElementInESL(Listitem selectedItem, ExpenseSheetLine line) { - OrderElement orderElement = (selectedItem == null ? null : (OrderElement) selectedItem.getValue()); + OrderElement orderElement = selectedItem == null ? null : (OrderElement) selectedItem.getValue(); line.setOrderElement(orderElement); } private void setResourceInESL(Listitem selectedItem, ExpenseSheetLine expenseSheetLine) { - Resource resource = (selectedItem == null ? null : (Resource) selectedItem.getValue()); + Resource resource = selectedItem == null ? null : (Resource) selectedItem.getValue(); expenseSheetLine.setResource(resource); } } @@ -442,26 +470,6 @@ public class ExpenseSheetCRUDController }; } - private Constraint checkConstraintLineCodes(final ExpenseSheetLine line) { - return (comp, value) -> { - if (!getExpenseSheet().isCodeAutogenerated()) { - String code = (String) value; - - if (code == null || code.isEmpty()) { - throw new WrongValueException(comp, _("Code cannot be empty.")); - } else { - String oldCode = line.getCode(); - line.setCode(code); - - if (!getExpenseSheet().isNonRepeatedExpenseSheetLinesCodesConstraint()) { - line.setCode(oldCode); - throw new WrongValueException(comp, _("The code must be unique.")); - } - } - } - }; - } - public Constraint checkConstraintExpendeCode() { return (comp, value) -> { if (!getExpenseSheet().isCodeAutogenerated()) { diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/chart/LoadChartFiller.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/chart/LoadChartFiller.java index bb3b64575..d00a16f55 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/chart/LoadChartFiller.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/chart/LoadChartFiller.java @@ -27,9 +27,14 @@ import org.zkoss.zk.ui.util.Clients; public abstract class LoadChartFiller extends ChartFiller { - public static final String COLOR_CAPABILITY_LINE = "#000000"; // Black - public static final String COLOR_ASSIGNED_LOAD = "#98D471"; // Green - public static final String COLOR_OVERLOAD = "#FF5A11"; // Red + /** Black */ + public static final String COLOR_CAPABILITY_LINE = "#000000"; + + /** Green */ + public static final String COLOR_ASSIGNED_LOAD = "#98D471"; + + /** Red */ + public static final String COLOR_OVERLOAD = "#FF5A11"; @Override public void fillChart(Timeplot chart, Interval interval, Integer size) { @@ -43,7 +48,7 @@ public abstract class LoadChartFiller extends ChartFiller { ValueGeometry valueGeometry = getValueGeometry(); TimeGeometry timeGeometry = getTimeGeometry(interval); - Plotinfo[] plotInfos = getPlotInfos(interval); + Plotinfo[] plotInfos = getPlotInfo(interval); for (Plotinfo each : plotInfos) { appendPlotinfo(chart, each, valueGeometry, timeGeometry); } @@ -58,8 +63,8 @@ public abstract class LoadChartFiller extends ChartFiller { * The order must be from the topmost one to the lowest one. * * @param interval - * @return the {@link Plotinfo plot infos} to show + * @return the {@link Plotinfo plot info} to show */ - protected abstract Plotinfo[] getPlotInfos(Interval interval); + protected abstract Plotinfo[] getPlotInfo(Interval interval); } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/chart/StandardLoadChartFiller.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/chart/StandardLoadChartFiller.java index 2c9462a3b..1bca09836 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/chart/StandardLoadChartFiller.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/chart/StandardLoadChartFiller.java @@ -14,22 +14,19 @@ import org.zkoss.ganttz.util.Interval; public abstract class StandardLoadChartFiller extends LoadChartFiller { @Override - protected Plotinfo[] getPlotInfos(Interval interval) { + protected Plotinfo[] getPlotInfo(Interval interval) { final ILoadChartData data = getDataOn(interval); - Plotinfo plotInfoLoad = createPlotinfoFromDurations(getLoad(data), - interval); + Plotinfo plotInfoLoad = createPlotinfoFromDurations(getLoad(data), interval); plotInfoLoad.setFillColor(COLOR_ASSIGNED_LOAD); plotInfoLoad.setLineWidth(0); - Plotinfo plotInfoMax = createPlotinfoFromDurations( - getCalendarMaximumAvailability(data), interval); + Plotinfo plotInfoMax = createPlotinfoFromDurations(getCalendarMaximumAvailability(data), interval); plotInfoMax.setLineColor(COLOR_CAPABILITY_LINE); plotInfoMax.setFillColor("#FFFFFF"); plotInfoMax.setLineWidth(2); - Plotinfo plotInfoOverload = createPlotinfoFromDurations( - getOverload(data), interval); + Plotinfo plotInfoOverload = createPlotinfoFromDurations(getOverload(data), interval); plotInfoOverload.setFillColor(COLOR_OVERLOAD); plotInfoOverload.setLineWidth(0); @@ -38,23 +35,17 @@ public abstract class StandardLoadChartFiller extends LoadChartFiller { protected abstract ILoadChartData getDataOn(Interval interval); - protected LocalDate getStart(LocalDate explicitlySpecifiedStart, - Interval interval) { - if (explicitlySpecifiedStart == null) { - return interval.getStart(); - } - return Collections.max(asList(explicitlySpecifiedStart, - interval.getStart())); + protected LocalDate getStart(LocalDate explicitlySpecifiedStart, Interval interval) { + return explicitlySpecifiedStart == null + ? interval.getStart() + : Collections.max(asList(explicitlySpecifiedStart, interval.getStart())); } @SuppressWarnings("unchecked") - protected LocalDate getEnd(LocalDate explicitlySpecifiedEnd, - Interval interval) { - if (explicitlySpecifiedEnd == null) { - return interval.getFinish(); - } - return Collections.min(asList(explicitlySpecifiedEnd, - interval.getFinish())); + protected LocalDate getEnd(LocalDate explicitlySpecifiedEnd, Interval interval) { + return explicitlySpecifiedEnd == null + ? interval.getFinish() + : Collections.min(asList(explicitlySpecifiedEnd, interval.getFinish())); } private SortedMap getLoad(ILoadChartData data) { @@ -65,8 +56,7 @@ public abstract class StandardLoadChartFiller extends LoadChartFiller { return groupAsNeededByZoom(data.getOverload()); } - private SortedMap getCalendarMaximumAvailability( - ILoadChartData data) { + private SortedMap getCalendarMaximumAvailability(ILoadChartData data) { return groupAsNeededByZoom(data.getAvailability()); } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/company/CompanyPlanningModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/company/CompanyPlanningModel.java index bfd6a4e58..28cfea64d 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/company/CompanyPlanningModel.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/company/CompanyPlanningModel.java @@ -32,7 +32,6 @@ import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.EnumSet; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -122,6 +121,13 @@ import org.zkoss.zul.Vbox; @Scope(BeanDefinition.SCOPE_PROTOTYPE) public class CompanyPlanningModel implements ICompanyPlanningModel { + /** All the status but CANCELLED and STORED */ + private static final EnumSet STATUS_VISUALIZED = OrderStatusEnum.getVisibleStatus(); + + private static final String CENTER = "center"; + + private static final String INDICATOR = "indicator"; + @Autowired private IOrderDAO orderDAO; @@ -134,12 +140,6 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { @Autowired private ICompanyEarnedValueCalculator earnedValueCalculator; - private List keepAliveZoomListeners = new ArrayList<>(); - - private List earnedValueChartConfigurationCheckboxes = new ArrayList<>(); - - private List keepAliveChartVisibilityListeners = new ArrayList<>(); - @Autowired private IConfigurationDAO configurationDAO; @@ -149,18 +149,21 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { @Autowired private TaskElementAdapter taskElementAdapterCreator; - private Scenario currentScenario; - @Autowired private PredefinedDatabaseSnapshots databaseSnapshots; + private List keepAliveZoomListeners = new ArrayList<>(); + + private List earnedValueChartConfigurationCheckboxes = new ArrayList<>(); + + private List keepAliveChartVisibilityListeners = new ArrayList<>(); + + private Scenario currentScenario; + private LocalDate filterStartDate; private LocalDate filterFinishDate; - /** All the status but CANCELLED and STORED */ - private static final EnumSet STATUS_VISUALIZED = OrderStatusEnum.getVisibleStatus(); - private static final class TaskElementNavigator implements IStructureNavigator { @Override @@ -229,18 +232,18 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { } else { // If the chart is not expanded, we load the data later with a listener - (planner.getFellow("graphics")).addEventListener("onOpen", - new EventListener() { - @Override - public void onEvent(Event event) { - transactionService.runOnReadOnlyTransaction((IOnTransaction) () -> { - setupChartAndItsContent(planner, chartComponent); - return null; - }); - // Data is loaded only once, then we remove the listener - event.getTarget().removeEventListener("onOpen", this); - } + planner.getFellow("graphics").addEventListener("onOpen", new EventListener() { + @Override + public void onEvent(Event event) { + transactionService.runOnReadOnlyTransaction((IOnTransaction) () -> { + setupChartAndItsContent(planner, chartComponent); + return null; }); + + // Data is loaded only once, then we remove the listener + event.getTarget().removeEventListener("onOpen", this); + } + }); } } @@ -313,7 +316,6 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { private Timeplot createEmptyTimeplot() { Timeplot timeplot = new Timeplot(); timeplot.appendChild(new Plotinfo()); - return timeplot; } @@ -341,7 +343,7 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { datebox.addEventListener(Events.ON_CHANGE, event -> { LocalDate date = new LocalDate(datebox.getValue()); updateEarnedValueChartLegend(vbox, earnedValueChartFiller, date); - dateInfutureMessage(datebox); + dateInFutureMessage(datebox); }); } @@ -355,7 +357,7 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { } } - private void dateInfutureMessage(Datebox datebox) { + private void dateInFutureMessage(Datebox datebox) { Date value = datebox.getValue(); Date today = LocalDate.fromDateFields(new Date()).toDateTimeAtStartOfDay().toDate(); @@ -374,15 +376,18 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { final Div div = new Div(); Timeplot timePlot = loadChartEmitter.getLastValue(); + if (timePlot != null) { div.appendChild(timePlot); } + loadChartEmitter.addListener(timePlot1 -> { div.getChildren().clear(); if (timePlot1 != null) { div.appendChild(timePlot1); } }); + div.setSclass("plannergraph"); hbox.appendChild(div); @@ -394,8 +399,8 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { public static org.zkoss.zk.ui.Component getLoadChartLegend() { Hbox hbox = new Hbox(); hbox.setClass("legend-container"); - hbox.setAlign("center"); - hbox.setPack("center"); + hbox.setAlign(CENTER); + hbox.setPack(CENTER); Executions.createComponents("/planner/_legendLoadChartCompany.zul", hbox, null); return hbox; @@ -407,8 +412,8 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { Vbox vbox = new Vbox(); vbox.setClass("legend-container"); - vbox.setAlign("center"); - vbox.setPack("center"); + vbox.setAlign(CENTER); + vbox.setPack(CENTER); Hbox dateHbox = new Hbox(); dateHbox.appendChild(new Label(_("Select date"))); @@ -438,6 +443,7 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { private org.zkoss.zk.ui.Component getEarnedValueChartConfigurableLegend( CompanyEarnedValueChartFiller earnedValueChartFiller, LocalDate date) { + Hbox mainhbox = new Hbox(); mainhbox.setId("indicatorsTable"); @@ -456,7 +462,7 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { for (EarnedValueType type : EarnedValueType.values()) { Checkbox checkbox = new Checkbox(type.getAcronym()); checkbox.setTooltiptext(type.getName()); - checkbox.setAttribute("indicator", type); + checkbox.setAttribute(INDICATOR, type); checkbox.setStyle("color: " + type.getColor()); Label valueLabel = new Label(getLabelTextEarnedValueType( @@ -468,6 +474,7 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { hbox.appendChild(valueLabel); columnNumber = columnNumber + 1; + switch (columnNumber) { case 1: @@ -518,7 +525,7 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { private void markAsSelectedDefaultIndicators() { for (Checkbox checkbox : earnedValueChartConfigurationCheckboxes) { - EarnedValueType type = (EarnedValueType) checkbox.getAttribute("indicator"); + EarnedValueType type = (EarnedValueType) checkbox.getAttribute(INDICATOR); switch (type) { @@ -541,7 +548,7 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { for (Checkbox checkbox : earnedValueChartConfigurationCheckboxes) { if (checkbox.isChecked()) { - EarnedValueType type = (EarnedValueType) checkbox.getAttribute("indicator"); + EarnedValueType type = (EarnedValueType) checkbox.getAttribute(INDICATOR); result.add(type); } } @@ -593,7 +600,7 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { } @Override - public void doPrint(HashMap parameters, Planner planner) { + public void doPrint(Map parameters, Planner planner) { CutyPrint.print(parameters, planner); } @@ -626,6 +633,7 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { }); keepAliveChartVisibilityListeners.add(chartVisibilityChangedListener); + return chartVisibilityChangedListener; } @@ -679,6 +687,7 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { } } Collections.sort(result, (arg0, arg1) -> arg0.getStartDate().compareTo(arg1.getStartDate())); + return result; } @@ -724,6 +733,9 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { } state = (OrderStatusEnum) filterPair.getValue(); break; + + default: + break; } } @@ -739,8 +751,8 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { Date endDate = FilterUtils.readProjectsEndDate(); String name = FilterUtils.readProjectsName(); - boolean calculateStartDate = (startDate == null); - boolean calculateEndDate = (endDate == null); + boolean calculateStartDate = startDate == null; + boolean calculateEndDate = endDate == null; // Filter predicate needs to be calculated based on the projects dates if ( (calculateStartDate) || (calculateEndDate) ) { @@ -762,6 +774,7 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { startDate = Collections.min( notNull(startDate, each.getInitDate(), associatedTaskElement.getStartDate())); } + if ( calculateEndDate ) { endDate = Collections.max( notNull(endDate, each.getDeadline(), associatedTaskElement.getEndDate())); @@ -789,15 +802,11 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { @Override public Date getFilterStartDate() { - return ((filterStartDate == null) ? null : filterStartDate.toDateTimeAtStartOfDay().toDate()); + return filterStartDate == null ? null : filterStartDate.toDateTimeAtStartOfDay().toDate(); } @Override public Date getFilterFinishDate() { - return ((filterStartDate == null) ? null : filterFinishDate.toDateTimeAtStartOfDay().toDate()); - } - - private AvailabilityTimeLine.Interval getFilterInterval() { - return AvailabilityTimeLine.Interval.create(filterStartDate, filterFinishDate); + return filterStartDate == null ? null : filterFinishDate.toDateTimeAtStartOfDay().toDate(); } private class CompanyLoadChartFiller extends StandardLoadChartFiller { @@ -829,19 +838,25 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { @Override protected void calculateBudgetedCostWorkScheduled(Interval interval) { - setIndicatorInInterval(EarnedValueType.BCWS, interval, + setIndicatorInInterval( + EarnedValueType.BCWS, + interval, earnedValueCalculator.calculateBudgetedCostWorkScheduled(getFilterInterval())); } @Override protected void calculateActualCostWorkPerformed(Interval interval) { - setIndicatorInInterval(EarnedValueType.ACWP, interval, + setIndicatorInInterval( + EarnedValueType.ACWP, + interval, earnedValueCalculator.calculateActualCostWorkPerformed(getFilterInterval())); } @Override protected void calculateBudgetedCostWorkPerformed(Interval interval) { - setIndicatorInInterval(EarnedValueType.BCWP, interval, + setIndicatorInInterval( + EarnedValueType.BCWP, + interval, earnedValueCalculator.calculateBudgetedCostWorkPerformed(getFilterInterval())); } @@ -850,6 +865,10 @@ public class CompanyPlanningModel implements ICompanyPlanningModel { return getEarnedValueSelectedIndicators(); } + private AvailabilityTimeLine.Interval getFilterInterval() { + return AvailabilityTimeLine.Interval.create(filterStartDate, filterFinishDate); + } + } @Override diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/order/OrderPlanningModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/order/OrderPlanningModel.java index d3fc85ef3..7d0de6561 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/order/OrderPlanningModel.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/order/OrderPlanningModel.java @@ -98,7 +98,6 @@ import org.zkoss.ganttz.util.Interval; import org.zkoss.ganttz.util.ProfilingLogFactory; import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.WrongValueException; -import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; import java.math.BigDecimal; @@ -108,7 +107,6 @@ import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.EnumSet; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -150,51 +148,15 @@ public class OrderPlanningModel implements IOrderPlanningModel { private static final Log LOG = LogFactory.getLog(OrderPlanningModel.class); - private static final Log PROFILING_LOG = ProfilingLogFactory - .getLog(OrderPlanningModel.class); + private static final Log PROFILING_LOG = ProfilingLogFactory.getLog(OrderPlanningModel.class); - public static > T loadRequiredDataFor(T resources) { - for (Resource each : resources) { - reattachCalendarFor(each); + private static final String CENTER = "center"; - // Loading criterions so there are no repeated instances - forceLoadOfCriterions(each); - } - return resources; - } - - private static void reattachCalendarFor(Resource each) { - if (each.getCalendar() != null) { - BaseCalendarModel.forceLoadBaseCalendar(each.getCalendar()); - } - } - - static void forceLoadOfCriterions(Resource resource) { - Set criterionSatisfactions = resource.getCriterionSatisfactions(); - for (CriterionSatisfaction each : criterionSatisfactions) { - each.getCriterion().getName(); - each.getCriterion().getType(); - } - } - - public static ZoomLevel calculateDefaultLevel(PlannerConfiguration configuration) { - if (configuration.getData().isEmpty()) { - return ZoomLevel.DETAIL_ONE; - } - TaskElement earliest = Collections.min(configuration.getData(), TaskElement.getByStartDateComparator()); - TaskElement latest = Collections.max(configuration.getData(), TaskElement.getByEndAndDeadlineDateComparator()); - - LocalDate startDate = earliest.getStartAsLocalDate(); - LocalDate endDate = latest.getBiggestAmongEndOrDeadline(); - - return ZoomLevel.getDefaultZoomByDates(startDate, endDate); - } + private static final String INDICATOR = "indicator"; @Autowired private IOrderDAO orderDAO; - private PlanningState planningState; - @Autowired private IUserDAO userDAO; @@ -237,14 +199,19 @@ public class OrderPlanningModel implements IOrderPlanningModel { @Autowired private ISubcontractCommand subcontractCommand; - private List keepAliveZoomListeners = new ArrayList<>(); - @Autowired private IOrderEarnedValueCalculator earnedValueCalculator; @Autowired private IOrderResourceLoadCalculator resourceLoadCalculator; + @Autowired + private PlanningStateCreator planningStateCreator; + + private List keepAliveZoomListeners = new ArrayList<>(); + + private PlanningState planningState; + private List earnedValueChartConfigurationCheckboxes = new ArrayList<>(); private List keepAliveChartVisibilityListeners = new ArrayList<>(); @@ -253,6 +220,51 @@ public class OrderPlanningModel implements IOrderPlanningModel { private String tabSelected = "load_tab"; + private OrderEarnedValueChartFiller earnedValueChartFiller; + + private Vbox earnedValueChartLegendContainer; + + private Datebox earnedValueChartLegendDatebox; + + private Chart earnedValueChart; + + public static > T loadRequiredDataFor(T resources) { + for (Resource each : resources) { + reattachCalendarFor(each); + + // Loading criterions so there are no repeated instances + forceLoadOfCriterions(each); + } + return resources; + } + + private static void reattachCalendarFor(Resource each) { + if (each.getCalendar() != null) { + BaseCalendarModel.forceLoadBaseCalendar(each.getCalendar()); + } + } + + static void forceLoadOfCriterions(Resource resource) { + Set criterionSatisfactions = resource.getCriterionSatisfactions(); + for (CriterionSatisfaction each : criterionSatisfactions) { + each.getCriterion().getName(); + each.getCriterion().getType(); + } + } + + public static ZoomLevel calculateDefaultLevel(PlannerConfiguration configuration) { + if (configuration.getData().isEmpty()) { + return ZoomLevel.DETAIL_ONE; + } + TaskElement earliest = Collections.min(configuration.getData(), TaskElement.getByStartDateComparator()); + TaskElement latest = Collections.max(configuration.getData(), TaskElement.getByEndAndDeadlineDateComparator()); + + LocalDate startDate = earliest.getStartAsLocalDate(); + LocalDate endDate = latest.getBiggestAmongEndOrDeadline(); + + return ZoomLevel.getDefaultZoomByDates(startDate, endDate); + } + private static class NullSeparatorCommandOnTask implements ICommandOnTask { @Override @@ -401,11 +413,8 @@ public class OrderPlanningModel implements IOrderPlanningModel { return zoomListener; } - private OrderEarnedValueChartFiller earnedValueChartFiller; - private void setupAdvanceAssignmentPlanningController( - final Planner planner, - AdvanceAssignmentPlanningController advanceAssignmentPlanningController) { + final Planner planner, AdvanceAssignmentPlanningController advanceAssignmentPlanningController) { advanceAssignmentPlanningController.setReloadEarnedValueListener( () -> Registry.getTransactionService().runOnReadOnlyTransaction( @@ -464,10 +473,6 @@ public class OrderPlanningModel implements IOrderPlanningModel { return result; } - private Vbox earnedValueChartLegendContainer; - - private Datebox earnedValueChartLegendDatebox; - private void appendEarnedValueChartAndLegend( Tabpanel earnedValueChartPanel, Timeplot chartEarnedValueTimeplot, @@ -476,8 +481,8 @@ public class OrderPlanningModel implements IOrderPlanningModel { Vbox vbox = new Vbox(); this.earnedValueChartLegendContainer = vbox; vbox.setClass("legend-container"); - vbox.setAlign("center"); - vbox.setPack("center"); + vbox.setAlign(CENTER); + vbox.setPack(CENTER); Hbox dateHbox = new Hbox(); dateHbox.appendChild(new Label(_("Select date"))); @@ -520,8 +525,6 @@ public class OrderPlanningModel implements IOrderPlanningModel { refillLoadChartWhenNeeded(changeHooker, planner, loadChart, false); } - private Chart earnedValueChart; - private void setupEarnedValueChart(Timeplot chartEarnedValueTimeplot, OrderEarnedValueChartFiller earnedValueChartFiller, Planner planner, @@ -611,7 +614,7 @@ public class OrderPlanningModel implements IOrderPlanningModel { } @Override - public void doPrint(HashMap parameters, Planner planner) { + public void doPrint(Map parameters, Planner planner) { CutyPrint.print(order, parameters, planner); } @@ -679,15 +682,16 @@ public class OrderPlanningModel implements IOrderPlanningModel { if ( id.equals(tabSelected) ) { tab.setSelected(true); } - tab.addEventListener("onClick", (EventListener) event -> selectTab(id)); + tab.addEventListener("onClick", event -> selectTab(id)); + return tab; } private org.zkoss.zk.ui.Component getLoadChartLegend() { Hbox hbox = new Hbox(); hbox.setClass("legend-container"); - hbox.setAlign("center"); - hbox.setPack("center"); + hbox.setAlign(CENTER); + hbox.setPack(CENTER); Executions.createComponents("/planner/_legendLoadChartOrder.zul", hbox, null); return hbox; @@ -715,8 +719,7 @@ public class OrderPlanningModel implements IOrderPlanningModel { } private void appendEventListenerToDateboxIndicators() { - - earnedValueChartLegendDatebox.addEventListener(Events.ON_CHANGE, (EventListener) event -> { + earnedValueChartLegendDatebox.addEventListener(Events.ON_CHANGE, event -> { updateEarnedValueChartLegend(); dateInFutureMessage(earnedValueChartLegendDatebox); }); @@ -729,8 +732,7 @@ public class OrderPlanningModel implements IOrderPlanningModel { earnedValueChartLegendDatebox.setValue(earnedValueChartLegendDatebox.getValue()); } catch (WrongValueException e) { - // The user moved the gantt and the legend became out of the visualization area, - // reset to a correct date + // The user moved the gantt and the legend became out of the visualization area, reset to a correct date earnedValueChartLegendDatebox .setValue(earnedValueChartFiller.initialDateForIndicatorValues().toDateTimeAtStartOfDay().toDate()); } @@ -766,7 +768,7 @@ public class OrderPlanningModel implements IOrderPlanningModel { for (EarnedValueType type : EarnedValueType.values()) { Checkbox checkbox = new Checkbox(type.getAcronym()); checkbox.setTooltiptext(type.getName()); - checkbox.setAttribute("indicator", type); + checkbox.setAttribute(INDICATOR, type); checkbox.setStyle("color: " + type.getColor()); Label valueLabel = new Label(getLabelTextEarnedValueType(earnedValueChartFiller, type, date)); @@ -777,6 +779,7 @@ public class OrderPlanningModel implements IOrderPlanningModel { hbox.appendChild(valueLabel); columnNumber = columnNumber + 1; + switch (columnNumber) { case 1: column1.appendChild(hbox); @@ -785,6 +788,10 @@ public class OrderPlanningModel implements IOrderPlanningModel { case 2: column2.appendChild(hbox); columnNumber = 0; + break; + + default: + break; } earnedValueChartConfigurationCheckboxes.add(checkbox); @@ -817,7 +824,8 @@ public class OrderPlanningModel implements IOrderPlanningModel { private void markAsSelectedDefaultIndicators() { for (Checkbox checkbox : earnedValueChartConfigurationCheckboxes) { - EarnedValueType type = (EarnedValueType) checkbox.getAttribute("indicator"); + EarnedValueType type = (EarnedValueType) checkbox.getAttribute(INDICATOR); + switch (type) { case BCWS: case ACWP: @@ -832,17 +840,6 @@ public class OrderPlanningModel implements IOrderPlanningModel { } } - private Set getEarnedValueSelectedIndicators() { - Set result = new HashSet<>(); - for (Checkbox checkbox : earnedValueChartConfigurationCheckboxes) { - if ( checkbox.isChecked() ) { - EarnedValueType type = (EarnedValueType) checkbox.getAttribute("indicator"); - result.add(type); - } - } - return result; - } - private void setEventListenerConfigurationCheckboxes(final Chart earnedValueChart) { for (Checkbox checkbox : earnedValueChartConfigurationCheckboxes) { checkbox.addEventListener(Events.ON_CHECK, event -> transactionService.runOnReadOnlyTransaction(() -> { @@ -997,8 +994,8 @@ public class OrderPlanningModel implements IOrderPlanningModel { Messagebox.show( _("Unsaved changes will be lost. Are you sure?"), _("Confirm exit dialog"), Messagebox.OK | Messagebox.CANCEL, Messagebox.QUESTION, - (EventListener) evt -> { - if (evt.getName().equals("onOK")) { + evt -> { + if ("onOK".equals(evt.getName())) { ConfirmCloseUtil.resetConfirmClose(); Executions.sendRedirect("/planner/index.zul;company_scheduling"); } @@ -1043,6 +1040,7 @@ public class OrderPlanningModel implements IOrderPlanningModel { }); keepAliveChartVisibilityListeners.add(chartVisibilityChangedListener); + return chartVisibilityChangedListener; } @@ -1069,9 +1067,6 @@ public class OrderPlanningModel implements IOrderPlanningModel { return zoomListener; } - @Autowired - private PlanningStateCreator planningStateCreator; - private PlanningState createPlanningStateFor(Order order) { return planningStateCreator.retrieveOrCreate(planner.getDesktop(), order, planningState1 -> { planningState1.reattach(); @@ -1087,10 +1082,10 @@ public class OrderPlanningModel implements IOrderPlanningModel { */ private class OrderLoadChartFiller extends LoadChartFiller { - // Soft green + /** Soft green */ private static final String COLOR_ASSIGNED_LOAD_GLOBAL = "#E0F3D3"; - // Soft red + /** Soft red */ private static final String COLOR_OVERLOAD_GLOBAL = "#FFD4C2"; private final Order order; @@ -1105,7 +1100,7 @@ public class OrderPlanningModel implements IOrderPlanningModel { } @Override - protected Plotinfo[] getPlotInfos(Interval interval) { + protected Plotinfo[] getPlotInfo(Interval interval) { resourceLoadCalculator.setOrder(order, planningState.getAssignmentsCalculator()); ContiguousDaysLine maxCapacityOnResources = @@ -1195,6 +1190,17 @@ public class OrderPlanningModel implements IOrderPlanningModel { return getEarnedValueSelectedIndicators(); } + private Set getEarnedValueSelectedIndicators() { + Set result = new HashSet<>(); + for (Checkbox checkbox : earnedValueChartConfigurationCheckboxes) { + if ( checkbox.isChecked() ) { + EarnedValueType type = (EarnedValueType) checkbox.getAttribute(INDICATOR); + result.add(type); + } + } + return result; + } + } private ISubcontractCommand buildSubcontractCommand(EditTaskController editTaskController) { diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/ResourcesLoadTabCreator.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/ResourcesLoadTabCreator.java index dfdc37197..550c0a7e6 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/ResourcesLoadTabCreator.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/tabs/ResourcesLoadTabCreator.java @@ -41,13 +41,13 @@ import org.zkoss.zul.Image; import org.zkoss.zul.Label; /** - * Handles Resources Load tab creation (Global and Local) + * Handles Resources Load tab creation (Global and Local). * * @author Óscar González Fernández */ public class ResourcesLoadTabCreator { - private String RESOURCES_LOAD = "Resources Load"; + private static final String RESOURCES_LOAD = "Resources Load"; private final IOrderPlanningGate orderPlanningGate; diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/print/CutyPrint.java b/libreplan-webapp/src/main/java/org/libreplan/web/print/CutyPrint.java index 310cf4064..01384adf8 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/print/CutyPrint.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/print/CutyPrint.java @@ -60,83 +60,39 @@ public class CutyPrint { private static final String CUTYCAPT_COMMAND = "cutycapt"; - // Estimated maximum execution time (ms) + private static final String INDEX_ZUL = "/planner/index.zul"; + + private static final String PX_IMPORTANT = "px !important; } \n"; + + /** Estimated maximum execution time (ms) */ private static final int CAPTURE_DELAY = 10000; /** * Default width in pixels of the task name text field for depth level 1. - *

- * Got from .listdetails .depth_1 input.task_title { width: 121px; } at - * src/main/webapp/planner/css/ganttzk.css + * Got from .listdetails .depth_1 input.task_title { width: 121px; } at src/main/webapp/planner/css/ganttzk.css */ private static final int BASE_TASK_NAME_PIXELS = 121; private static int TASK_HEIGHT = 25; - public static void print(Order order) { - print("/planner/index.zul", entryPointForShowingOrder(order), Collections. emptyMap()); - } - - public static void print(Order order, Map parameters) { - print("/planner/index.zul", entryPointForShowingOrder(order), parameters); - } - - public static void print(Order order, HashMap parameters, Planner planner) { - print("/planner/index.zul", entryPointForShowingOrder(order), parameters, planner); - } - - public static void print() { - print("/planner/index.zul", Collections. emptyMap(), Collections. emptyMap()); - } - - public static void print(Map parameters) { - print("/planner/index.zul", Collections. emptyMap(), parameters); - } - - public static void print(HashMap parameters, Planner planner) { - print("/planner/index.zul", Collections. emptyMap(), parameters, planner); - } - - private static Map entryPointForShowingOrder(Order order) { - final Map result = new HashMap<>(); - result.put("order", order.getCode() + ""); - - return result; - } - - public static void print( - final String forwardURL, final Map entryPointsMap, Map parameters) { - print(forwardURL, entryPointsMap, parameters, null); - } - - public static void print(final String forwardURL, - final Map entryPointsMap, - Map parameters, - Planner planner) { - - CutyCaptParameters params = new CutyCaptParameters(forwardURL, entryPointsMap, parameters, planner); - String generatedSnapshotServerPath = takeSnapshot(params); - - openInAnotherTab(generatedSnapshotServerPath); - } - - private static void openInAnotherTab(String producedPrintFilePath) { - Executions.getCurrent().sendRedirect(producedPrintFilePath, "_blank"); - } - private static class CutyCaptParameters { private static final AtomicLong counter = new AtomicLong(); private final HttpServletRequest request = (HttpServletRequest) Executions.getCurrent().getNativeRequest(); + private final ServletContext context = request.getSession().getServletContext(); private final String forwardURL; + private final Map entryPointsMap; + private final Map printParameters; + private final Planner planner; private final boolean containersExpandedByDefault; + private final int minWidthForTaskNameColumn; private final String generatedSnapshotServerPath; @@ -149,10 +105,9 @@ public class CutyPrint { Planner planner) { this.forwardURL = forwardURL; - this.entryPointsMap = (entryPointsMap != null) ? entryPointsMap : Collections. emptyMap(); + this.entryPointsMap = (entryPointsMap != null) ? entryPointsMap : Collections.emptyMap(); - this.printParameters = - (printParameters != null) ? printParameters : Collections. emptyMap(); + this.printParameters = (printParameters != null) ? printParameters : Collections.emptyMap(); this.planner = planner; @@ -166,11 +121,13 @@ public class CutyPrint { } private String buildCaptureDestination(String extension) { - if ( StringUtils.isEmpty(extension) ) { - extension = ".pdf"; + String newExtension = extension; + + if ( StringUtils.isEmpty(newExtension) ) { + newExtension = ".pdf"; } - - return String.format("/print/%tY% parameters) { + print(INDEX_ZUL, entryPointForShowingOrder(order), parameters); + } + + public static void print(Order order, Map parameters, Planner planner) { + print(INDEX_ZUL, entryPointForShowingOrder(order), parameters, planner); + } + + public static void print() { + print(INDEX_ZUL, Collections.emptyMap(), Collections.emptyMap()); + } + + public static void print(Map parameters) { + print(INDEX_ZUL, Collections.emptyMap(), parameters); + } + + public static void print(Map parameters, Planner planner) { + print(INDEX_ZUL, Collections.emptyMap(), parameters, planner); + } + + private static Map entryPointForShowingOrder(Order order) { + final Map result = new HashMap<>(); + result.put("order", order.getCode() + ""); + return result; + } + + public static void print(final String forwardURL, final Map entryPointsMap, Map parameters) { + print(forwardURL, entryPointsMap, parameters, null); + } + + public static void print(final String forwardURL, + final Map entryPointsMap, + Map parameters, + Planner planner) { + + CutyCaptParameters params = new CutyCaptParameters(forwardURL, entryPointsMap, parameters, planner); + String generatedSnapshotServerPath = takeSnapshot(params); + + openInAnotherTab(generatedSnapshotServerPath); + } + + private static void openInAnotherTab(String producedPrintFilePath) { + Executions.getCurrent().sendRedirect(producedPrintFilePath, "_blank"); } /** @@ -381,7 +399,7 @@ public class CutyPrint { printProcess = capture.start(); printProcess.waitFor(); - // once the printProcess finishes, the print snapshot is available + // Once the printProcess finishes, the print snapshot is available return generatedSnapshotServerPath; } catch (InterruptedException e) { throw new RuntimeException(e); @@ -406,20 +424,4 @@ public class CutyPrint { } } - private static IServletRequestHandler executeOnOriginalContext(final IServletRequestHandler original) { - final SecurityContext originalContext = SecurityContextHolder.getContext(); - final Locale current = Locales.getCurrent(); - - return new IServletRequestHandler() { - @Override - public void handle( - HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - - Locales.setThreadLocal(current); - SecurityContextHolder.setContext(originalContext); - original.handle(request, response); - } - }; - } - } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/resourceload/ResourceLoadController.java b/libreplan-webapp/src/main/java/org/libreplan/web/resourceload/ResourceLoadController.java index 61bb6e882..4f901c726 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/resourceload/ResourceLoadController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/resourceload/ResourceLoadController.java @@ -134,15 +134,14 @@ public class ResourceLoadController implements Composer { } }; - - public ResourceLoadController() {} + public ResourceLoadController() { + } @Override public void doAfterCompose(org.zkoss.zk.ui.Component comp) { this.parent = comp; } - public void add(IToolbarCommand... commands) { Validate.noNullElements(commands); this.commands.addAll(Arrays.asList(commands)); @@ -179,7 +178,6 @@ public class ResourceLoadController implements Composer { }); } - public interface IListenerAdder { Object addAndReturnListener(ResourcesLoadPanel panel); @@ -197,10 +195,12 @@ public class ResourceLoadController implements Composer { super(onChange, filterBy); } + @Override void setup(ResourcesLoadPanel panel) { panel.setLoadChart(buildChart(emitter)); } + @Override public Object addAndReturnListener(ResourcesLoadPanel panel) { IChartVisibilityChangedListener visibilityChangedListener = fillOnChartVisibilityChange(); panel.addChartVisibilityListener(visibilityChangedListener); @@ -209,8 +209,7 @@ public class ResourceLoadController implements Composer { } private IChartVisibilityChangedListener fillOnChartVisibilityChange() { - IChartVisibilityChangedListener result = new IChartVisibilityChangedListener() { - + return new IChartVisibilityChangedListener() { @Override public void chartVisibilityChanged(final boolean visible) { if (visible && loadChart != null) { @@ -218,7 +217,6 @@ public class ResourceLoadController implements Composer { } } }; - return result; } private Tabbox buildChart(Emitter timePlot) { @@ -291,7 +289,6 @@ public class ResourceLoadController implements Composer { private Timeplot createEmptyTimeplot() { Timeplot timeplot = new Timeplot(); timeplot.appendChild(new Plotinfo()); - return timeplot; } } @@ -318,13 +315,17 @@ public class ResourceLoadController implements Composer { return filterBy != null; } - void setup(ResourcesLoadPanel panel) {} + void setup(ResourcesLoadPanel panel) { + } - void checkDependencies() {} + void checkDependencies() { + } - void applyToParameters(ResourceLoadParameters parameters) {} + void applyToParameters(ResourceLoadParameters parameters) { + } - void updateUI(ResourcesLoadPanel panel, ResourceLoadDisplayData generatedData) {} + void updateUI(ResourcesLoadPanel panel, ResourceLoadDisplayData generatedData) { + } } private abstract static class DependingOnFiltering extends VisualizationModifier { @@ -514,7 +515,6 @@ public class ResourceLoadController implements Composer { if ( isAppliedToOrder() ) { return; } - panel.setSecondOptionalFilter(buildBandboxFilterer()); } @@ -543,7 +543,6 @@ public class ResourceLoadController implements Composer { private Label getLabel() { updateLabelValue(); - return label; } @@ -711,11 +710,9 @@ public class ResourceLoadController implements Composer { // TODO resolve deprecated if ( !ObjectUtils.equals(aElement.getId(), bElement.getId()) ) { - return false; } } - return true; } @@ -801,7 +798,8 @@ public class ResourceLoadController implements Composer { private List listenersToAdd = null; - public Reloader() {} + public Reloader() { + } private List getVisualizationModifiers() { if ( visualizationModifiers != null ) { @@ -897,7 +895,6 @@ public class ResourceLoadController implements Composer { public IOnTransaction reload() { return () -> { reloadInTransaction(); - return null; }; } @@ -1066,7 +1063,6 @@ public class ResourceLoadController implements Composer { } - public void setPlanningControllerEntryPoints(IOrderPlanningGate planningControllerEntryPoints) { this.planningControllerEntryPoints = planningControllerEntryPoints; } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/PersonalTimesheetDTO.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/PersonalTimesheetDTO.java index 0f6c6a6d4..db326f16d 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/PersonalTimesheetDTO.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/dashboard/PersonalTimesheetDTO.java @@ -27,15 +27,16 @@ import org.libreplan.business.workingday.EffortDuration; import org.libreplan.business.workreports.entities.WorkReport; /** - * Simple class to represent the personal timesheets to be shown in the list.
- * - * This is only a utility class for the UI, everything will be saved using - * {@link WorkReport} class. + * Simple class to represent the personal timesheets to be shown in the list. + *
+ * This is only a utility class for the UI, everything will be saved using {@link WorkReport} class. * * @author Manuel Rego Casasnovas */ public class PersonalTimesheetDTO { + private static final String MMMM_Y_PATTERN = "MMMM y"; + private LocalDate date; private WorkReport workReport; @@ -61,9 +62,8 @@ public class PersonalTimesheetDTO { * @param tasksNumber * Number of tasks in the personal timesheet */ - public PersonalTimesheetDTO(LocalDate date, WorkReport workReport, - EffortDuration resourceCapacity, EffortDuration totalHours, - int tasksNumber) { + public PersonalTimesheetDTO(LocalDate date, WorkReport workReport, EffortDuration resourceCapacity, + EffortDuration totalHours, int tasksNumber) { this.date = date; this.workReport = workReport; this.resourceCapacity = resourceCapacity; @@ -101,30 +101,31 @@ public class PersonalTimesheetDTO { */ public static String toString(PersonalTimesheetsPeriodicityEnum periodicity, LocalDate date) { switch (periodicity) { + case WEEKLY: LocalDate start = periodicity.getStart(date); LocalDate end = periodicity.getEnd(date); String string = date.toString("w"); if (start.getMonthOfYear() == end.getMonthOfYear()) { - string += " (" + date.toString("MMMM y") + ")"; + string += " (" + date.toString(MMMM_Y_PATTERN) + ")"; } else { if (start.getYear() == end.getYear()) { - string += " (" + start.toString("MMMM") + " - " - + end.toString("MMMM y") + ")"; + string += " (" + start.toString("MMMM") + " - " + end.toString(MMMM_Y_PATTERN) + ")"; } else { - string += " (" + start.toString("MMMM y") + " - " - + end.toString("MMMM y") + ")"; + string += " (" + start.toString(MMMM_Y_PATTERN) + " - " + end.toString(MMMM_Y_PATTERN) + ")"; } } return _("Week {0}", string); + case TWICE_MONTHLY: - return (date.getDayOfMonth() <= 15) ? - _("{0} 1st fortnight", date.toString("MMMM y")) : - _("{0} 2nd fortnight", date.toString("MMMM y")); + return (date.getDayOfMonth() <= 15) + ? _("{0} 1st fortnight", date.toString(MMMM_Y_PATTERN)) + : _("{0} 2nd fortnight", date.toString(MMMM_Y_PATTERN)); + case MONTHLY: default: - return date.toString("MMMM y"); + return date.toString(MMMM_Y_PATTERN); } } diff --git a/libreplan-webapp/src/main/resources/i18n/ca.po b/libreplan-webapp/src/main/resources/i18n/ca.po index d74f30c2b..9b9bf1147 100644 --- a/libreplan-webapp/src/main/resources/i18n/ca.po +++ b/libreplan-webapp/src/main/resources/i18n/ca.po @@ -3575,6 +3575,9 @@ msgid "Extra" msgstr "Extra" #: libreplan-webapp/src/main/java/org/libreplan/web/common/components/TwoWaySelector.java:79 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:576 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:585 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:593 msgid "Unassigned" msgstr "Sense assignar" @@ -7221,12 +7224,6 @@ msgstr "Nombre d'aplicacions finalitzades" msgid "Invalid queue element" msgstr "Element de cua invàlid" -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:576 -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:585 -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:593 -msgid "Unassigned" -msgstr "Sense assignar" - #: libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardController.java:236 #: libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardController.java:263 #: libreplan-webapp/src/main/webapp/myaccount/_personalTimesheetsArea.zul:35 diff --git a/libreplan-webapp/src/main/resources/i18n/cs.po b/libreplan-webapp/src/main/resources/i18n/cs.po index b01fc37dd..9acb0392b 100644 --- a/libreplan-webapp/src/main/resources/i18n/cs.po +++ b/libreplan-webapp/src/main/resources/i18n/cs.po @@ -3542,6 +3542,9 @@ msgid "Extra" msgstr "Navíc" #: libreplan-webapp/src/main/java/org/libreplan/web/common/components/TwoWaySelector.java:79 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:576 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:585 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:593 msgid "Unassigned" msgstr "Nepřiděleno" @@ -7138,12 +7141,6 @@ msgstr "Počet dokončených aplikací" msgid "Invalid queue element" msgstr "Neplatný prvek fronty" -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:576 -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:585 -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:593 -msgid "Unassigned" -msgstr "Nepřiděleno" - #: libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardController.java:236 #: libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardController.java:263 #: libreplan-webapp/src/main/webapp/myaccount/_personalTimesheetsArea.zul:35 diff --git a/libreplan-webapp/src/main/resources/i18n/de.po b/libreplan-webapp/src/main/resources/i18n/de.po index 78e84f676..32eae3112 100644 --- a/libreplan-webapp/src/main/resources/i18n/de.po +++ b/libreplan-webapp/src/main/resources/i18n/de.po @@ -3543,6 +3543,9 @@ msgid "Extra" msgstr "Extra" #: libreplan-webapp/src/main/java/org/libreplan/web/common/components/TwoWaySelector.java:79 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:576 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:585 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:593 msgid "Unassigned" msgstr "Nicht zugeordnet" @@ -7139,12 +7142,6 @@ msgstr "Anzahl beendetet Anwendungen" msgid "Invalid queue element" msgstr "Ungültiges Ablaufelement" -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:576 -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:585 -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:593 -msgid "Unassigned" -msgstr "" - #: libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardController.java:236 #: libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardController.java:263 #: libreplan-webapp/src/main/webapp/myaccount/_personalTimesheetsArea.zul:35 diff --git a/libreplan-webapp/src/main/resources/i18n/pl.po b/libreplan-webapp/src/main/resources/i18n/pl.po index b5a233480..111d791e4 100644 --- a/libreplan-webapp/src/main/resources/i18n/pl.po +++ b/libreplan-webapp/src/main/resources/i18n/pl.po @@ -2977,6 +2977,9 @@ msgid "Project" msgstr "Projekt" #: libreplan-webapp/src/main/java/org/libreplan/web/common/components/TwoWaySelector.java:79 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:575 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:584 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:592 msgid "Unassigned" msgstr "Nieprzypisany" @@ -6032,12 +6035,6 @@ msgstr "Liczba zakończonych aplikacji" msgid "Invalid queue element" msgstr "Nieprawidłowy element kolejki" -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:575 -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:584 -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:592 -msgid "Unassigned" -msgstr "Nieprzypisany" - #: libreplan-webapp/src/main/java/org/libreplan/web/orders/criterionrequirements/AssignedCriterionRequirementController.java:405 msgid "At least one HoursGroup is needed" msgstr "Co najmniej jedna HoursGroup jest potrzebna" diff --git a/libreplan-webapp/src/main/resources/i18n/pt.po b/libreplan-webapp/src/main/resources/i18n/pt.po index 4ba6838b5..90efa8af8 100644 --- a/libreplan-webapp/src/main/resources/i18n/pt.po +++ b/libreplan-webapp/src/main/resources/i18n/pt.po @@ -3577,6 +3577,9 @@ msgid "Extra" msgstr "Extra" #: libreplan-webapp/src/main/java/org/libreplan/web/common/components/TwoWaySelector.java:79 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:576 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:585 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:593 msgid "Unassigned" msgstr "Não atribuído" @@ -7223,12 +7226,6 @@ msgstr "Número de aplicações finalizadas" msgid "Invalid queue element" msgstr "Elemento de fila inválido" -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:576 -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:585 -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:593 -msgid "Unassigned" -msgstr "Não atribuído" - #: libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardController.java:236 #: libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardController.java:263 #: libreplan-webapp/src/main/webapp/myaccount/_personalTimesheetsArea.zul:35 diff --git a/libreplan-webapp/src/main/resources/i18n/ru.po b/libreplan-webapp/src/main/resources/i18n/ru.po index 461f8d846..a2d3f822a 100644 --- a/libreplan-webapp/src/main/resources/i18n/ru.po +++ b/libreplan-webapp/src/main/resources/i18n/ru.po @@ -2978,6 +2978,9 @@ msgid "Project" msgstr "Проект" #: libreplan-webapp/src/main/java/org/libreplan/web/common/components/TwoWaySelector.java:79 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:575 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:584 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:592 msgid "Unassigned" msgstr "Нераспределенные" @@ -5962,12 +5965,6 @@ msgstr "Количество законченных приложений" msgid "Invalid queue element" msgstr "Неверный элемент очереди" -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:575 -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:584 -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:592 -msgid "Unassigned" -msgstr "Нераспределенный" - #: libreplan-webapp/src/main/webapp/externalcompanies/_editExternalCompany.zul:61 #: libreplan-webapp/src/main/webapp/common/layout/login.zul:70 msgid "User" diff --git a/libreplan-webapp/src/main/resources/i18n/zh.po b/libreplan-webapp/src/main/resources/i18n/zh.po index 0abbe1733..bd97d38b3 100644 --- a/libreplan-webapp/src/main/resources/i18n/zh.po +++ b/libreplan-webapp/src/main/resources/i18n/zh.po @@ -3575,6 +3575,9 @@ msgid "Extra" msgstr "额外" #: libreplan-webapp/src/main/java/org/libreplan/web/common/components/TwoWaySelector.java:79 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:576 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:585 +#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:593 msgid "Unassigned" msgstr "未分配" @@ -7221,12 +7224,6 @@ msgstr "完成的应用程序数量" msgid "Invalid queue element" msgstr "无效的队列元素" -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:576 -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:585 -#: libreplan-webapp/src/main/java/org/libreplan/web/limitingresources/ManualAllocationController.java:593 -msgid "Unassigned" -msgstr "Unassigned" - #: libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardController.java:236 #: libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardController.java:263 #: libreplan-webapp/src/main/webapp/myaccount/_personalTimesheetsArea.zul:35 diff --git a/libreplan-webapp/src/main/resources/log4j.xml b/libreplan-webapp/src/main/resources/log4j.xml index 6615f947a..30709d35d 100644 --- a/libreplan-webapp/src/main/resources/log4j.xml +++ b/libreplan-webapp/src/main/resources/log4j.xml @@ -2,102 +2,115 @@ - - - - - - - - - + + + + + + - - - - + + + - - - + + + + - - - + + + - - - - + + + - - - + + + + - - - + + + - - - - + + + - - - - - - + + + + - - - - - + + + + + + - - - - + + + + + - - - + + + - - - - + + + + - - - - + + + + - - - - + + + + + + + + - - - - - - - - + + + + - - - - + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libreplan-webapp/src/main/webapp/WEB-INF/web.xml b/libreplan-webapp/src/main/webapp/WEB-INF/web.xml index 3f79ec1e9..0d9d85935 100644 --- a/libreplan-webapp/src/main/webapp/WEB-INF/web.xml +++ b/libreplan-webapp/src/main/webapp/WEB-INF/web.xml @@ -124,9 +124,7 @@ CXF Servlet CXFServlet - - org.apache.cxf.transport.servlet.CXFServlet - + org.apache.cxf.transport.servlet.CXFServlet 1 diff --git a/libreplan-webapp/src/main/webapp/WEB-INF/zk.xml b/libreplan-webapp/src/main/webapp/WEB-INF/zk.xml index 061e7dd0f..37c3aa601 100644 --- a/libreplan-webapp/src/main/webapp/WEB-INF/zk.xml +++ b/libreplan-webapp/src/main/webapp/WEB-INF/zk.xml @@ -29,9 +29,7 @@ ThreadLocal - - org.springframework.security.core.context.ThreadLocalSecurityContextHolderStrategy=contextHolder - + org.springframework.security.core.context.ThreadLocalSecurityContextHolderStrategy=contextHolder diff --git a/libreplan-webapp/src/main/webapp/resourceload/_resourceload.zul b/libreplan-webapp/src/main/webapp/resourceload/_resourceload.zul index 24aa534ca..c6d0ec5e8 100644 --- a/libreplan-webapp/src/main/webapp/resourceload/_resourceload.zul +++ b/libreplan-webapp/src/main/webapp/resourceload/_resourceload.zul @@ -22,11 +22,10 @@ - - + + -

-
+
\ No newline at end of file diff --git a/pom.xml b/pom.xml index eac2e4ba6..73cc5b015 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ UTF-8 - 8081 + 8080 9967 @@ -166,6 +166,12 @@ thirdparty http://nexus.libreplan.org/nexus/content/repositories/thirdparty-libreplan16/ + + + + ZK CE + http://mavensync.zkoss.org/maven2/ + @@ -404,13 +410,6 @@ 1.2 - - - org.slf4j - slf4j-api - 1.7.21 - - org.slf4j @@ -462,9 +461,26 @@ org.jruby jruby + + org.slf4j + slf4j-jdk14 + + + org.zkoss.common + zcommon + 8.0.1.1 + + + org.slf4j + slf4j-jdk14 + + + + + org.jgrapht @@ -588,7 +604,7 @@ org.zkoss.zkforge timeplotz - 1.1_50_1 + 1.1_50 @@ -833,12 +849,11 @@ manual ${jetty-stop-port} stop - + true @@ -854,20 +869,13 @@ ${jdbcDriver.version} - + com.jolbox bonecp 0.8.0.RELEASE - - - org.slf4j - slf4j-api - 1.7.21 - - org.slf4j slf4j-simple From 321d5cf56740dca4421dec1b8c578826a43f2da0 Mon Sep 17 00:00:00 2001 From: Vova Perebykivskyi Date: Thu, 17 Nov 2016 11:05:25 +0200 Subject: [PATCH 4/4] Update hibernate-core to 5.1.1. Resolve some no sessions exceptions. --- .../business/orders/entities/Orders.hbm.xml | 34 +- .../web/planner/TaskElementAdapter.java | 335 ++++++++---------- pom.xml | 3 +- 3 files changed, 156 insertions(+), 216 deletions(-) diff --git a/libreplan-business/src/main/resources/org/libreplan/business/orders/entities/Orders.hbm.xml b/libreplan-business/src/main/resources/org/libreplan/business/orders/entities/Orders.hbm.xml index 3415245de..c4f710cb9 100644 --- a/libreplan-business/src/main/resources/org/libreplan/business/orders/entities/Orders.hbm.xml +++ b/libreplan-business/src/main/resources/org/libreplan/business/orders/entities/Orders.hbm.xml @@ -1,6 +1,5 @@ - + @@ -94,8 +93,7 @@ - + @@ -105,18 +103,20 @@ - + - + + + + + @@ -182,8 +182,7 @@ - + @@ -231,7 +230,6 @@ - @@ -249,10 +247,9 @@ - + - + @@ -264,13 +261,12 @@ - + - + @@ -313,6 +309,7 @@ + @@ -351,8 +348,7 @@ - + diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/planner/TaskElementAdapter.java b/libreplan-webapp/src/main/java/org/libreplan/web/planner/TaskElementAdapter.java index 5cda22893..6bd7d34be 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/planner/TaskElementAdapter.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/planner/TaskElementAdapter.java @@ -115,6 +115,35 @@ public class TaskElementAdapter { private static final Log LOG = LogFactory.getLog(TaskElementAdapter.class); + @Autowired + private IAdHocTransactionService transactionService; + + @Autowired + private IOrderElementDAO orderElementDAO; + + @Autowired + private ITaskElementDAO taskDAO; + + @Autowired + private ICriterionDAO criterionDAO; + + @Autowired + private IResourceAllocationDAO resourceAllocationDAO; + + @Autowired + private IExternalCompanyDAO externalCompanyDAO; + + @Autowired + private IResourcesSearcher searcher; + + @Autowired + private IConfigurationDAO configurationDAO; + + @Autowired + private IMoneyCostCalculator moneyCostCalculator; + + private final ReentranceGuard reentranceGuard = new ReentranceGuard(); + public static List> getStartConstraintsFor(TaskElement taskElement, LocalDate orderInitDate) { if ( taskElement instanceof ITaskPositionConstrained ) { ITaskPositionConstrained task = (ITaskPositionConstrained) taskElement; @@ -123,16 +152,18 @@ public class TaskElementAdapter { switch (constraintType) { case AS_SOON_AS_POSSIBLE: - if ( orderInitDate != null ) { - return Collections.singletonList(biggerOrEqualThan(toGantt(orderInitDate))); - } - return Collections.emptyList(); + return orderInitDate != null + ? Collections.singletonList(biggerOrEqualThan(toGantt(orderInitDate))) + : Collections.emptyList(); case START_IN_FIXED_DATE: return Collections.singletonList(equalTo(toGantt(startConstraint.getConstraintDate()))); case START_NOT_EARLIER_THAN: return Collections.singletonList(biggerOrEqualThan(toGantt(startConstraint.getConstraintDate()))); + + default: + break; } } @@ -152,9 +183,10 @@ public class TaskElementAdapter { } case FINISH_NOT_LATER_THAN: - GanttDate date = toGantt(endConstraint.getConstraintDate()); + return Collections.singletonList(lessOrEqualThan(toGantt(endConstraint.getConstraintDate()))); - return Collections.singletonList(lessOrEqualThan(date)); + default: + break; } } @@ -166,24 +198,22 @@ public class TaskElementAdapter { } public static GanttDate toGantt(IntraDayDate date, EffortDuration dayCapacity) { + EffortDuration newDayCapacity = dayCapacity; + if ( date == null ) { return null; } - if ( dayCapacity == null ) { - // a sensible default - dayCapacity = EffortDuration.hours(8); + if ( newDayCapacity == null ) { + // A sensible default + newDayCapacity = EffortDuration.hours(8); } - return new GanttDateAdapter(date, dayCapacity); + return new GanttDateAdapter(date, newDayCapacity); } public static GanttDate toGantt(LocalDate date) { - if ( date == null ) { - return null; - } - - return GanttDate.createFrom(date); + return date == null ? null : GanttDate.createFrom(date); } public static IntraDayDate toIntraDay(GanttDate date) { @@ -228,40 +258,12 @@ public class TaskElementAdapter { return date != null ? LocalDate.fromDateFields(date) : null; } - @Autowired - private IAdHocTransactionService transactionService; - - private final ReentranceGuard reentranceGuard = new ReentranceGuard(); - - @Autowired - private IOrderElementDAO orderElementDAO; - - @Autowired - private ITaskElementDAO taskDAO; - - @Autowired - private ICriterionDAO criterionDAO; - - @Autowired - private IResourceAllocationDAO resourceAllocationDAO; - - @Autowired - private IExternalCompanyDAO externalCompanyDAO; - - @Autowired - private IResourcesSearcher searcher; - - @Autowired - private IConfigurationDAO configurationDAO; - - @Autowired - private IMoneyCostCalculator moneyCostCalculator; - static class GanttDateAdapter extends CustomDate { private static final int DAY_MILLISECONDS = (int) Days.days(1).toStandardDuration().getMillis(); private final IntraDayDate date; + private final Duration workingDayDuration; GanttDateAdapter(IntraDayDate date, EffortDuration capacityForDay) { @@ -269,16 +271,17 @@ public class TaskElementAdapter { this.workingDayDuration = toMilliseconds(capacityForDay); } + @Override protected int compareToCustom(CustomDate customType) { if ( customType instanceof GanttDateAdapter ) { GanttDateAdapter other = (GanttDateAdapter) customType; - return this.date.compareTo(other.date); } throw new RuntimeException("incompatible type: " + customType); } + @Override protected int compareToLocalDate(LocalDate localDate) { return this.date.compareTo(localDate); } @@ -306,7 +309,6 @@ public class TaskElementAdapter { protected boolean isEqualsToCustom(CustomDate customType) { if ( customType instanceof GanttDateAdapter ) { GanttDateAdapter other = (GanttDateAdapter) customType; - return this.date.equals(other.date); } @@ -337,7 +339,7 @@ public class TaskElementAdapter { try { return new Duration(fraction.multiplyBy(Fraction.getFraction(DAY_MILLISECONDS, 1)).intValue()); } catch (ArithmeticException e) { - // if fraction overflows use floating point arithmetic + // If fraction overflows use floating point arithmetic return new Duration((int) (fraction.doubleValue() * DAY_MILLISECONDS)); } } @@ -346,7 +348,7 @@ public class TaskElementAdapter { private Fraction fractionOfWorkingDayFor(EffortDuration effortDuration) { Duration durationInDay = toMilliseconds(effortDuration); - // cast to int is safe because there are not enough seconds in day to overflow + // Cast to int is safe because there are not enough seconds in day to overflow Fraction fraction = Fraction.getFraction( (int) durationInDay.getStandardSeconds(), (int) workingDayDuration.getStandardSeconds()); @@ -360,8 +362,8 @@ public class TaskElementAdapter { } /** - * Responsible of adaptation a {@link TaskElement} into a {@link ITaskFundamentalProperties}
- * + * Responsible of adaptation a {@link TaskElement} into a {@link ITaskFundamentalProperties}. + *
* @author Óscar González Fernández */ public class Adapter implements IAdapterToTaskFundamentalProperties { @@ -376,6 +378,14 @@ public class TaskElementAdapter { private final PlanningState planningState; + public Adapter() { + this(null); + } + + public Adapter(PlanningState planningState) { + this.planningState = planningState; + } + private void useScenario(Scenario scenario) { this.scenario = scenario; } @@ -397,26 +407,12 @@ public class TaskElementAdapter { this.preventCalculateResourcesText = preventCalculateResourcesText; } - public Adapter() { - this(null); - } - - public Adapter(PlanningState planningState) { - this.planningState = planningState; - } - private class TaskElementWrapper implements ITaskFundamentalProperties { private final TaskElement taskElement; private final Scenario currentScenario; - protected TaskElementWrapper(Scenario currentScenario, TaskElement taskElement) { - Validate.notNull(currentScenario); - this.currentScenario = currentScenario; - this.taskElement = taskElement; - } - private final IUpdatablePosition position = new IUpdatablePosition() { @Override @@ -456,8 +452,34 @@ public class TaskElementAdapter { task.explicityMoved(toIntraDay(newStart), toIntraDay(newEnd)); } } + + private void updateTaskPositionConstraint(GanttDate endDate) { + if ( taskElement instanceof ITaskPositionConstrained ) { + ITaskPositionConstrained task = (ITaskPositionConstrained) taskElement; + PositionConstraintType constraintType = task.getPositionConstraint().getConstraintType(); + + if ( constraintType.compareTo(PositionConstraintType.FINISH_NOT_LATER_THAN) == 0 || + constraintType.compareTo(PositionConstraintType.AS_LATE_AS_POSSIBLE) == 0) { + + task.explicityMoved(taskElement.getIntraDayStartDate(), toIntraDay(endDate)); + } + } + } + + private GanttDate inferEndFrom(GanttDate newStart) { + return taskElement instanceof Task + ? toGantt(((Task) taskElement).calculateEndKeepingLength(toIntraDay(newStart))) + : newStart; + } }; + + protected TaskElementWrapper(Scenario currentScenario, TaskElement taskElement) { + Validate.notNull(currentScenario); + this.currentScenario = currentScenario; + this.taskElement = taskElement; + } + @Override public void setName(String name) { taskElement.setName(name); @@ -490,18 +512,14 @@ public class TaskElementAdapter { @Override public GanttDate getBeginDate() { - IntraDayDate start = taskElement.getIntraDayStartDate(); - - return toGantt(start); + return toGantt(taskElement.getIntraDayStartDate()); } private GanttDate toGantt(IntraDayDate date) { BaseCalendar calendar = taskElement.getCalendar(); - if ( calendar == null ) { - return TaskElementAdapter.toGantt(date); - } - - return TaskElementAdapter.toGantt(date, calendar.getCapacityOn(PartialDay.wholeDay(date.getDate()))); + return calendar == null + ? TaskElementAdapter.toGantt(date) + : TaskElementAdapter.toGantt(date, calendar.getCapacityOn(PartialDay.wholeDay(date.getDate()))); } @Override @@ -540,19 +558,6 @@ public class TaskElementAdapter { return taskElement.getDatesHandler(currentScenario, searcher); } - private void updateTaskPositionConstraint(GanttDate endDate) { - if ( taskElement instanceof ITaskPositionConstrained ) { - ITaskPositionConstrained task = (ITaskPositionConstrained) taskElement; - PositionConstraintType constraintType = task.getPositionConstraint().getConstraintType(); - - if ( constraintType.compareTo(PositionConstraintType.FINISH_NOT_LATER_THAN) == 0 || - constraintType.compareTo(PositionConstraintType.AS_LATE_AS_POSSIBLE) == 0) { - - task.explicityMoved(taskElement.getIntraDayStartDate(), toIntraDay(endDate)); - } - } - } - @Override public GanttDate getHoursAdvanceBarEndDate() { return calculateLimitDateProportionalToTaskElementSize(getHoursAdvanceBarPercentage()); @@ -580,7 +585,8 @@ public class TaskElementAdapter { } } - return new BigDecimal(totalChargedEffort.divivedBy(estimatedEffort).doubleValue()) + return BigDecimal + .valueOf(totalChargedEffort.divivedBy(estimatedEffort).doubleValue()) .setScale(2, RoundingMode.HALF_UP); } @@ -611,46 +617,33 @@ public class TaskElementAdapter { } private BigDecimal getBudget() { - if ( (taskElement == null) || (taskElement.getOrderElement() == null) ) { - return BigDecimal.ZERO; - } - - return taskElement.getOrderElement().getBudget(); + return (taskElement == null) || (taskElement.getOrderElement() == null) + ? BigDecimal.ZERO + : taskElement.getOrderElement().getBudget(); } private BigDecimal getTotalCalculatedBudget() { - if ( (taskElement == null) || (taskElement.getOrderElement() == null) ) { - return BigDecimal.ZERO; - } - - return transactionService.runOnReadOnlyTransaction(() -> taskElement.getOrderElement().getTotalBudget()); + return (taskElement == null) || (taskElement.getOrderElement() == null) + ? BigDecimal.ZERO + : transactionService.runOnReadOnlyTransaction(() -> taskElement.getOrderElement().getTotalBudget()); } private BigDecimal getMoneyCost() { - if ( (taskElement == null) || (taskElement.getOrderElement() == null) ) { - return BigDecimal.ZERO; - } - - return transactionService.runOnReadOnlyTransaction(() -> - moneyCostCalculator.getTotalMoneyCost(taskElement.getOrderElement())); + return (taskElement == null) || (taskElement.getOrderElement() == null) + ? BigDecimal.ZERO + : transactionService.runOnReadOnlyTransaction(() -> moneyCostCalculator.getTotalMoneyCost(taskElement.getOrderElement())); } private BigDecimal getHoursMoneyCost() { - if ( (taskElement == null) || (taskElement.getOrderElement() == null) ) { - return BigDecimal.ZERO; - } - - return transactionService.runOnReadOnlyTransaction(() -> - moneyCostCalculator.getHoursMoneyCost(taskElement.getOrderElement())); + return (taskElement == null) || (taskElement.getOrderElement() == null) + ? BigDecimal.ZERO + : transactionService.runOnReadOnlyTransaction(() -> moneyCostCalculator.getHoursMoneyCost(taskElement.getOrderElement())); } private BigDecimal getExpensesMoneyCost() { - if ( (taskElement == null) || (taskElement.getOrderElement() == null) ) { - return BigDecimal.ZERO; - } - - return transactionService.runOnReadOnlyTransaction(() -> - moneyCostCalculator.getExpensesMoneyCost(taskElement.getOrderElement())); + return (taskElement == null) || (taskElement.getOrderElement() == null) + ? BigDecimal.ZERO + : transactionService.runOnReadOnlyTransaction(() -> moneyCostCalculator.getExpensesMoneyCost(taskElement.getOrderElement())); } @Override @@ -660,10 +653,10 @@ public class TaskElementAdapter { private GanttDate getAdvanceBarEndDate(ProgressType progressType) { BigDecimal advancePercentage = BigDecimal.ZERO; + if ( taskElement.getOrderElement() != null ) { advancePercentage = taskElement.getAdvancePercentage(progressType); } - return getAdvanceBarEndDate(advancePercentage); } @@ -677,8 +670,7 @@ public class TaskElementAdapter { } private ProgressType getProgressTypeFromConfiguration() { - return transactionService.runOnReadOnlyTransaction(() -> - configurationDAO.getConfiguration().getProgressType()); + return transactionService.runOnReadOnlyTransaction(() -> configurationDAO.getConfiguration().getProgressType()); } private GanttDate getAdvanceBarEndDate(BigDecimal advancePercentage) { @@ -693,7 +685,6 @@ public class TaskElementAdapter { return transactionService.runOnReadOnlyTransaction(() -> { orderElementDAO.reattach(taskElement.getOrderElement()); - return buildTooltipText(); }); } @@ -706,7 +697,6 @@ public class TaskElementAdapter { return transactionService.runOnReadOnlyTransaction(() -> { orderElementDAO.reattach(taskElement.getOrderElement()); - return buildLabelsText(); }); } @@ -723,13 +713,11 @@ public class TaskElementAdapter { if ( taskElement.isSubcontracted() ) { externalCompanyDAO.reattach(taskElement.getSubcontractedCompany()); } - return buildResourcesText(); }); } catch (Exception e) { LOG.error("error calculating resources text", e); - return ""; } } @@ -741,11 +729,9 @@ public class TaskElementAdapter { } else { HashSet