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 org.apache.commons.lang.StringUtils;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.criterion.MatchMode;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
|
@ -407,12 +408,11 @@ public class OrderDAO extends IntegrationEntityDAO<Order> implements
|
|||
@Override
|
||||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW)
|
||||
public boolean existsByNameAnotherTransaction(String name) {
|
||||
try {
|
||||
Order order = findByName(name);
|
||||
return order.getName().equals(name);
|
||||
} catch (InstanceNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Criteria c = getSession().createCriteria(getEntityClass());
|
||||
c.add(Restrictions.eq("infoComponent.name", name).ignoreCase());
|
||||
|
||||
return c.list().size() > 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
import org.libreplan.business.calendars.entities.BaseCalendar;
|
||||
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.templates.entities.OrderTemplate;
|
||||
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.planner.consolidations.AdvanceConsolidationController;
|
||||
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.Executions;
|
||||
import org.zkoss.zk.ui.SuspendNotAllowedException;
|
||||
|
|
@ -90,6 +92,9 @@ public class ProjectDetailsController extends GenericForwardComposer {
|
|||
|
||||
private Datebox deadline;
|
||||
|
||||
@Autowired
|
||||
private IOrderDAO orderDAO;
|
||||
|
||||
public ProjectDetailsController() {
|
||||
Window window = (Window) Executions.createComponents(
|
||||
"/orders/_projectDetails.zul", null,
|
||||
|
|
@ -155,6 +160,10 @@ public class ProjectDetailsController extends GenericForwardComposer {
|
|||
showWrongValue();
|
||||
return false;
|
||||
}
|
||||
if (orderDAO.existsByNameAnotherTransaction(txtName.getValue())) {
|
||||
showWrongName();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -162,6 +171,11 @@ public class ProjectDetailsController extends GenericForwardComposer {
|
|||
throw new WrongValueException(initDate, _("cannot be null or empty"));
|
||||
}
|
||||
|
||||
private void showWrongName() {
|
||||
throw new WrongValueException(txtName,
|
||||
_("project name already being used"));
|
||||
}
|
||||
|
||||
private void close() {
|
||||
window.setVisible(false);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue