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/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-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..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,10 +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}. * - * @author Created by Vova Perebykivskyi on 20.01.2016. + * 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 4343c0d02..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,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_RESOURCE_REMOVED_FROM_TASK}. * - * @author Created by Vova Perebykivskyi on 20.01.2016. + * 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 5f7a417cd..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}. * - * @author Created by Vova Perebykivskyi on 13.10.2015. + * 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 e0d808d0a..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}. * - * @author Created by Vova Perebykivskyi on 20.01.2016. + * 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 34743d3a9..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 Created by Vova Perebykivskyi on 20.01.2016 + * @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 279f46971..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}. * - * @author Created by Vova Perebykivskyi on 20.01.2016. + * 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/SendEmailOnMilestoneReached.java b/libreplan-webapp/src/main/java/org/libreplan/importers/notifications/realization/SendEmailOnMilestoneReached.java index 0d7fbc976..b27fbecf3 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 @@ -51,7 +51,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 @@ -129,7 +129,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()); @@ -138,14 +141,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 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/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..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 @@ - + 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)