use of com.twinsoft.convertigo.beans.core.StepWithExpressions in project convertigo by convertigo.
the class SourcePickerHelper method displayTargetWsdlDom.
public void displayTargetWsdlDom(final DatabaseObject dbo) {
try {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = getParentShell();
shell.setCursor(waitCursor);
boolean needToClean = true;
try {
if (dbo instanceof Step) {
Step step = (Step) dbo;
String xpath = getSourceXPath();
String anchor = step.getAnchor();
Document stepDoc = null;
Step targetStep = step;
while (targetStep instanceof IteratorStep) {
targetStep = getTargetStep(targetStep);
}
if (targetStep != null) {
Project project = step.getProject();
String projectName = project.getName();
XmlSchema schema = Engine.theApp.schemaManager.getSchemaForProject(projectName, Option.fullSchema);
XmlSchemaObject xso = SchemaMeta.getXmlSchemaObject(schema, targetStep);
if (xso != null) {
stepDoc = XmlSchemaUtils.getDomInstance(xso);
} else {
System.out.println("Could not retrieve schema for step \"" + targetStep.getName() + "\"!");
}
} else {
System.out.println("Could not retrieve schema : targeted step is null!");
}
if (stepDoc != null) /* && !(targetStep instanceof IteratorStep)*/
{
// stepDoc can be null for non "xml" step : e.g jIf
Document doc = step.getSequence().createDOM();
Element root = (Element) doc.importNode(stepDoc.getDocumentElement(), true);
doc.replaceChild(root, doc.getDocumentElement());
removeUserDefinedNodes(doc.getDocumentElement());
boolean shouldDisplayDom = (!(!step.isXml() && (step instanceof StepWithExpressions) && !(step instanceof IteratorStep)));
if ((doc != null) && (shouldDisplayDom)) {
needToClean = false;
xpath = onDisplayXhtml(xpath);
displayXhtml(doc);
xpathEvaluator.removeAnchor();
xpathEvaluator.displaySelectionXpathWithAnchor(twsDomTree, anchor, xpath);
}
}
}
} catch (Exception e) {
e.printStackTrace();
needToClean = true;
} finally {
if (needToClean) {
clean();
}
onDisplayDone();
shell.setCursor(null);
waitCursor.dispose();
}
}
});
} catch (Exception e) {
ConvertigoPlugin.logException(e, StringUtils.readStackTraceCauses(e));
clean();
}
}
use of com.twinsoft.convertigo.beans.core.StepWithExpressions in project convertigo by convertigo.
the class ProjectTreeObject method checkForImports.
private void checkForImports(List<String> missingList, List<Step> steps) {
String targetProjectName;
for (Step step : steps) {
if (step instanceof StepWithExpressions) {
checkForImports(missingList, ((StepWithExpressions) step).getSteps());
} else {
if (step instanceof TransactionStep) {
TransactionStep transactionStep = ((TransactionStep) step);
targetProjectName = transactionStep.getProjectName();
if (!targetProjectName.equals(getName())) {
try {
transactionStep.getSequence().getLoadedProject(targetProjectName);
} catch (EngineException e) {
if (!missingList.contains(targetProjectName))
missingList.add(targetProjectName);
}
}
} else if (step instanceof SequenceStep) {
SequenceStep sequenceStep = ((SequenceStep) step);
targetProjectName = sequenceStep.getProjectName();
if (!targetProjectName.equals(getName())) {
try {
sequenceStep.getSequence().getLoadedProject(targetProjectName);
} catch (EngineException e) {
if (!missingList.contains(targetProjectName))
missingList.add(targetProjectName);
}
}
}
}
}
}
use of com.twinsoft.convertigo.beans.core.StepWithExpressions in project convertigo by convertigo.
the class OutputStepAction method output.
private void output(Step step) {
if (step != null) {
step.setOutput(output);
step.hasChanged = true;
if (recurse && (step instanceof StepWithExpressions)) {
for (Step child : ((StepWithExpressions) step).getSteps()) {
output(child);
}
}
}
}
use of com.twinsoft.convertigo.beans.core.StepWithExpressions in project convertigo by convertigo.
the class VariableGenerateFromXmlAndLinkAction 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 StepVariable))) {
StepVariable stepVariable = (StepVariable) databaseObject;
RequestableStep requestableStep = (RequestableStep) stepVariable.getParent();
if (requestableStep != null) {
DatabaseObjectTreeObject parentDboTreeObject = ((DatabaseObjectTreeObject) treeObject).getParentDatabaseObjectTreeObject().getParentDatabaseObjectTreeObject();
RequestableObject requestableObject = null;
if (requestableStep instanceof SequenceStep) {
requestableObject = ((SequenceStep) requestableStep).getTargetSequence();
} else if (requestableStep instanceof TransactionStep) {
requestableObject = ((TransactionStep) requestableStep).getTargetTransaction();
}
if ((requestableObject != null) && (requestableObject instanceof IVariableContainer)) {
String variableName = stepVariable.getName();
IVariableContainer container = (IVariableContainer) requestableObject;
RequestableVariable variable = (RequestableVariable) container.getVariable(variableName);
// generate dom model
Document document = null;
try {
String description = variable.getDescription();
document = XMLUtils.parseDOMFromString(description);
} catch (Exception e) {
}
if (document != null) {
Element root = document.getDocumentElement();
if (root != null) {
// create step's structure from dom
DatabaseObject parentObject = requestableStep.getParent();
Step step = StepUtils.createStepFromXmlDomModel(parentObject, root);
// add step's structure to parent of requestableStep
if (parentObject instanceof Sequence) {
Sequence parentSequence = (Sequence) parentObject;
parentSequence.addStep(step);
parentSequence.insertAtOrder(step, requestableStep.priority);
} else {
StepWithExpressions parentSwe = (StepWithExpressions) parentObject;
parentSwe.addStep(step);
parentSwe.insertAtOrder(step, requestableStep.priority);
}
// set source definition of variable
XMLVector<String> sourceDefinition = new XMLVector<String>();
sourceDefinition.add(String.valueOf(step.priority));
sourceDefinition.add(".");
stepVariable.setSourceDefinition(sourceDefinition);
stepVariable.hasChanged = true;
// Reload parent dbo in tree
explorerView.reloadTreeObject(parentDboTreeObject);
// Select variable dbo in tree
explorerView.objectSelected(new CompositeEvent(databaseObject));
}
}
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to generate and link variable!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.beans.core.StepWithExpressions 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);
}
}
}
}
Aggregations