Reverted unnecesary changes on Label and Criterion save operations to clear removed entities
Since the "foreign key" constraint with onDelete parameter introduced into liquibase is handling at database level the integrity, the external operations to clean the setting values are not longer needed. FEA: ItEr77S15FilteringEnhancements
This commit is contained in:
parent
46ba611952
commit
6b4ee3641c
4 changed files with 0 additions and 60 deletions
|
|
@ -25,8 +25,6 @@ import java.util.List;
|
|||
|
||||
import org.libreplan.business.common.daos.IGenericDAO;
|
||||
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.libreplan.business.labels.entities.Label;
|
||||
import org.libreplan.business.resources.entities.Criterion;
|
||||
import org.libreplan.business.resources.entities.Worker;
|
||||
import org.libreplan.business.scenarios.entities.Scenario;
|
||||
import org.libreplan.business.users.entities.OrderAuthorization;
|
||||
|
|
@ -104,8 +102,4 @@ public interface IUserDAO extends IGenericDAO<User, Long>{
|
|||
|
||||
List<User> findAll();
|
||||
|
||||
public List<User> findByLabelFilterSetting(List<Label> removedLabels);
|
||||
|
||||
public List<User> findByCriterionFilterSetting(List<Criterion> criteria);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,6 @@ import org.hibernate.Criteria;
|
|||
import org.hibernate.criterion.Restrictions;
|
||||
import org.libreplan.business.common.daos.GenericDAOHibernate;
|
||||
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.libreplan.business.labels.entities.Label;
|
||||
import org.libreplan.business.resources.entities.Criterion;
|
||||
import org.libreplan.business.resources.entities.Worker;
|
||||
import org.libreplan.business.scenarios.entities.Scenario;
|
||||
import org.libreplan.business.users.entities.OrderAuthorization;
|
||||
|
|
@ -180,18 +178,4 @@ public class UserDAO extends GenericDAOHibernate<User, Long>
|
|||
return list(User.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> findByLabelFilterSetting(List<Label> labels) {
|
||||
Criteria c = getSession().createCriteria(User.class);
|
||||
c.add(Restrictions.in("projectsFilterLabel", labels));
|
||||
return c.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> findByCriterionFilterSetting(List<Criterion> criteria) {
|
||||
Criteria c = getSession().createCriteria(User.class);
|
||||
c.add(Restrictions.in("resourcesLoadFilterCriterion", criteria));
|
||||
return c.list();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,9 +39,6 @@ import org.libreplan.business.labels.daos.ILabelDAO;
|
|||
import org.libreplan.business.labels.daos.ILabelTypeDAO;
|
||||
import org.libreplan.business.labels.entities.Label;
|
||||
import org.libreplan.business.labels.entities.LabelType;
|
||||
import org.libreplan.business.users.daos.IUserDAO;
|
||||
import org.libreplan.business.users.entities.User;
|
||||
import org.libreplan.web.common.FilterUtils;
|
||||
import org.libreplan.web.common.IntegrationEntityModel;
|
||||
import org.libreplan.web.common.concurrentdetection.OnConcurrentModification;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -68,13 +65,8 @@ public class LabelTypeModel extends IntegrationEntityModel implements
|
|||
@Autowired
|
||||
private IConfigurationDAO configurationDAO;
|
||||
|
||||
@Autowired
|
||||
private IUserDAO userDAO;
|
||||
|
||||
private LabelType labelType;
|
||||
|
||||
private List<Label> removedLabels = new ArrayList<Label>();
|
||||
|
||||
public LabelTypeModel() {
|
||||
|
||||
}
|
||||
|
|
@ -137,15 +129,6 @@ public class LabelTypeModel extends IntegrationEntityModel implements
|
|||
|
||||
generateCodes();
|
||||
labelTypeDAO.save(labelType);
|
||||
|
||||
if (!removedLabels.isEmpty()) {
|
||||
List<User> users = userDAO.findByLabelFilterSetting(removedLabels);
|
||||
for (User user : users) {
|
||||
user.setProjectsFilterLabel(null);
|
||||
userDAO.save(user);
|
||||
}
|
||||
FilterUtils.clearBandboxes();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -250,7 +233,6 @@ public class LabelTypeModel extends IntegrationEntityModel implements
|
|||
@Override
|
||||
public void confirmDeleteLabel(Label label) {
|
||||
labelType.removeLabel(label);
|
||||
removedLabels.add(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import java.util.Set;
|
|||
import org.apache.commons.lang.Validate;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.hibernate.annotations.Filters;
|
||||
import org.libreplan.business.common.IntegrationEntity;
|
||||
import org.libreplan.business.common.daos.IConfigurationDAO;
|
||||
import org.libreplan.business.common.entities.EntityNameEnum;
|
||||
|
|
@ -45,9 +44,6 @@ import org.libreplan.business.resources.entities.CriterionType;
|
|||
import org.libreplan.business.resources.entities.ICriterionType;
|
||||
import org.libreplan.business.resources.entities.Resource;
|
||||
import org.libreplan.business.resources.entities.Worker;
|
||||
import org.libreplan.business.users.daos.IUserDAO;
|
||||
import org.libreplan.business.users.entities.User;
|
||||
import org.libreplan.web.common.FilterUtils;
|
||||
import org.libreplan.web.common.IntegrationEntityModel;
|
||||
import org.libreplan.web.common.concurrentdetection.OnConcurrentModification;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -82,17 +78,12 @@ public class CriterionsModel extends IntegrationEntityModel implements ICriterio
|
|||
@Autowired
|
||||
private IConfigurationDAO configurationDAO;
|
||||
|
||||
@Autowired
|
||||
private IUserDAO userDAO;
|
||||
|
||||
private CriterionType criterionType;
|
||||
|
||||
private Criterion criterion;
|
||||
|
||||
private ICriterionTreeModel criterionTreeModel;
|
||||
|
||||
private List<Criterion> removedCriterion = new ArrayList<Criterion>();
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<CriterionType> getTypes() {
|
||||
|
|
@ -196,16 +187,6 @@ public class CriterionsModel extends IntegrationEntityModel implements ICriterio
|
|||
}
|
||||
criterionTreeModel.saveCriterions(criterionType);
|
||||
criterionTypeDAO.save(criterionType);
|
||||
|
||||
if (!removedCriterion.isEmpty()) {
|
||||
List<User> users = userDAO
|
||||
.findByCriterionFilterSetting(removedCriterion);
|
||||
for (User user : users) {
|
||||
user.setResourcesLoadFilterCriterion(null);
|
||||
userDAO.save(user);
|
||||
}
|
||||
FilterUtils.clearBandboxes();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -282,7 +263,6 @@ public class CriterionsModel extends IntegrationEntityModel implements ICriterio
|
|||
@Override
|
||||
public void addForRemoval(Criterion criterion) {
|
||||
criterionType.getCriterions().remove(criterion);
|
||||
removedCriterion.add(criterion);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue