Commit 079bff09 authored by helene ortiz's avatar helene ortiz
Browse files

bug fixed: range property condition for dynamic properties

parent a081dcad
......@@ -186,7 +186,7 @@ public class PropertyFactory {
property.addCondition(new RangePropertyCondition(conditionDescriptor.getMin(), conditionDescriptor.getMax()));
} else if (conditionDescriptor.getType().equals(PropertyParser.TAG_PROPERTY_RANGE)) {
property.addCondition(new RangePropertyDependentCondition(property, conditionDescriptor.getMinProperty(), conditionDescriptor.getMaxProperty(), conditionDescriptor.getMinPropertyExcluded(), conditionDescriptor.getMaxPropertyExcluded()));
property.addCondition(new RangePropertyDependentCondition(property, conditionDescriptor, propertyDescriptor.isDynamic()));
} else if (conditionDescriptor.getType().equals(PropertyParser.TAG_SPECIFIC_VALUES)) {
property.addCondition(new SpecificValuesPropertyCondition(property, conditionDescriptor.getValues()));
......
......@@ -20,6 +20,7 @@ package fr.ill.ics.core.property.condition;
import fr.ill.ics.core.property.Property;
import fr.ill.ics.core.property.PropertyManager;
import fr.ill.ics.core.property.parser.descriptor.ConditionDescriptor;
import fr.ill.ics.nscclient.dataprovider.PropertyDatabase;
import fr.ill.ics.util.ConfigManager;
......@@ -35,20 +36,28 @@ public class RangePropertyDependentCondition implements IPropertyCondition {
private boolean minPropertyExcluded;
private boolean maxPropertyExcluded;
private boolean isDynamic; // concerns main property (the one stored in "property" attribute)
public RangePropertyDependentCondition(Property property, String minPropertyName, String maxPropertyName, boolean minPropertyExcluded, boolean maxPropertyExcluded) {
public RangePropertyDependentCondition(Property property, ConditionDescriptor conditionDescriptor, boolean isDynamic) {
this.property = property;
this.minPropertyName = minPropertyName;
this.maxPropertyName = maxPropertyName;
this.minPropertyExcluded = minPropertyExcluded;
this.maxPropertyExcluded = maxPropertyExcluded;
this.minPropertyName = conditionDescriptor.getMinProperty();
this.maxPropertyName = conditionDescriptor.getMaxProperty();
this.minPropertyExcluded = conditionDescriptor.getMinPropertyExcluded();
this.maxPropertyExcluded = conditionDescriptor.getMaxPropertyExcluded();
this.isDynamic = isDynamic;
}
public boolean isOk(String valueToBeTested) {
try {
if (minProperty == null && maxProperty == null) {
int servantId = PropertyDatabase.getInstance().getServantIdForProperty(property.getPropertyID());
int servantId = -1;
if (isDynamic) {
servantId = PropertyDatabase.getInstance().getServantIdForDynamicProperty(property.getPropertyID());
} else {
servantId = PropertyDatabase.getInstance().getServantIdForProperty(property.getPropertyID());
}
if (servantId != -1) {
int minPropertyId = PropertyDatabase.getInstance().getPropertyIdForServant(servantId, minPropertyName);
......
......@@ -51,6 +51,10 @@ public class XMLDynamicPropertyDescriptor extends XMLPropertyDescriptor {
return sizePropertyName;
}
public boolean isDynamic() {
return true;
}
public String toString() {
return "DynamicPropertyDescriptor " + propertyName;
}
......
......@@ -132,4 +132,8 @@ public class XMLPropertyDescriptor {
public String getDecimaFormatPropertyName() {
return decimalFormatPropertyName;
}
public boolean isDynamic() {
return false;
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment