use of com.twinsoft.convertigo.beans.transactions.SqlTransaction in project convertigo by convertigo.
the class TransactionTreeObject method treeObjectPropertyChanged.
@Override
public void treeObjectPropertyChanged(TreeObjectEvent treeObjectEvent) {
super.treeObjectPropertyChanged(treeObjectEvent);
String propertyName = (String) treeObjectEvent.propertyName;
propertyName = ((propertyName == null) ? "" : propertyName);
TreeObject treeObject = (TreeObject) treeObjectEvent.getSource();
if (treeObject instanceof DatabaseObjectTreeObject) {
DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
// If a bean name has changed
if ("name".equals(propertyName)) {
handlesBeanNameChanged(treeObjectEvent);
} else if ("sqlQuery".equals(propertyName)) {
if (treeObject.equals(this)) {
try {
SqlTransaction sqlTransaction = (SqlTransaction) databaseObject;
sqlTransaction.initializeQueries(true);
String oldValue = (String) treeObjectEvent.oldValue;
detectVariables(sqlTransaction.getSqlQuery(), oldValue, sqlTransaction.getVariablesList());
ConvertigoPlugin.getDefault().getProjectExplorerView().reloadTreeObject(this);
} catch (Exception e) {
ConvertigoPlugin.logWarning(e, "Could not reload in tree Transaction \"" + databaseObject.getName() + "\" !");
}
}
} else if ("subDir".equals(propertyName)) {
if (treeObject.equals(this)) {
try {
Object oldValue = treeObjectEvent.oldValue;
Object newValue = treeObjectEvent.newValue;
AbstractHttpTransaction httpTransaction = (AbstractHttpTransaction) databaseObject;
List<String> oldPathVariableList = AbstractHttpTransaction.getPathVariableList(oldValue.toString());
List<String> newPathVariableList = AbstractHttpTransaction.getPathVariableList(newValue.toString());
// Check for variables to be renamed
if (oldValue.toString().replaceAll("\\{([a-zA-Z0-9_]+)\\}", "{}").equals(newValue.toString().replaceAll("\\{([a-zA-Z0-9_]+)\\}", "{}"))) {
for (int i = 0; i < oldPathVariableList.size(); i++) {
String oldVariableName = oldPathVariableList.get(i);
String newVariableName = newPathVariableList.get(i);
if (!oldVariableName.equals(newVariableName)) {
RequestableHttpVariable httpVariable = (RequestableHttpVariable) httpTransaction.getVariable(oldVariableName);
if (httpVariable != null) {
try {
VariableTreeObject2 vto = (VariableTreeObject2) findTreeObjectByUserObject(httpVariable);
int update = TreeObjectEvent.UPDATE_NONE;
CustomDialog customDialog = new CustomDialog(viewer.getControl().getShell(), "Update object references", "Do you want to update " + "variable" + " references ?\n You can replace '" + oldVariableName + "' by '" + newVariableName + "' in all loaded projects \n or replace '" + oldVariableName + "' by '" + newVariableName + "' in current project only.", 670, 200, new ButtonSpec("Replace in all loaded projects", true), new ButtonSpec("Replace in current project", false), new ButtonSpec("Do not replace anywhere", false));
int response = customDialog.open();
if (response == 0) {
update = TreeObjectEvent.UPDATE_ALL;
}
if (response == 1) {
update = TreeObjectEvent.UPDATE_LOCAL;
}
if (update != 0) {
httpVariable.setName(newVariableName);
httpVariable.hasChanged = true;
TreeObjectEvent toEvent = new TreeObjectEvent(vto, "name", oldVariableName, newVariableName, update);
ConvertigoPlugin.getDefault().getProjectExplorerView().fireTreeObjectPropertyChanged(toEvent);
}
} catch (Exception e) {
ConvertigoPlugin.logWarning(e, "Could not rename variable for Transaction \"" + databaseObject.getName() + "\" !");
}
}
}
}
} else {
// Check for variables to be added
for (String variableName : newPathVariableList) {
if (httpTransaction.getVariable(variableName) == null) {
RequestableHttpVariable httpVariable = new RequestableHttpVariable();
httpVariable.setName(variableName);
httpVariable.setHttpMethod("GET");
httpVariable.setHttpName("");
httpVariable.bNew = true;
httpVariable.hasChanged = true;
httpTransaction.addVariable(httpVariable);
httpTransaction.hasChanged = true;
}
}
// Check for variables to be deleted
for (String variableName : oldPathVariableList) {
RequestableHttpVariable httpVariable = (RequestableHttpVariable) httpTransaction.getVariable(variableName);
if (httpVariable != null) {
if (!newPathVariableList.contains(variableName)) {
try {
MessageBox messageBox = new MessageBox(viewer.getControl().getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
messageBox.setMessage("Do you want to delete the variable \"" + variableName + "\"?");
messageBox.setText("Delete \"" + variableName + "\"?");
if (messageBox.open() == SWT.YES) {
httpVariable.delete();
httpTransaction.hasChanged = true;
}
} catch (EngineException e) {
ConvertigoPlugin.logException(e, "Error when deleting the variable \"" + variableName + "\"");
}
}
}
}
}
if (httpTransaction.hasChanged) {
ConvertigoPlugin.getDefault().getProjectExplorerView().reloadTreeObject(this);
}
} catch (Exception e) {
ConvertigoPlugin.logWarning(e, "Could not reload in tree Transaction \"" + databaseObject.getName() + "\" !");
}
}
}
}
}
use of com.twinsoft.convertigo.beans.transactions.SqlTransaction in project convertigo by convertigo.
the class NewObjectWizard method doFinish.
private void doFinish(IProgressMonitor monitor) throws CoreException {
String dboName, name;
boolean bContinue = true;
int index = 0;
try {
int total = 0;
Class<?> c = getCreatedBeanClass();
if (c != null) {
total = 4;
if (c.equals(WebServiceReference.class)) {
total += ImportWsReference.getTotalTaskNumber();
}
}
monitor.beginTask("Creating new object", total);
newBean = getCreatedBean();
if (newBean != null) {
monitor.setTaskName("Object created");
monitor.worked(1);
dboName = newBean.getName();
if (!StringUtils.isNormalized(dboName))
throw new EngineException("Bean name is not normalized : \"" + dboName + "\".");
// Verify if a child object with same name exist and change name
while (bContinue) {
if (index == 0)
name = dboName;
else
name = dboName + index;
newBean.setName(name);
newBean.hasChanged = true;
newBean.bNew = true;
try {
new WalkHelper() {
boolean root = true;
boolean find = false;
@Override
protected boolean before(DatabaseObject dbo, Class<? extends DatabaseObject> dboClass) {
boolean isInstance = dboClass.isInstance(newBean);
find |= isInstance;
return isInstance;
}
@Override
protected void walk(DatabaseObject dbo) throws Exception {
if (root) {
root = false;
super.walk(dbo);
if (!find) {
throw new EngineException("You cannot add to a " + newBean.getClass().getSimpleName() + " a database object of type " + parentObject.getClass().getSimpleName());
}
} else {
if (newBean.getName().equalsIgnoreCase(dbo.getName())) {
throw new ObjectWithSameNameException("Unable to add the object because an object with the same name already exists in target.");
}
}
}
}.init(parentObject);
bContinue = false;
} catch (ObjectWithSameNameException owsne) {
if ((parentObject instanceof HtmlTransaction) && (newBean instanceof Statement)) {
throw new EngineException("HtmlTransaction already contains a statement named \"" + name + "\".", owsne);
}
// Silently ignore
index++;
} catch (EngineException ee) {
throw ee;
} catch (Exception e) {
throw new EngineException("Exception in create", e);
}
}
// Now add bean to target
try {
boolean hasChanged = parentObject.hasChanged;
if ((newBean instanceof Statement) && (parentObject instanceof Transaction)) {
newBean.priority = 0;
}
if (newBean instanceof ScreenClass)
newBean.priority = parentObject.priority + 1;
if (newBean instanceof Criteria) {
Connector connector = parentObject.getConnector();
if (parentObject.equals(((IScreenClassContainer<?>) connector).getDefaultScreenClass()))
throw new EngineException("You cannot add a new criterion on default screenclass.");
}
parentObject.add(newBean);
monitor.setTaskName("Object added");
monitor.worked(1);
if (newBean instanceof HTTPStatement) {
HTTPStatement httpStatement = (HTTPStatement) newBean;
HtmlConnector connector = (HtmlConnector) httpStatement.getParentTransaction().getParent();
httpStatement.setMethod("GET");
httpStatement.setHost(connector.getServer());
httpStatement.setPort(connector.getPort());
httpStatement.setHttps(connector.isHttps());
}
if (newBean instanceof ContinueWithSiteClipperStatement) {
Project project = newBean.getProject();
if (project != null) {
String[] connectorWithSiteClipperConnector = ContinueWithSiteClipperStatement.getSiteClippersConnectorNames(project);
if (connectorWithSiteClipperConnector.length > 0) {
((ContinueWithSiteClipperStatement) newBean).setSiteClipperConnectorName(connectorWithSiteClipperConnector[0]);
}
}
}
if (newBean instanceof Connector) {
Project project = (Project) parentObject;
if (project.getDefaultConnector() == null)
project.setDefaultConnector((Connector) newBean);
Connector.setupConnector(newBean);
}
if (newBean instanceof PageComponent) {
ApplicationComponent application = (ApplicationComponent) parentObject;
if (application.getRootPage() == null)
application.setRootPage((PageComponent) newBean);
}
if (newBean instanceof SequenceStep) {
Project project = newBean.getProject();
((SequenceStep) newBean).setSourceSequence(project.getName() + TransactionStep.SOURCE_SEPARATOR + project.getSequencesList().get(0));
}
if (newBean instanceof TransactionStep) {
Project project = newBean.getProject();
Connector connector = project.getDefaultConnector();
Transaction transaction = connector.getDefaultTransaction();
((TransactionStep) newBean).setSourceTransaction(project.getName() + TransactionStep.SOURCE_SEPARATOR + connector.getName() + TransactionStep.SOURCE_SEPARATOR + transaction.getName());
}
if (newBean instanceof IThenElseContainer) {
ThenStep thenStep = new ThenStep();
((IThenElseContainer) newBean).addStep(thenStep);
ElseStep elseStep = new ElseStep();
((IThenElseContainer) newBean).addStep(elseStep);
}
if (newBean instanceof IThenElseStatementContainer) {
ThenStatement thenStatement = new ThenStatement();
((IThenElseStatementContainer) newBean).addStatement(thenStatement);
ElseStatement elseStatement = new ElseStatement();
((IThenElseStatementContainer) newBean).addStatement(elseStatement);
}
if (newBean instanceof Sheet) {
InputStream is = null;
try {
String sheetName = newBean.getName() + ".xsl";
is = new FileInputStream(new File(Engine.XSL_PATH + "/customsheet.xsl"));
String projectName = ((DatabaseObject) parentObject).getProject().getName();
IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(projectName);
final IFile file = project.getFile(sheetName);
if (!file.exists())
file.create(is, true, null);
((Sheet) newBean).setUrl(sheetName);
} catch (Exception e) {
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
}
}
}
}
if (newBean instanceof TestCase) {
TestCase testCase = (TestCase) newBean;
testCase.importRequestableVariables((RequestableObject) testCase.getParent());
}
if (newBean instanceof RequestableHttpVariable) {
RequestableHttpVariable variable = (RequestableHttpVariable) newBean;
AbstractHttpTransaction httpTransaction = (AbstractHttpTransaction) variable.getParent();
HttpMethodType httpMethodType = httpTransaction.getHttpVerb();
boolean isVarPost = httpMethodType.equals(HttpMethodType.PUT) || httpMethodType.equals(HttpMethodType.POST);
variable.setHttpMethod(isVarPost ? HttpMethodType.POST.name() : HttpMethodType.GET.name());
if (!(httpTransaction instanceof HtmlTransaction)) {
variable.setHttpName(variable.getName());
}
}
if (newBean instanceof WebServiceReference) {
try {
Project project = (Project) parentObject;
WebServiceReference webServiceReference = (WebServiceReference) newBean;
ImportWsReference wsr = new ImportWsReference(webServiceReference);
wsr.importInto(project);
} catch (Exception e) {
if (newBean != null) {
parentObject.remove(newBean);
parentObject.hasChanged = hasChanged;
}
throw new Exception(e);
}
}
if (newBean instanceof RestServiceReference) {
try {
Project project = (Project) parentObject;
RestServiceReference restServiceReference = (RestServiceReference) newBean;
ImportWsReference wsr = new ImportWsReference(restServiceReference);
wsr.importInto(project);
} catch (Exception e) {
if (newBean != null) {
parentObject.remove(newBean);
parentObject.hasChanged = hasChanged;
}
throw new Exception(e);
}
}
if (newBean instanceof SqlTransaction) {
SqlTransaction sqlTransaction = (SqlTransaction) newBean;
sqlTransaction.setSqlQuery(sqlQueriesWizardPage.getSQLQueries());
sqlTransaction.initializeQueries(true);
}
if (newBean instanceof SapJcoLogonTransaction) {
SapJcoLogonTransaction sapLogonTransaction = (SapJcoLogonTransaction) newBean;
sapLogonTransaction.addCredentialsVariables();
}
if (newBean instanceof AbstractCouchDbTransaction) {
AbstractCouchDbTransaction abstractCouchDbTransaction = (AbstractCouchDbTransaction) newBean;
List<CouchVariable> selectedVariables = objectInfoPage.getSelectedParameters();
abstractCouchDbTransaction.createVariables(selectedVariables);
}
ConvertigoPlugin.logInfo("New object class '" + this.className + "' named '" + newBean.getName() + "' has been added");
monitor.setTaskName("Object setted up");
monitor.worked(1);
bContinue = false;
} catch (com.twinsoft.convertigo.engine.ObjectWithSameNameException owsne) {
if (newBean instanceof HandlerStatement) {
throw owsne;
}
}
} else {
throw new Exception("Could not instantiate bean!");
}
} catch (Exception e) {
String message = "Unable to create a new object from class '" + this.className + "'.";
ConvertigoPlugin.logException(e, message);
if (objectExplorerPage != null) {
objectExplorerPage.doCancel();
}
}
}
use of com.twinsoft.convertigo.beans.transactions.SqlTransaction in project convertigo by convertigo.
the class Migration7_0_0 method migrate.
public static void migrate(final String projectName) {
try {
Map<String, Reference> referenceMap = new HashMap<String, Reference>();
XmlSchema projectSchema = null;
Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName, false);
// Copy all xsd files to project's xsd directory
File destDir = new File(project.getXsdDirPath());
copyXsdOfProject(projectName, destDir);
String projectWsdlFilePath = Engine.PROJECTS_PATH + "/" + projectName + "/" + projectName + ".wsdl";
File wsdlFile = new File(projectWsdlFilePath);
String projectXsdFilePath = Engine.PROJECTS_PATH + "/" + projectName + "/" + projectName + ".xsd";
File xsdFile = new File(projectXsdFilePath);
if (xsdFile.exists()) {
// Load project schema from old XSD file
XmlSchemaCollection collection = new XmlSchemaCollection();
collection.setSchemaResolver(new DefaultURIResolver() {
public InputSource resolveEntity(String targetNamespace, String schemaLocation, String baseUri) {
// Case of a c8o project location
if (schemaLocation.startsWith("../") && schemaLocation.endsWith(".xsd")) {
try {
String targetProjectName = schemaLocation.substring(3, schemaLocation.indexOf("/", 3));
File pDir = new File(Engine.projectDir(targetProjectName));
if (pDir.exists()) {
File pFile = new File(Engine.PROJECTS_PATH + schemaLocation.substring(2));
// Case c8o project is already migrated
if (!pFile.exists()) {
Document doc = Engine.theApp.schemaManager.getSchemaForProject(targetProjectName).getSchemaDocument();
DOMSource source = new DOMSource(doc);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
TransformerFactory.newInstance().newTransformer().transform(source, result);
StringReader reader = new StringReader(writer.toString());
return new InputSource(reader);
}
}
return null;
} catch (Exception e) {
Engine.logDatabaseObjectManager.warn("[Migration 7.0.0] Unable to find schema location \"" + schemaLocation + "\"", e);
return null;
}
} else if (schemaLocation.indexOf("://") == -1 && schemaLocation.endsWith(".xsd")) {
return super.resolveEntity(targetNamespace, schemaLocation, Engine.PROJECTS_PATH + "/" + projectName);
}
return super.resolveEntity(targetNamespace, schemaLocation, baseUri);
}
});
projectSchema = SchemaUtils.loadSchema(new File(projectXsdFilePath), collection);
ConvertigoError.updateXmlSchemaObjects(projectSchema);
SchemaMeta.setCollection(projectSchema, collection);
for (Connector connector : project.getConnectorsList()) {
for (Transaction transaction : connector.getTransactionsList()) {
try {
// Migrate transaction in case of a Web Service consumption project
if (transaction instanceof XmlHttpTransaction) {
XmlHttpTransaction xmlHttpTransaction = (XmlHttpTransaction) transaction;
String reqn = xmlHttpTransaction.getResponseElementQName();
if (!reqn.equals("")) {
boolean useRef = reqn.indexOf(";") == -1;
// Doc/Literal case
if (useRef) {
try {
String[] qn = reqn.split(":");
QName refName = new QName(projectSchema.getNamespaceContext().getNamespaceURI(qn[0]), qn[1]);
xmlHttpTransaction.setXmlElementRefAffectation(new XmlQName(refName));
} catch (Exception e) {
}
} else // RPC case
{
int index, index2;
try {
index = reqn.indexOf(";");
String opName = reqn.substring(0, index);
if ((index2 = reqn.indexOf(";", index + 1)) != -1) {
String eltName = reqn.substring(index + 1, index2);
String eltType = reqn.substring(index2 + 1);
String[] qn = eltType.split(":");
QName typeName = new QName(projectSchema.getNamespaceContext().getNamespaceURI(qn[0]), qn[1]);
String responseElementQName = opName + ";" + eltName + ";" + "{" + typeName.getNamespaceURI() + "}" + typeName.getLocalPart();
xmlHttpTransaction.setResponseElementQName(responseElementQName);
}
} catch (Exception e) {
}
}
}
}
// Retrieve required XmlSchemaObjects for transaction
QName requestQName = new QName(project.getTargetNamespace(), transaction.getXsdRequestElementName());
QName responseQName = new QName(project.getTargetNamespace(), transaction.getXsdResponseElementName());
LinkedHashMap<QName, XmlSchemaObject> map = new LinkedHashMap<QName, XmlSchemaObject>();
XmlSchemaWalker dw = XmlSchemaWalker.newDependencyWalker(map, true, false);
dw.walkByElementRef(projectSchema, requestQName);
dw.walkByElementRef(projectSchema, responseQName);
// Create transaction schema
String targetNamespace = projectSchema.getTargetNamespace();
String prefix = projectSchema.getNamespaceContext().getPrefix(targetNamespace);
XmlSchema transactionSchema = SchemaUtils.createSchema(prefix, targetNamespace, XsdForm.unqualified.name(), XsdForm.unqualified.name());
// Add required prefix declarations
List<String> nsList = new LinkedList<String>();
for (QName qname : map.keySet()) {
String nsURI = qname.getNamespaceURI();
if (!nsURI.equals(Constants.URI_2001_SCHEMA_XSD)) {
if (!nsList.contains(nsURI)) {
nsList.add(nsURI);
}
}
String nsPrefix = qname.getPrefix();
if (!nsURI.equals(targetNamespace)) {
NamespaceMap nsMap = SchemaUtils.getNamespaceMap(transactionSchema);
if (nsMap.getNamespaceURI(nsPrefix) == null) {
nsMap.add(nsPrefix, nsURI);
transactionSchema.setNamespaceContext(nsMap);
}
}
}
// Add required imports
for (String namespaceURI : nsList) {
XmlSchemaObjectCollection includes = projectSchema.getIncludes();
for (int i = 0; i < includes.getCount(); i++) {
XmlSchemaObject xmlSchemaObject = includes.getItem(i);
if (xmlSchemaObject instanceof XmlSchemaImport) {
if (((XmlSchemaImport) xmlSchemaObject).getNamespace().equals(namespaceURI)) {
// do not allow import with same ns !
if (namespaceURI.equals(project.getTargetNamespace()))
continue;
String location = ((XmlSchemaImport) xmlSchemaObject).getSchemaLocation();
// This is a convertigo project reference
if (location.startsWith("../")) {
// Copy all xsd files to xsd directory
String targetProjectName = location.substring(3, location.indexOf("/", 3));
copyXsdOfProject(targetProjectName, destDir);
}
// Add reference
addReferenceToMap(referenceMap, namespaceURI, location);
// Add import
addImport(transactionSchema, namespaceURI, location);
}
}
}
}
QName responseTypeQName = new QName(project.getTargetNamespace(), transaction.getXsdResponseTypeName());
// Add required schema objects
for (QName qname : map.keySet()) {
if (qname.getNamespaceURI().equals(targetNamespace)) {
XmlSchemaObject ob = map.get(qname);
if (qname.getLocalPart().startsWith("ConvertigoError"))
continue;
transactionSchema.getItems().add(ob);
// Add missing response error element and attributes
if (qname.equals(responseTypeQName)) {
Transaction.addSchemaResponseObjects(transactionSchema, (XmlSchemaComplexType) ob);
}
}
}
// Add missing ResponseType (with document)
if (map.containsKey(responseTypeQName)) {
Transaction.addSchemaResponseType(transactionSchema, transaction);
}
// Add everything
if (map.isEmpty()) {
Transaction.addSchemaObjects(transactionSchema, transaction);
}
// Add c8o error objects (for internal xsd edition only)
ConvertigoError.updateXmlSchemaObjects(transactionSchema);
// Save schema to file
String transactionXsdFilePath = transaction.getSchemaFilePath();
new File(transaction.getSchemaFileDirPath()).mkdirs();
SchemaUtils.saveSchema(transactionXsdFilePath, transactionSchema);
} catch (Exception e) {
Engine.logDatabaseObjectManager.error("[Migration 7.0.0] An error occured while migrating transaction \"" + transaction.getName() + "\"", e);
}
if (transaction instanceof TransactionWithVariables) {
TransactionWithVariables transactionVars = (TransactionWithVariables) transaction;
handleRequestableVariable(transactionVars.getVariablesList());
// Change SQLQuery variables : i.e. {id} --> {{id}}
if (transaction instanceof SqlTransaction) {
String sqlQuery = ((SqlTransaction) transaction).getSqlQuery();
sqlQuery = sqlQuery.replaceAll("\\{([a-zA-Z0-9_]+)\\}", "{{$1}}");
((SqlTransaction) transaction).setSqlQuery(sqlQuery);
}
}
}
}
} else {
// Should only happen for projects which version <= 4.6.0
XmlSchemaCollection collection = new XmlSchemaCollection();
String prefix = project.getName() + "_ns";
projectSchema = SchemaUtils.createSchema(prefix, project.getNamespaceUri(), XsdForm.unqualified.name(), XsdForm.unqualified.name());
ConvertigoError.addXmlSchemaObjects(projectSchema);
SchemaMeta.setCollection(projectSchema, collection);
for (Connector connector : project.getConnectorsList()) {
for (Transaction transaction : connector.getTransactionsList()) {
if (transaction instanceof TransactionWithVariables) {
TransactionWithVariables transactionVars = (TransactionWithVariables) transaction;
handleRequestableVariable(transactionVars.getVariablesList());
}
}
}
}
// Handle sequence objects
for (Sequence sequence : project.getSequencesList()) {
handleSteps(projectSchema, referenceMap, sequence.getSteps());
handleRequestableVariable(sequence.getVariablesList());
}
// Add all references to project
if (!referenceMap.isEmpty()) {
for (Reference reference : referenceMap.values()) project.add(reference);
}
// Delete XSD file
if (xsdFile.exists())
xsdFile.delete();
// Delete WSDL file
if (wsdlFile.exists())
wsdlFile.delete();
} catch (Exception e) {
Engine.logDatabaseObjectManager.error("[Migration 7.0.0] An error occured while migrating project \"" + projectName + "\"", e);
}
}
use of com.twinsoft.convertigo.beans.transactions.SqlTransaction in project convertigo by convertigo.
the class SqlConnector method prepareForTransaction.
public void prepareForTransaction(Context context) throws EngineException {
SqlTransaction sqlTransaction = null;
try {
sqlTransaction = (SqlTransaction) context.requestedObject;
} catch (ClassCastException e) {
throw new EngineException("Requested object is not a SQL transaction", e);
}
if (Engine.isEngineMode() && KeyManager.getCV(Session.EmulIDSQL) < 1) {
String msg;
if (KeyManager.has(Session.EmulIDSQL) && KeyManager.hasExpired(Session.EmulIDSQL)) {
Engine.logEngine.error(msg = "Key expired for the SQL connector.");
throw new KeyExpiredException(msg);
}
Engine.logEngine.error(msg = "No key for the SQL connector.");
throw new MaxCvsExceededException(msg);
}
// Overwrites JDBC url, user and password if needed (#369)
String variableValue = sqlTransaction.getParameterStringValue(Parameter.ConnectorConnectionString.getName());
if (variableValue != null && !variableValue.isEmpty()) {
if (!variableValue.equals(getJdbcURL()) && !variableValue.equals(getOverJdbcURL())) {
setOverJdbcURL(variableValue);
Engine.logBeans.debug("(SqlConnector) Connection string overriden!");
}
}
Engine.logBeans.debug("(SqlConnector) JDBC URL: " + getConnectionJdbcURL());
}
use of com.twinsoft.convertigo.beans.transactions.SqlTransaction in project convertigo by convertigo.
the class SqlConnectorDesignComposite method createSqlTransactions.
protected void createSqlTransactions(final TableItem[] items) {
Display display = Display.getDefault();
Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
Shell shell = display.getActiveShell();
if (shell != null) {
try {
shell.setCursor(waitCursor);
for (int i = 0; i < items.length; i++) {
TableItem item = items[i];
String callableName = item.getText(0);
String callableDesc = item.getText(1);
String specific_name = (String) item.getData("specific_name");
ConvertigoPlugin.logDebug("Creating transaction for CALL '" + callableName + "' ...");
if (specific_name.isEmpty()) {
specific_name = callableName;
}
SqlTransaction sqlTransaction = SqlConnector.createSqlTransaction(sqlConnector, callableName, specific_name);
if (sqlTransaction != null) {
Transaction transaction = sqlConnector.getTransactionByName(sqlTransaction.getName());
if (transaction != null) {
try {
File xsdFile = new File(transaction.getSchemaFilePath());
if (xsdFile.exists()) {
xsdFile.delete();
}
} catch (Exception e) {
}
sqlConnector.remove(transaction);
}
sqlTransaction.setComment(callableDesc);
sqlConnector.add(sqlTransaction);
fireObjectChanged(new CompositeEvent(sqlConnector));
ConvertigoPlugin.logDebug("Transaction added.");
}
}
} catch (Exception ee) {
ConvertigoPlugin.logException(ee, "Error while creating transaction(s)");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
}
Aggregations