use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.
the class DatabaseObjectDeleteAction method delete.
private void delete(DatabaseObject databaseObject, boolean deleteProjectOnDisk) throws EngineException, CoreException {
if (databaseObject instanceof Connector) {
if (((Connector) databaseObject).isDefault) {
throw new EngineException("Cannot delete the default connector!");
}
String dirPath, projectName;
File dir;
projectName = databaseObject.getParent().getName();
MessageBox messageBox = new MessageBox(getParentShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
messageBox.setText("Also delete linked resources?");
// Delete soap templates for this connector
dirPath = Engine.projectDir(projectName) + "/soap-templates/" + databaseObject.getName();
dir = new File(dirPath);
if (dir.exists()) {
messageBox.setMessage("Some resources are linked to the deleted connector.\n\n" + "Do you also want to delete folder:\n\n\"" + dirPath + "\"");
if (messageBox.open() == SWT.YES) {
try {
DatabaseObjectsManager.deleteDir(dir);
} catch (IOException e) {
ConvertigoPlugin.logDebug("Unable to delete directory \"" + dirPath + "\"!");
}
}
}
// Delete directory corresponding to connector under Traces directory
dirPath = Engine.projectDir(projectName) + "/Traces/" + databaseObject.getName();
dir = new File(dirPath);
if (dir.exists()) {
messageBox.setMessage("Some resources are linked to the deleted connector.\n\n" + "Do you also want to delete folder:\n\n\"" + dirPath + "\"");
if (messageBox.open() == SWT.YES) {
try {
DatabaseObjectsManager.deleteDir(dir);
} catch (IOException e) {
ConvertigoPlugin.logDebug("Unable to delete directory \"" + dirPath + "\"!");
}
}
}
} else if (databaseObject instanceof Transaction) {
if (((Transaction) databaseObject).isDefault) {
throw new EngineException("Cannot delete the default transaction!");
}
} else if (databaseObject instanceof ScreenClass) {
if ((databaseObject.getParent()) instanceof Project) {
throw new EngineException("Cannot delete the root screen class!");
}
} else if (databaseObject instanceof Statement) {
if ((databaseObject instanceof ThenStatement) || (databaseObject instanceof ElseStatement)) {
throw new EngineException("Cannot delete this statement!");
}
} else if (databaseObject instanceof Step) {
if ((databaseObject instanceof ThenStep) || (databaseObject instanceof ElseStep)) {
throw new EngineException("Cannot delete this step!");
}
} else if (databaseObject instanceof MobilePlatform) {
MobilePlatform mobilePlatform = (MobilePlatform) databaseObject;
File resourceFolder = mobilePlatform.getResourceFolder();
if (resourceFolder.exists()) {
MessageBox messageBox = new MessageBox(getParentShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
messageBox.setMessage("Do you want to delete the whole resource folder \"" + mobilePlatform.getRelativeResourcePath() + "\"?");
messageBox.setText("Delete the \"" + resourceFolder.getName() + "\" folder?");
if (messageBox.open() == SWT.YES) {
FileUtils.deleteQuietly(resourceFolder);
}
}
} else if (databaseObject instanceof PageComponent) {
if (((PageComponent) databaseObject).isRoot) {
throw new EngineException("Cannot delete the root page!");
}
}
String dboQName = databaseObject.getQName();
if (databaseObject instanceof Project) {
// Engine.theApp.databaseObjectsManager.deleteProject(databaseObject.getName());
if (deleteProjectOnDisk) {
Engine.theApp.databaseObjectsManager.deleteProjectAndCar(databaseObject.getName(), DeleteProjectOption.unloadOnly);
} else {
Engine.theApp.databaseObjectsManager.deleteProject(databaseObject.getName(), DeleteProjectOption.unloadOnly);
}
ConvertigoPlugin.getDefault().deleteProjectPluginResource(deleteProjectOnDisk, databaseObject.getName());
} else {
databaseObject.delete();
}
if (databaseObject instanceof CouchDbConnector) {
CouchDbConnector couchDbConnector = (CouchDbConnector) databaseObject;
String db = couchDbConnector.getDatabaseName();
if (!db.isEmpty()) {
MessageBox messageBox = new MessageBox(getParentShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
messageBox.setMessage("Do you want to delete the \"" + db + "\" database from the CouchDb server?");
messageBox.setText("Delete the database?");
if (messageBox.open() == SWT.YES) {
couchDbConnector.getCouchClient().deleteDatabase(db);
}
}
}
ConvertigoPlugin.logDebug("The object \"" + dboQName + "\" has been deleted from the database repository!");
}
use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.
the class CreateStubFromXMLAction method getXML.
public Document getXML(TreeObject treeObject) throws Exception {
Document dom = XMLUtils.createDom("java");
ProjectTreeObject projectTreeObject = treeObject.getProjectTreeObject();
Object requestable = treeObject.getObject();
if (requestable instanceof Transaction) {
Transaction transaction = (Transaction) requestable;
ConnectorEditor connectorEditor = projectTreeObject.getConnectorEditor((Connector) transaction.getParent());
dom = connectorEditor.getLastGeneratedDocument();
} else if (requestable instanceof Sequence) {
SequenceEditor sequenceEditor = projectTreeObject.getSequenceEditor((Sequence) requestable);
dom = sequenceEditor.getLastGeneratedDocument();
}
if (dom == null) {
throw new NoSuchElementException();
}
return dom;
}
use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.
the class ReferencesView method getRequiredRequestables.
private void getRequiredRequestables(Step step, Project projectSelected, ProjectExplorerView projectExplorerView, AbstractParentNode parentNode, List<String> transactionList, List<String> sequenceList) {
try {
if (step instanceof SequenceStep) {
SequenceStep sequenceStep = (SequenceStep) step;
String sourceProjectName = sequenceStep.getProjectName();
if (!sourceProjectName.equals(projectSelected.getName())) {
Project project;
project = getProject(sourceProjectName, projectExplorerView);
ProjectNode projectNode = new ProjectNode(parentNode, sourceProjectName, project);
Sequence sourceSequence = null;
String sourceSequenceName = sequenceStep.getSequenceName();
try {
if (project != null)
sourceSequence = project.getSequenceByName(sourceSequenceName);
} catch (EngineException e) {
sourceSequence = null;
}
projectNode.addChild(new SequenceNode(projectNode, sourceSequenceName, sourceSequence));
if (!sequenceList.contains(sourceProjectName + sourceSequenceName)) {
sequenceList.add(sourceProjectName + sourceSequenceName);
parentNode.addChild(projectNode);
}
}
} else if (step instanceof TransactionStep) {
TransactionStep transactionStep = (TransactionStep) step;
String sourceProjectName = transactionStep.getProjectName();
if (!sourceProjectName.equals(projectSelected.getName())) {
Project project;
project = getProject(sourceProjectName, projectExplorerView);
ProjectNode projectNode = new ProjectNode(parentNode, sourceProjectName, project);
if (project != null) {
Connector connector = project.getConnectorByName(transactionStep.getConnectorName());
ConnectorNode connectorNode = null;
connectorNode = getConnectorNode(projectNode, connector);
projectNode.addChild(connectorNode);
Transaction sourceTransaction = null;
String sourceTransactionName = transactionStep.getTransactionName();
try {
if (connector != null)
sourceTransaction = connector.getTransactionByName(sourceTransactionName);
} catch (Exception e) {
sourceTransaction = null;
}
connectorNode.addChild(new TransactionNode(connectorNode, sourceTransactionName, sourceTransaction));
if (!transactionList.contains(project.getName() + connector.getName() + sourceTransactionName)) {
transactionList.add(project.getName() + connector.getName() + sourceTransactionName);
parentNode.addChild(projectNode);
}
}
}
} else if (isStepContainer(step)) {
List<Step> steps = getStepList(step);
if (steps != null) {
for (Step s : steps) {
getRequiredRequestables(s, projectSelected, projectExplorerView, parentNode, transactionList, sequenceList);
}
}
}
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Unable to load the project", true);
}
}
use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.
the class ReferencesView method getConnectorReferencingIsUsedBy.
private void getConnectorReferencingIsUsedBy(Step step, ProjectExplorerView projectExplorerView, SequenceNode sequenceNode, List<Transaction> transactions, String connectorProjectName, String connectorSelectedName) {
if (step instanceof TransactionStep) {
TransactionStep transactionStep = (TransactionStep) step;
String sourcetransaction = transactionStep.getSourceTransaction();
for (Transaction transaction : transactions) {
if (sourcetransaction.equals(connectorProjectName + RequestableStep.SOURCE_SEPARATOR + connectorSelectedName + RequestableStep.SOURCE_SEPARATOR + transaction.getName())) {
sequenceNode.addChild(new TransactionStepNode(sequenceNode, step.getName(), step));
}
}
} else if (isStepContainer(step)) {
List<Step> steps = getStepList(step);
for (Step s : steps) {
getConnectorReferencingIsUsedBy(s, projectExplorerView, sequenceNode, transactions, connectorProjectName, connectorSelectedName);
}
}
}
use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.
the class ReferencesView method handleTransactionSelection.
private void handleTransactionSelection(Object firstElement) {
TransactionTreeObject transactionTreeObject = (TransactionTreeObject) firstElement;
Transaction transaction = transactionTreeObject.getObject();
String transactionName = transactionTreeObject.getName();
// Get the referencing sequence steps
String transactionProjectName = transaction.getProject().getName();
String transactionConnectorName = transaction.getParent().getName();
try {
Project project = null;
List<String> projectNames = Engine.theApp.databaseObjectsManager.getAllProjectNamesList();
ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
treeViewer.setInput(null);
RootNode root = new RootNode();
TransactionNode transactionFolder = new TransactionNode(root, transactionName, transaction);
root.addChild(transactionFolder);
IsUsedByNode isUsedByNode = new IsUsedByNode(transactionFolder, "Is used by");
RequiresNode requiresNode = new RequiresNode(transactionFolder, "Requires");
ProjectNode projectFolder = null;
// Searching all objects are required transaction selected
Connector connector = transaction.getConnector();
if (connector instanceof HtmlConnector) {
Project proj = ((HtmlConnector) connector).getProject();
ProjectNode projectNode = new ProjectNode(requiresNode, transactionProjectName, proj);
HtmlTransaction htmlTransaction = (HtmlTransaction) transaction;
List<Statement> statements = htmlTransaction.getStatements();
List<ScreenClass> screenClassList = new ArrayList<ScreenClass>();
List<String> siteClipperConnectorNames = new ArrayList<String>();
for (Statement statement : statements) {
if (statement instanceof ScHandlerStatement) {
ScHandlerStatement scHandlerStatement = (ScHandlerStatement) statement;
String screenClassName = scHandlerStatement.getNormalizedScreenClassName();
ScreenClass screenClass = ((HtmlConnector) connector).getScreenClassByName(screenClassName);
if (screenClass != null) {
if (!screenClassList.contains(screenClass)) {
screenClassList.add(screenClass);
requiresNode.addChild(new ScreenClassNode(requiresNode, screenClassName, screenClass));
}
}
}
List<Statement> statementList = ((FunctionStatement) statement).getStatements();
for (Statement st : statementList) {
if (st instanceof ContinueWithSiteClipperStatement) {
ContinueWithSiteClipperStatement continueWithSiteClipperStatement = (ContinueWithSiteClipperStatement) st;
String siteClipperconnectorName = continueWithSiteClipperStatement.getSiteClipperConnectorName();
if (!siteClipperConnectorNames.contains(siteClipperconnectorName)) {
siteClipperConnectorNames.add(siteClipperconnectorName);
Connector siteClipperConnector = proj.getConnectorByName(siteClipperconnectorName);
ConnectorNode connectorSiteClipperNode = new SiteClipperConnectorNode(projectNode, siteClipperconnectorName, siteClipperConnector);
projectNode.addChild(connectorSiteClipperNode);
}
}
}
}
if (projectNode.hasChildren()) {
requiresNode.addChild(projectNode);
}
} else if (connector instanceof JavelinConnector) {
JavelinTransaction javelinTransaction = (JavelinTransaction) transaction;
String handlers = javelinTransaction.handlers;
List<JavelinScreenClass> screenClasses = ((JavelinConnector) connector).getAllScreenClasses();
List<JavelinScreenClass> screenClassList = new ArrayList<JavelinScreenClass>();
for (JavelinScreenClass screenClass : screenClasses) {
if (handlers.indexOf("function on" + screenClass.getName()) != -1) {
if (!screenClassList.contains(screenClass)) {
screenClassList.add(screenClass);
requiresNode.addChild(new ScreenClassNode(requiresNode, screenClass.getName(), screenClass));
}
}
}
}
// Searching all objects are used transaction selected
for (String projectName : projectNames) {
project = getProject(projectName, projectExplorerView);
if (project != null) {
projectFolder = new ProjectNode(isUsedByNode, project.getName(), project);
UrlMapper urlMapper = project.getUrlMapper();
if (urlMapper != null) {
MapperNode mapperNode = new MapperNode(projectFolder, urlMapper.getName(), urlMapper);
List<UrlMapping> mappings = urlMapper.getMappingList();
for (UrlMapping mapping : mappings) {
MappingPathNode pathNode = new MappingPathNode(mapperNode, mapping.getPath(), mapping);
List<UrlMappingOperation> operations = mapping.getOperationList();
for (UrlMappingOperation operation : operations) {
String targetRequestable = operation.getTargetRequestable();
if (targetRequestable.equals(transactionProjectName + "." + transactionConnectorName + "." + transactionName)) {
MappingOperationNode operationNode = new MappingOperationNode(pathNode, operation.getName(), operation);
pathNode.addChild(operationNode);
}
}
if (pathNode.hasChildren()) {
mapperNode.addChild(pathNode);
}
}
if (mapperNode.hasChildren()) {
projectFolder.addChild(mapperNode);
}
}
List<Sequence> sequences = project.getSequencesList();
for (Sequence sequence : sequences) {
List<Step> stepList = sequence.getAllSteps();
SequenceNode sequenceNode = new SequenceNode(projectFolder, sequence.getName(), sequence);
for (Step step : stepList) {
getTransactionReferencing(step, projectExplorerView, sequenceNode, transactionProjectName, transactionConnectorName, transactionName);
}
if (sequenceNode.hasChildren()) {
projectFolder.addChild(sequenceNode);
}
}
if (projectFolder.hasChildren()) {
isUsedByNode.addChild(projectFolder);
}
}
}
if (requiresNode.hasChildren()) {
transactionFolder.addChild(requiresNode);
}
if (isUsedByNode.hasChildren()) {
transactionFolder.addChild(isUsedByNode);
}
if (!transactionFolder.hasChildren()) {
transactionFolder.addChild(new InformationNode(projectFolder, "This transaction is not used in any sequence"));
}
treeViewer.setInput(root);
treeViewer.expandAll();
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Error while analyzing the projects hierarchy", true);
}
}
Aggregations