use of com.twinsoft.convertigo.beans.steps.SequenceStep in project convertigo by convertigo.
the class StepImportSequenceVariablesAction method run.
public void run() {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = getParentShell();
shell.setCursor(waitCursor);
try {
ProjectExplorerView explorerView = getProjectExplorerView();
if (explorerView != null) {
TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
Object databaseObject = treeObject.getObject();
if ((databaseObject != null) && (databaseObject instanceof SequenceStep)) {
SequenceStep sequenceStep = (SequenceStep) databaseObject;
sequenceStep.importVariableDefinition();
if (sequenceStep.hasChanged) {
explorerView.reloadTreeObject(treeObject);
StructuredSelection structuredSelection = new StructuredSelection(treeObject);
ConvertigoPlugin.getDefault().getPropertiesView().selectionChanged((IWorkbenchPart) explorerView, structuredSelection);
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to add sequence variables to step!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.beans.steps.SequenceStep in project convertigo by convertigo.
the class SequenceExecuteSelectedAction method openEditors.
private void openEditors(ProjectExplorerView explorerView, List<Step> steps, Set<SequenceStep> alreadyOpened) {
for (Step step : steps) {
if (step.isEnabled()) {
if (step instanceof SequenceStep) {
SequenceStep sequenceStep = (SequenceStep) step;
String projectName = sequenceStep.getProjectName();
// load project if necessary
if (!step.getSequence().getProject().getName().equals(projectName))
loadProject(explorerView, projectName);
if (alreadyOpened.contains(sequenceStep)) {
// avoid sequence recursion
return;
}
alreadyOpened.add(sequenceStep);
try {
ProjectTreeObject projectTreeObject = (ProjectTreeObject) explorerView.getProjectRootObject(projectName);
Sequence subSequence = projectTreeObject.getObject().getSequenceByName(sequenceStep.getSequenceName());
SequenceTreeObject subSequenceTreeObject = (SequenceTreeObject) explorerView.findTreeObjectByUserObject(subSequence);
// recurse on sequence
openEditors(explorerView, subSequenceTreeObject, alreadyOpened);
} catch (EngineException e) {
e.printStackTrace();
}
} else if (step instanceof TransactionStep) {
TransactionStep transactionStep = (TransactionStep) step;
String projectName = transactionStep.getProjectName();
if (!step.getSequence().getProject().getName().equals(projectName))
// load project if necessary
loadProject(explorerView, projectName);
try {
ProjectTreeObject projectTreeObject = (ProjectTreeObject) explorerView.getProjectRootObject(projectName);
Connector connector = projectTreeObject.getObject().getConnectorByName(transactionStep.getConnectorName());
ConnectorTreeObject connectorTreeObject = (ConnectorTreeObject) explorerView.findTreeObjectByUserObject(connector);
// open connector editor
connectorTreeObject.openConnectorEditor();
} catch (EngineException e) {
e.printStackTrace();
}
} else if (step instanceof StepWithExpressions) {
openEditors(explorerView, ((StepWithExpressions) step).getSteps(), alreadyOpened);
}
}
}
}
use of com.twinsoft.convertigo.beans.steps.SequenceStep in project convertigo by convertigo.
the class Migration7_0_0 method handleSteps.
private static void handleSteps(XmlSchema projectSchema, Map<String, Reference> referenceMap, List<Step> stepList) {
for (Step step : stepList) {
if (step instanceof XMLActionStep) {
XMLVector<XMLVector<Object>> sourcesDefinition = ((XMLActionStep) step).getSourcesDefinition();
for (XMLVector<Object> row : sourcesDefinition) {
if (row.size() > 1) {
XMLVector<String> definition = GenericUtils.cast(row.get(1));
handleSourceDefinition(definition);
}
}
}
if (step instanceof TransactionStep) {
XMLVector<String> definition = ((TransactionStep) step).getConnectionStringDefinition();
handleSourceDefinition(definition);
}
if (step instanceof IStepSourceContainer) {
/**
* Case step's xpath has not been migrated when project has been deployed
** on a 5.0 server from a Studio with an older version *
*/
IStepSourceContainer stepSourceContainer = (IStepSourceContainer) step;
XMLVector<String> definition = stepSourceContainer.getSourceDefinition();
handleSourceDefinition(definition);
}
if (step instanceof IVariableContainer) {
IVariableContainer variableContainer = (IVariableContainer) step;
for (Variable variable : variableContainer.getVariables()) {
if (variable instanceof IStepSourceContainer) {
IStepSourceContainer stepSourceContainer = (IStepSourceContainer) variable;
XMLVector<String> definition = stepSourceContainer.getSourceDefinition();
handleSourceDefinition(definition);
}
}
}
String targetProjectName = null;
String typeLocalName = null;
if (step instanceof TransactionStep) {
targetProjectName = ((TransactionStep) step).getProjectName();
typeLocalName = ((TransactionStep) step).getConnectorName() + "__" + ((TransactionStep) step).getTransactionName() + "ResponseType";
} else if (step instanceof SequenceStep) {
targetProjectName = ((SequenceStep) step).getProjectName();
typeLocalName = ((SequenceStep) step).getSequenceName() + "ResponseType";
}
String namespaceURI = null;
// Case of Requestable steps
if (targetProjectName != null) {
try {
namespaceURI = Project.CONVERTIGO_PROJECTS_NAMESPACEURI + targetProjectName;
if (!targetProjectName.equals(step.getProject().getName())) {
try {
namespaceURI = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(targetProjectName).getTargetNamespace();
} catch (Exception e) {
}
// Add reference
String location = "../" + targetProjectName + "/" + targetProjectName + ".xsd";
addReferenceToMap(referenceMap, namespaceURI, location);
}
// Set step's typeQName
step.setXmlComplexTypeAffectation(new XmlQName(new QName(namespaceURI, typeLocalName)));
} catch (Exception e) {
e.printStackTrace();
}
} else // Other steps
{
try {
String targetNamespace = projectSchema.getTargetNamespace();
String targetPrefix = projectSchema.getNamespaceContext().getPrefix(targetNamespace);
String s = null;
try {
if (step instanceof XMLCopyStep) {
XmlSchemaCollection collection = SchemaMeta.getCollection(projectSchema);
XmlSchemaObject ob = step.getXmlSchemaObject(collection, projectSchema);
if (ob != null) {
if (ob instanceof XmlSchemaSequence) {
ob = ((XmlSchemaSequence) ob).getItems().getItem(0);
}
if (ob instanceof XmlSchemaElement || ob instanceof XmlSchemaAttribute) {
QName schemaTypeName = ob instanceof XmlSchemaElement ? ((XmlSchemaElement) ob).getSchemaTypeName() : ((XmlSchemaAttribute) ob).getSchemaTypeName();
String schemaTypePrefix = projectSchema.getNamespaceContext().getPrefix(schemaTypeName.getNamespaceURI());
String schemaTypeLocalName = schemaTypeName.getLocalPart();
s = schemaTypePrefix + ":" + schemaTypeLocalName;
}
}
} else {
String schemaType = step.getSchemaDataType();
s = schemaType.equals("") ? "xsd:string" : schemaType;
}
} catch (Exception e) {
s = "xsd:string";
}
if ((s != null) && (!s.equals("")) && (!s.startsWith("xsd:"))) {
String prefix = s.split(":")[0];
typeLocalName = s.split(":")[1];
if (prefix.equals(targetPrefix)) {
// ignore
} else {
// Retrieve namespace uri
namespaceURI = projectSchema.getNamespaceContext().getNamespaceURI(prefix);
// Set step's typeQName
QName qname = new QName(namespaceURI, typeLocalName);
XmlSchemaType schemaType = projectSchema.getTypeByName(qname);
if (schemaType instanceof XmlSchemaComplexType)
step.setXmlComplexTypeAffectation(new XmlQName(qname));
if (schemaType instanceof XmlSchemaSimpleType)
step.setXmlSimpleTypeAffectation(new XmlQName(qname));
}
}
} catch (Exception e) {
}
}
if (step instanceof ISimpleTypeAffectation) {
QName qName = XmlSchemaUtils.getSchemaDataTypeName(step.getSchemaDataType());
step.setXmlSimpleTypeAffectation(new XmlQName(qName));
}
if (step instanceof StepWithExpressions) {
handleSteps(projectSchema, referenceMap, ((StepWithExpressions) step).getSteps());
}
}
}
use of com.twinsoft.convertigo.beans.steps.SequenceStep in project convertigo by convertigo.
the class TreeDropAdapter method paste.
private boolean paste(Node node, TreeObject targetTreeObject) throws EngineException {
if (targetTreeObject instanceof DatabaseObjectTreeObject) {
DatabaseObject parent = ((DatabaseObjectTreeObject) targetTreeObject).getObject();
DatabaseObject databaseObject = paste(node, null, true);
Element element = (Element) ((Element) node).getElementsByTagName("dnd").item(0);
// SEQUENCER
if (parent instanceof Sequence || parent instanceof StepWithExpressions) {
if (parent instanceof XMLElementStep)
return false;
if (parent instanceof IThenElseContainer)
return false;
// Add a TransactionStep
if (databaseObject instanceof Transaction) {
String projectName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name");
String connectorName = ((Element) element.getElementsByTagName("connector").item(0)).getAttribute("name");
Transaction transaction = (Transaction) databaseObject;
TransactionStep transactionStep = new TransactionStep();
transactionStep.setSourceTransaction(projectName + TransactionStep.SOURCE_SEPARATOR + connectorName + TransactionStep.SOURCE_SEPARATOR + transaction.getName());
transactionStep.bNew = true;
parent.add(transactionStep);
parent.hasChanged = true;
if (transaction instanceof TransactionWithVariables) {
for (Variable variable : ((TransactionWithVariables) transaction).getVariablesList()) {
StepVariable stepVariable = variable.isMultiValued() ? new StepMultiValuedVariable() : new StepVariable();
stepVariable.setName(variable.getName());
stepVariable.setComment(variable.getComment());
stepVariable.setDescription(variable.getDescription());
stepVariable.setRequired(variable.isRequired());
stepVariable.setValueOrNull(variable.getValueOrNull());
stepVariable.setVisibility(variable.getVisibility());
transactionStep.addVariable(stepVariable);
}
}
return true;
} else // Add a SequenceStep
if (databaseObject instanceof Sequence) {
String projectName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name");
Sequence seq = (Sequence) databaseObject;
SequenceStep sequenceStep = new SequenceStep();
sequenceStep.setSourceSequence(projectName + SequenceStep.SOURCE_SEPARATOR + seq.getName());
sequenceStep.bNew = true;
parent.add(sequenceStep);
parent.hasChanged = true;
for (Variable variable : seq.getVariablesList()) {
StepVariable stepVariable = variable.isMultiValued() ? new StepMultiValuedVariable() : new StepVariable();
stepVariable.setName(variable.getName());
stepVariable.setComment(variable.getComment());
stepVariable.setDescription(variable.getDescription());
stepVariable.setRequired(variable.isRequired());
stepVariable.setValueOrNull(variable.getValueOrNull());
stepVariable.setVisibility(variable.getVisibility());
sequenceStep.addVariable(stepVariable);
}
return true;
}
} else // URLMAPPER
if (parent instanceof UrlMappingOperation) {
// Set associated requestable, add all parameters for operation
if (databaseObject instanceof RequestableObject) {
String dboQName = "";
if (databaseObject instanceof Sequence) {
dboQName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name") + "." + databaseObject.getName();
} else if (databaseObject instanceof Transaction) {
dboQName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name") + "." + ((Element) element.getElementsByTagName("connector").item(0)).getAttribute("name") + "." + databaseObject.getName();
}
UrlMappingOperation operation = (UrlMappingOperation) parent;
operation.setTargetRequestable(dboQName);
if (operation.getComment().isEmpty()) {
operation.setComment(databaseObject.getComment());
}
operation.hasChanged = true;
try {
StringTokenizer st = new StringTokenizer(dboQName, ".");
int count = st.countTokens();
Project p = Engine.theApp.databaseObjectsManager.getProjectByName(st.nextToken());
List<RequestableVariable> variables = new ArrayList<RequestableVariable>();
if (count == 2) {
variables = p.getSequenceByName(st.nextToken()).getVariablesList();
} else if (count == 3) {
variables = ((TransactionWithVariables) p.getConnectorByName(st.nextToken()).getTransactionByName(st.nextToken())).getVariablesList();
}
for (RequestableVariable variable : variables) {
String variableName = variable.getName();
Object variableValue = variable.getValueOrNull();
UrlMappingParameter parameter = null;
try {
parameter = operation.getParameterByName(variableName);
} catch (Exception e) {
}
if (parameter == null) {
boolean acceptForm = operation.getMethod().equalsIgnoreCase(HttpMethodType.POST.name()) || operation.getMethod().equalsIgnoreCase(HttpMethodType.PUT.name());
parameter = acceptForm ? new FormParameter() : new QueryParameter();
parameter.setName(variableName);
parameter.setComment(variable.getComment());
parameter.setArray(false);
parameter.setExposed(((RequestableVariable) variable).isWsdl());
parameter.setMultiValued(variable.isMultiValued());
parameter.setRequired(variable.isRequired());
parameter.setValueOrNull(!variable.isMultiValued() ? variableValue : null);
parameter.setMappedVariableName(variableName);
parameter.bNew = true;
operation.add(parameter);
operation.hasChanged = true;
}
}
} catch (Exception e) {
}
return true;
} else // Add a parameter to mapping operation
if (databaseObject instanceof RequestableVariable) {
RequestableVariable variable = (RequestableVariable) databaseObject;
UrlMappingOperation operation = (UrlMappingOperation) parent;
UrlMappingParameter parameter = null;
String variableName = variable.getName();
Object variableValue = variable.getValueOrNull();
try {
parameter = operation.getParameterByName(variableName);
} catch (Exception e) {
}
if (parameter == null) {
boolean acceptForm = operation.getMethod().equalsIgnoreCase(HttpMethodType.POST.name()) || operation.getMethod().equalsIgnoreCase(HttpMethodType.PUT.name());
parameter = acceptForm ? new FormParameter() : new QueryParameter();
parameter.setName(variableName);
parameter.setComment(variable.getComment());
parameter.setArray(false);
parameter.setExposed(((RequestableVariable) variable).isWsdl());
parameter.setMultiValued(variable.isMultiValued());
parameter.setRequired(variable.isRequired());
parameter.setValueOrNull(!variable.isMultiValued() ? variableValue : null);
parameter.setMappedVariableName(variableName);
parameter.bNew = true;
operation.add(parameter);
operation.hasChanged = true;
}
return true;
}
} else // MOBILE COMPONENTS
if (parent instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
return pasteMobileComponent(parent, databaseObject, element);
} else // NGX COMPONENTS
if (parent instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
return pasteNgxComponent(parent, databaseObject, element);
}
}
return false;
}
use of com.twinsoft.convertigo.beans.steps.SequenceStep in project convertigo by convertigo.
the class ReferencesView method handleCallStepselection.
private void handleCallStepselection(Object firstElement) {
try {
ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
StepTreeObject stepTreeObject = (StepTreeObject) firstElement;
Step step = stepTreeObject.getObject();
RootNode root = new RootNode();
if (step instanceof TransactionStep) {
TransactionStep transactionStep = (TransactionStep) step;
String transactionStepName = transactionStep.getName();
TransactionStepNode transactionStepNode = new TransactionStepNode(root, transactionStepName, transactionStep);
RequiresNode requiresNode = new RequiresNode(transactionStepNode, "Requires");
String transactionName = transactionStep.getTransactionName();
String connectorName = transactionStep.getConnectorName();
String projectName = transactionStep.getProjectName();
Project project = getProject(projectName, projectExplorerView);
ProjectNode projectNode = new ProjectNode(requiresNode, projectName, project);
Connector connector = null;
Transaction transaction = null;
try {
if (project != null) {
connector = project.getConnectorByName(connectorName);
if (connector != null) {
transaction = connector.getTransactionByName(transactionName);
}
}
} catch (EngineException e) {
connector = null;
transaction = null;
}
ConnectorNode connectorNode = getConnectorNode(projectNode, connector);
if (connectorNode == null)
connectorNode = new ConnectorNode(projectNode, connectorName, connector);
projectNode.addChild(connectorNode);
TransactionNode transactionNode = new TransactionNode(projectNode, transactionName, transaction);
connectorNode.addChild(transactionNode);
requiresNode.addChild(projectNode);
transactionStepNode.addChild(requiresNode);
root.addChild(transactionStepNode);
} else if (step instanceof SequenceStep) {
SequenceStep sequenceStep = (SequenceStep) step;
String sequenceStepName = sequenceStep.getName();
SequenceStepNode sequenceStepNode = new SequenceStepNode(root, sequenceStepName, sequenceStep);
RequiresNode requiresNode = new RequiresNode(sequenceStepNode, "Requires");
String sequenceName = sequenceStep.getSequenceName();
String projectName = sequenceStep.getProjectName();
Project project = getProject(projectName, projectExplorerView);
ProjectNode projectNode = new ProjectNode(requiresNode, projectName, project);
Sequence sequence = null;
try {
if (project != null)
sequence = project.getSequenceByName(sequenceName);
} catch (EngineException e) {
sequence = null;
}
projectNode.addChild(new SequenceNode(projectNode, sequenceName, sequence));
requiresNode.addChild(projectNode);
sequenceStepNode.addChild(requiresNode);
root.addChild(sequenceStepNode);
} else {
root.addChild(new InformationNode(root, "References are not handled for this object"));
treeViewer.setInput(root);
}
treeViewer.setInput(root);
treeViewer.expandAll();
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Error while analyzing the projects hierarchy", true);
}
}
Aggregations