ItEr60S04ValidacionEProbasFuncionaisItEr59S04: [Bug #557] Add field predefinedTypeInternalName.

This will allow to keep track of the original predefined criterion
type inspite of changing the name of the criterion type.
This commit is contained in:
Óscar González Fernández 2010-08-03 12:10:23 +02:00
parent 3263824951
commit e82812788b
4 changed files with 23 additions and 3 deletions

View file

@ -46,7 +46,7 @@ public class PredefinedCriterionTypesProvider implements ICriterionTypeProvider
public Map<CriterionType, List<String>> getRequiredCriterions() {
Map<CriterionType, List<String>> result = new HashMap<CriterionType, List<String>>();
for (PredefinedCriterionTypes type : PredefinedCriterionTypes.values()) {
result.put(CriterionType.asCriterionType(type), type.getPredefined());
result.put(CriterionType.fromPredefined(type), type.getPredefined());
}
return result;
}

View file

@ -129,6 +129,14 @@ public class CriterionType extends IntegrationEntity implements
private String name;
/**
* The original name of the criterion type. It only exists for
* CriterionTypes created from {@link PredefinedCriterionTypes}. Important:
* This value must <strong>not</strong> be editable and should only be set
* at creation time
*/
private String predefinedTypeInternalName;
private String description;
private Boolean allowHierarchy = true;
@ -167,6 +175,13 @@ public class CriterionType extends IntegrationEntity implements
this.resource = resource;
}
public static CriterionType fromPredefined(
PredefinedCriterionTypes predefinedType) {
CriterionType result = asCriterionType(predefinedType);
result.predefinedTypeInternalName = predefinedType.getName();
return result;
}
public static CriterionType asCriterionType(ICriterionType<?> criterionType) {
return create(criterionType.getName(),criterionType.getDescription(),
criterionType.allowHierarchy(), criterionType
@ -191,6 +206,10 @@ public class CriterionType extends IntegrationEntity implements
return name;
}
public String getPredefinedTypeInternalName() {
return predefinedTypeInternalName;
}
public void setName(String name) {
this.name = name;
}
@ -239,7 +258,7 @@ public class CriterionType extends IntegrationEntity implements
PredefinedCriterionTypes predefinedCriterionType, String name) {
CriterionType criterionType = CriterionType
.asCriterionType(predefinedCriterionType);
.fromPredefined(predefinedCriterionType);
return Criterion.withNameAndType(name, criterionType);
}

View file

@ -119,7 +119,7 @@ public enum PredefinedCriterionTypes implements ICriterionType<Criterion> {
@Override
public Criterion createCriterion(String name) {
return Criterion.create(name, CriterionType.asCriterionType(this));
return Criterion.create(name, CriterionType.fromPredefined(this));
}
@Override

View file

@ -163,6 +163,7 @@
<version name="version" access="property" type="long" />
<property name="code" access="property" not-null="true" unique="true"/>
<property name="name" unique="true"/>
<property name="predefinedTypeInternalName" not-null="false" />
<property name="description"/>
<property name="allowSimultaneousCriterionsPerResource"/>
<property name="allowHierarchy"/>