use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.
the class DeploymentTree method isMyself.
/**
* Little helper for the renderer. Just because it seems nice for the user. The
* specified node must contain a ClientInfo user object.
*/
protected boolean isMyself(DefaultMutableTreeNode node) {
try {
// find manager node
DefaultMutableTreeNode n = node;
do {
n = (DefaultMutableTreeNode) n.getParent();
} while (!(n.getUserObject() instanceof IMaciSupervisor));
// compare handles
ClientInfo info = (ClientInfo) node.getUserObject();
return (maciSupervisor(n).myMaciHandle() == info.h);
} catch (Exception e) {
// instead of making the above code rock-stable, let's do it cheap
return false;
}
}
use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.
the class MaciInfo method addInfoNodes.
protected void addInfoNodes(SortingTreeNode node, Map<Object, String> auxiliary) {
Object info = node.getUserObject();
int infokey = System.identityHashCode(info);
if (info instanceof ContainerInfo) {
//ContainerInfo casted = (ContainerInfo)info;
node.add(createNode(new InfoDetail("location", auxiliary.get(infokey + ".location"))));
} else if (info instanceof ClientInfo) {
ClientInfo casted = (ClientInfo) info;
node.add(createNode(new InfoDetail("location", auxiliary.get(infokey + ".location"))));
node.add(createNode(new InfoDetail("components", casted.components, true)));
node.add(createNode(new InfoDetail("access", casted.access, false)));
node.add(createNode(new InfoDetail("reference", casted.reference)));
} else if (info instanceof ComponentInfo) {
ComponentInfo casted = (ComponentInfo) info;
node.add(createNode(new InfoDetail("clients", casted.clients, true)));
node.add(createNode(new InfoDetail("container", casted.container, true)));
node.add(createNode(new InfoDetail("container_name", casted.container_name)));
node.add(createNode(new InfoDetail("access", casted.access, false)));
node.add(createNode(new InfoDetail("reference", casted.reference)));
node.add(createNode(new InfoDetail("interfaces", casted.interfaces)));
node.add(createNode(new InfoDetail("type", casted.type)));
node.add(createNode(new InfoDetail("code", casted.code)));
}
}
use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.
the class MaciInfo method setContents.
/**
* Sets the components, containers, and clients.
* The given lists must not be changed anymore (otherwise
* this method would have to make a copy of them).
*/
protected void setContents(List<ComponentInfo> newComponents, List<ContainerInfo> newContainers, List<ClientInfo> newClientApps, Map<Object, String> auxiliary) {
// bend references, each assignment is atomic and triggers a flush.
// note we shall not modify the lists anymore after this point!
this.components = newComponents;
this.containers = newContainers;
this.clientApps = newClientApps;
// re-populate the toplevel nodes
// ---------------------------------------------
componentNode.removeAllChildren();
for (ComponentInfo comp : newComponents) {
SortingTreeNode n = createNode(comp);
addInfoNodes(n, auxiliary);
componentNode.add(n);
}
containerNode.removeAllChildren();
for (ContainerInfo cont : newContainers) {
SortingTreeNode n = createNode(cont);
addInfoNodes(n, auxiliary);
// attach components that are active in this container
for (ComponentInfo comp : newComponents) {
if (comp.container == cont.h && comp.h != 0)
n.add(createNode(comp));
}
containerNode.add(n);
}
clientNode.removeAllChildren();
for (ClientInfo client : newClientApps) {
SortingTreeNode n = createNode(client);
addInfoNodes(n, auxiliary);
clientNode.add(n);
}
// we sort - for some great user experience
componentNode.sortChildrenByName();
containerNode.sortChildrenByName();
clientNode.sortChildrenByName();
// send out change event
nodeStructureChanged(managerNode);
}
use of si.ijs.maci.ClientInfo in project ACS by ACS-Community.
the class MaciSupervisorTest method debug.
// msc: it's not always easy to get the arguments for mocking right.
// the below code registers for any arguments, and prints the arguments.
void debug() throws Exception {
Mockito.when(manager.login(administrator)).thenAnswer(new Answer<ClientInfo>() {
public ClientInfo answer(InvocationOnMock invocation) throws Throwable {
System.out.println(Arrays.toString(invocation.getArguments()));
Thread.sleep(5000);
return new ClientInfo();
}
});
Mockito.when(manager.get_component_info(anyInt(), any(int[].class), anyString(), anyString(), anyBoolean())).thenAnswer(new Answer<ComponentInfo[]>() {
public ComponentInfo[] answer(InvocationOnMock invocation) throws Throwable {
System.out.println("get_component_info (" + Arrays.toString(invocation.getArguments()) + ")");
Thread.sleep(5000);
return new ComponentInfo[] {};
}
});
}
Aggregations