Added validation when creating new project that the same name is not being used
FEA: ItEr75S04BugFixing
This commit is contained in:
parent
e602d39b80
commit
3bd402d5ba
2 changed files with 20 additions and 6 deletions
|
|
@ -27,6 +27,7 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.hibernate.Criteria;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.hibernate.criterion.MatchMode;
|
import org.hibernate.criterion.MatchMode;
|
||||||
import org.hibernate.criterion.Restrictions;
|
import org.hibernate.criterion.Restrictions;
|
||||||
|
|
@ -407,12 +408,11 @@ public class OrderDAO extends IntegrationEntityDAO<Order> implements
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW)
|
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW)
|
||||||
public boolean existsByNameAnotherTransaction(String name) {
|
public boolean existsByNameAnotherTransaction(String name) {
|
||||||
try {
|
|
||||||
Order order = findByName(name);
|
Criteria c = getSession().createCriteria(getEntityClass());
|
||||||
return order.getName().equals(name);
|
c.add(Restrictions.eq("infoComponent.name", name).ignoreCase());
|
||||||
} catch (InstanceNotFoundException e) {
|
|
||||||
return false;
|
return c.list().size() > 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.libreplan.business.calendars.entities.BaseCalendar;
|
import org.libreplan.business.calendars.entities.BaseCalendar;
|
||||||
import org.libreplan.business.externalcompanies.entities.ExternalCompany;
|
import org.libreplan.business.externalcompanies.entities.ExternalCompany;
|
||||||
|
import org.libreplan.business.orders.daos.IOrderDAO;
|
||||||
import org.libreplan.business.orders.entities.Order;
|
import org.libreplan.business.orders.entities.Order;
|
||||||
import org.libreplan.business.templates.entities.OrderTemplate;
|
import org.libreplan.business.templates.entities.OrderTemplate;
|
||||||
import org.libreplan.web.common.ConstraintChecker;
|
import org.libreplan.web.common.ConstraintChecker;
|
||||||
|
|
@ -38,6 +39,7 @@ import org.libreplan.web.common.Util;
|
||||||
import org.libreplan.web.common.components.bandboxsearch.BandboxSearch;
|
import org.libreplan.web.common.components.bandboxsearch.BandboxSearch;
|
||||||
import org.libreplan.web.planner.consolidations.AdvanceConsolidationController;
|
import org.libreplan.web.planner.consolidations.AdvanceConsolidationController;
|
||||||
import org.libreplan.web.planner.tabs.MultipleTabsPlannerController;
|
import org.libreplan.web.planner.tabs.MultipleTabsPlannerController;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
import org.zkoss.zk.ui.Executions;
|
import org.zkoss.zk.ui.Executions;
|
||||||
import org.zkoss.zk.ui.SuspendNotAllowedException;
|
import org.zkoss.zk.ui.SuspendNotAllowedException;
|
||||||
|
|
@ -90,6 +92,9 @@ public class ProjectDetailsController extends GenericForwardComposer {
|
||||||
|
|
||||||
private Datebox deadline;
|
private Datebox deadline;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IOrderDAO orderDAO;
|
||||||
|
|
||||||
public ProjectDetailsController() {
|
public ProjectDetailsController() {
|
||||||
Window window = (Window) Executions.createComponents(
|
Window window = (Window) Executions.createComponents(
|
||||||
"/orders/_projectDetails.zul", null,
|
"/orders/_projectDetails.zul", null,
|
||||||
|
|
@ -155,6 +160,10 @@ public class ProjectDetailsController extends GenericForwardComposer {
|
||||||
showWrongValue();
|
showWrongValue();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (orderDAO.existsByNameAnotherTransaction(txtName.getValue())) {
|
||||||
|
showWrongName();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,6 +171,11 @@ public class ProjectDetailsController extends GenericForwardComposer {
|
||||||
throw new WrongValueException(initDate, _("cannot be null or empty"));
|
throw new WrongValueException(initDate, _("cannot be null or empty"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showWrongName() {
|
||||||
|
throw new WrongValueException(txtName,
|
||||||
|
_("project name already being used"));
|
||||||
|
}
|
||||||
|
|
||||||
private void close() {
|
private void close() {
|
||||||
window.setVisible(false);
|
window.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue