use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.
the class ChangeMongoDBConnectionMinimalVersionMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
if (item instanceof NoSQLConnectionItem) {
boolean modify = false;
Connection connection = ((NoSQLConnectionItem) item).getConnection();
if (connection instanceof NoSQLConnection) {
NoSQLConnection noSqlConn = (NoSQLConnection) connection;
try {
if (!noSqlConn.isContextMode()) {
String version = noSqlConn.getAttributes().get(ICassandraAttributies.DB_VERSION);
if (version == null || Arrays.asList(unsupportedVersion).contains(version)) {
// 1,No DB version => add one.
// 2,Has DB version, check if we still use it, if not change to the "lastestVersion".
noSqlConn.getAttributes().put(ICassandraAttributies.DB_VERSION, latestMajor2X);
modify = true;
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
if (modify) {
try {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
factory.save(item, true);
return ExecutionResult.SUCCESS_WITH_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
return ExecutionResult.NOTHING_TO_DO;
}
use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.
the class NoSQLDragAndDropHandler method filterNeededComponents.
@Override
public List<IComponent> filterNeededComponents(Item item, RepositoryNode seletetedNode, ERepositoryObjectType type) {
List<IComponent> neededComponents = new ArrayList<IComponent>();
if (!(item instanceof NoSQLConnectionItem)) {
return neededComponents;
}
NoSQLConnection connection = (NoSQLConnection) ((NoSQLConnectionItem) item).getConnection();
IComponentsService service = (IComponentsService) GlobalServiceRegister.getDefault().getService(IComponentsService.class);
Collection<IComponent> components = service.getComponentsFactory().readComponents();
for (IComponent component : components) {
if (isValid(item, type, seletetedNode, component, getRepType(connection)) && !neededComponents.contains(component)) {
neededComponents.add(component);
}
}
return neededComponents;
}
use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.
the class NoSQLConnWizardPage method init.
private void init() {
if (!creation) {
NoSQLConnection connection = (NoSQLConnection) connectionItem.getConnection();
List<String> dbTypes = repFactory.getAllRegisteredDBTypes();
for (int n = 0; n < dbTypes.size(); n++) {
if (dbTypes.get(n).equals(connection.getDbType())) {
dbTypeCombo.select(n);
}
}
} else if (dbTypeCombo.getItemCount() > 0) {
dbTypeCombo.select(0);
}
// getForm().checkFieldsValue();
}
use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.
the class NoSQLConnWizardPage method addFieldsListeners.
protected void addFieldsListeners() {
final AbstractForm.ICheckListener formCheckListener = new AbstractForm.ICheckListener() {
@Override
public void checkPerformed(final AbstractForm source) {
if (source.isStatusOnError()) {
setPageComplete(false);
setErrorMessage(source.getStatus());
} else {
setPageComplete(isRepositoryObjectEditable);
setErrorMessage(null);
setMessage(source.getStatus(), source.getStatusLevel());
}
}
};
dbTypeCombo.addModifyListener(new ModifyListener() {
@Override
public void modifyText(final ModifyEvent e) {
NoSQLConnection connection = (NoSQLConnection) connectionItem.getConnection();
String originalDbType = connection.getDbType();
String dbType = repositoryTranslator.getValue(dbTypeCombo.getText());
if (!StringUtils.equals(originalDbType, dbType)) {
connection.setDbType(dbType);
connection.getAttributes().clear();
} else if (connectionForm != null) {
return;
}
wizPageProvider = repFactory.getWizardPageProvider(dbType);
if (wizPageProvider == null) {
return;
}
clearForm(connectionForm);
connectionForm = getConnectionForm();
if (connectionForm == null) {
return;
}
connectionForm.setReadOnly(!isRepositoryObjectEditable);
connectionForm.setListener(formCheckListener);
if (StringUtils.isNotEmpty(connectionItem.getProperty().getLabel())) {
connectionForm.checkFieldsValue();
}
parentComp.layout();
}
});
}
use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.
the class NoSQLRetrieveSchemaWizardPage method createControl.
@Override
public void createControl(final Composite parent) {
NoSQLConnection connection = (NoSQLConnection) connectionItem.getConnection();
String dbType = connection.getDbType();
IWizardPageProvider wizPageProvider = NoSQLRepositoryFactory.getInstance().getWizardPageProvider(dbType);
if (wizPageProvider == null) {
return;
}
retrieveSchemaForm = wizPageProvider.createRetrieveSchemaForm(parent, connectionItem, creation, this);
if (retrieveSchemaForm == null) {
return;
}
retrieveSchemaForm.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);
setErrorMessage(null);
setMessage(source.getStatus(), source.getStatusLevel());
}
}
};
retrieveSchemaForm.setListener(listener);
setControl(retrieveSchemaForm);
if (StringUtils.isNotEmpty(connectionItem.getProperty().getLabel())) {
retrieveSchemaForm.checkFieldsValue();
}
}
Aggregations