use of org.talend.dq.nodes.ConnectionRepNode in project tdq-studio-se by Talend.
the class SwitchContextProvider method shouldShowSwitchMenu.
/**
* DOC msjian Comment method "shouldShowReloadMenu".
*
* @param node
* @return
*/
@SuppressWarnings("unchecked")
private boolean shouldShowSwitchMenu(RepositoryNode node) {
ENodeType type = node.getType();
// MOD msjian 2012-2-13 TDQ-4559: make it support file/mdm connection
if ((ENodeType.REPOSITORY_ELEMENT.equals(type) || ENodeType.TDQ_REPOSITORY_ELEMENT.equals(type)) && node instanceof ConnectionRepNode) {
// MOD qiongli 2011-10-10
String contextId = null;
Item item = node.getObject().getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection connection = ((ConnectionItem) item).getConnection();
if (connection != null) {
contextId = connection.getContextId();
}
}
// This menu will be available only when a context is not null and has more than one group.
if (contextId != null && !PluginConstant.EMPTY_STRING.equals(contextId.trim())) {
ContextItem objContextItem = ContextUtils.getContextItemById2(contextId);
EList<Context> contexts = objContextItem.getContext();
if (contexts != null && contexts.size() > 1) {
return true;
}
}
}
return false;
}
use of org.talend.dq.nodes.ConnectionRepNode in project tdq-studio-se by Talend.
the class RepNodeUtilsTest method testIsValidSelectionForMatchAnalysis.
/**
* Test: 1) when the selected node is: connection, catalog,schema, folder, will not be valid; 2) when the selected
* nodes are: multiple table/views, multiple columns from different table/view, will not be valid; 3) when the
* selected node is: one single table/view/file table,will be valid; 4) when the selected nodes are: multiple
* columns from one same table/view, will be valid.
*/
@Test
public void testIsValidSelectionForMatchAnalysis() {
// 1) when the selected node is: connection, catalog,schema, folder, will not be valid;
List<IRepositoryNode> nodes = new ArrayList<IRepositoryNode>();
ConnectionRepNode cNode = mock(ConnectionRepNode.class);
nodes.add(cNode);
Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
DBConnectionRepNode dbNode = mock(DBConnectionRepNode.class);
nodes.clear();
nodes.add(dbNode);
Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
DBConnectionFolderRepNode dbfNode = mock(DBConnectionFolderRepNode.class);
nodes.clear();
nodes.add(dbfNode);
Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
DQDBFolderRepositoryNode folderNode = mock(DQDBFolderRepositoryNode.class);
nodes.clear();
nodes.add(folderNode);
Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
DBCatalogRepNode catalogNode = mock(DBCatalogRepNode.class);
nodes.clear();
nodes.add(catalogNode);
Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
DBSchemaRepNode schemaNode = mock(DBSchemaRepNode.class);
nodes.clear();
nodes.add(schemaNode);
Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
}
use of org.talend.dq.nodes.ConnectionRepNode in project tdq-studio-se by Talend.
the class ConnectionEditor method doSave.
@Override
public void doSave(IProgressMonitor monitor) {
if (masterPage.isDirty()) {
masterPage.doSave(monitor);
setPartName(masterPage.getIntactElemenetName());
// MOD qiongli 2012-11-29 avoid item is proxy(get item form IRepositoryViewObject).
ConnectionRepNode connectionRepNode = ((ConnectionInfoPage) getMasterPage()).getCurrentRepNode();
if (connectionRepNode != null && connectionRepNode instanceof DBConnectionRepNode) {
IRepositoryViewObject object = connectionRepNode.getObject();
if (object != null) {
ConnectionItem item = (ConnectionItem) object.getProperty().getItem();
String name = ((DatabaseConnectionItem) item).getConnection().getName();
CWMPlugin.getDefault().updateConnetionAliasByName(item.getConnection(), masterPage.getOldDataproviderName());
masterPage.setOldDataproviderName(name);
}
}
// refresh the analysis editor
if (masterPage.isNameTextUpdate()) {
WorkbenchUtils.nodifyDependedAnalysis((ConnectionItem) connectionRepNode.getObject().getProperty().getItem());
// WorkbenchUtils.refreshCurrentAnalysisEditor();
masterPage.setModify(false);
// TDQ-11312
if (this.getEditorInput() instanceof FileEditorInput) {
this.setInput(masterPage.getEditorInput());
}
}
}
setEditorObject(((ConnectionInfoPage) getMasterPage()).getCurrentRepNode());
super.doSave(monitor);
}
use of org.talend.dq.nodes.ConnectionRepNode in project tdq-studio-se by Talend.
the class LocalRepositoryObjectCRUD method moveRepositoryNodes.
/**
* move RepositoryNodes to the target RepositoryNode.
*
* @param repositoryNodes
* @param targetNode
* @throws PersistenceException
*/
private void moveRepositoryNodes(IRepositoryNode[] repositoryNodes, IRepositoryNode targetNode) throws PersistenceException {
if (repositoryNodes != null) {
for (IRepositoryNode sourceNode : repositoryNodes) {
if (sourceNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
if (sourceNode instanceof AnalysisRepNode || sourceNode instanceof ConnectionRepNode) {
moveAnaConNode(sourceNode, targetNode);
} else if (sourceNode instanceof ReportRepNode) {
moveReportRepNode(sourceNode, targetNode);
} else {
IPath makeRelativeTo = getMakeRelativeTo(sourceNode);
IPath removeLastSegments = makeRelativeTo.removeLastSegments(1);
if (sourceNode instanceof SysIndicatorDefinitionRepNode) {
// SystemIndicatorDefinition can't be moved
if (!((SysIndicatorDefinitionRepNode) sourceNode).isSystemIndicator()) {
moveOthersNode(sourceNode, targetNode, removeLastSegments);
}
} else if (sourceNode instanceof PatternRepNode) {
moveOthersNode(sourceNode, targetNode, removeLastSegments);
} else if (sourceNode instanceof JrxmlTempleteRepNode) {
moveJrxmlFileRepNode(sourceNode, targetNode, makeRelativeTo);
} else if (sourceNode instanceof SourceFileRepNode || sourceNode instanceof RuleRepNode) {
moveOthersNode(sourceNode, targetNode, makeRelativeTo);
} else {
moveOthersNode(sourceNode, targetNode, removeLastSegments);
}
}
} else if (sourceNode.getType() == ENodeType.SIMPLE_FOLDER) {
moveFolderRepNode(sourceNode, targetNode);
}
// refresh the dq repository tree view
CorePlugin.getDefault().refreshDQView(targetNode.getParent());
// MOD qiongli 2012-4-23,only refresh the parent of source node at here.
CorePlugin.getDefault().refreshDQView(sourceNode.getParent());
}
}
}
use of org.talend.dq.nodes.ConnectionRepNode in project tdq-studio-se by Talend.
the class SwitchContextAction method run.
/*
* MOD yyin 20120917 TDQ-5362, do NOT reload DB when switching context.
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
// MOD msjian 2012-2-13 TDQ-4559: make it support file connection
if (selectedObject instanceof ConnectionRepNode) {
ConnectionRepNode conRepNode = (ConnectionRepNode) selectedObject;
Item item = conRepNode.getObject().getProperty().getItem();
if (item instanceof ConnectionItem) {
ConnectionItem connItem = (ConnectionItem) item;
// Added yyin 20120925 TDQ-5668, check this connection's editor is open or not, if open, close.
CorePlugin.getDefault().closeEditorIfOpened(connItem);
// ~
String chooseContext = chooseContext(connItem.getConnection());
boolean isUpdated = SwitchContextGroupNameImpl.getInstance().updateContextGroup(connItem, chooseContext);
if (isUpdated) {
if (log.isDebugEnabled()) {
// $NON-NLS-1$ //$NON-NLS-2$
log.debug(DefaultMessagesImpl.getString("SwitchContextAction.saveMessage", chooseContext, "successful"));
}
// ADD msjian TDQ-8834 2014-4-10: after switch the context, update the sql explore alias
// information.
CWMPlugin.getDefault().updateConnetionAliasByName(connItem.getConnection(), connItem.getProperty().getLabel());
// TDQ-8834~
CorePlugin.getDefault().refreshDQView(selectedObject);
} else {
// $NON-NLS-1$
MessageDialog.openWarning(// $NON-NLS-1$
CorePlugin.getDefault().getWorkbench().getDisplay().getActiveShell(), // $NON-NLS-1$
"", // $NON-NLS-1$
DefaultMessagesImpl.getString("SwitchContextAction.nullParameterError"));
// $NON-NLS-1$ //$NON-NLS-2$
log.error(DefaultMessagesImpl.getString("SwitchContextAction.saveMessage", chooseContext, "failed"));
}
}
}
// TDQ-4559~
}
Aggregations