use of com.twinsoft.convertigo.beans.core.Step in project convertigo by convertigo.
the class ShowStepInPickerAction 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();
if (treeObject != null) {
if (treeObject instanceof DatabaseObjectTreeObject) {
DatabaseObject selectedDbo = ((DatabaseObjectTreeObject) treeObject).getObject();
if (selectedDbo != null) {
StepSourceEvent event = null;
if (showSource) {
if (selectedDbo instanceof Step) {
Step step = (Step) selectedDbo;
Set<StepSource> sources = step.getSources();
if (!sources.isEmpty()) {
event = new StepSourceEvent(sources.iterator().next());
} else {
throw new Exception("No Source defined");
}
}
} else {
event = new StepSourceEvent(selectedDbo);
}
if (event != null) {
SourcePickerView spv = ConvertigoPlugin.getDefault().getSourcePickerView();
if (spv == null) {
spv = (SourcePickerView) getActivePage().showView("com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView");
}
if (spv != null) {
spv.sourceSelected(event);
}
}
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to show object in Picker!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.beans.core.Step 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.core.Step in project convertigo by convertigo.
the class SequenceImportFromXsdAction 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) {
DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) explorerView.getFirstSelectedTreeObject();
DatabaseObject databaseObject = databaseObjectTreeObject.getObject();
SequenceTreeObject sequenceTreeObject = (SequenceTreeObject) ((databaseObject instanceof Sequence) ? databaseObjectTreeObject : databaseObjectTreeObject.getParentDatabaseObjectTreeObject());
Sequence sequence = (databaseObject instanceof Sequence) ? (Sequence) databaseObject : ((StepWithExpressions) databaseObject).getSequence();
FileDialog fileDialog = new FileDialog(shell, SWT.PRIMARY_MODAL | SWT.SAVE);
fileDialog.setText("Import schema file");
fileDialog.setFilterExtensions(new String[] { "*.xsd" });
fileDialog.setFilterNames(new String[] { "Schema files" });
fileDialog.setFilterPath(Engine.PROJECTS_PATH);
String filePath = fileDialog.open();
if (filePath != null) {
filePath = filePath.replaceAll("\\\\", "/");
XmlSchemaCollection collection = new XmlSchemaCollection();
collection.setBaseUri(filePath);
XmlSchema xmlSchema = SchemaUtils.loadSchema(new File(filePath), collection);
SchemaMeta.setCollection(xmlSchema, collection);
SchemaObjectsDialog dlg = new SchemaObjectsDialog(shell, sequence, xmlSchema);
if (dlg.open() == Window.OK) {
if (dlg.result instanceof Throwable) {
throw (Throwable) dlg.result;
} else {
Step step = (Step) dlg.result;
if (step != null) {
if (databaseObject instanceof Sequence) {
sequence.addStep(step);
sequence.hasChanged = true;
} else {
StepWithExpressions swe = (StepWithExpressions) databaseObject;
swe.addStep(step);
swe.hasChanged = true;
}
sequence.hasChanged = true;
// Reload sequence in tree without updating its schema for faster reload
ConvertigoPlugin.logDebug("Reload sequence: start");
explorerView.reloadTreeObject(sequenceTreeObject);
ConvertigoPlugin.logDebug("Reload sequence: end");
// Select target dbo in tree
explorerView.objectSelected(new CompositeEvent(databaseObject));
}
}
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to import step from xsd!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.beans.core.Step in project convertigo by convertigo.
the class DatabaseObjectsManager method replaceXpath.
private void replaceXpath(String version, Sequence sequence, List<String> definition) {
if (definition.size() > 0) {
String xpath = definition.get(1);
if (xpath.startsWith("./")) {
Long key = Long.valueOf(definition.get(0));
Step sourceStep = sequence.loadedSteps.get(key);
if (sourceStep != null) {
if (VersionUtils.compare(version, "4.6.0") < 0) {
if (sourceStep instanceof RequestableStep) {
String replace = (sourceStep instanceof TransactionStep) ? "transaction" : "sequence";
xpath = xpath.replaceFirst("./", "./" + replace + "/document/");
definition.set(1, xpath);
}
} else if (VersionUtils.compare(version, "6.2.0") < 0) {
if (sourceStep instanceof ReadFileStep) {
xpath = ((ReadFileStep) sourceStep).migrateSourceXpathFor620(xpath);
definition.set(1, xpath);
}
}
}
}
}
}
use of com.twinsoft.convertigo.beans.core.Step in project convertigo by convertigo.
the class DatabaseObjectsManager method performWsMigration.
private boolean performWsMigration(String version, String projectName) {
if (VersionUtils.compare(version, "4.6.0") < 0) {
try {
// Retrieve a !clone! of project to perform update
Project project = getProjectByName(projectName);
for (Connector connector : project.getConnectorsList()) {
// Retrieve backup wsdlTypes and store Transaction's schema
for (Transaction transaction : connector.getTransactionsList()) {
try {
String xsdTypes = transaction.migrateToXsdTypes();
transaction.writeSchemaToFile(xsdTypes);
Engine.logDatabaseObjectManager.info("Internal schema stored for \"" + transaction.getName() + "\" transaction");
} catch (Exception e) {
Engine.logDatabaseObjectManager.error("An error occured while writing schema to file for \"" + transaction.getName() + "\" transaction");
}
}
}
// Fix sequence's steps sources
for (Sequence sequence : project.getSequencesList()) {
try {
List<Step> steps = sequence.getSteps();
// Replace source's xpath
// replace ./xxx by
// ./transaction/document/xxx or by
// ./sequence/document/xxx
replaceSourceXpath(version, sequence, steps);
Engine.logDatabaseObjectManager.info("Step sources updated for sequence \"" + sequence.getName() + "\"");
} catch (Exception e) {
Engine.logDatabaseObjectManager.error("An error occured while updating step sources for sequence \"" + sequence.getName() + "\"");
}
}
} catch (Exception e) {
Engine.logDatabaseObjectManager.error("An error occured while updating project '" + projectName + "' for XSD", e);
return false;
}
}
return true;
}
Aggregations