Commit 6bf61a59 authored by Cristina Cocho's avatar Cristina Cocho

Added methods that allow retrieval of different controller configurations...

Added methods that allow retrieval of different controller configurations (different sets of references associated)
parent 9b9fa88b
......@@ -18,6 +18,7 @@
package fr.ill.ics.nscclient.dataprovider;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
......@@ -45,6 +46,7 @@ import fr.ill.ics.nomadserver.configuration.ServantDataConfiguration.ServantDyna
import fr.ill.ics.nomadserver.configuration.ServantDataConfiguration.ServantPropertiesValue;
import fr.ill.ics.nomadserver.configuration.ServantDataConfiguration.ServantSpyProperties;
import fr.ill.ics.nomadserver.servantmanager.ServantManagerRequest;
import fr.ill.ics.nomadserver.servantmanager.ServantManagerRequest.ReferenceConfiguration;
import fr.ill.ics.nscclient.servant.ClientCommandDescriptor;
import fr.ill.ics.nscclient.servant.ClientServantDescriptor;
import fr.ill.ics.nscclient.servant.ConfigurationManager;
......@@ -56,6 +58,9 @@ import fr.ill.ics.nscclient.servant.ResourceNotFoundException;
import fr.ill.ics.nscclient.servant.Servant;
import fr.ill.ics.nscclient.servant.SpyPropertyDescriptor;
import fr.ill.ics.nscclient.servant.StandardPropertyDescriptor;
import fr.ill.ics.nscclient.servant.configuration.ConfigurationPropertyDescriptor;
import fr.ill.ics.nscclient.servant.configuration.ControllerConfigurationDescriptor;
import fr.ill.ics.nscclient.servant.configuration.ControllerReferenceDescriptor;
import fr.ill.ics.nscclient.servant.scan.IcsParameterizableScan1D;
import fr.ill.ics.nscclient.serverconnection.ServerInstance;
......@@ -537,6 +542,43 @@ public class ServantManagerAccessor {
return null;
}
/*
* Method used in Configura project. Test method.
*/
public List<ControllerConfigurationDescriptor> getControllerReferencesConfigurations(String controllerType) {
// Create the message type.
ServantManagerRequest.Message type = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.GetControllerReferencesConfigurations).build();
// Create the request.
ServantManagerRequest.GetControllerReferencesConfigurationsRequest request = ServantManagerRequest.GetControllerReferencesConfigurationsRequest.newBuilder().setControllerType(controllerType).build();
servantManagerRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
List<ControllerConfigurationDescriptor> controllerConfigurations = new ArrayList<ControllerConfigurationDescriptor>();
try {
ServantManagerRequest.ControllerReferencesConfigurationsResponse response = ServantManagerRequest.ControllerReferencesConfigurationsResponse.parseFrom(servantManagerRequester.receive());
List<ServantManagerRequest.ReferenceConfiguration> configurations = response.getConfigurationList();
// Convert to our POJOS
for (ReferenceConfiguration configuration : configurations) {
ServantManagerRequest.Property property = configuration.getProperty();
ConfigurationPropertyDescriptor propertyDescriptor = new ConfigurationPropertyDescriptor(property.getName(), property.getValue(), property.getType());
List<ControllerReferenceDescriptor> controllerReferenceDescriptors = new ArrayList<ControllerReferenceDescriptor>();
List<ServantManagerRequest.Reference> referencesConfs = configuration.getReferenceList();
for (ServantManagerRequest.Reference reference : referencesConfs) {
controllerReferenceDescriptors.add(new ControllerReferenceDescriptor(reference.getRole(), reference.getType()));
}
controllerConfigurations.add(new ControllerConfigurationDescriptor(propertyDescriptor, controllerReferenceDescriptors));
}
} catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getControllerReferencesConfigurations", "error in parsing response");
}
return controllerConfigurations;
}
public void loadWholeConfiguration() throws LoadConfigurationFailure {
ServantData servantData = getWholeConfiguration(DATABASE_ID);
......
package fr.ill.ics.nscclient.servant.configuration;
public class ConfigurationPropertyDescriptor {
private String name;
private String value;
private String type;
public ConfigurationPropertyDescriptor(String name, String value, String type) {
this.name = name;
this.value = value;
this.type = type;
}
public String getName() {
return name;
}
public String getValue() {
return value;
}
public String getType() {
return type;
}
}
package fr.ill.ics.nscclient.servant.configuration;
import java.util.List;
public class ControllerConfigurationDescriptor {
private ConfigurationPropertyDescriptor configurationPropertyDescriptor;
private List<ControllerReferenceDescriptor> controllerReferenceDescriptors;
public ControllerConfigurationDescriptor(ConfigurationPropertyDescriptor configurationPropertyDescriptor, List<ControllerReferenceDescriptor> controllerReferenceDescriptors) {
this.configurationPropertyDescriptor = configurationPropertyDescriptor;
this.controllerReferenceDescriptors = controllerReferenceDescriptors;
}
public ConfigurationPropertyDescriptor getConfigurationPropertyDescriptor() {
return configurationPropertyDescriptor;
}
public List<ControllerReferenceDescriptor> getControllerReferenceDescriptor() {
return controllerReferenceDescriptors;
}
}
package fr.ill.ics.nscclient.servant.configuration;
public class ControllerReferenceDescriptor {
private String role;
private String type;
public ControllerReferenceDescriptor(String role, String type) {
this.role = role;
this.type = type;
}
public String getRole() {
return role;
}
public String getType() {
return type;
}
}
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