use of org.talend.repository.model.nosql.NoSQLConnectionItem 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.NoSQLConnectionItem in project tbd-studio-se by Talend.
the class NoSQLRepositoryTypeProcessor method selectRepositoryNode.
/*
* (non-Javadoc)
*
* @see
* org.talend.repository.ui.processor.SingleTypeProcessor#selectRepositoryNode(org.eclipse.jface.viewers.Viewer,
* org.talend.repository.model.RepositoryNode, org.talend.repository.model.RepositoryNode)
*/
@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
final String repositoryType = getRepositoryType();
if (node == null || repositoryType == null) {
return false;
}
ERepositoryObjectType repObjType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
if (repObjType == ERepositoryObjectType.REFERENCED_PROJECTS) {
return true;
}
if (node.getType() == ENodeType.SYSTEM_FOLDER) {
return true;
}
IRepositoryViewObject object = node.getObject();
if (object == null || object.getProperty().getItem() == null) {
return false;
}
if (object instanceof MetadataTable) {
return false;
}
Item item = object.getProperty().getItem();
if (item instanceof FolderItem) {
return true;
}
if (item instanceof NoSQLConnectionItem) {
NoSQLConnectionItem connectionItem = (NoSQLConnectionItem) item;
NoSQLConnection connection = (NoSQLConnection) connectionItem.getConnection();
if (repositoryType.startsWith(INoSQLConstants.NOSQL_TYPE_PREFIX)) {
// $NON-NLS-1$
String realDbType = repositoryType.substring(repositoryType.indexOf(":") + 1);
if (!StringUtils.equalsIgnoreCase(realDbType, connection.getDbType())) {
return false;
}
}
}
return true;
}
use of org.talend.repository.model.nosql.NoSQLConnectionItem 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;
}
Aggregations