Commit 2ad3a039 authored by Cristina Cocho's avatar Cristina Cocho
Browse files

Added possibility to use dynamic properties to define the property range

of another dynamic property.
parent f2c650ef
......@@ -2,6 +2,7 @@
-----
* Catch exception thrown when trying to format a invalid float value (avoid a client crash : see brisp 03 nov 2016).
* Replaced Corba with Cameo.
* Added possibility to use dynamic properties to define a property range ("min_property" and "max_property") of a dynamic property.
3.0.4
-----
......
......@@ -18,11 +18,14 @@
package fr.ill.ics.core.property.condition;
import fr.ill.ics.bridge.Controller;
import fr.ill.ics.bridge.ControllerManager;
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;
import fr.ill.ics.util.exception.PropertyNotFoundException;
public class RangePropertyDependentCondition implements IPropertyCondition {
......@@ -38,6 +41,7 @@ public class RangePropertyDependentCondition implements IPropertyCondition {
private boolean maxPropertyExcluded;
private boolean isDynamic; // concerns main property (the one stored in "property" attribute)
private int index;
public RangePropertyDependentCondition(Property property, ConditionDescriptor conditionDescriptor, boolean isDynamic) {
this.property = property;
......@@ -46,6 +50,13 @@ public class RangePropertyDependentCondition implements IPropertyCondition {
this.minPropertyExcluded = conditionDescriptor.getMinPropertyExcluded();
this.maxPropertyExcluded = conditionDescriptor.getMaxPropertyExcluded();
this.isDynamic = isDynamic;
if (isDynamic) {
try {
this.index = Integer.valueOf(property.getName().substring(property.getName().indexOf(".")+1));
} catch (Exception e) {
this.index = -1;
}
}
}
public boolean isOk(String valueToBeTested) {
......@@ -63,8 +74,30 @@ public class RangePropertyDependentCondition implements IPropertyCondition {
int minPropertyId = PropertyDatabase.getInstance().getPropertyIdForServant(servantId, minPropertyName);
minProperty = PropertyManager.getInstance().getProperty(servantId, minPropertyName);
if (minProperty == null) {
try {
if (index != -1) {
Controller controller = ControllerManager.getInstance().getController(property.getControllerNameForDynamic());
minProperty = PropertyManager.getInstance().getDynamicProperty(controller, minPropertyName+"."+index);
}
} catch (PropertyNotFoundException e) {
// not a real problem...
}
}
int maxPropertyId = PropertyDatabase.getInstance().getPropertyIdForServant(servantId, maxPropertyName);
maxProperty = PropertyManager.getInstance().getProperty(servantId, maxPropertyName);
if (maxProperty == null) {
try {
if (index != -1) {
Controller controller = ControllerManager.getInstance().getController(property.getControllerNameForDynamic());
maxProperty = PropertyManager.getInstance().getDynamicProperty(controller, maxPropertyName+"."+index);
}
} catch (PropertyNotFoundException e) {
// not a real problem...
}
}
}
}
if (minProperty != null && maxProperty != null) {
......
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