[Bug #1248] Project general data tab now validates if project or code exists
FEA: ItEr75S04BugFixing
This commit is contained in:
parent
88ff83aa7e
commit
16dde59dde
2 changed files with 40 additions and 2 deletions
|
|
@ -36,8 +36,13 @@ import org.apache.commons.lang.StringUtils;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
import org.hibernate.validator.InvalidValue;
|
||||
import org.libreplan.business.calendars.entities.BaseCalendar;
|
||||
import org.libreplan.business.common.Registry;
|
||||
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.libreplan.business.common.exceptions.ValidationException;
|
||||
import org.libreplan.business.externalcompanies.entities.ExternalCompany;
|
||||
import org.libreplan.business.materials.daos.IMaterialCategoryDAO;
|
||||
import org.libreplan.business.materials.entities.MaterialCategory;
|
||||
import org.libreplan.business.orders.daos.IOrderDAO;
|
||||
import org.libreplan.business.orders.entities.HoursGroup;
|
||||
import org.libreplan.business.orders.entities.Order;
|
||||
import org.libreplan.business.orders.entities.Order.SchedulingMode;
|
||||
|
|
@ -217,6 +222,9 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
|
||||
private ProjectDetailsController projectDetailsController;
|
||||
|
||||
@Autowired
|
||||
private IOrderDAO orderDAO;
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
|
|
@ -1473,4 +1481,30 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
}
|
||||
}
|
||||
|
||||
public void chekValidProjectName(Textbox textbox) {
|
||||
try {
|
||||
Order found = orderDAO.findByNameAnotherTransaction(textbox
|
||||
.getValue());
|
||||
if ((found != null) && (!found.getId().equals(getOrder().getId()))) {
|
||||
throw new WrongValueException(textbox,
|
||||
_("project name already being used"));
|
||||
}
|
||||
} catch (InstanceNotFoundException e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void chekValidProjectCode(Textbox textbox) {
|
||||
try {
|
||||
Order found = orderDAO.findByCodeAnotherTransaction(textbox
|
||||
.getValue());
|
||||
if ((found != null) && (!found.getId().equals(getOrder().getId()))) {
|
||||
throw new WrongValueException(textbox,
|
||||
_("code already being used"));
|
||||
}
|
||||
} catch (InstanceNotFoundException e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,13 +70,17 @@
|
|||
<rows>
|
||||
<row>
|
||||
<label value="${i18n:_('Name')}" />
|
||||
<textbox value="@{controller.order.name}" width="500px"/>
|
||||
<textbox value="@{controller.order.name}" width="500px"
|
||||
constraint="no empty:${i18n:_('cannot be null or empty')}"
|
||||
onBlur="controller.chekValidProjectName(self)"/>
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Code')}" />
|
||||
<hbox>
|
||||
<textbox value="@{controller.order.code}" width="250px"
|
||||
disabled="@{controller.codeAutogenerated}" />
|
||||
disabled="@{controller.codeAutogenerated}"
|
||||
constraint="no empty:${i18n:_('cannot be null or empty')}"
|
||||
onBlur="controller.chekValidProjectCode(self)" />
|
||||
<checkbox label="${i18n:_('Generate code')}"
|
||||
checked="@{controller.codeAutogenerated}" />
|
||||
</hbox>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue