ItEr51S10AdaptacionServiciosRESTItEr50S13: Replaced the attribute CodeGenerated in the LabelTypeModel with a newly created in the entity LabelType.
This way, we make its value persistent.
This commit is contained in:
parent
6b6dd5e050
commit
da4f6f0cd4
6 changed files with 23 additions and 37 deletions
|
|
@ -46,6 +46,8 @@ public class LabelType extends IntegrationEntity implements Comparable {
|
|||
|
||||
private Set<Label> labels = new HashSet<Label>();
|
||||
|
||||
private Boolean generateCode = false;
|
||||
|
||||
// Default constructor, needed by Hibernate
|
||||
// At least package visibility, https://www.hibernate.org/116.html#A6
|
||||
protected LabelType() {
|
||||
|
|
@ -72,6 +74,14 @@ public class LabelType extends IntegrationEntity implements Comparable {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public Boolean getGenerateCode() {
|
||||
return generateCode;
|
||||
}
|
||||
|
||||
public void setGenerateCode(Boolean generateCode) {
|
||||
this.generateCode = generateCode;
|
||||
}
|
||||
|
||||
public Set<Label> getLabels() {
|
||||
return Collections.unmodifiableSet(labels);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
<property name="code" access="property" not-null="true" unique="true"/>
|
||||
<property name="name" unique="true"/>
|
||||
<property name="generateCode" not-null="true" />
|
||||
|
||||
<set name="labels" inverse="false" cascade="all">
|
||||
<key column="LABEL_TYPE_ID"/>
|
||||
|
|
|
|||
|
|
@ -94,15 +94,4 @@ public interface ILabelTypeModel {
|
|||
*/
|
||||
boolean labelNameIsUnique(String value);
|
||||
|
||||
/**
|
||||
* Checks if the autogeneration of codes for Labels is active
|
||||
* @return
|
||||
*/
|
||||
boolean isCodeGenerated();
|
||||
|
||||
/**
|
||||
* Sets the state of the autogeneration of codes for Labels
|
||||
*/
|
||||
void setCodeGenerated(boolean codeGenerated);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -341,26 +341,24 @@ public class LabelTypeCRUDController extends GenericForwardComposer {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isCodeGenerated() {
|
||||
return labelTypeModel.isCodeGenerated();
|
||||
}
|
||||
|
||||
public void setCodeGenerated(boolean codeGenerated) {
|
||||
labelTypeModel.setCodeGenerated(codeGenerated);
|
||||
}
|
||||
|
||||
public void onCheckGenerateCode(Event e) {
|
||||
CheckEvent ce = (CheckEvent) e;
|
||||
boolean redraw = false;
|
||||
if(ce.isChecked()) {
|
||||
//we have to auto-generate the code for new objects
|
||||
if(labelTypeModel.getLabelType().isNewObject()) {
|
||||
labelTypeModel.getLabelType().setCodeAutogenerated();
|
||||
redraw = true;
|
||||
}
|
||||
for(Label label : labelTypeModel.getLabels()) {
|
||||
if(label.isNewObject()) {
|
||||
label.setCodeAutogenerated();
|
||||
redraw = true;
|
||||
}
|
||||
}
|
||||
if(redraw) {
|
||||
Util.reloadBindings(editWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,8 +57,6 @@ public class LabelTypeModel implements ILabelTypeModel {
|
|||
|
||||
private LabelType labelType;
|
||||
|
||||
private boolean codeGenerated;
|
||||
|
||||
public LabelTypeModel() {
|
||||
|
||||
}
|
||||
|
|
@ -82,13 +80,14 @@ public class LabelTypeModel implements ILabelTypeModel {
|
|||
@Override
|
||||
@Transactional(readOnly=true)
|
||||
public void initCreate() {
|
||||
codeGenerated = configurationDAO.getConfiguration().getGenerateCodeForLabel();
|
||||
boolean codeGenerated = configurationDAO.getConfiguration().getGenerateCodeForLabel();
|
||||
if(codeGenerated) {
|
||||
labelType = LabelType.create("");
|
||||
}
|
||||
else {
|
||||
labelType = LabelType.create("", "");
|
||||
}
|
||||
labelType.setGenerateCode(codeGenerated);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -149,7 +148,6 @@ public class LabelTypeModel implements ILabelTypeModel {
|
|||
public void initEdit(LabelType labelType) {
|
||||
Validate.notNull(labelType);
|
||||
this.labelType = getFromDB(labelType);
|
||||
codeGenerated = configurationDAO.getConfiguration().getGenerateCodeForLabel();
|
||||
}
|
||||
|
||||
private LabelType getFromDB(LabelType labelType) {
|
||||
|
|
@ -186,7 +184,7 @@ public class LabelTypeModel implements ILabelTypeModel {
|
|||
@Override
|
||||
public void addLabel(String value) {
|
||||
Label label;
|
||||
if(codeGenerated) {
|
||||
if(labelType.getGenerateCode()) {
|
||||
label = Label.create(value);
|
||||
}
|
||||
else {
|
||||
|
|
@ -213,14 +211,4 @@ public class LabelTypeModel implements ILabelTypeModel {
|
|||
return (count == 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCodeGenerated() {
|
||||
return codeGenerated;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCodeGenerated(boolean codeGenerated) {
|
||||
this.codeGenerated = codeGenerated;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,10 +47,10 @@
|
|||
<hbox>
|
||||
<textbox width="350px" value="@{controller.labelType.code}"
|
||||
constraint="no empty:${i18n:_('cannot be null or empty')}"
|
||||
disabled="@{controller.codeGenerated}" />
|
||||
disabled="@{controller.labelType.generateCode}" />
|
||||
<checkbox id="generateCode" label="${i18n:_('Generate code')}"
|
||||
onCheck="controller.onCheckGenerateCode(event)"
|
||||
checked="@{controller.codeGenerated}" />
|
||||
checked="@{controller.labelType.generateCode}" />
|
||||
</hbox>
|
||||
</row>
|
||||
</rows>
|
||||
|
|
@ -82,7 +82,7 @@
|
|||
constraint="no empty:${i18n:_('cannot be null or empty')}" />
|
||||
|
||||
<textbox value="@{label.code}" width="95%"
|
||||
disabled="@{controller.codeGenerated}"
|
||||
disabled="@{controller.labelType.generateCode}"
|
||||
constraint="no empty:${i18n:_('cannot be null or empty')}" />
|
||||
|
||||
<button sclass="icono" image="/common/img/ico_borrar1.png"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue