use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.
the class NoSQLSchemaWizardPage method createControl.
@Override
public void createControl(final Composite parent) {
String dbType = ((NoSQLConnection) connectionItem.getConnection()).getDbType();
IWizardPageProvider wizPageProvider = NoSQLRepositoryFactory.getInstance().getWizardPageProvider(dbType);
if (wizPageProvider == null) {
return;
}
schemaForm = wizPageProvider.createSchemaForm(parent, connectionItem, metadataTable, creation, this);
if (schemaForm == null) {
return;
}
schemaForm.setReadOnly(!isRepositoryObjectEditable);
AbstractForm.ICheckListener listener = new AbstractForm.ICheckListener() {
@Override
public void checkPerformed(final AbstractForm source) {
if (source.isStatusOnError()) {
setPageComplete(false);
setErrorMessage(source.getStatus());
} else {
setPageComplete(isRepositoryObjectEditable);
schemaForm.setButtonsVisibility(isRepositoryObjectEditable);
setErrorMessage(null);
setMessage(source.getStatus(), source.getStatusLevel());
}
}
};
schemaForm.setListener(listener);
setControl(schemaForm);
}
use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.
the class NoSqlContextUpdateService method updateContextParameter.
@Override
public boolean updateContextParameter(Connection conn, String oldValue, String newValue) {
boolean isModified = false;
if (conn.isContextMode()) {
if (conn instanceof NoSQLConnection) {
NoSQLConnection connection = (NoSQLConnection) conn;
EMap<String, String> connAttributes = (EMap<String, String>) connection.getAttributes();
if (connAttributes == null) {
return isModified;
}
for (Map.Entry<String, String> attr : connection.getAttributes()) {
if (attr.equals(IMongoDBAttributes.REPLICA_SET)) {
String replicaSets = connAttributes.get(IMongoDBAttributes.REPLICA_SET);
try {
JSONArray jsa = new JSONArray(replicaSets);
for (int i = 0; i < jsa.length(); i++) {
JSONObject jso = jsa.getJSONObject(i);
String hostValue = jso.getString(IMongoConstants.REPLICA_HOST_KEY);
if (hostValue != null && hostValue.equals(oldValue)) {
jso.put(IMongoConstants.REPLICA_HOST_KEY, newValue);
connAttributes.put(IMongoDBAttributes.REPLICA_SET, jsa.toString());
isModified = true;
}
String portValue = jso.getString(IMongoConstants.REPLICA_PORT_KEY);
if (portValue != null && portValue.equals(oldValue)) {
jso.put(IMongoConstants.REPLICA_PORT_KEY, newValue);
connAttributes.put(IMongoDBAttributes.REPLICA_SET, jsa.toString());
isModified = true;
}
}
} catch (JSONException e) {
ExceptionHandler.process(e);
}
} else if (attr.getValue().equals(oldValue)) {
attr.setValue(newValue);
isModified = true;
}
}
}
}
return isModified;
}
use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.
the class NoSQLDragAndDropHandler method getCorrespondingComponentName.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public IComponentName getCorrespondingComponentName(Item item, ERepositoryObjectType type) {
RepositoryComponentSetting setting = null;
if (item instanceof NoSQLConnectionItem) {
NoSQLConnection connection = (NoSQLConnection) ((NoSQLConnectionItem) item).getConnection();
String repType = getRepType(connection);
setting = new RepositoryComponentSetting();
setting.setName(repType);
setting.setRepositoryType(repType);
setting.setWithSchema(true);
setting.setInputComponent(getInputComponentName(connection));
setting.setOutputComponent(getOutputComponentName(connection));
List<Class<Item>> list = new ArrayList<Class<Item>>();
Class clazz = null;
try {
clazz = Class.forName(NoSQLConnectionItem.class.getName());
} catch (ClassNotFoundException e) {
ExceptionHandler.process(e);
}
list.add(clazz);
setting.setClasses(list.toArray(new Class[0]));
}
return setting;
}
use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.
the class NoSQLDragAndDropHandler method handleTableRelevantParameters.
@Override
public void handleTableRelevantParameters(Connection connection, IElement ele, IMetadataTable metadataTable) {
if (canHandle(connection)) {
NoSQLConnection conn = (NoSQLConnection) connection;
String dbType = conn.getDbType();
IDNDProvider dndProvider = NoSQLRepositoryFactory.getInstance().getDNDProvider(dbType);
if (dndProvider != null) {
dndProvider.handleTableRelevantParameters(conn, ele, metadataTable);
}
}
}
use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.
the class CreateNoSQLSchemaAction method doRun.
@Override
protected void doRun() {
if (repositoryNode == null) {
repositoryNode = getCurrentRepositoryNode();
}
NoSQLConnection connection = null;
MetadataTable metadataTable = null;
boolean creation = false;
if (repositoryNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
ERepositoryObjectType nodeType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
String metadataTableLabel = (String) repositoryNode.getProperties(EProperties.LABEL);
NoSQLConnectionItem item = null;
if (nodeType == ERepositoryObjectType.METADATA_CON_TABLE) {
item = (NoSQLConnectionItem) repositoryNode.getObject().getProperty().getItem();
connection = (NoSQLConnection) item.getConnection();
metadataTable = TableHelper.findByLabel(connection, metadataTableLabel);
creation = false;
} else if (nodeType == NoSQLRepositoryNodeType.METADATA_NOSQL_CONNECTIONS) {
item = (NoSQLConnectionItem) repositoryNode.getObject().getProperty().getItem();
connection = (NoSQLConnection) item.getConnection();
creation = true;
} else {
return;
}
boolean isOK = true;
if (creation) {
isOK = checkNoSQLConnection((NoSQLConnection) item.getConnection());
}
if (isOK) {
openNoSQLSchemaWizard(item, metadataTable, false, creation);
}
}
}
Aggregations