use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.
the class MobilePickerComposite method getJsonModel.
private JSONObject getJsonModel(Map<String, Object> data, DatabaseObject databaseObject) throws Exception {
JSONObject jsonModel = new JSONObject();
Map<String, String> params;
DatabaseObject dbo;
String dataPath;
if (databaseObject == null) {
dbo = (DatabaseObject) data.get("databaseObject");
params = GenericUtils.cast(data.get("params"));
dataPath = (String) data.get("searchPath");
} else {
dbo = databaseObject;
params = new HashMap<String, String>();
dataPath = "";
}
if (dbo != null) {
// case of requestable
if (dbo instanceof RequestableObject) {
RequestableObject ro = (RequestableObject) dbo;
Project project = ro.getProject();
String responseEltName = ro.getXsdTypePrefix() + ro.getName() + "Response";
boolean isDocumentNode = JsonRoot.docNode.equals(project.getJsonRoot()) && dataPath.isEmpty();
XmlSchema schema = Engine.theApp.schemaManager.getSchemaForProject(project.getName());
XmlSchemaObject xso = SchemaMeta.getXmlSchemaObject(schema, ro);
if (xso != null) {
Document document = XmlSchemaUtils.getDomInstance(xso);
// System.out.println(XMLUtils.prettyPrintDOM(document));
String jsonString = XMLUtils.XmlToJson(document.getDocumentElement(), true, true);
JSONObject jsonObject = new JSONObject(jsonString);
String searchPath = "document." + responseEltName + ".response";
searchPath += isDocumentNode || !dataPath.startsWith(".document") ? dataPath : dataPath.replaceFirst("\\.document", "");
JSONObject jsonOutput = findJSONObject(jsonObject, searchPath);
jsonModel = isDocumentNode ? new JSONObject().put("document", jsonOutput) : jsonOutput;
}
} else if (dbo instanceof DesignDocument) {
DesignDocument dd = (DesignDocument) dbo;
Connector connector = dd.getConnector();
String ddoc = params.get("ddoc");
String view = params.get("view");
String viewName = ddoc + "/" + view;
String includeDocs = params.get("include_docs");
Display.getDefault().asyncExec(new Runnable() {
public void run() {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
ConnectorEditor connectorEditor = ConvertigoPlugin.getDefault().getConnectorEditor(connector);
if (connectorEditor == null) {
try {
connectorEditor = (ConnectorEditor) activePage.openEditor(new ConnectorEditorInput(connector), "com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor");
} catch (PartInitException e) {
ConvertigoPlugin.logException(e, "Error while loading the connector editor '" + connector.getName() + "'");
}
}
if (connectorEditor != null) {
// activate connector's editor
activePage.activate(connectorEditor);
// set transaction's parameters
Transaction transaction = connector.getTransactionByName(CouchDbConnector.internalView);
((GetViewTransaction) transaction).setViewname(viewName);
((GetViewTransaction) transaction).setQ_include_docs(includeDocs);
Variable view_reduce = ((GetViewTransaction) transaction).getVariable(CouchParam.prefix + "reduce");
view_reduce.setValueOrNull(false);
// execute view transaction
connectorEditor.getDocument(CouchDbConnector.internalView, false);
}
}
});
} else // case of UIForm
if (dbo instanceof UIForm) {
// JSONObject jsonObject = new JSONObject("{\"controls\":{\"['area']\":{\"value\":\"\"}}}");
JSONObject jsonObject = new JSONObject(((UIForm) dbo).computeJsonModel());
String searchPath = dataPath;
JSONObject jsonOutput = findJSONObject(jsonObject, searchPath);
jsonModel = jsonOutput;
} else // case of UIACtionStack
if (dbo instanceof UIActionStack) {
JSONObject jsonObject = new JSONObject(((UIActionStack) dbo).computeJsonModel());
String searchPath = dataPath;
JSONObject jsonOutput = findJSONObject(jsonObject, searchPath);
jsonModel = jsonOutput;
} else // case of UIDynamicAction or UICustomAction
if (dbo instanceof IAction) {
JSONObject jsonObject = new JSONObject();
if (dbo instanceof UIDynamicAction) {
UIDynamicAction uida = (UIDynamicAction) dbo;
jsonObject = new JSONObject(uida.computeJsonModel());
IonBean ionBean = uida.getIonBean();
if (ionBean != null) {
String name = ionBean.getName();
if ("CallSequenceAction".equals(name)) {
String qname = ionBean.getProperty("requestable").getValue().toString();
DatabaseObject sequence = Engine.theApp.databaseObjectsManager.getDatabaseObjectByQName(qname);
if (sequence != null) {
JSONObject targetJsonModel = getJsonModel(data, sequence);
if (jsonObject.has("out")) {
jsonObject.put("out", targetJsonModel);
}
}
} else if ("CallFullSyncAction".equals(name)) {
String qname = ionBean.getProperty("requestable").getValue().toString();
String verb = ionBean.getProperty("verb").getValue().toString();
Connector connector = (Connector) Engine.theApp.databaseObjectsManager.getDatabaseObjectByQName(qname);
if (connector != null) {
XmlSchema schema = Engine.theApp.schemaManager.getSchemaForProject(connector.getProject().getName());
AbstractCouchDbTransaction act = null;
if ("all".equals(verb))
act = new AllDocsTransaction();
else if ("create".equals(verb))
act = new PutDatabaseTransaction();
else if ("destroy".equals(verb))
act = new DeleteDatabaseTransaction();
else if ("get".equals(verb))
act = new GetDocumentTransaction();
else if ("delete".equals(verb))
act = new DeleteDocumentTransaction();
else if ("delete_attachment".equals(verb))
act = new DeleteDocumentAttachmentTransaction();
else if ("post".equals(verb))
act = new PostDocumentTransaction();
else if ("put_attachment".equals(verb))
act = new PutDocumentAttachmentTransaction();
else if ("replicate_push".equals(verb))
act = new PostReplicateTransaction();
else if ("reset".equals(verb))
act = new ResetDatabaseTransaction();
else if ("view".equals(verb))
act = new GetViewTransaction();
if (act != null) {
QName typeQName = act.getComplexTypeAffectation();
XmlSchemaType xmlSchemaType = schema.getTypeByName(typeQName);
Document document = XmlSchemaUtils.getDomInstance(xmlSchemaType);
String jsonString = XMLUtils.XmlToJson(document.getDocumentElement(), true, true);
JSONObject jsonOutput = new JSONObject(jsonString).getJSONObject("document");
cleanJsonModel(jsonOutput);
jsonOutput.remove("_c8oMeta");
jsonOutput.remove("error");
jsonOutput.remove("reason");
if (jsonObject.has("out")) {
jsonObject.put("out", jsonOutput);
}
}
}
} else if ("FullSyncGetAction".equals(name)) {
String qname = ionBean.getProperty("requestable").getValue().toString();
String docid = ionBean.getProperty("_id").getValue().toString();
Connector connector = (Connector) Engine.theApp.databaseObjectsManager.getDatabaseObjectByQName(qname);
if (connector != null) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
ConnectorEditor connectorEditor = ConvertigoPlugin.getDefault().getConnectorEditor(connector);
if (connectorEditor == null) {
try {
connectorEditor = (ConnectorEditor) activePage.openEditor(new ConnectorEditorInput(connector), "com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor");
} catch (PartInitException e) {
ConvertigoPlugin.logException(e, "Error while loading the connector editor '" + connector.getName() + "'");
}
}
if (connectorEditor != null) {
// activate connector's editor
activePage.activate(connectorEditor);
// set transaction's parameters
Transaction transaction = connector.getTransactionByName(CouchDbConnector.internalDocument);
Variable var_docid = ((GetDocumentTransaction) transaction).getVariable(CouchParam.docid.param());
var_docid.setValueOrNull(docid);
// execute view transaction
connectorEditor.getDocument(CouchDbConnector.internalDocument, false);
}
}
});
}
} else if ("FullSyncViewAction".equals(name)) {
String fsview = ionBean.getProperty("fsview").getValue().toString();
String includeDocs = ionBean.getProperty("include_docs").getValue().toString();
String reduce = ionBean.getProperty("reduce").getValue().toString();
String qname = fsview.substring(0, fsview.lastIndexOf('.'));
DesignDocument dd = (DesignDocument) Engine.theApp.databaseObjectsManager.getDatabaseObjectByQName(qname);
Connector connector = dd.getConnector();
String viewName = dd.getName() + "/" + fsview.substring(fsview.lastIndexOf('.') + 1);
Display.getDefault().asyncExec(new Runnable() {
public void run() {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
ConnectorEditor connectorEditor = ConvertigoPlugin.getDefault().getConnectorEditor(connector);
if (connectorEditor == null) {
try {
connectorEditor = (ConnectorEditor) activePage.openEditor(new ConnectorEditorInput(connector), "com.twinsoft.convertigo.eclipse.editors.connector.ConnectorEditor");
} catch (PartInitException e) {
ConvertigoPlugin.logException(e, "Error while loading the connector editor '" + connector.getName() + "'");
}
}
if (connectorEditor != null) {
// activate connector's editor
activePage.activate(connectorEditor);
// set transaction's parameters
Transaction transaction = connector.getTransactionByName(CouchDbConnector.internalView);
((GetViewTransaction) transaction).setViewname(viewName);
((GetViewTransaction) transaction).setQ_include_docs(includeDocs);
Variable view_reduce = ((GetViewTransaction) transaction).getVariable(CouchParam.prefix + "reduce");
view_reduce.setValueOrNull(reduce);
// execute view transaction
connectorEditor.getDocument(CouchDbConnector.internalView, false);
}
}
});
} else if (name.startsWith("FullSync")) {
if (ionBean.getProperty("requestable") != null) {
String qname = ionBean.getProperty("requestable").getValue().toString();
DatabaseObject connector = Engine.theApp.databaseObjectsManager.getDatabaseObjectByQName(qname);
if (connector != null) {
XmlSchema schema = Engine.theApp.schemaManager.getSchemaForProject(connector.getProject().getName());
AbstractCouchDbTransaction act = null;
if ("FullSyncDeleteAction".equals(name))
act = new DeleteDocumentTransaction();
else if ("FullSyncDeleteAttachmentAction".equals(name))
act = new DeleteDocumentAttachmentTransaction();
else if ("FullSyncPostAction".equals(name))
act = new PostDocumentTransaction();
else if ("FullSyncPutAttachmentAction".equals(name))
act = new PutDocumentAttachmentTransaction();
if (act != null) {
QName typeQName = act.getComplexTypeAffectation();
XmlSchemaType xmlSchemaType = schema.getTypeByName(typeQName);
Document document = XmlSchemaUtils.getDomInstance(xmlSchemaType);
String jsonString = XMLUtils.XmlToJson(document.getDocumentElement(), true, true);
JSONObject jsonOutput = new JSONObject(jsonString).getJSONObject("document");
cleanJsonModel(jsonOutput);
jsonOutput.remove("_c8oMeta");
jsonOutput.remove("error");
jsonOutput.remove("reason");
if (jsonObject.has("out")) {
jsonObject.put("out", jsonOutput);
}
}
}
}
}
}
} else if (dbo instanceof UICustomAction) {
jsonObject = new JSONObject(((UICustomAction) dbo).computeJsonModel());
}
String searchPath = dataPath;
JSONObject jsonOutput = findJSONObject(jsonObject, searchPath);
jsonModel = jsonOutput;
} else // case of UISharedComponent
if (dbo instanceof UISharedComponent) {
JSONObject jsonObject = new JSONObject(((UISharedComponent) dbo).computeJsonModel());
String searchPath = dataPath;
JSONObject jsonOutput = findJSONObject(jsonObject, searchPath);
jsonModel = jsonOutput;
} else // case of ApplicationComponent
if (dbo instanceof ApplicationComponent) {
String json = params.get("json");
jsonModel = new JSONObject(json);
} else // should not happened
{
throw new Exception("DatabaseObject " + dbo.getClass().getName() + " not supported!");
}
}
return jsonModel;
}
use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.
the class TransactionStep method getTargetTransaction.
public Transaction getTargetTransaction() throws EngineException {
Project p = getTargetProject(projectName);
Connector connector = (connectorName.equals("") ? p.getDefaultConnector() : p.getConnectorByName(connectorName));
Transaction targetTransaction = (transactionName.equals("") ? connector.getDefaultTransaction() : connector.getTransactionByName(transactionName));
return targetTransaction;
}
use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.
the class TransactionStep method prepareForRequestable.
protected void prepareForRequestable(Context javascriptContext, Scriptable scope) throws MalformedURLException, EngineException {
Transaction targetTransaction = getTargetTransaction();
Connector targetConnector = targetTransaction.getConnector();
String ctxName = getContextName(javascriptContext, scope);
boolean useSequenceJSession = sequence.useSameJSessionForSteps();
String connectionStringValue = (String) getConnectionStringValue();
if (isInternalInvoke()) {
request.put(Parameter.Project.getName(), new String[] { projectName });
// request.put(Parameter.Pool.getName(), new String[] { "" });
request.put(Parameter.MotherSequenceContext.getName(), new String[] { sequence.context.contextID });
request.put(Parameter.Transaction.getName(), new String[] { targetTransaction.getName() });
request.put(Parameter.Connector.getName(), new String[] { targetConnector.getName() });
request.put(Parameter.Context.getName(), new String[] { sequence.addStepContextName(ctxName) });
request.put(Parameter.SessionId.getName(), new String[] { getTransactionSessionId() });
if (!connectionStringValue.equals(""))
request.put(Parameter.ConnectorConnectionString.getName(), new String[] { connectionStringValue });
getPostQuery(scope);
} else {
targetUrl = EnginePropertiesManager.getProperty(PropertyName.APPLICATION_SERVER_CONVERTIGO_URL);
targetUrl += "/projects/" + projectName + "/.xml?";
URL url = new URL(targetUrl);
String host = url.getHost();
int port = url.getPort();
Engine.logBeans.trace("(TransactionStep) Host: " + host + ":" + port);
hostConfiguration.setHost(host, port);
method = new PostMethod(targetUrl);
HeaderName.ContentType.setRequestHeader(method, MimeType.WwwForm.value());
// Set transaction sessionId from context maintainer
String sessionId = getTransactionSessionId();
if (useSequenceJSession) {
Engine.logBeans.trace("(TransactionStep) JSESSIONID required : " + sessionId);
if (sessionId != null) {
method.setRequestHeader("Cookie", "JSESSIONID=" + sessionId + ";");
Engine.logBeans.trace("(TransactionStep) JSESSIONID used : " + sessionId);
} else {
Engine.logBeans.trace("(TransactionStep) JSESSIONID is null");
}
} else {
if (sessionId != null) {
method.setRequestHeader("Cookie", "JSESSIONID=" + sessionId + ";");
Engine.logBeans.trace("(TransactionStep) Transaction JSESSIONID used : " + sessionId);
} else {
Engine.logBeans.trace("(TransactionStep) Transaction JSESSIONID is null");
}
}
String postQuery = getPostQuery(scope);
if (postQuery.indexOf(Parameter.Connector.getName()) == -1)
postQuery = addParamToPostQuery(Parameter.Connector.getName(), targetConnector.getName(), postQuery);
if (postQuery.indexOf(Parameter.Transaction.getName()) == -1)
postQuery = addParamToPostQuery(Parameter.Transaction.getName(), targetTransaction.getName(), postQuery);
if (postQuery.indexOf(Parameter.MotherSequenceContext.getName()) == -1)
postQuery = addParamToPostQuery(Parameter.MotherSequenceContext.getName(), sequence.context.contextID, postQuery);
if (postQuery.indexOf(Parameter.Context.getName()) == -1)
postQuery = addParamToPostQuery(Parameter.Context.getName(), sequence.addStepContextName(ctxName), postQuery);
if (!connectionStringValue.equals(""))
postQuery = addParamToPostQuery(Parameter.ConnectorConnectionString.getName(), connectionStringValue, postQuery);
if (Engine.logBeans.isTraceEnabled())
Engine.logBeans.trace("(TransactionStep) postQuery :" + Visibility.Logs.replaceVariables(getVariables(), postQuery));
try {
method.setRequestEntity(new StringRequestEntity(postQuery, null, "UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new EngineException("Encoding error", e);
}
}
}
use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.
the class WebServiceServlet method generateWsdlForDocLiteral.
public static String generateWsdlForDocLiteral(String servletURI, String projectName) throws EngineException {
Engine.logEngine.debug("(WebServiceServlet) Generating WSDL...");
long timeStart = System.currentTimeMillis();
String locationPath = servletURI.substring(0, servletURI.indexOf("/.w"));
String targetNamespace = Project.CONVERTIGO_PROJECTS_NAMESPACEURI + projectName;
Project project = null;
// server mode
if (Engine.isEngineMode()) {
project = Engine.theApp.databaseObjectsManager.getProjectByName(projectName);
targetNamespace = project.getTargetNamespace();
} else // studio mode
{
project = Engine.objectsProvider.getProject(projectName);
targetNamespace = project.getTargetNamespace();
}
// Create WSDL definition
Definition definition = new DefinitionImpl();
definition.setExtensionRegistry(new PopulatedExtensionRegistry());
definition.setTargetNamespace(targetNamespace);
definition.setQName(new QName(targetNamespace, projectName));
definition.addNamespace("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
definition.addNamespace("soapenc", "http://schemas.xmlsoap.org/soap/encoding/");
definition.addNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/");
definition.addNamespace("xsd", "http://www.w3.org/2001/XMLSchema");
definition.addNamespace(projectName + "_ns", targetNamespace);
// Add WSDL Types
Types types = definition.createTypes();
definition.setTypes(types);
// Add WSDL service
Service service = definition.createService();
service.setQName(new QName(targetNamespace, projectName));
definition.addService(service);
// Add WSDL binding
PortType portType = definition.createPortType();
portType.setQName(new QName(targetNamespace, projectName + "PortType"));
portType.setUndefined(false);
definition.addPortType(portType);
SOAPBindingImpl soapBinding = new SOAPBindingImpl();
soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
soapBinding.setStyle("document");
Binding binding = definition.createBinding();
binding.setQName(new QName(targetNamespace, projectName + "SOAPBinding"));
binding.setUndefined(false);
definition.addBinding(binding);
binding.addExtensibilityElement(soapBinding);
binding.setPortType(portType);
// Add WSDL port
SOAPAddress soapAddress = new SOAPAddressImpl();
soapAddress.setLocationURI(locationPath + "/.wsl");
Port port = definition.createPort();
port.setName(projectName + "SOAP");
port.addExtensibilityElement(soapAddress);
port.setBinding(binding);
service.addPort(port);
// Add all WSDL operations
// remember qnames for accessibility
List<QName> partElementQNames = new ArrayList<QName>();
if (project != null) {
for (Connector connector : project.getConnectorsList()) {
for (Transaction transaction : connector.getTransactionsList()) {
if (transaction.isPublicAccessibility()) {
addWsdlOperation(definition, transaction, partElementQNames);
}
}
}
for (Sequence sequence : project.getSequencesList()) {
if (sequence.isPublicAccessibility()) {
addWsdlOperation(definition, sequence, partElementQNames);
}
}
}
// Add all schemas of project under WSDL Types
try {
// Retrieve the only needed schema objects map
XmlSchemaCollection xmlSchemaCollection = Engine.theApp.schemaManager.getSchemasForProject(projectName);
XmlSchema projectSchema = xmlSchemaCollection.getXmlSchema(targetNamespace)[0];
LinkedHashMap<QName, XmlSchemaObject> map = new LinkedHashMap<QName, XmlSchemaObject>();
XmlSchemaWalker dw = XmlSchemaWalker.newDependencyWalker(map, true, true);
for (QName qname : partElementQNames) {
dw.walkByElementRef(projectSchema, qname);
}
if (Engine.logEngine.isTraceEnabled()) {
String message = "";
for (QName qname : map.keySet()) {
message += "\n\t" + qname.toString();
}
Engine.logEngine.trace("(WebServiceServlet) needed schema objects :" + message);
}
// Read schemas into a new Collection in order to modify them
XmlSchemaCollection wsdlSchemaCollection = new XmlSchemaCollection();
for (XmlSchema xmlSchema : xmlSchemaCollection.getXmlSchemas()) {
String tns = xmlSchema.getTargetNamespace();
if (tns.equals(Constants.URI_2001_SCHEMA_XSD))
continue;
if (tns.equals(SchemaUtils.URI_SOAP_ENC))
continue;
if (wsdlSchemaCollection.schemaForNamespace(tns) == null) {
wsdlSchemaCollection.read(xmlSchema.getSchemaDocument(), xmlSchema.getSourceURI(), null);
}
}
// Modify schemas and add them
Map<String, Schema> schemaMap = new HashMap<String, Schema>();
for (XmlSchema xmlSchema : wsdlSchemaCollection.getXmlSchemas()) {
if (xmlSchema.getTargetNamespace().equals(Constants.URI_2001_SCHEMA_XSD))
continue;
if (xmlSchema.getTargetNamespace().equals(SchemaUtils.URI_SOAP_ENC))
continue;
String tns = xmlSchema.getTargetNamespace();
// Reduce schema to needed objects
reduceSchema(xmlSchema, map.keySet());
// Retrieve schema Element
Schema wsdlSchema = schemaMap.get(tns);
if (wsdlSchema == null) {
wsdlSchema = (Schema) definition.getExtensionRegistry().createExtension(Types.class, SchemaConstants.Q_ELEM_XSD_2001);
Element schemaElt = xmlSchema.getSchemaDocument().getDocumentElement();
// Remove 'schemaLocation' attribute on imports
NodeList importList = schemaElt.getElementsByTagNameNS(Constants.URI_2001_SCHEMA_XSD, "import");
if (importList.getLength() > 0) {
for (int i = 0; i < importList.getLength(); i++) {
Element importElt = (Element) importList.item(i);
importElt.removeAttribute("schemaLocation");
}
}
// Remove includes
NodeList includeList = schemaElt.getElementsByTagNameNS(Constants.URI_2001_SCHEMA_XSD, "include");
if (includeList.getLength() > 0) {
for (int i = 0; i < includeList.getLength(); i++) {
schemaElt.removeChild(includeList.item(i));
}
}
// Add schema Element
schemaMap.put(tns, wsdlSchema);
wsdlSchema.setElement(schemaElt);
types.addExtensibilityElement(wsdlSchema);
} else {
// case of schema include (same targetNamespace) or same schema
Element schemaElt = wsdlSchema.getElement();
// Add missing attributes
NamedNodeMap attributeMap = xmlSchema.getSchemaDocument().getDocumentElement().getAttributes();
for (int i = 0; i < attributeMap.getLength(); i++) {
Node node = attributeMap.item(i);
if (schemaElt.getAttributes().getNamedItem(node.getNodeName()) == null) {
schemaElt.setAttribute(node.getNodeName(), node.getNodeValue());
}
}
// Add children
NodeList children = xmlSchema.getSchemaDocument().getDocumentElement().getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node node = children.item(i);
// Special cases
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element el = (Element) node;
// Do not add include
if (el.getTagName().endsWith("include"))
continue;
// Add import at first
if (el.getTagName().endsWith("import")) {
String ins = el.getAttribute("namespace");
if (!tns.equals(ins) && el.hasAttribute("schemaLocation")) {
if (!hasElement(schemaElt, el.getLocalName(), ins))
schemaElt.insertBefore(schemaElt.getOwnerDocument().importNode(el, true), schemaElt.getFirstChild());
continue;
}
}
// Else
if (!hasElement(schemaElt, el.getLocalName(), el.getAttribute("name")))
schemaElt.appendChild(schemaElt.getOwnerDocument().importNode(el, true));
} else {
// Others
schemaElt.appendChild(schemaElt.getOwnerDocument().importNode(node, true));
}
}
}
}
} catch (Exception e1) {
Engine.logEngine.error("An error occured while adding schemas for WSDL", e1);
}
// Write WSDL to string
WSDLWriter wsdlWriter = new WSDLWriterImpl();
StringWriter sw = new StringWriter();
try {
wsdlWriter.writeWSDL(definition, sw);
} catch (WSDLException e) {
Engine.logEngine.error("An error occured while generating WSDL", e);
}
String wsdl = sw.toString();
long timeStop = System.currentTimeMillis();
System.out.println("Wsdl for " + projectName + " | Times >> total : " + (timeStop - timeStart) + " ms");
return wsdl;
}
use of com.twinsoft.convertigo.beans.core.Transaction in project convertigo by convertigo.
the class DatabaseObjectDeleteAction method delete.
private void delete(DatabaseObject databaseObject) throws EngineException, IOException {
if (databaseObject instanceof Connector) {
if (((Connector) databaseObject).isDefault) {
throw new EngineException("Cannot delete the default connector!");
}
String projectName = databaseObject.getParent().getName();
deleteResourcesFolder(projectName, "soap-templates", databaseObject.getName());
deleteResourcesFolder(projectName, "Traces", databaseObject.getName());
} 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!");
}
}
if (databaseObject instanceof Project) {
// Deleted project will be backup, car will be deleted to avoid its deployment at engine restart
// Engine.theApp.databaseObjectsManager.deleteProject(databaseObject.getName());
Engine.theApp.databaseObjectsManager.deleteProjectAndCar(databaseObject.getName());
// ConvertigoPlugin.getDefault().deleteProjectPluginResource(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 \"" + databaseObject.getQName() + "\" has been deleted from the database repository!");
}
Aggregations