Changes to EmailSending feature.
Code refactoring.
This commit is contained in:
parent
dd06b250c3
commit
acbb41cddf
33 changed files with 144 additions and 111 deletions
|
|
@ -27,7 +27,7 @@ import java.util.List;
|
|||
* DAO interface for the <code>Limits</code> entity.
|
||||
* Contract for {@link LimitsDAO}.
|
||||
*
|
||||
* @author Created by Vova Perebykivskyi <vova@libreplan-enterprise.com> on 17.12.2015.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
public interface ILimitsDAO extends IGenericDAO<Limits, Long> {
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import java.util.List;
|
|||
/**
|
||||
* DAO for {@link Limits}.
|
||||
*
|
||||
* @author Created by Vova Perebykivskyi <vova@libreplan-enterprise.com> on 24.09.2015.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
|
||||
@Repository
|
||||
|
|
@ -41,16 +41,22 @@ public class LimitsDAO extends GenericDAOHibernate<Limits, Long> implements ILim
|
|||
@Override
|
||||
public Limits getUsersType() {
|
||||
List<Limits> 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<Limits> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <vova@libreplan-enterprise.com> on 17.12.2015.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <vova@libreplan-enterprise.com> on 19.10.2015.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
@Repository
|
||||
public class EmailNotificationDAO
|
||||
|
|
@ -54,11 +54,11 @@ public class EmailNotificationDAO
|
|||
public boolean deleteAll() {
|
||||
List<EmailNotification> 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
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ import java.util.List;
|
|||
/**
|
||||
* DAO for {@link EmailTemplate}
|
||||
*
|
||||
* @author Created by Vova Perebykivskyi <vova@libreplan-enterprise.com> on 24.09.2015.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
@Repository
|
||||
public class EmailTemplateDAO extends GenericDAOHibernate<EmailTemplate, Long> implements IEmailTemplateDAO{
|
||||
public class EmailTemplateDAO extends GenericDAOHibernate<EmailTemplate, Long> implements IEmailTemplateDAO {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
|
|
@ -68,6 +68,7 @@ public class EmailTemplateDAO extends GenericDAOHibernate<EmailTemplate, Long> i
|
|||
public void delete(EmailTemplate entity) {
|
||||
try {
|
||||
remove(entity.getId());
|
||||
} catch (InstanceNotFoundException ignored) {}
|
||||
} catch (InstanceNotFoundException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import java.util.List;
|
|||
/**
|
||||
* Contract for {@link EmailNotificationDAO}
|
||||
*
|
||||
* @author Created by Vova Perebykivskyi <vova@libreplan-enterprise.com> on 19.10.2015.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
public interface IEmailNotificationDAO extends IGenericDAO<EmailNotification, Long> {
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import java.util.List;
|
|||
* DAO interface for the <code>EmailTemplate</code> entity.
|
||||
* Contract for {@link EmailTemplateDAO}.
|
||||
*
|
||||
* @author Created by Vova Perebykivskyi <vova@libreplan-enterprise.com> on 29.09.2015.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
public interface IEmailTemplateDAO extends IGenericDAO<EmailTemplate, Long>{
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <vova@libreplan-enterprise.com> on 19.10.2015.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <vova@libreplan-enterprise.com> on 29.09.2015.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,10 +24,10 @@ import static org.libreplan.business.i18n.I18nHelper._;
|
|||
/**
|
||||
* Available E-mail templates.
|
||||
*
|
||||
* @author Created by Vova Perebykivskyi <vova@libreplan-enterprise.com> on 28.09.2015.
|
||||
*
|
||||
* TEMPLATE_N(_("Template N")) - for i18n
|
||||
* TEMPLATE_A("Template A") - for general use (no internationalizing)
|
||||
*
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
public enum EmailTemplateEnum {
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import org.libreplan.business.orders.entities.OrderFile;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Created by Vova Perebykivskyi <vova@libreplan-enterprise.com> on 12.24.2015.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
|
||||
public interface IOrderFileDAO extends IGenericDAO<OrderFile, Long> {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@ import org.springframework.stereotype.Repository;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Created by Vova Perebykivskyi <vova@libreplan-enterprise.com> on 12.24.2015.
|
||||
* DAO for {@link OrderFile}.
|
||||
*
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
|
||||
@Repository
|
||||
|
|
@ -44,7 +46,8 @@ public class OrderFileDAO extends GenericDAOHibernate<OrderFile, Long> implement
|
|||
public void delete(OrderFile file) {
|
||||
try {
|
||||
remove(file.getId());
|
||||
} catch (InstanceNotFoundException ignored) {}
|
||||
} catch (InstanceNotFoundException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -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 <vova@libreplan-enterprise.com> on 25.12.2015.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
|
||||
public class OrderFile extends BaseEntity {
|
||||
|
|
|
|||
|
|
@ -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 <dpino@igalia.com>
|
||||
*/
|
||||
public interface IResourcesSearcher {
|
||||
|
||||
public interface IResourcesQuery<T extends Resource> {
|
||||
interface IResourcesQuery<T extends Resource> {
|
||||
|
||||
/**
|
||||
* 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<T> 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<T> byCriteria(Collection<? extends Criterion> 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<T>}
|
||||
*/
|
||||
List<T> execute();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 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}.
|
||||
* </p>
|
||||
* 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<CriterionType, Set<Criterion>>
|
||||
*/
|
||||
Map<CriterionType, Set<Criterion>> getCriteria();
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the search limited to workers
|
||||
* Do the search limited to workers.
|
||||
*
|
||||
* @return
|
||||
* @return {@link IResourcesQuery<Worker>}
|
||||
*/
|
||||
public IResourcesQuery<Worker> searchWorkers();
|
||||
IResourcesQuery<Worker> searchWorkers();
|
||||
|
||||
/**
|
||||
* Do the search limited to machines
|
||||
* @return
|
||||
* Do the search limited to machines.
|
||||
* @return {@link IResourcesQuery<Machine>}
|
||||
*/
|
||||
public IResourcesQuery<Machine> searchMachines();
|
||||
IResourcesQuery<Machine> 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<Resource>}
|
||||
*/
|
||||
public IResourcesQuery<Resource> searchBoth();
|
||||
IResourcesQuery<Resource> searchBoth();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <vova@libreplan-enterprise.com> on 13.10.2015.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
|
||||
public interface IEmailNotificationJob {
|
||||
|
|
|
|||
|
|
@ -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 <vova@libreplan-enterprise.com> on 20.01.2016.
|
||||
* It is used!
|
||||
*
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
public class SendEmailOnMilestoneReachedJob extends QuartzJobBean {
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <vova@libreplan-enterprise.com> on 20.01.2016.
|
||||
* It is used!
|
||||
*
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
public class SendEmailOnResourceRemovedFromTaskJob extends QuartzJobBean {
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <vova@libreplan-enterprise.com> on 13.10.2015.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
|
||||
public class SendEmailOnTaskAssignedToResourceJob extends QuartzJobBean {
|
||||
|
|
|
|||
|
|
@ -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 <vova@libreplan-enterprise.com> on 20.01.2016.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
public class SendEmailOnTaskShouldFinishJob extends QuartzJobBean {
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <vova@libreplan-enterprise.com> on 20.01.2016
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
public class SendEmailOnTaskShouldStartJob extends QuartzJobBean {
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <vova@libreplan-enterprise.com> on 20.01.2016.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
public class SendEmailOnTimesheetDataMissingJob extends QuartzJobBean {
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <vova@libreplan-enterprise.com> on 20.01.2016.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
|
||||
@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<TaskElement> list = taskElementDAO.getTaskElementsWithMilestones();
|
||||
List<TaskElement> 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();
|
||||
|
|
|
|||
|
|
@ -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 <vova@libreplan-enterprise.com> on 20.01.2016.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
|
||||
@Component
|
||||
|
|
@ -65,9 +65,11 @@ public class SendEmailOnResourceRemovedFromTask implements IEmailNotificationJob
|
|||
List<EmailNotification> 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <vova@libreplan-enterprise.com> on 13.10.2015.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
@Component
|
||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <vova@libreplan-enterprise.com> on 20.01.2016.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
|
||||
@Component
|
||||
|
|
@ -99,9 +99,11 @@ public class SendEmailOnTimesheetDataMissing implements IEmailNotificationJob {
|
|||
List<EmailNotification> 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);
|
||||
|
|
|
|||
|
|
@ -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 <vova@libreplan-enterprise.com> on 25.09.2015.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
|
||||
public class EmailTemplateController extends GenericForwardComposer<Component> {
|
||||
|
||||
private IUserDAO userDAO;
|
||||
|
||||
private User user;
|
||||
|
||||
private IEmailTemplateModel emailTemplateModel;
|
||||
|
||||
private IMessagesForUser messages;
|
||||
|
|
@ -77,8 +68,9 @@ public class EmailTemplateController extends GenericForwardComposer<Component> {
|
|||
|
||||
|
||||
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<Component> {
|
|||
* 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<Component> {
|
|||
subjectTextbox.setValue(emailTemplateModel.getSubject(getSelectedLanguage(), getSelectedEmailTemplateEnum()));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
private void setUser() {
|
||||
try {
|
||||
user = userDAO.findByLoginName(SecurityUtils.getSessionUserLoginName());
|
||||
} catch (InstanceNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import java.util.List;
|
|||
/**
|
||||
* Model for operations related to {@link EmailTemplate}.
|
||||
*
|
||||
* @author Created by Vova Perebykivskyi <vova@libreplan-enterprise.com> on 25.09.2015.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import java.util.List;
|
|||
/**
|
||||
* Contract for {@link EmailTemplate}.
|
||||
*
|
||||
* @author Created by Vova Perebykivskyi <vova@libreplan-enterprise.com> on 28.09.2015.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
public interface IEmailTemplateModel {
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Created by Vova Perebykivskyi <vova@libreplan-enterprise.com> on 12.24.2015.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
|
||||
@Service
|
||||
|
|
@ -80,6 +80,7 @@ public class OrderFileModel implements IOrderFileModel {
|
|||
return fileDAO.findByParent(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderFile getOrderFile() {
|
||||
return orderFile;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ import static org.libreplan.web.I18nHelper._;
|
|||
/**
|
||||
* Controller for managing Order files.
|
||||
*
|
||||
* @author Created by Vova Perebykivskyi <vova@libreplan-enterprise.com> on 12.24.2015.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
|
||||
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)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
<http auto-config="false" realm="LibrePlan Web Application" >
|
||||
|
||||
<!-- In Spring 4.1.0 it is useless to use hasRole() for single role because Spring calling hasAnyRole() anyway -->
|
||||
<!-- In Spring Security 4.1.0 it is useless to use hasRole() for single role because Spring calling hasAnyRole() anyway -->
|
||||
|
||||
<!-- Web services -->
|
||||
<intercept-url pattern="/ws/rest/bounduser/**" access="hasAnyRole('ROLE_BOUND_USER')" method="GET" />
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ import java.util.Date;
|
|||
/**
|
||||
* Tests for {@link OrderFile}.
|
||||
*
|
||||
* @author Created by Vova Perebykivskyi <vova@libreplan-enterprise.com> on 11.01.2016.
|
||||
* @author Vova Perebykivskyi <vova@libreplan-enterprise.com>
|
||||
*/
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue