ItEr51S10AdaptacionServiciosRESTItEr50S13: Added the checkbox 'generate code' to the Criterion administration page. Currently it only affects to CriterionType.
The attribute 'generateCode' was added to the entity CriterionType; also a new create method has to be added, to be able to create CriterionTypes without autogenerated code.
This commit is contained in:
parent
da4f6f0cd4
commit
43e3d65361
5 changed files with 48 additions and 3 deletions
|
|
@ -48,6 +48,9 @@ public class CriterionType extends IntegrationEntity implements
|
|||
return create(new CriterionType());
|
||||
}
|
||||
|
||||
public static CriterionType create(String code) {
|
||||
return create(new CriterionType(), code);
|
||||
}
|
||||
|
||||
public static CriterionType createUnvalidated(String code, String name,
|
||||
String description, Boolean allowHierarchy,
|
||||
|
|
@ -140,6 +143,8 @@ public class CriterionType extends IntegrationEntity implements
|
|||
|
||||
private int numCriterions;
|
||||
|
||||
private Boolean generateCode = false;
|
||||
|
||||
/**
|
||||
* Constructor for hibernate. Do not use!
|
||||
*/
|
||||
|
|
@ -469,4 +474,12 @@ public class CriterionType extends IntegrationEntity implements
|
|||
return Registry.getCriterionTypeDAO();
|
||||
}
|
||||
|
||||
public Boolean getGenerateCode() {
|
||||
return generateCode;
|
||||
}
|
||||
|
||||
public void setGenerateCode(Boolean generateCode) {
|
||||
this.generateCode = generateCode;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@
|
|||
<property name="allowSimultaneousCriterionsPerResource"/>
|
||||
<property name="allowHierarchy"/>
|
||||
<property name="enabled"/>
|
||||
<property name="generateCode" not-null="true" />
|
||||
<property name="resource">
|
||||
<type name="org.hibernate.type.EnumType">
|
||||
<param name="enumClass">org.navalplanner.business.resources.entities.ResourceEnum</param>
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ import org.navalplanner.web.common.MessagesForUser;
|
|||
import org.navalplanner.web.common.OnlyOneVisible;
|
||||
import org.navalplanner.web.common.Util;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.event.CheckEvent;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zul.Checkbox;
|
||||
import org.zkoss.zul.Combobox;
|
||||
|
|
@ -334,4 +336,15 @@ public class CriterionAdminController_V2 extends GenericForwardComposer {
|
|||
editionTree.doAfterCompose(comp.getFellow(
|
||||
"criterionsTree"));
|
||||
}
|
||||
|
||||
public void onCheckGenerateCode(Event e) {
|
||||
CheckEvent ce = (CheckEvent) e;
|
||||
if(ce.isChecked()) {
|
||||
//we have to auto-generate the code for new objects
|
||||
if(((CriterionType)criterionsModel_V2.getCriterionType()).isNewObject()) {
|
||||
((CriterionType)criterionsModel_V2.getCriterionType()).setCodeAutogenerated();
|
||||
Util.reloadBindings(createComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import java.util.List;
|
|||
import org.apache.commons.lang.Validate;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.navalplanner.business.common.daos.IConfigurationDAO;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.resources.daos.ICriterionDAO;
|
||||
|
|
@ -66,6 +67,9 @@ public class CriterionsModel_V2 implements ICriterionsModel_V2 {
|
|||
@Autowired
|
||||
private IResourceDAO resourceDAO;
|
||||
|
||||
@Autowired
|
||||
private IConfigurationDAO configurationDAO;
|
||||
|
||||
private CriterionType criterionType;
|
||||
|
||||
private Criterion criterion;
|
||||
|
|
@ -100,8 +104,16 @@ public class CriterionsModel_V2 implements ICriterionsModel_V2 {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly=true)
|
||||
public void prepareForCreate() {
|
||||
this.criterionType = CriterionType.create();
|
||||
boolean generateCode = configurationDAO.getConfiguration().getGenerateCodeForCriterion();
|
||||
if(generateCode) {
|
||||
this.criterionType = CriterionType.create();
|
||||
}
|
||||
else {
|
||||
this.criterionType = CriterionType.create("");
|
||||
}
|
||||
this.criterionType.setGenerateCode(generateCode);
|
||||
this.criterionTreeModel = new CriterionTreeModel(criterionType);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,8 +63,14 @@
|
|||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Code')}" />
|
||||
<textbox value="@{controller.criterionType.code}" width="390px"
|
||||
constraint="no empty:${i18n:_('cannot be null or empty')}" />
|
||||
<hbox>
|
||||
<textbox width="250px" value="@{controller.criterionType.code}"
|
||||
constraint="no empty:${i18n:_('cannot be null or empty')}"
|
||||
disabled="@{controller.criterionType.generateCode}" />
|
||||
<checkbox id="generateCode" label="${i18n:_('Generate code')}"
|
||||
onCheck="controller.onCheckGenerateCode(event)"
|
||||
checked="@{controller.criterionType.generateCode}" />
|
||||
</hbox>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue