use of com.twinsoft.convertigo.beans.couchdb.JsonIndex in project convertigo by convertigo.
the class ProjectTreeObject method treeObjectAdded.
@Override
public void treeObjectAdded(TreeObjectEvent treeObjectEvent) {
super.treeObjectAdded(treeObjectEvent);
TreeObject treeObject = (TreeObject) treeObjectEvent.getSource();
if (treeObject instanceof DatabaseObjectTreeObject) {
DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
if (databaseObject instanceof CouchDbConnector) {
CouchDbConnector couchDbConnector = (CouchDbConnector) databaseObject;
if (couchDbConnector.bNew) {
CouchDbManager.syncDocument(couchDbConnector);
}
}
if (databaseObject instanceof JsonIndex) {
JsonIndex jsonIndex = (JsonIndex) databaseObject;
if (jsonIndex.bNew && jsonIndex.getConnector() != null) {
CouchDbManager.syncDocument(jsonIndex.getConnector());
}
}
if (this.equals(treeObject.getProjectTreeObject())) {
checkMissingProjects();
Engine.theApp.schemaManager.clearCache(getName());
}
}
}
use of com.twinsoft.convertigo.beans.couchdb.JsonIndex in project convertigo by convertigo.
the class ConnectorTreeObject method treeObjectRemoved.
@Override
public void treeObjectRemoved(TreeObjectEvent treeObjectEvent) {
super.treeObjectRemoved(treeObjectEvent);
TreeObject treeObject = (TreeObject) treeObjectEvent.getSource();
if (!(treeObject.equals(this)) && (treeObject.getParents().contains(this))) {
if (treeObject instanceof DatabaseObjectTreeObject) {
DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
Connector connector = this.getObject();
// A transaction has been removed
if (databaseObject instanceof Transaction) {
if (connector.getEndTransactionName().equals(databaseObject.getName())) {
connector.setEndTransactionName("");
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) {
CouchDbManager.syncDocument(connector);
}
}
}
}
use of com.twinsoft.convertigo.beans.couchdb.JsonIndex 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.couchdb.JsonIndex 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 !");
}
}
}
}
Aggregations