...
 
Commits (19)
3.2.1 DD/MM/YYYY
3.2.5 08/07/2019
------
* Moved Property.ExpressionResult to expression package so that it is accessible to other classes.
3.2.4 14/06/2019
------
* Re-added the client check of a property value in the AutoApplyState that had been removed in the previous version.
3.2.3 07/06/2019
------
* Removed checkValue in AutoApplyState.setValue. Otherwise setting an hexadecimal value is not possible because the value is verified as an expression by the server.
3.2.2 04/06/2019
------
* Added GetWholeDynamicProperties request to get the alias of dynamic properties.
* In Property.checkServerValue, check also the constant by the server because a value can be accepted by the client but not the server e.g. 24d is not a numeric constant for the mu parser.
3.2.1 29/04/2019
------
* Overwritten equals method in Property class.
* Added attribute "view_max_length" used in text widgets.
3.2.0 11/02/2019
------
......
......@@ -42,6 +42,12 @@
</properties>
<dependencies>
<dependency>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-client</artifactId>
<version>3.1.10</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework-impl</artifactId>
......
......@@ -128,11 +128,16 @@ public class ControllerManager implements ServerConfigurationChangeListener {
return ServantDatabase.getInstance().getControllersOfType(type, onlyVisibleOnes);
}
public Set<String> getControllerTypes() {
return ServantDatabase.getInstance().getControllerTypes();
}
public Set<String> getControllerTypesInheritingType(int databaseID, String controllerType) {
return ServantManagerAccessor.getInstance(serverId).getControllerTypesInheritingType(databaseID, controllerType);
}
public boolean controllerIsEnabled(String controllerName) {
return ServantDatabase.getInstance().controllerIsEnabled(controllerName);
......@@ -312,8 +317,6 @@ public class ControllerManager implements ServerConfigurationChangeListener {
// and SettingsSelectionPlugin classes.
if (enable == ClientConfigurationState.PROPERTY) {
ServantManagerAccessor.getInstance(serverId).updateDynamicProperties(servantID);
System.out.println("ServantManagerAccessor updateDynamicProperties " + servantID);
}
}
......
package fr.ill.ics.core.expression;
import fr.ill.ics.nscclient.command.CommandZoneAccessor;
public class ExpressionResult {
public enum ExpressionStatus {VALID_CONSTANT, INVALID_CONSTANT, VALID_EXPRESSION, INVALID_EXPRESSION};
public enum ExpressionError {NO_ERROR, PARSER_ERROR, DISABLED_CONTROLLER_ERROR, ENUMERATED_VALUE_ERROR, UNDEFINED_VARIABLE_ERROR};
private ExpressionStatus status;
private ExpressionError error;
private String message;
public ExpressionResult(ExpressionStatus status, ExpressionError error, String message) {
this.status = status;
this.error = error;
this.message = message;
}
public static ExpressionError convertExpressionError(CommandZoneAccessor.ExpressionError result) {
if (result == CommandZoneAccessor.ExpressionError.PARSER_ERROR) {
return ExpressionError.PARSER_ERROR;
}
else if (result == CommandZoneAccessor.ExpressionError.ENUMERATED_VALUE_ERROR) {
return ExpressionError.ENUMERATED_VALUE_ERROR;
}
else if (result == CommandZoneAccessor.ExpressionError.DISABLED_CONTROLLER_ERROR) {
return ExpressionError.DISABLED_CONTROLLER_ERROR;
}
else if (result == CommandZoneAccessor.ExpressionError.UNDEFINED_VARIABLE_ERROR) {
return ExpressionError.UNDEFINED_VARIABLE_ERROR;
}
return ExpressionError.NO_ERROR;
}
public ExpressionResult(ExpressionStatus status) {
this.status = status;
}
public ExpressionStatus getStatus() {
return status;
}
public ExpressionError getError() {
return error;
}
public boolean isValid() {
return status == ExpressionStatus.VALID_CONSTANT || status == ExpressionStatus.VALID_EXPRESSION;
}
public String getMessage() {
return message;
}
}
package fr.ill.ics.core.expression;
/**
* Helper class for the getPropertyExpression method.
*/
public class GetExpressionResult extends ExpressionResult {
private String expression;
public GetExpressionResult(String expression, ExpressionStatus status, ExpressionError error, String message) {
super(status, error, message);
this.expression = expression;
}
public GetExpressionResult(String expression, ExpressionStatus status) {
super(status);
this.expression = expression;
}
public String getExpression() {
return expression;
}
}
......@@ -19,6 +19,9 @@
package fr.ill.ics.core.property;
import fr.ill.ics.bridge.events.ServerPropertyChangeEvent;
import fr.ill.ics.core.expression.ExpressionResult;
import fr.ill.ics.core.expression.ExpressionResult.ExpressionStatus;
import fr.ill.ics.core.expression.GetExpressionResult;
import fr.ill.ics.core.property.array.Array;
import fr.ill.ics.core.property.undo.AutoApplyArrayState;
import fr.ill.ics.core.property.undo.UndoArrayState;
......
......@@ -27,6 +27,10 @@ import java.util.Set;
import fr.ill.ics.bridge.StatusBarMessageSender;
import fr.ill.ics.bridge.events.ServerPropertyChangeEvent;
import fr.ill.ics.bridge.listeners.ServerPropertyChangeListener;
import fr.ill.ics.core.expression.ExpressionResult;
import fr.ill.ics.core.expression.ExpressionResult.ExpressionError;
import fr.ill.ics.core.expression.ExpressionResult.ExpressionStatus;
import fr.ill.ics.core.expression.GetExpressionResult;
import fr.ill.ics.core.property.condition.IPropertyCondition;
import fr.ill.ics.core.property.event.LockEvent;
import fr.ill.ics.core.property.event.PropertyVerifyListener;
......@@ -45,85 +49,6 @@ import fr.ill.ics.nscclient.notification.commandzone.ICommandBoxPropertyEventLis
import fr.ill.ics.util.ConfigManager;
public abstract class Property implements ServerPropertyChangeListener, ICommandBoxPropertyEventListener {
public enum ExpressionStatus {VALID_CONSTANT, INVALID_CONSTANT, VALID_EXPRESSION, INVALID_EXPRESSION};
public enum ExpressionError {NO_ERROR, PARSER_ERROR, DISABLED_CONTROLLER_ERROR, ENUMERATED_VALUE_ERROR, UNDEFINED_VARIABLE_ERROR};
/**
* Helper class for the checkPropertyExpression method.
*/
public static class ExpressionResult {
private ExpressionStatus status;
private ExpressionError error;
private String message;
public ExpressionResult(ExpressionStatus status, ExpressionError error, String message) {
this.status = status;
this.error = error;
this.message = message;
}
public static ExpressionError convertExpressionError(CommandZoneAccessor.ExpressionError result) {
if (result == CommandZoneAccessor.ExpressionError.PARSER_ERROR) {
return ExpressionError.PARSER_ERROR;
}
else if (result == CommandZoneAccessor.ExpressionError.ENUMERATED_VALUE_ERROR) {
return ExpressionError.ENUMERATED_VALUE_ERROR;
}
else if (result == CommandZoneAccessor.ExpressionError.DISABLED_CONTROLLER_ERROR) {
return ExpressionError.DISABLED_CONTROLLER_ERROR;
}
else if (result == CommandZoneAccessor.ExpressionError.UNDEFINED_VARIABLE_ERROR) {
return ExpressionError.UNDEFINED_VARIABLE_ERROR;
}
return ExpressionError.NO_ERROR;
}
public ExpressionResult(ExpressionStatus status) {
this.status = status;
}
public ExpressionStatus getStatus() {
return status;
}
public ExpressionError getError() {
return error;
}
public boolean isValid() {
return status == ExpressionStatus.VALID_CONSTANT || status == ExpressionStatus.VALID_EXPRESSION;
}
public String getMessage() {
return message;
}
}
/**
* Helper class for the getPropertyExpression method.
*/
public static class GetExpressionResult extends ExpressionResult {
private String expression;
public GetExpressionResult(String expression, ExpressionStatus status, ExpressionError error, String message) {
super(status, error, message);
this.expression = expression;
}
public GetExpressionResult(String expression, ExpressionStatus status) {
super(status);
this.expression = expression;
}
public String getExpression() {
return expression;
}
}
protected String serverId = "real";
private int databaseId = 0;
......@@ -147,6 +72,7 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
private boolean isCheckable = true;
private int maxLength;
private int viewMaxLength;
private boolean maxLengthOnlyForTextFieldSize = false;
// private long lastPropertyChangedTime;
private String errorMessage;
......@@ -169,7 +95,7 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
this.name = PropertyDatabase.getInstance().getPropertyName(id);
maxLength = getDefaultMaxLength();
viewMaxLength = getDefaultMaxLength();
// Set property change listeners initial size to 2
this.propertyChangeListeners = new HashSet<IPropertyChangeListener>(1);
......@@ -316,44 +242,62 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
}
/**
* This method is the same for Int32Property, Float64Property and BooleanProperty.
* For StringProperty and ArrayProperty, it is overrided.
* Checks the server value.
* @param value
* @return
*/
public ExpressionResult checkServerValue(String value) {
public ExpressionResult checkServerValue(boolean constant, String value) {
// Test the validity of the expression by the server even for constant expression (a constant can be accepted by the client check but not the server so we check both).
CommandZoneAccessor.ExpressionResult result = null;
if (isCommandBox) {
result = CommandZoneAccessor.getInstance(serverId).checkPropertyExpression(containerId, id, value);
}
else {
result = CommandZoneAccessor.getInstance(serverId).checkStaticPropertyExpression(id, value);
}
// If the expression is invalid for the server, return an ExpressionResult for constants and expressions.
if (result.getStatus() == CommandZoneAccessor.ExpressionStatus.INVALID_EXPRESSION) {
if (constant) {
return new ExpressionResult(ExpressionStatus.INVALID_CONSTANT, ExpressionResult.convertExpressionError(result.getError()), result.getMessage());
} else {
return new ExpressionResult(ExpressionStatus.INVALID_EXPRESSION, ExpressionResult.convertExpressionError(result.getError()), result.getMessage());
}
}
if (isConstant(value)) {
// The expression is valid.
return new ExpressionResult(ExpressionStatus.VALID_EXPRESSION);
}
/**
* Checks the client value.
* @param value
* @return
*/
public ExpressionResult checkClientValue(boolean constant, String value) {
// Check the client conditions in case of a constant.
if (constant) {
// Check the value and set the value.
String serverValue = this.propertyFormat.unformat(value);
// Check the client conditions.
CheckConditionResult result = isOk(serverValue);
if (!result.isOk()) {
return new ExpressionResult(ExpressionStatus.INVALID_CONSTANT, ExpressionError.NO_ERROR, result.getErrorMessage());
} else {
return new ExpressionResult(ExpressionStatus.VALID_CONSTANT);
}
} else {
// Expression: first check it without setting it.
CommandZoneAccessor.ExpressionResult result = null;
if (isCommandBox) {
result = CommandZoneAccessor.getInstance(serverId).checkPropertyExpression(containerId, id, value);
} else {
// First check the expression without setting it.
result = CommandZoneAccessor.getInstance(serverId).checkStaticPropertyExpression(id, value);
CheckConditionResult conditionResult = isOk(serverValue);
if (!conditionResult.isOk()) {
return new ExpressionResult(ExpressionStatus.INVALID_CONSTANT, ExpressionError.NO_ERROR, conditionResult.getErrorMessage());
}
if (result.getStatus() == CommandZoneAccessor.ExpressionStatus.INVALID_EXPRESSION) {
return new ExpressionResult(ExpressionStatus.INVALID_EXPRESSION, ExpressionResult.convertExpressionError(result.getError()), result.getMessage());
} else {
return new ExpressionResult(ExpressionStatus.VALID_EXPRESSION);
else {
return new ExpressionResult(ExpressionStatus.VALID_CONSTANT);
}
}
else {
// The expression is valid.
return new ExpressionResult(ExpressionStatus.VALID_EXPRESSION);
}
}
public String getServerValue() {
try {
......@@ -693,6 +637,8 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
s.append(this.hashCode());
s.append(" ");
s.append("serverId=" + serverId);
s.append(" ");
s.append("undoState=" + undoState);
return s.toString();
}
......@@ -738,6 +684,10 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
public int getMaxLength() {
return maxLength;
}
public int getViewMaxLength() {
return viewMaxLength;
}
public boolean maxLengthOnlyForTextFieldSize() {
return maxLengthOnlyForTextFieldSize;
......@@ -751,6 +701,10 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
this.maxLength = maxlength;
}
public void setViewMaxLength(int viewMaxLength) {
this.viewMaxLength = viewMaxLength;
}
public final boolean acceptsValue(String value, boolean isFinalValue) {
if (propertyFormat.verifiesValue()) {
// the propertyFormat is in charge of the control
......@@ -865,6 +819,15 @@ public abstract class Property implements ServerPropertyChangeListener, ICommand
}
public String getControllerNameForDynamicOrNot() {
int servantId = PropertyDatabase.getInstance().getServantIdForProperty(id);
if (servantId == -1) {
servantId = PropertyDatabase.getInstance().getServantIdForDynamicProperty(id);
}
return getServantName(servantId);
}
private String getServantName(int servantId) {
if (ServantDatabase.getInstance().isController(servantId)) {
return ServantDatabase.getInstance().getControllerName(servantId);
......
......@@ -138,6 +138,9 @@ public class PropertyFactory {
// max length
property.setMaxLength(propertyDescriptor.getMaxLength());
// max view length
property.setViewMaxLength(propertyDescriptor.getViewMaxLength());
// add conditions
Iterator<ConditionDescriptor> it = propertyDescriptor.getConditionsIterator();
......
......@@ -226,7 +226,6 @@ public class PropertyManager {
return false;
}
} else {
for (int i = 0; i < files.length; i++) {
// We may have more than one "Properties.xml" file (see acquisition controller for example)
propertyParser.parseXmlFile(files[i]);
......@@ -248,6 +247,7 @@ public class PropertyManager {
clientFilesFoundPerControllerType.put(controllerType, !(files == null || files.length == 0));
return clientFilesFoundPerControllerType.get(controllerType);
*/
}
......@@ -314,7 +314,7 @@ public class PropertyManager {
*
* @param controller
* @param propertyName
* @param pluginType TODO
* @param pluginType
* @return
* @throws PropertyNotFoundException
*/
......@@ -336,7 +336,7 @@ public class PropertyManager {
*
* @param controller
* @param propertyName
* @param pluginType TODO
* @param pluginType
* @return
*/
public Property getProperty(Controller controller, String propertyName) {
......@@ -667,7 +667,7 @@ public class PropertyManager {
/**
*
* @param pluginType TODO
* @param pluginType
* @param controllers
* @param propertyName
* @return
......
......@@ -18,6 +18,10 @@
package fr.ill.ics.core.property;
import fr.ill.ics.core.expression.ExpressionResult;
import fr.ill.ics.core.expression.ExpressionResult.ExpressionError;
import fr.ill.ics.core.expression.ExpressionResult.ExpressionStatus;
import fr.ill.ics.core.expression.GetExpressionResult;
import fr.ill.ics.nscclient.command.CommandZoneAccessor;
import fr.ill.ics.nscclient.command.CommandZoneAccessor.GetPropertyExpressionResult;
import fr.ill.ics.nscclient.dataprovider.DataAccessor;
......
......@@ -77,6 +77,7 @@ public class PropertyParser extends GenericParser {
private final static String ATTRIBUTE_MAX_EXCLUDED = "max_excluded";
private final static String ATTRIBUTE_DECIMAL_FORMAT_PROPERTY_NAME = "property_name";
protected final static String ATTRIBUTE_SIZE_PROPERTY = "size_property";
protected final static String ATTRIBUTE_VIEW_MAX_LENGTH = "view_max_length";
protected String controllerType;
private Map properties; // KEY=property name VALUE=PropertyDescriptor instance
......@@ -102,6 +103,7 @@ public class PropertyParser extends GenericParser {
propertyDescriptor = new XMLPropertyDescriptor(getAttribute(attributes, ATTRIBUTE_PROPERTY_NAME), getAttribute(attributes, ATTRIBUTE_PROPERTY_TYPE));
propertyDescriptor.setMaxLength(getAttribute(attributes, ATTRIBUTE_MAX_LENGTH));
propertyDescriptor.setUndoable(getAttribute(attributes, ATTRIBUTE_IS_UNDOABLE));
propertyDescriptor.setViewMaxLength(getAttribute(attributes, ATTRIBUTE_VIEW_MAX_LENGTH));
// Store it in the map
properties.put(propertyDescriptor.getPropertyName(), propertyDescriptor);
......
......@@ -37,6 +37,7 @@ public class XMLPropertyDescriptor {
private String format = PropertyParser.TAG_NO_FORMAT;
private int nbDecimalPlaces = DEFAULT_NB_PLACES;
private String decimalFormatPropertyName;
private int viewMaxLength = DEFAULT_STRING_MAX_LENGTH;
private Set<ConditionDescriptor> conditions = new HashSet<ConditionDescriptor>(); // set of ConditionDescriptor instances
......@@ -109,6 +110,17 @@ public class XMLPropertyDescriptor {
} catch (NumberFormatException nbe) {
}
}
public int getViewMaxLength() {
return viewMaxLength;
}
public void setViewMaxLength(String viewMaxLength) {
try {
this.viewMaxLength = Integer.parseInt(viewMaxLength);
} catch (NumberFormatException nbe) {
}
}
public int getNbDecimalPlaces() {
return nbDecimalPlaces;
......
......@@ -18,6 +18,8 @@
package fr.ill.ics.core.property.undo;
import fr.ill.ics.core.expression.ExpressionResult;
import fr.ill.ics.core.expression.ExpressionResult.ExpressionStatus;
import fr.ill.ics.core.property.Property;
import fr.ill.ics.core.property.array.Array;
......@@ -54,4 +56,9 @@ public class AutoApplyArrayState extends UndoArrayState {
public void setAutoApply() {
// do nothing
}
@Override
protected ExpressionResult checkPropertyValue(boolean constant, String value) {
return new ExpressionResult(ExpressionStatus.VALID_EXPRESSION);
}
}
\ No newline at end of file
......@@ -18,8 +18,9 @@
package fr.ill.ics.core.property.undo;
import fr.ill.ics.core.expression.ExpressionResult;
import fr.ill.ics.core.expression.GetExpressionResult;
import fr.ill.ics.core.property.Property;
import fr.ill.ics.core.property.Property.GetExpressionResult;
/**
* Subclass of UndoState. Here all values are immediately passed to the server (setting) and
......@@ -44,20 +45,23 @@ public class AutoApplyState extends UndoState {
return property.getServerExpression();
}
protected ExpressionResult checkPropertyValue(boolean constant, String value) {
// Only check the value by the client.
return property.checkClientValue(constant, value);
}
/**
* Sets server value
*/
public boolean setValue(String value) {
// Validity of the value for the property does not depend on UndoState => call to super class method
boolean ok = checkValue(value);
// First step is ok if the result is accepted.
boolean ok = checkValue(value);
if (ok) {
// Set the server value.
ok = property.setServerValue(value).isValid();
return property.setServerValue(value).isValid();
}
return ok;
return false;
}
/**
......
......@@ -18,10 +18,10 @@
package fr.ill.ics.core.property.undo;
import fr.ill.ics.core.expression.ExpressionResult.ExpressionStatus;
import fr.ill.ics.core.expression.GetExpressionResult;
import fr.ill.ics.core.property.ArrayProperty;
import fr.ill.ics.core.property.Property;
import fr.ill.ics.core.property.Property.ExpressionStatus;
import fr.ill.ics.core.property.Property.GetExpressionResult;
import fr.ill.ics.core.property.array.Array;
public abstract class UndoArrayState extends UndoState {
......
......@@ -18,11 +18,11 @@
package fr.ill.ics.core.property.undo;
import fr.ill.ics.core.expression.ExpressionResult;
import fr.ill.ics.core.expression.ExpressionResult.ExpressionError;
import fr.ill.ics.core.expression.ExpressionResult.ExpressionStatus;
import fr.ill.ics.core.expression.GetExpressionResult;
import fr.ill.ics.core.property.Property;
import fr.ill.ics.core.property.Property.ExpressionError;
import fr.ill.ics.core.property.Property.ExpressionResult;
import fr.ill.ics.core.property.Property.ExpressionStatus;
import fr.ill.ics.core.property.Property.GetExpressionResult;
/**
* Abstract class for State of undo of Property. Subsclassed as UndoableState and AutoApplyState.
......@@ -59,31 +59,44 @@ public abstract class UndoState {
*/
public abstract GetExpressionResult getExpression();
/**
* Checks the property value. Implemented in UndoableState (client and server check) and AutoApplyState (client check).
* @param constant
* @param value
* @return
*/
protected abstract ExpressionResult checkPropertyValue(boolean constant, String value);
/**
* Checks the value.
* @param value
* @return
*/
protected boolean checkValue(String value) {
// Result.
boolean ok = true;
// Factorise the call to isConstant.
boolean constant = property.isConstant(value);
// First check the value by the server.
ExpressionResult result = property.checkServerValue(value);
ExpressionResult result = checkPropertyValue(constant, value);
if (result.getStatus() == ExpressionStatus.INVALID_EXPRESSION) {
if (result.getError() == ExpressionError.PARSER_ERROR || result.getError() == ExpressionError.UNDEFINED_VARIABLE_ERROR) {
// Should not occurs here because the error has been detected earlier, in SelectionTree.addToCommandList method
System.out.println(result.getMessage() + " (" + getClass() + ".setValue('" + value.trim() + "'))");
// Should not occur here because the error has been detected earlier, in SelectionTree.addToCommandList method
System.out.println("Unexpected expression error while checking the value : " + result.getMessage() + " for " + value.trim());
ok = false;
} else {
// DISABLED_CONTROLLER_ERROR, ENUMERATED_VALUE_ERROR, UNDEFINED_VARIABLE_ERROR
// Those errors are warnings: the expression is not valid as this time but may be valid later
System.out.println(result.getMessage() + " (" + getClass() + ".setValue('" + value.trim() + "'))");
System.out.println("Expression error while checking the value : " + result.getMessage() + " for " + value.trim());
ok = true;
}
}
else if (result.getStatus() == ExpressionStatus.INVALID_CONSTANT) {
System.out.println(result.getMessage() + " (" + getClass() + ".setValue('" + value.trim() + "'))");
System.out.println("Constant error while checking the value : " + result.getMessage() + " for " + value.trim());
ok = false;
}
return ok;
......
......@@ -18,6 +18,8 @@
package fr.ill.ics.core.property.undo;
import fr.ill.ics.core.expression.ExpressionResult;
import fr.ill.ics.core.expression.ExpressionResult.ExpressionStatus;
import fr.ill.ics.core.property.Property;
import fr.ill.ics.core.property.array.Array;
......@@ -56,4 +58,9 @@ public class UndoableArrayState extends UndoArrayState {
public void setAutoApply() {
property.setUndoState(new UndoableArrayState(property));
}
@Override
protected ExpressionResult checkPropertyValue(boolean constant, String value) {
return new ExpressionResult(ExpressionStatus.VALID_EXPRESSION);
}
}
\ No newline at end of file
......@@ -20,9 +20,10 @@ package fr.ill.ics.core.property.undo;
import java.util.LinkedList;
import fr.ill.ics.core.expression.ExpressionResult;
import fr.ill.ics.core.expression.ExpressionResult.ExpressionStatus;
import fr.ill.ics.core.expression.GetExpressionResult;
import fr.ill.ics.core.property.Property;
import fr.ill.ics.core.property.Property.ExpressionStatus;
import fr.ill.ics.core.property.Property.GetExpressionResult;
/**
* Implements undoable state of a property allowing changes to be stored locally
......@@ -65,6 +66,18 @@ public class UndoableState extends UndoState {
return new GetExpressionResult(getValue(), status);
}
protected ExpressionResult checkPropertyValue(boolean constant, String value) {
// First check the value by the client.
ExpressionResult result = property.checkClientValue(constant, value);
if (result.getStatus() == ExpressionStatus.INVALID_CONSTANT || result.getStatus() == ExpressionStatus.INVALID_EXPRESSION) {
return result;
}
// Then check the value by the server if the client value is ok.
return property.checkServerValue(constant, value);
}
/**
* Store the new local modification in the linked list.
......
......@@ -38,13 +38,6 @@ public class ServerControlCommandBox extends ServerCommandBox {
public void setExpression(String expression) throws InvalidExpressionException {
ExpressionResult result = CommandZoneAccessor.getInstance(serverId).setExpression(commandBoxId, expression);
if (result.getStatus() == CommandZoneAccessor.ExpressionStatus.INVALID_EXPRESSION) {
System.out.println("ServerControlCommandBox : Expression " + expression + " is " + result.getStatus() + ", error : " + result.getError() + ", message = " + result.getMessage());
}
else {
System.out.println("ServerControlCommandBox : Expression " + expression + " is " + result.getStatus());
}
}
public String getExpression() {
......
......@@ -796,7 +796,7 @@ public class DataAccessor {
.build();
// Create the request.
DatabaseRequest.GetWholeScannablePropertiesRequest request = DatabaseRequest.GetWholeScannablePropertiesRequest.newBuilder()
DatabaseRequest.GetWholePropertiesRequest request = DatabaseRequest.GetWholePropertiesRequest.newBuilder()
.setDatabaseID(databaseID)
.build();
......@@ -814,6 +814,32 @@ public class DataAccessor {
return "";
}
public String getWholeDynamicProperties(int databaseID) {
// Create the message type.
DatabaseRequest.Message type = DatabaseRequest.Message.newBuilder()
.setType(DatabaseRequest.Message.Type.GetWholeDynamicProperties)
.build();
// Create the request.
DatabaseRequest.GetWholePropertiesRequest request = DatabaseRequest.GetWholePropertiesRequest.newBuilder()
.setDatabaseID(databaseID)
.build();
databaseRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
try {
Common.StringResponse response = Common.StringResponse.parseFrom(databaseRequester.receive());
return response.getValue();
}
catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getWholeDynamicProperties", "error in parsing response");
}
return "";
}
public static String getServerId(int databaseId) {
if (databaseId == 0) {
return CommandZoneWrapper.SERVER_ID;
......
......@@ -19,11 +19,13 @@
package fr.ill.ics.nscclient.dataprovider;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.logging.Level;
......@@ -1026,4 +1028,36 @@ public class ServantManagerAccessor {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "logUserMessage", "error in parsing response");
}
}
public Set<String> getControllerTypesInheritingType(int databaseID, String controllerType) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder()
.setType(ServantManagerRequest.Message.Type.GetControllerTypesInheritingType)
.build();
// Create the request.
ServantManagerRequest.GetControllerTypesInheritingTypeRequest request = ServantManagerRequest.GetControllerTypesInheritingTypeRequest.newBuilder()
.setDatabaseID(databaseID)
.setType(controllerType)
.build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
try {
Common.StringArrayResponse response = Common.StringArrayResponse.parseFrom(servantManagerRequester.receive());
HashSet<String> result = new HashSet<String>();
Iterator<String> t = response.getValueList().iterator();
while (t.hasNext()) {
result.add(t.next());
}
return result;
}
catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getControllerTypesInheritingType", "error in parsing response");
}
return null;
}
}
\ No newline at end of file
......@@ -229,8 +229,6 @@ public class DataChangeSubscriber {
clientState = ClientConditionState.ON_ACTIVATION_DELAY;
}
System.out.println("condition state changed " + message.getConditionID() + " " + message.getOn() + " " + clientState);
DataNotificationClient.getInstance().conditionStateChanged(message.getConditionID(), message.getOn(), clientState);
}
......@@ -252,13 +250,13 @@ public class DataChangeSubscriber {
}
private void notifyUserVariableValueChanged(UserVariableValueChanged message) {
System.out.println("UserVariableValueChanged " + message.getVariableName() + " : " + message.getValue());
//System.out.println("UserVariableValueChanged " + message.getVariableName() + " : " + message.getValue());
DataNotificationClient.getInstance().variableValueChanged(message.getVariableName(), message.getValue());
}
private void notifyUserVariableStateChanged(UserVariableStateChanged message) {
System.out.println("UserVariableStateChanged " + message.getVariableName() + " : " + message.getState());
//System.out.println("UserVariableStateChanged " + message.getVariableName() + " : " + message.getState());
DataNotificationClient.getInstance().variableStateChanged(message.getVariableName(), message.getState());
}
......