Commit 8b662ee7 authored by Cristina Cocho's avatar Cristina Cocho

Some modifs related to references management

parent 36709315
......@@ -502,7 +502,7 @@ public class ServantManagerAccessor {
/*
* Method used in Configura project. Test method.
*/
public void addControllerReference(int controllerID, String referenceName, String referenceRole) {
public void addControllerReference(int controllerID, String referenceName, String referenceRole, String referenceType) {
// Create the message type
ServantManagerRequest.Message messageType = ServantManagerRequest.Message.newBuilder().setType(ServantManagerRequest.Message.Type.AddControllerReference).build();
......@@ -513,7 +513,12 @@ public class ServantManagerAccessor {
// Get response even if we do not treat it
servantManagerRequester.receive();
// TODO Update here the content of the descriptor
boolean ok = true;
if (ok) {
// Update here the content of the descriptor
String controllerName = ServantDatabase.getInstance().getControllerName(controllerID);
((ClientControllerServantDescriptor)ServantDatabase.getInstance().getControllerDescriptor(controllerName)).modifyReference(referenceRole, referenceName, referenceType);
}
}
/*
......
package fr.ill.ics.nscclient.servant;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class ClientControllerServantDescriptor extends ClientServantDescriptor {
......@@ -23,6 +25,20 @@ public class ClientControllerServantDescriptor extends ClientServantDescriptor {
}
}
public void modifyReference(String role, String name, String type) {
// The must not be two references with the same role so use the role to find the reference that has been changed
List<ReferencesDescriptor> refs = referencesDescriptors.stream().filter(referenceDescriptor->referenceDescriptor.getRole().equals(role)).collect(Collectors.toList());
// There must be only one
if (refs.size() == 1) {
ReferencesDescriptor referenceDescriptor = refs.get(0);
referenceDescriptor.setName(name);
referenceDescriptor.setType(type);
} else {
// error
}
}
public void addReference(String role, String name, String type) {
referencesDescriptors.add(new ReferencesDescriptor(role, name, type));
}
......@@ -57,6 +73,14 @@ public class ClientControllerServantDescriptor extends ClientServantDescriptor {
public void setName(String name) {
this.name = name;
}
public void setType(String type) {
this.type = type;
}
public boolean isConfigured() {
return (name != NOT_CONFIGURED_NAME);
}
}
}
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