use of com.twinsoft.convertigo.beans.connectors.CouchDbConnector in project convertigo by convertigo.
the class ImportDesignDocumentsFromDatabaseAction 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 CouchDbConnector) {
CouchDbConnector connector = (CouchDbConnector) databaseObject;
connector.importCouchDbDesignDocuments();
if (connector.hasChanged) {
explorerView.reloadTreeObject(treeObject);
explorerView.setSelectedTreeObject(treeObject);
}
}
}
} catch (Throwable e) {
ConvertigoPlugin.logException(e, "Unable to import design documents from CouchDB database!");
} finally {
shell.setCursor(null);
waitCursor.dispose();
}
}
use of com.twinsoft.convertigo.beans.connectors.CouchDbConnector in project convertigo by convertigo.
the class ComponentInfoWizardPage method createControl.
public void createControl(Composite parent) {
container = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
container.setLayout(layout);
layout.numColumns = 2;
layout.verticalSpacing = 9;
Label label = new Label(container, SWT.NULL);
label.setText("&Name:");
beanName = new Text(container, SWT.BORDER | SWT.SINGLE);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
beanName.setLayoutData(gd);
beanName.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
dialogChanged(false);
}
});
if (parentObject instanceof CouchDbConnector || parentObject instanceof FullSyncConnector) {
couchVariablesComposite = new CouchVariablesComposite(container, SWT.V_SCROLL);
GridData couchVarData = new GridData(GridData.FILL_BOTH);
couchVarData.horizontalSpan = 2;
couchVariablesComposite.setLayoutData(couchVarData);
} else {
tree = new Tree(container, SWT.SINGLE | SWT.BORDER);
tree.setHeaderVisible(false);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.verticalSpan = 20;
gridData.horizontalSpan = 2;
tree.setLayoutData(gridData);
tree.addListener(SWT.Selection, new Listener() {
public void handleEvent(final Event event) {
TreeItem item = (TreeItem) event.item;
treeItemName = item.getText();
String suffix = getBeanName().endsWith(ScHandlerStatement.EVENT_ENTRY_HANDLER) ? ScHandlerStatement.EVENT_ENTRY_HANDLER : getBeanName().endsWith(ScHandlerStatement.EVENT_EXIT_HANDLER) ? ScHandlerStatement.EVENT_EXIT_HANDLER : "";
setBeanName("on" + treeItemName + suffix);
dialogChanged(true);
}
});
tree.setVisible(false);
}
initialize();
dialogChanged(true);
setControl(container);
}
use of com.twinsoft.convertigo.beans.connectors.CouchDbConnector in project convertigo by convertigo.
the class ConnectorTreeObject 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();
Connector connector = getObject();
if (treeObject instanceof DatabaseObjectTreeObject) {
// If a bean name has changed
if (propertyName.equals("name")) {
handlesBeanNameChanged(treeObjectEvent);
} else if (treeObject.equals(this)) {
// if this connector has changed
if (connector instanceof SapJcoConnector) {
try {
((SapJcoConnector) connector).getSapJCoProvider().updateDestination();
} catch (Exception e) {
ConvertigoPlugin.logWarning(e, "Could not update SAP destination !");
}
} else if (connector instanceof CouchDbConnector) {
if (propertyName.equals("https") || propertyName.equals("port") || propertyName.equals("server") || propertyName.equals("couchUsername") || propertyName.equals("couchPassword")) {
((CouchDbConnector) connector).release();
CouchDbManager.syncDocument(connector);
try {
ConvertigoPlugin.getDefault().getProjectExplorerView().reloadTreeObject(this);
} catch (Exception e) {
ConvertigoPlugin.logWarning(e, "Could not reload connector \"" + connector.getName() + "\" in tree !");
}
} else if (propertyName.equals("databaseName")) {
CouchDbManager.syncDocument(connector);
try {
ConvertigoPlugin.getDefault().getProjectExplorerView().reloadTreeObject(this);
} catch (Exception e) {
ConvertigoPlugin.logWarning(e, "Could not reload connector \"" + connector.getName() + "\" in tree !");
}
}
}
} else if (connector instanceof CouchDbConnector) {
DatabaseObject dbo = ((DatabaseObjectTreeObject) treeObject).getObject();
if (dbo instanceof JsonIndex && connector.equals(dbo.getParent()) && (propertyName.equals("fields") || propertyName.equals("ascending") || propertyName.equals("name"))) {
CouchDbManager.syncDocument(getObject());
}
}
}
}
use of com.twinsoft.convertigo.beans.connectors.CouchDbConnector in project convertigo by convertigo.
the class ConnectorTreeObject method handlesBeanNameChanged.
protected void handlesBeanNameChanged(TreeObjectEvent treeObjectEvent) {
DatabaseObjectTreeObject treeObject = (DatabaseObjectTreeObject) treeObjectEvent.getSource();
DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
Object oldValue = treeObjectEvent.oldValue;
Object newValue = treeObjectEvent.newValue;
Connector connector = this.getObject();
if (databaseObject instanceof Transaction) {
Transaction transaction = (Transaction) databaseObject;
if (transaction.getConnector().equals(connector)) {
if (connector.getEndTransactionName().equals(oldValue)) {
connector.setEndTransactionName((String) newValue);
try {
ConvertigoPlugin.getDefault().getProjectExplorerView().refreshTreeObject(this);
} catch (Exception e) {
ConvertigoPlugin.logWarning(e, "Could not refresh in tree Connector \"" + databaseObject.getName() + "\" !");
}
}
}
} else if (databaseObject instanceof JsonIndex && connector.equals(databaseObject.getParent())) {
CouchDbManager.syncDocument(connector);
}
// Case of this connector rename : update all transaction schemas
if (treeObject.equals(this)) {
String path = Project.XSD_FOLDER_NAME + "/" + Project.XSD_INTERNAL_FOLDER_NAME;
String oldPath = path + "/" + (String) oldValue;
String newPath = path + "/" + (String) newValue;
IFolder folder = getProjectTreeObject().getFolder(oldPath);
try {
folder.getParent().refreshLocal(IResource.DEPTH_ONE, null);
if (folder.exists()) {
// rename folder (xsd/internal/connector)
folder.move(new Path((String) newValue), true, null);
// make replacements in schema file
List<Replacement> replacements = new ArrayList<Replacement>();
replacements.add(new Replacement((String) oldValue + "__", (String) newValue + "__"));
IFolder newFolder = folder.getParent().getFolder(new Path((String) newValue));
for (Transaction transaction : getObject().getTransactionsList()) {
IFile file = newFolder.getFile(new Path(transaction.getName() + ".xsd"));
if (file.exists()) {
String filePath = file.getLocation().makeAbsolute().toString();
try {
ProjectUtils.makeReplacementsInFile(replacements, filePath);
} catch (Exception e) {
ConvertigoPlugin.logWarning(e, "Could rename \"" + oldValue + "\" to \"" + newValue + "\" in schema file \"" + filePath + "\" !");
}
}
}
// refresh folder
folder.refreshLocal(IResource.DEPTH_ONE, null);
Engine.theApp.schemaManager.clearCache(getProjectTreeObject().getName());
}
} catch (Exception e) {
ConvertigoPlugin.logWarning(e, "Could not rename folder from \"" + oldPath + "\" to \"" + newPath + "\" !");
}
if (connector instanceof CouchDbConnector) {
CouchDbManager.syncDocument(connector);
try {
ConvertigoPlugin.getDefault().getProjectExplorerView().reloadTreeObject(this);
} catch (Exception e) {
ConvertigoPlugin.logWarning(e, "Could not reload connector \"" + connector.getName() + "\" in tree !");
}
}
}
}
use of com.twinsoft.convertigo.beans.connectors.CouchDbConnector in project convertigo by convertigo.
the class DesignDocumentTreeObject method syncDocument.
private void syncDocument() {
try {
DesignDocument dd = getObject();
JSONObject jso = dd.getJSONObject();
if (CouchKey._id.has(jso)) {
CouchDbConnector couchDbConnector = dd.getConnector();
lastRev = CouchDbManager.syncDocument(couchDbConnector.getCouchClient(), couchDbConnector.getDatabaseName(), jso.toString());
}
} catch (Throwable t) {
ConvertigoPlugin.logException(t, "Failed to syncDocument");
}
}
Aggregations