Merge pull request #125 from PaulLuchyn/master

Bug fixing
This commit is contained in:
Jeroen Baten 2016-11-21 14:51:28 +01:00 committed by GitHub
commit d362632a78
11 changed files with 89 additions and 4 deletions

View file

@ -23,6 +23,7 @@ import java.util.List;
import org.libreplan.business.common.daos.IIntegrationEntityDAO;
import org.libreplan.business.logs.entities.IssueLog;
import org.libreplan.business.orders.entities.Order;
/**
* Contract for {@link IssueLogDAO}
@ -37,4 +38,11 @@ public interface IIssueLogDAO extends IIntegrationEntityDAO<IssueLog> {
* @return a list of {@link IssueLog} objects
*/
List<IssueLog> getIssueLogs();
/**
* Returns a list of {@link IssueLog} for a specified {@link Order}
*
* @param order parent element for IssueLogs
*/
List<IssueLog> getByParent(Order order);
}

View file

@ -23,6 +23,7 @@ import java.util.List;
import org.libreplan.business.common.daos.IIntegrationEntityDAO;
import org.libreplan.business.logs.entities.RiskLog;
import org.libreplan.business.orders.entities.Order;
public interface IRiskLogDAO extends IIntegrationEntityDAO<RiskLog> {
@ -33,4 +34,11 @@ public interface IRiskLogDAO extends IIntegrationEntityDAO<RiskLog> {
*/
List<RiskLog> getRiskLogs();
/**
* Returns a list of {@link RiskLog} for a specified {@link Order}
*
* @param order parent element for RiskLogs
*/
List<RiskLog> getByParent(Order order);
}

View file

@ -21,8 +21,10 @@ package org.libreplan.business.logs.daos;
import java.util.List;
import org.hibernate.criterion.Restrictions;
import org.libreplan.business.common.daos.IntegrationEntityDAO;
import org.libreplan.business.logs.entities.IssueLog;
import org.libreplan.business.orders.entities.Order;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;
@ -42,5 +44,12 @@ public class IssueLogDAO extends IntegrationEntityDAO<IssueLog> implements
return list(IssueLog.class);
}
@Override
public List<IssueLog> getByParent(Order order) {
return getSession()
.createCriteria(IssueLog.class)
.add(Restrictions.eq("project", order))
.list();
}
}

View file

@ -21,8 +21,10 @@ package org.libreplan.business.logs.daos;
import java.util.List;
import org.hibernate.criterion.Restrictions;
import org.libreplan.business.common.daos.IntegrationEntityDAO;
import org.libreplan.business.logs.entities.RiskLog;
import org.libreplan.business.orders.entities.Order;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;
@ -43,4 +45,12 @@ public class RiskLogDAO extends IntegrationEntityDAO<RiskLog> implements
return list(RiskLog.class);
}
@Override
public List<RiskLog> getByParent(Order order) {
return getSession()
.createCriteria(RiskLog.class)
.add(Restrictions.eq("project", order))
.list();
}
}

View file

@ -19,6 +19,8 @@
package org.libreplan.importers.notifications;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.libreplan.business.common.entities.ConnectorProperty;
import org.libreplan.business.email.entities.EmailNotification;
import org.libreplan.business.email.entities.EmailTemplate;
@ -83,6 +85,8 @@ public class ComposeMessage {
private Properties properties;
private static final Log LOG = LogFactory.getLog(ComposeMessage.class);
public boolean composeMessageForUser(EmailNotification notification) {
// Gather data about EmailTemplate needs to be used
@ -102,6 +106,11 @@ public class ComposeMessage {
EmailTemplate currentEmailTemplate = findCurrentEmailTemplate(type, locale);
if (currentEmailTemplate == null) {
LOG.error("Email template is null");
return false;
}
// Modify text that will be composed
String text = currentEmailTemplate.getContent();
text = replaceKeywords(text, currentWorker, notification);

View file

@ -115,5 +115,12 @@ public interface IIssueLogModel {
*/
void remove(IssueLog issueLog);
/**
* Returns a list of {@link IssueLog} for a specified {@link Order}
*
* @param order parent element for IssueLogs
*/
List<IssueLog> getByParent(Order order);
}

View file

@ -115,5 +115,12 @@ public interface IRiskLogModel {
*/
void remove(RiskLog riskLog);
/**
* Returns a list of {@link RiskLog} for a specified {@link Order}
*
* @param order parent element for RiskLogs
*/
List<RiskLog> getByParent(Order order);
}

View file

@ -139,6 +139,11 @@ public class IssueLogModel extends IntegrationEntityModel implements IIssueLogMo
}
}
@Override
public List<IssueLog> getByParent(Order order) {
return issueLogDAO.getByParent(order);
}
@Override
public EntityNameEnum getEntityName() {
return EntityNameEnum.ISSUE_LOG;

View file

@ -140,6 +140,11 @@ public class RiskLogModel extends IntegrationEntityModel implements IRiskLogMode
}
}
@Override
public List<RiskLog> getByParent(Order order) {
return riskLogDAO.getByParent(order);
}
@Override
public EntityNameEnum getEntityName() {
return EntityNameEnum.RISK_LOG;

View file

@ -59,7 +59,6 @@ import org.libreplan.business.orders.entities.Order;
import org.libreplan.business.orders.entities.OrderElement;
import org.libreplan.business.orders.entities.OrderLineGroup;
import org.libreplan.business.orders.entities.OrderStatusEnum;
import org.libreplan.business.orders.entities.OrderFile;
import org.libreplan.business.planner.entities.PositionConstraintType;
import org.libreplan.business.qualityforms.daos.IQualityFormDAO;
import org.libreplan.business.qualityforms.entities.QualityForm;
@ -85,6 +84,8 @@ import org.libreplan.business.users.entities.UserRole;
import org.libreplan.web.calendars.BaseCalendarModel;
import org.libreplan.web.common.IntegrationEntityModel;
import org.libreplan.web.common.concurrentdetection.OnConcurrentModification;
import org.libreplan.web.logs.IIssueLogModel;
import org.libreplan.web.logs.IRiskLogModel;
import org.libreplan.web.orders.files.IOrderFileModel;
import org.libreplan.web.orders.labels.LabelsOnConversation;
import org.libreplan.web.planner.order.ISaveCommand.IBeforeSaveActions;
@ -174,6 +175,12 @@ public class OrderModel extends IntegrationEntityModel implements IOrderModel {
@Autowired
private IOrderFileModel orderFileModel;
@Autowired
private IRiskLogModel riskLogModel;
@Autowired
private IIssueLogModel issueLogModel;
private List<Order> orderList = new ArrayList<>();
@Override
@ -514,8 +521,9 @@ public class OrderModel extends IntegrationEntityModel implements IOrderModel {
public void remove(Order detachedOrder) {
Order order = orderDAO.findExistingEntity(detachedOrder.getId());
List<OrderFile> orderFiles = orderFileModel.findByParent(order);
orderFiles.forEach((orderFile -> orderFileModel.delete(orderFile)));
removeFiles(order);
removeLogs(order);
removeVersions(order);
@ -524,6 +532,15 @@ public class OrderModel extends IntegrationEntityModel implements IOrderModel {
}
}
private void removeLogs(Order order) {
riskLogModel.getByParent(order).forEach(riskLog -> riskLogModel.remove(riskLog));
issueLogModel.getByParent(order).forEach(issueLog -> issueLogModel.remove(issueLog));
}
private void removeFiles(Order order) {
orderFileModel.findByParent(order).forEach(orderFile -> orderFileModel.delete(orderFile));
}
private void removeVersions(Order order) {
Map<Long, OrderVersion> versionsRemovedById = new HashMap<>();
List<Scenario> currentAndDerived = currentAndDerivedScenarios();

View file

@ -605,7 +605,7 @@
<dependency>
<groupId>org.zkoss.zkforge</groupId>
<artifactId>timeplotz</artifactId>
<version>1.1_50</version>
<version>1.1_50_1</version>
</dependency>
<dependency>