Commit 6663f899 authored by yannick legoc's avatar yannick legoc
Browse files

Replaced corba scan command box accessor.

parent 2aaa816d
......@@ -34,6 +34,8 @@ import fr.ill.ics.cameo.RequesterCreationException;
import fr.ill.ics.nomadserver.commandzone.CommandZoneRequests;
import fr.ill.ics.nomadserver.common.Common;
import fr.ill.ics.nomadserver.common.Common.Error.Type;
import fr.ill.ics.nomadserver.core.commandzone.ScanCommandBoxAccessorPackage.BadCommandBoxTypeException;
import fr.ill.ics.nomadserver.core.commandzone.ScanCommandBoxAccessorPackage.CommandBoxNotFoundException;
import fr.ill.ics.nscclient.serverconnection.ServerInstance;
public class CommandZoneAccessor {
......@@ -45,6 +47,8 @@ public class CommandZoneAccessor {
public enum ExecutionPhaseState {CONSTRUCTION, RUNNING, FINISHED, PAUSED};
public enum ContainerType {COMMANDZONE, IFTHEN, IFELSE, FORLOOP, SCAN};
private static Map<String, CommandZoneAccessor> instances = new HashMap<String, CommandZoneAccessor>();
public class InvalidExpressionException extends Exception {
......@@ -1154,7 +1158,28 @@ public class CommandZoneAccessor {
return null;
}
public Set<ServerCommandBox> getContent(boolean thenBlock, int commandBoxID) {
private CommandZoneRequests.Container.Type convertContainerType(ContainerType containerType) {
if (containerType == ContainerType.COMMANDZONE) {
return CommandZoneRequests.Container.Type.CommandZone;
}
else if (containerType == ContainerType.IFTHEN) {
return CommandZoneRequests.Container.Type.IfThenCommmandBox;
}
else if (containerType == ContainerType.IFELSE) {
return CommandZoneRequests.Container.Type.IfElseCommmandBox;
}
else if (containerType == ContainerType.FORLOOP) {
return CommandZoneRequests.Container.Type.ForLoopCommandBox;
}
else if (containerType == ContainerType.SCAN) {
return CommandZoneRequests.Container.Type.ScanCommandBox;
}
return CommandZoneRequests.Container.Type.CommandZone;
}
public Set<ServerCommandBox> getContent(ContainerType containerType, int commandBoxID) {
Set<ServerCommandBox> content = new LinkedHashSet<ServerCommandBox>();
......@@ -1165,7 +1190,7 @@ public class CommandZoneAccessor {
// Create the request.
CommandZoneRequests.GetCommandListRequest request = CommandZoneRequests.GetCommandListRequest.newBuilder()
.setType((thenBlock ? CommandZoneRequests.Container.Type.IfThenCommmandBox : CommandZoneRequests.Container.Type.IfElseCommmandBox))
.setType(convertContainerType(containerType))
.setContainerID(commandBoxID)
.build();
......@@ -1215,8 +1240,8 @@ public class CommandZoneAccessor {
return content;
}
public ServerAtomicCommandBox addNewAtomicCommandBoxAtEnd(boolean thenBlock, int commandBoxID, int commandID, boolean isSettings) {
public ServerAtomicCommandBox addNewAtomicCommandBoxAtEnd(ContainerType containerType, int commandBoxID, int commandID, boolean isSettings) {
// Create the message type.
CommandZoneRequests.Message type = CommandZoneRequests.Message.newBuilder()
......@@ -1225,7 +1250,7 @@ public class CommandZoneAccessor {
// Create the request.
CommandZoneRequests.AddNewAtomicCommandBoxAtEndRequest request = CommandZoneRequests.AddNewAtomicCommandBoxAtEndRequest.newBuilder()
.setType((thenBlock ? CommandZoneRequests.Container.Type.IfThenCommmandBox : CommandZoneRequests.Container.Type.IfElseCommmandBox))
.setType(convertContainerType(containerType))
.setContainerID(commandBoxID)
.setCommandID(commandID)
.setIsSettings(isSettings)
......@@ -1252,7 +1277,7 @@ public class CommandZoneAccessor {
return null;
}
public ServerAtomicCommandBox addNewAtomicCommandBox(boolean thenBlock, int commandBoxID, int commandID, boolean isSettings, int commandBoxIDToMove, boolean above) {
public ServerAtomicCommandBox addNewAtomicCommandBox(ContainerType containerType, int commandBoxID, int commandID, boolean isSettings, int commandBoxIDToMove, boolean above) {
// Create the message type.
CommandZoneRequests.Message type = CommandZoneRequests.Message.newBuilder()
......@@ -1261,7 +1286,7 @@ public class CommandZoneAccessor {
// Create the request.
CommandZoneRequests.AddNewAtomicCommandBoxRequest request = CommandZoneRequests.AddNewAtomicCommandBoxRequest.newBuilder()
.setType((thenBlock ? CommandZoneRequests.Container.Type.IfThenCommmandBox : CommandZoneRequests.Container.Type.IfElseCommmandBox))
.setType(convertContainerType(containerType))
.setContainerID(commandBoxID)
.setCommandID(commandID)
.setIsSettings(isSettings)
......@@ -1289,7 +1314,7 @@ public class CommandZoneAccessor {
return null;
}
public ServerScanCommandBox addNewScanCommandBoxAtEnd(boolean thenBlock, int commandBoxID, String scanName) {
public ServerScanCommandBox addNewScanCommandBoxAtEnd(ContainerType containerType, int commandBoxID, String scanName) {
// Create the message type.
CommandZoneRequests.Message type = CommandZoneRequests.Message.newBuilder()
......@@ -1298,7 +1323,7 @@ public class CommandZoneAccessor {
// Create the request.
CommandZoneRequests.AddNewScanCommandBoxAtEndRequest request = CommandZoneRequests.AddNewScanCommandBoxAtEndRequest.newBuilder()
.setType((thenBlock ? CommandZoneRequests.Container.Type.IfThenCommmandBox : CommandZoneRequests.Container.Type.IfElseCommmandBox))
.setType(convertContainerType(containerType))
.setContainerID(commandBoxID)
.setScanName(scanName)
.build();
......@@ -1323,7 +1348,7 @@ public class CommandZoneAccessor {
return null;
}
public ServerScanCommandBox addNewScanCommandBox(boolean thenBlock, int commandBoxID, String scanName, int commandBoxIDToMove, boolean above) {
public ServerScanCommandBox addNewScanCommandBox(ContainerType containerType, int commandBoxID, String scanName, int commandBoxIDToMove, boolean above) {
// Create the message type.
CommandZoneRequests.Message type = CommandZoneRequests.Message.newBuilder()
......@@ -1332,7 +1357,7 @@ public class CommandZoneAccessor {
// Create the request.
CommandZoneRequests.AddNewScanCommandBoxRequest request = CommandZoneRequests.AddNewScanCommandBoxRequest.newBuilder()
.setType((thenBlock ? CommandZoneRequests.Container.Type.IfThenCommmandBox : CommandZoneRequests.Container.Type.IfElseCommmandBox))
.setType(convertContainerType(containerType))
.setContainerID(commandBoxID)
.setScanName(scanName)
.setCommandBoxIDToMove(commandBoxIDToMove)
......@@ -1359,7 +1384,7 @@ public class CommandZoneAccessor {
return null;
}
public ServerForLoopCommandBox addNewForLoopCommandBoxAtEnd(boolean thenBlock, int commandBoxID, String variableName) {
public ServerForLoopCommandBox addNewForLoopCommandBoxAtEnd(ContainerType containerType, int commandBoxID, String variableName) {
// Create the message type.
CommandZoneRequests.Message type = CommandZoneRequests.Message.newBuilder()
......@@ -1368,7 +1393,7 @@ public class CommandZoneAccessor {
// Create the request.
CommandZoneRequests.AddNewForLoopCommandBoxAtEndRequest request = CommandZoneRequests.AddNewForLoopCommandBoxAtEndRequest.newBuilder()
.setType((thenBlock ? CommandZoneRequests.Container.Type.IfThenCommmandBox : CommandZoneRequests.Container.Type.IfElseCommmandBox))
.setType(convertContainerType(containerType))
.setContainerID(commandBoxID)
.setVariableName(variableName)
.build();
......@@ -1393,7 +1418,7 @@ public class CommandZoneAccessor {
return null;
}
public ServerForLoopCommandBox addNewForLoopCommandBox(boolean thenBlock, int commandBoxID, String variableName, int commandBoxIDToMove, boolean above) {
public ServerForLoopCommandBox addNewForLoopCommandBox(ContainerType containerType, int commandBoxID, String variableName, int commandBoxIDToMove, boolean above) {
// Create the message type.
CommandZoneRequests.Message type = CommandZoneRequests.Message.newBuilder()
......@@ -1402,7 +1427,7 @@ public class CommandZoneAccessor {
// Create the request.
CommandZoneRequests.AddNewForLoopCommandBoxRequest request = CommandZoneRequests.AddNewForLoopCommandBoxRequest.newBuilder()
.setType((thenBlock ? CommandZoneRequests.Container.Type.IfThenCommmandBox : CommandZoneRequests.Container.Type.IfElseCommmandBox))
.setType(convertContainerType(containerType))
.setContainerID(commandBoxID)
.setVariableName(variableName)
.setCommandBoxIDToMove(commandBoxIDToMove)
......@@ -1430,7 +1455,7 @@ public class CommandZoneAccessor {
}
public ServerGenericCommandBox addNewGenericCommandBox(boolean thenBlock, int commandBoxID, int boxType) {
public ServerGenericCommandBox addNewGenericCommandBoxAtEnd(ContainerType containerType, int commandBoxID, int boxType) {
// Create the message type.
CommandZoneRequests.Message type = CommandZoneRequests.Message.newBuilder()
......@@ -1439,7 +1464,7 @@ public class CommandZoneAccessor {
// Create the request.
CommandZoneRequests.AddNewGenericCommandBoxAtEndRequest request = CommandZoneRequests.AddNewGenericCommandBoxAtEndRequest.newBuilder()
.setType((thenBlock ? CommandZoneRequests.Container.Type.IfThenCommmandBox : CommandZoneRequests.Container.Type.IfElseCommmandBox))
.setType(convertContainerType(containerType))
.setContainerID(commandBoxID)
.setBoxType(boxType)
.build();
......@@ -1464,7 +1489,7 @@ public class CommandZoneAccessor {
return null;
}
public ServerGenericCommandBox addNewGenericCommandBox(boolean thenBlock, int commandBoxID, int boxType, int commandBoxIDToMove, boolean above) {
public ServerGenericCommandBox addNewGenericCommandBox(ContainerType containerType, int commandBoxID, int boxType, int commandBoxIDToMove, boolean above) {
// Create the message type.
CommandZoneRequests.Message type = CommandZoneRequests.Message.newBuilder()
......@@ -1473,7 +1498,7 @@ public class CommandZoneAccessor {
// Create the request.
CommandZoneRequests.AddNewGenericCommandBoxRequest request = CommandZoneRequests.AddNewGenericCommandBoxRequest.newBuilder()
.setType((thenBlock ? CommandZoneRequests.Container.Type.IfThenCommmandBox : CommandZoneRequests.Container.Type.IfElseCommmandBox))
.setType(convertContainerType(containerType))
.setContainerID(commandBoxID)
.setBoxType(boxType)
.setCommandBoxIDToMove(commandBoxIDToMove)
......@@ -1500,7 +1525,7 @@ public class CommandZoneAccessor {
return null;
}
public ServerControlCommandBox addNewControlCommandBox(boolean thenBlock, int commandBoxID, int boxType) {
public ServerControlCommandBox addNewControlCommandBoxAtEnd(ContainerType containerType, int commandBoxID, int boxType) {
// Create the message type.
CommandZoneRequests.Message type = CommandZoneRequests.Message.newBuilder()
......@@ -1509,7 +1534,7 @@ public class CommandZoneAccessor {
// Create the request.
CommandZoneRequests.AddNewControlCommandBoxAtEndRequest request = CommandZoneRequests.AddNewControlCommandBoxAtEndRequest.newBuilder()
.setType((thenBlock ? CommandZoneRequests.Container.Type.IfThenCommmandBox : CommandZoneRequests.Container.Type.IfElseCommmandBox))
.setType(convertContainerType(containerType))
.setContainerID(commandBoxID)
.setBoxType(boxType)
.build();
......@@ -1535,7 +1560,7 @@ public class CommandZoneAccessor {
}
public ServerControlCommandBox addNewControlCommandBox(boolean thenBlock, int commandBoxID, int boxType, int commandBoxIDToMove, boolean above) {
public ServerControlCommandBox addNewControlCommandBox(ContainerType containerType, int commandBoxID, int boxType, int commandBoxIDToMove, boolean above) {
// Create the message type.
CommandZoneRequests.Message type = CommandZoneRequests.Message.newBuilder()
......@@ -1544,7 +1569,7 @@ public class CommandZoneAccessor {
// Create the request.
CommandZoneRequests.AddNewControlCommandBoxRequest request = CommandZoneRequests.AddNewControlCommandBoxRequest.newBuilder()
.setType((thenBlock ? CommandZoneRequests.Container.Type.IfThenCommmandBox : CommandZoneRequests.Container.Type.IfElseCommmandBox))
.setType(convertContainerType(containerType))
.setContainerID(commandBoxID)
.setBoxType(boxType)
.setCommandBoxIDToMove(commandBoxIDToMove)
......@@ -1571,7 +1596,7 @@ public class CommandZoneAccessor {
return null;
}
public boolean moveCommandBox(boolean thenBlock, int commandBoxID, int commandBoxIDToMove, int commandBoxIDToShift, boolean above) {
public boolean moveCommandBox(ContainerType containerType, int commandBoxID, int commandBoxIDToMove, int commandBoxIDToShift, boolean above) {
// Create the message type.
CommandZoneRequests.Message type = CommandZoneRequests.Message.newBuilder()
......@@ -1580,7 +1605,7 @@ public class CommandZoneAccessor {
// Create the request.
CommandZoneRequests.MoveCommandBoxRequest request = CommandZoneRequests.MoveCommandBoxRequest.newBuilder()
.setType((thenBlock ? CommandZoneRequests.Container.Type.IfThenCommmandBox : CommandZoneRequests.Container.Type.IfElseCommmandBox))
.setType(convertContainerType(containerType))
.setContainerID(commandBoxID)
.setCommandBoxIDToMove(commandBoxIDToMove)
.setCommandBoxIDToShift(commandBoxIDToShift)
......@@ -1607,7 +1632,7 @@ public class CommandZoneAccessor {
return false;
}
public boolean moveCommandBoxToEnd(boolean thenBlock, int commandBoxID, int commandBoxIDToMove) {
public boolean moveCommandBoxToEnd(ContainerType containerType, int commandBoxID, int commandBoxIDToMove) {
// Create the message type.
CommandZoneRequests.Message type = CommandZoneRequests.Message.newBuilder()
......@@ -1616,7 +1641,7 @@ public class CommandZoneAccessor {
// Create the request.
CommandZoneRequests.MoveCommandBoxToEndRequest request = CommandZoneRequests.MoveCommandBoxToEndRequest.newBuilder()
.setType((thenBlock ? CommandZoneRequests.Container.Type.IfThenCommmandBox : CommandZoneRequests.Container.Type.IfElseCommmandBox))
.setType(convertContainerType(containerType))
.setContainerID(commandBoxID)
.setCommandBoxIDToMove(commandBoxIDToMove)
.build();
......@@ -1641,7 +1666,7 @@ public class CommandZoneAccessor {
return false;
}
public boolean deleteCommandBox(boolean thenBlock, int commandBoxID, int commandBoxIDToDelete) {
public boolean deleteCommandBox(ContainerType containerType, int commandBoxID, int commandBoxIDToDelete) {
// Create the message type.
CommandZoneRequests.Message type = CommandZoneRequests.Message.newBuilder()
......@@ -1650,7 +1675,7 @@ public class CommandZoneAccessor {
// Create the request.
CommandZoneRequests.DeleteCommandBoxRequest request = CommandZoneRequests.DeleteCommandBoxRequest.newBuilder()
.setType((thenBlock ? CommandZoneRequests.Container.Type.IfThenCommmandBox : CommandZoneRequests.Container.Type.IfElseCommmandBox))
.setType(convertContainerType(containerType))
.setContainerID(commandBoxID)
.setCommandBoxIDToDelete(commandBoxIDToDelete)
.build();
......@@ -1674,5 +1699,37 @@ public class CommandZoneAccessor {
return false;
}
public String getScanName(int commandBoxID) {
// Create the message type.
CommandZoneRequests.Message type = CommandZoneRequests.Message.newBuilder()
.setType(CommandZoneRequests.Message.Type.GetScanName)
.build();
// Create the request.
CommandZoneRequests.CommandBoxRequest request = CommandZoneRequests.CommandBoxRequest.newBuilder()
.setCommandBoxID(commandBoxID)
.build();
commandBoxRequester.sendTwoParts(type.toByteArray(), request.toByteArray());
try {
Common.StringResponse response = Common.StringResponse.parseFrom(commandBoxRequester.receive());
// Test the error.
if (response.hasError()) {
processError(response.getError(), commandBoxID);
}
else {
return response.getValue();
}
}
catch (InvalidProtocolBufferException e) {
LOGGER.logp(Level.WARNING, this.getClass().getName(), "getScanName", "error in parsing response for command box " + commandBoxID);
}
return null;
}
}
\ No newline at end of file
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
package fr.ill.ics.nscclient.command;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import fr.ill.ics.nomadserver.common.ListItem;
import fr.ill.ics.nomadserver.common.ListIterator;
import fr.ill.ics.nomadserver.core.commandzone.CommandBoxDescriptor;
import fr.ill.ics.nomadserver.core.commandzone.CommandBoxDescriptorHelper;
import fr.ill.ics.nomadserver.core.commandzone.ScanCommandBoxAccessor;
import fr.ill.ics.nomadserver.core.commandzone.ScanCommandBoxAccessorHelper;
import fr.ill.ics.nomadserver.core.commandzone.CommandBoxDescriptorPackage.CommandBoxType;
import fr.ill.ics.nomadserver.core.commandzone.ScanCommandBoxAccessorPackage.BadCommandBoxTypeException;
import fr.ill.ics.nomadserver.core.commandzone.ScanCommandBoxAccessorPackage.CommandBoxForbiddenException;
import fr.ill.ics.nomadserver.core.commandzone.ScanCommandBoxAccessorPackage.CommandBoxNotFoundException;
import fr.ill.ics.nomadserver.core.commandzone.ScanCommandBoxAccessorPackage.CommandListCreationException;
import fr.ill.ics.nomadserver.core.commandzone.ScanCommandBoxAccessorPackage.NoSuchCommandException;
import fr.ill.ics.nscclient.corbabase.CorbaNamingService;
public class ScanCommandBoxAccessorProxy {
private static final Logger LOGGER = Logger.getLogger(ScanCommandBoxAccessorProxy.class.getName());
private String serverId;
private ScanCommandBoxAccessor scanCommandBoxAccessor;
private static Map<String, ScanCommandBoxAccessorProxy> instances = new HashMap<String, ScanCommandBoxAccessorProxy>();
private ScanCommandBoxAccessorProxy(String serverId) {
this.serverId = serverId;
}
public static ScanCommandBoxAccessorProxy getInstance(String serverId) {
if (!instances.containsKey(serverId)) {
ScanCommandBoxAccessorProxy instance = new ScanCommandBoxAccessorProxy(serverId);
instances.put(serverId, instance);
}
return instances.get(serverId);
}
public void init() {
try {
String contextName = "NomadServer";
if (!serverId.equals("real")) {
contextName += serverId;
}
org.omg.CORBA.Object corbaObj = CorbaNamingService.getInstance().resolveObject(contextName, "Core","scanCommandBoxAccessor");
scanCommandBoxAccessor = ScanCommandBoxAccessorHelper.narrow(corbaObj);
} catch (CorbaNamingService.CORBAResolveFailureException rfe) {
System.err.println("Unable to obtain ScanCommandBoxAccessor from Naming Service");
} catch (org.omg.CORBA.SystemException e) {
System.err.println("Unable to obtain ScanCommandBoxAccessor from Naming Service");
}
}
public String getScanName(int commandBoxID) {
try {
return scanCommandBoxAccessor.getScanName(commandBoxID);
} catch (BadCommandBoxTypeException e) {
LOGGER.log(Level.SEVERE, "BadCommandBoxTypeException occured while scan name for ScanCommandBox " + commandBoxID);
} catch (CommandBoxNotFoundException e) {
LOGGER.log(Level.SEVERE, "CommandBoxNotFoundException occured while scan name for ScanCommandBox " + commandBoxID);
}
return null;
}
public Set<ServerCommandBox> getContent(int commandBoxId) {
Set<ServerCommandBox> content = new LinkedHashSet<ServerCommandBox>();
try {
ListIterator iterator = scanCommandBoxAccessor.getCommandListIterator(commandBoxId);
// iterate over the list and create a new non-corba ServantDescriptor for each item
while (iterator.hasNext()) {
ListItem item = iterator.next();
CommandBoxDescriptor commandBoxDescriptor = CommandBoxDescriptorHelper.narrow(item);
int id = commandBoxDescriptor.getCommandBoxID();
CommandBoxType type = commandBoxDescriptor.getType();
if (type == CommandBoxType.ATOMIC) {
content.add(new ServerAtomicCommandBox(serverId, id));
} else if (type == CommandBoxType.SCAN) {
content.add(new ServerScanCommandBox(serverId, id));
} else if (type == CommandBoxType.FOR_LOOP) {
content.add(new ServerForLoopCommandBox(serverId, id));
} else if (type == CommandBoxType.GENERIC) {
content.add(new ServerGenericCommandBox(serverId, id));
} else if (type == CommandBoxType.CONTROL) {
content.add(new ServerControlCommandBox(serverId, id));
}
}
// release the corba object
iterator.releaseIterator();
} catch (CommandListCreationException e) {
LOGGER.log(Level.SEVERE, "CommandListCreationException occured while getting command box descriptors for ScanCommandBox " + commandBoxId);
} catch (BadCommandBoxTypeException e) {
LOGGER.log(Level.SEVERE, "BadCommandBoxTypeException occured while getting command box descriptors for ScanCommandBox " + commandBoxId);
} catch (CommandBoxNotFoundException e) {
LOGGER.log(Level.SEVERE, "CommandBoxNotFoundException occured while getting command box descriptors for ScanCommandBox " + commandBoxId);
}
return content;
}
public ServerAtomicCommandBox addNewAtomicCommandBoxAtEnd(int commandBoxID, int commandID, boolean isSettings) {
try {
return new ServerAtomicCommandBox(serverId, scanCommandBoxAccessor.addNewAtomicCommandBoxAtEnd(commandBoxID, commandID, isSettings));
} catch (BadCommandBoxTypeException e) {
LOGGER.log(Level.SEVERE, "BadCommandBoxTypeException occured for ScanCommandBox " + commandBoxID);
} catch (CommandBoxNotFoundException e) {
LOGGER.log(Level.SEVERE, "CommandBoxNotFoundException occured for ScanCommandBox " + commandBoxID);
} catch (NoSuchCommandException e) {
LOGGER.log(Level.SEVERE, "NoSuchCommandException occured for ScanCommandBox " + commandBoxID);
}
return null;
}
public ServerScanCommandBox addNewScanCommandBoxAtEnd(int commandBoxID, String scanName) {
try {
return new ServerScanCommandBox(serverId, scanCommandBoxAccessor.addNewScanCommandBoxAtEnd(commandBoxID, scanName));
} catch (BadCommandBoxTypeException e) {
LOGGER.log(Level.SEVERE, "BadCommandBoxTypeException occured for ScanCommandBox " + commandBoxID);
} catch (CommandBoxNotFoundException e) {
LOGGER.log(Level.SEVERE, "CommandBoxNotFoundException occured for ScanCommandBox " + commandBoxID);
}
return null;
}
public ServerForLoopCommandBox addNewForLoopCommandBoxAtEnd(int commandBoxID, String variableName) {
try {
return new ServerForLoopCommandBox(serverId, scanCommandBoxAccessor.addNewForLoopCommandBoxAtEnd(commandBoxID, variableName));
} catch (BadCommandBoxTypeException e) {
LOGGER.log(Level.SEVERE, "BadCommandBoxTypeException occured for ScanCommandBox " + commandBoxID);
} catch (CommandBoxNotFoundException e) {
LOGGER.log(Level.SEVERE, "CommandBoxNotFoundException occured for ScanCommandBox " + commandBoxID);
}
return null;
}
public ServerGenericCommandBox addNewGenericCommandBoxAtEnd(int commandBoxID, int boxType) {
try {
return new ServerGenericCommandBox(serverId, scanCommandBoxAccessor.addNewGenericCommandBoxAtEnd(commandBoxID, boxType));
} catch (BadCommandBoxTypeException e) {
LOGGER.log(Level.SEVERE, "BadCommandBoxTypeException occured for ScanCommandBox " + commandBoxID);
} catch (CommandBoxNotFoundException e) {
LOGGER.log(Level.SEVERE, "CommandBoxNotFoundException occured for ScanCommandBox " + commandBoxID);
}
return null;
}
public ServerControlCommandBox addNewControlCommandBoxAtEnd(int commandBoxId, int boxType) {
try {
return new ServerControlCommandBox(serverId, scanCommandBoxAccessor.addNewControlCommandBoxAtEnd(commandBoxId, boxType));
} catch (BadCommandBoxTypeException e) {
LOGGER.log(Level.SEVERE, "BadCommandBoxTypeException occured for ForLoopCommandBox " + commandBoxId);
} catch (CommandBoxNotFoundException e) {
LOGGER.log(Level.SEVERE, "CommandBoxNotFoundException occured for ForLoopCommandBox " + commandBoxId);
} catch (CommandBoxForbiddenException e) {
e.printStackTrace();
}
return null;
}
}
\ No newline at end of file
......@@ -31,6 +31,10 @@ public class ServerControlCommandBox extends ServerCommandBox {
super(serverId, commandBoxId);
}
private CommandZoneAccessor.ContainerType convertContainerType(boolean thenBlock) {
return (thenBlock ? CommandZoneAccessor.ContainerType.IFTHEN : CommandZoneAccessor.ContainerType.IFELSE);
}
public void setExpression(String expression) throws InvalidExpressionException {
CommandZoneAccessor.getInstance(serverId).setExpression(commandBoxId, expression);
}
......@@ -44,59 +48,59 @@ public class ServerControlCommandBox extends ServerCommandBox {
}
public Set<ServerCommandBox> getContent(boolean thenBlock) {
return CommandZoneAccessor.getInstance(serverId).getContent(thenBlock, commandBoxId);
return CommandZoneAccessor.getInstance(serverId).getContent(convertContainerType(thenBlock), commandBoxId);
}
public ServerAtomicCommandBox addNewAtomicCommandBoxAtEnd(boolean thenBlock, int commandID, boolean isSettings) {
return CommandZoneAccessor.getInstance(serverId).addNewAtomicCommandBoxAtEnd(thenBlock, commandBoxId, commandID, isSettings);
return CommandZoneAccessor.getInstance(serverId).addNewAtomicCommandBoxAtEnd(convertContainerType(thenBlock), commandBoxId, commandID, isSettings);
}
public ServerAtomicCommandBox addNewAtomicCommandBox(boolean thenBlock, int commandID, boolean isSettings, ServerCommandBox commandBoxToMove, boolean above) {
return CommandZoneAccessor.getInstance(serverId).addNewAtomicCommandBox(thenBlock, commandBoxId, commandID, isSettings, commandBoxToMove.getId(), above);
return CommandZoneAccessor.getInstance(serverId).addNewAtomicCommandBox(convertContainerType(thenBlock), commandBoxId, commandID, isSettings, commandBoxToMove.getId(), above);
}
public ServerScanCommandBox addNewScanCommandBoxAtEnd(boolean thenBlock, String scanName) {
return CommandZoneAccessor.getInstance(serverId).addNewScanCommandBoxAtEnd(thenBlock, commandBoxId, scanName);
return CommandZoneAccessor.getInstance(serverId).addNewScanCommandBoxAtEnd(convertContainerType(thenBlock), commandBoxId, scanName);
}
public ServerScanCommandBox addNewScanCommandBox(boolean thenBlock, String scanName, ServerCommandBox commandBoxToMove, boolean above) {
return CommandZoneAccessor.getInstance(serverId).addNewScanCommandBox(thenBlock, commandBoxId, scanName, commandBoxToMove.getId(), above);
return CommandZoneAccessor.getInstance(serverId).addNewScanCommandBox(convertContainerType(thenBlock), commandBoxId, scanName, commandBoxToMove.getId(), above);
}
public ServerForLoopCommandBox addNewForLoopCommandBoxAtEnd(boolean thenBlock, String variableName) {
return CommandZoneAccessor.getInstance(serverId).addNewForLoopCommandBoxAtEnd(thenBlock, commandBoxId, variableName);
return CommandZoneAccessor.getInstance(serverId).addNewForLoopCommandBoxAtEnd(convertContainerType(thenBlock), commandBoxId, variableName);
}
public ServerForLoopCommandBox addNewForLoopCommandBox(boolean thenBlock, String variableName, ServerCommandBox commandBoxToMove, boolean above) {
return CommandZoneAccessor.getInstance(serverId).addNewForLoopCommandBox(thenBlock, commandBoxId, variableName, commandBoxToMove.getId(), above);