use of org.talend.dq.nodes.AnalysisRepNode 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.AnalysisRepNode in project tdq-studio-se by Talend.
the class RespositoryDetailView method selectionChanged.
/*
* (non-Javadoc)
*
* @seeorg.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui. IWorkbenchPart,
* org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
clearContainer();
boolean isNeedcreateDefault = true;
try {
if (part instanceof DQRespositoryView) {
StructuredSelection sel = (StructuredSelection) selection;
// MOD by zshen for bug 15750 TODO 39(13) make Detail View can be used.
Object fe = sel.getFirstElement();
// MOD klliu 2011-02-24 if choose diffirent node ,that will load diffirent child ,so that not use up.
if (fe instanceof AnalysisRepNode || fe instanceof ReportRepNode || fe instanceof SysIndicatorDefinitionRepNode || fe instanceof PatternRepNode || fe instanceof RuleRepNode) {
fe = ((IRepositoryNode) fe).getObject();
}
if (fe instanceof IFile) {
IFile fe2 = (IFile) fe;
isNeedcreateDefault = createFileDetail(isNeedcreateDefault, fe2);
} else if (fe instanceof IRepositoryViewObject) {
isNeedcreateDefault = createFileDetail(isNeedcreateDefault, (IRepositoryViewObject) fe);
} else if (fe instanceof DBConnectionRepNode) {
DBConnectionRepNode connNode = (DBConnectionRepNode) fe;
// MOD sizhaoliu TDQ-6316
ConnectionItem connectionItem = (ConnectionItem) connNode.getObject().getProperty().getItem();
createDataProviderDetail(connectionItem);
isNeedcreateDefault = false;
} else if (fe instanceof DBCatalogRepNode) {
DBCatalogRepNode catalogNode = (DBCatalogRepNode) fe;
Catalog catalog = catalogNode.getCatalog();
createTdCatalogDetail(catalog);
isNeedcreateDefault = false;
} else if (fe instanceof DBSchemaRepNode) {
DBSchemaRepNode schemaNode = (DBSchemaRepNode) fe;
Schema schema = schemaNode.getSchema();
createTdSchemaDetail(schema);
isNeedcreateDefault = false;
} else if (fe instanceof DBTableRepNode) {
DBTableRepNode tableNode = (DBTableRepNode) fe;
// MOD gdbu 2011-9-14 TDQ-3243
if (!DQRepositoryNode.isOnFilterring()) {
tableNode.getChildren().get(0).getChildren();
}
// ~TDQ-3243
TdTable tdTable = tableNode.getTdTable();
createTableDetail(tdTable);
isNeedcreateDefault = false;
} else if (fe instanceof DBViewRepNode) {
DBViewRepNode viewNode = (DBViewRepNode) fe;
// MOD gdbu 2011-9-14 TDQ-3243
if (!DQRepositoryNode.isOnFilterring()) {
viewNode.getChildren().get(0).getChildren();
}
// ~TDQ-3243
createNameCommentDetail(viewNode.getTdView());
isNeedcreateDefault = false;
} else if (fe instanceof DBColumnRepNode) {
DBColumnRepNode columnNode = (DBColumnRepNode) fe;
TdColumn column = columnNode.getTdColumn();
createTdColumn(column);
isNeedcreateDefault = false;
} else if (fe instanceof IEcosComponent) {
IEcosComponent component = (IEcosComponent) fe;
createEcosComponent(component);
isNeedcreateDefault = false;
} else if (fe instanceof RegularExpression) {
// MOD mzhao 2009-04-20,Bug 6349.
RegularExpression regularExpression = (RegularExpression) fe;
createRegularExpression(regularExpression);
isNeedcreateDefault = false;
} else if (fe instanceof PatternLanguageRepNode) {
// MOD mzhao 2012-08-15,feature TDQ-4037.
PatternLanguageRepNode pattLangNode = (PatternLanguageRepNode) fe;
createRegularExpression(pattLangNode.getRegularExpression());
isNeedcreateDefault = false;
} else if (fe instanceof SourceFileRepNode) {
// MOD klliu 2001-02-28 bug 19154
IPath filePath = WorkbenchUtils.getFilePath((SourceFileRepNode) fe);
DQRepositoryNode node = (DQRepositoryNode) fe;
IFile file = ResourceManager.getRoot().getProject(node.getProject().getTechnicalLabel()).getFile(filePath);
createSqlFileDetail(file);
} else if (fe instanceof ExchangeComponentRepNode) {
// MOD klliu 2001-02-28 bug 19154
IEcosComponent ecosComponent = ((ExchangeComponentRepNode) fe).getEcosComponent();
IEcosComponent component = ecosComponent;
createEcosComponent(component);
isNeedcreateDefault = false;
// ADD by msjian 2011-5-12 21186: don't check whether the selected object is "MDMConnectionRepNode"
} else if (fe instanceof DFConnectionRepNode) {
DFConnectionRepNode dfNode = (DFConnectionRepNode) fe;
DelimitedFileConnection dfConnection = dfNode.getDfConnection();
createDFconnectionName(dfNode.getObject().getLabel());
createDataProviderDetail(dfConnection);
isNeedcreateDefault = false;
}
if (PluginChecker.isTDQLoaded()) {
if (fe instanceof EObject) {
createTechnicalDetail((EObject) fe);
} else if (fe instanceof IFile) {
createTechnicalDetail((IFile) fe);
} else if (fe instanceof IRepositoryViewObject) {
createTechnicalDetail((IRepositoryViewObject) fe);
} else {
createExtDefault();
}
}
if (!scomp.isDisposed()) {
scomp.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
composite.layout();
}
} else if (part instanceof CommonFormEditor) {
CommonFormEditor editor = (CommonFormEditor) part;
IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
IFileEditorInput input = (IFileEditorInput) editorInput;
IFile file = input.getFile();
isNeedcreateDefault = createFileDetail(isNeedcreateDefault, file);
}
}
if (isNeedcreateDefault) {
createDefault();
}
// feature 19053
if (!gContainer.isDisposed()) {
gContainer.layout();
if (tContainer != null) {
tContainer.layout();
}
}
} catch (MissingDriverException e) {
if (PluginChecker.isOnlyTopLoaded()) {
MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), // $NON-NLS-1$
DefaultMessagesImpl.getString("RespositoryDetailView.warning"), e.getErrorMessage());
} else {
log.error(e, e);
}
}
}
use of org.talend.dq.nodes.AnalysisRepNode in project tdq-studio-se by Talend.
the class AbstractCommonActionProviderTest method createAnalysisNode.
private RepositoryNode createAnalysisNode(String name, IFolder folder, boolean isDelete) {
IPath createPath = Path.EMPTY;
if (folder != null) {
createPath = new Path(folder.getFullPath().lastSegment());
}
// connection
Analysis createAnalysis = AnalysisFactory.eINSTANCE.createAnalysis();
createAnalysis.setName(name);
// ~connection
TDQAnalysisItem createAnalysisItem = org.talend.dataquality.properties.PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
org.talend.core.model.properties.Property createAnaProperty = PropertiesFactory.eINSTANCE.createProperty();
createAnaProperty.setId(EcoreUtil.generateUUID());
createAnaProperty.setItem(createAnalysisItem);
createAnaProperty.setLabel(createAnalysis.getName());
createAnalysisItem.setProperty(createAnaProperty);
createAnalysisItem.setAnalysis(createAnalysis);
ItemState createItemState = PropertiesFactory.eINSTANCE.createItemState();
createItemState.setDeleted(isDelete);
createAnalysisItem.setState(createItemState);
// Indicator
CountsIndicator createCountsIndicator = IndicatorsFactory.eINSTANCE.createCountsIndicator();
List<IRepositoryViewObject> all = null;
IndicatorDefinition createIndicatorDefinition = null;
try {
all = factory.getAll(ERepositoryObjectType.TDQ_SYSTEM_INDICATORS);
for (IRepositoryViewObject indicatorViewObject : all) {
if (indicatorViewObject.getLabel().equalsIgnoreCase("ROW COUNT")) {
// $NON-NLS-1$
createIndicatorDefinition = (IndicatorDefinition) PropertyHelper.getModelElement(indicatorViewObject.getProperty());
break;
}
}
} catch (PersistenceException e1) {
e1.printStackTrace();
Assert.fail(e1.getMessage());
}
createCountsIndicator.setIndicatorDefinition(createIndicatorDefinition);
AnalysisParameters createAnalysisParameters = AnalysisFactory.eINSTANCE.createAnalysisParameters();
AnalysisContext createAnalysisContext = AnalysisFactory.eINSTANCE.createAnalysisContext();
createAnalysis.setContext(createAnalysisContext);
AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
ExecutionInformations createExecutionInformations = AnalysisFactory.eINSTANCE.createExecutionInformations();
createAnalysisResult.setResultMetadata(createExecutionInformations);
createAnalysisResult.getIndicators().add(createCountsIndicator);
createAnalysis.setResults(createAnalysisResult);
createAnalysis.setParameters(createAnalysisParameters);
IRepositoryViewObject repViewObject = null;
try {
factory.create(createAnalysisItem, createPath, false);
repViewObject = factory.getLastVersion(createAnaProperty.getId());
} catch (PersistenceException e) {
Assert.fail(e.getMessage());
}
RepositoryNode anaRepNode = new AnalysisRepNode(repViewObject, null, ENodeType.TDQ_REPOSITORY_ELEMENT, null);
// set the contentType for anaRepNode from its parentNode
setParentNode(anaRepNode, ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT);
// ~
return anaRepNode;
}
use of org.talend.dq.nodes.AnalysisRepNode in project tdq-studio-se by Talend.
the class EMFSharedResourcesTest method testReloadModelElementInNode.
/**
* Test method for
* {@link org.talend.dq.writer.EMFSharedResources#reloadModelElementInNode(org.talend.repository.model.IRepositoryNode)}
* .
*/
@Test
public void testReloadModelElementInNode() {
IRepositoryViewObject viewObject = UnitTestBuildHelper.buildRepositoryViewObjectSystemFolder(currentProject.getEmfProject(), currentProject.getAuthor(), ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT);
RepositoryNode node = new RepositoryNode(viewObject, null, ENodeType.SYSTEM_FOLDER);
viewObject.setRepositoryNode(node);
// $NON-NLS-1$
Item anaItem = createRealAnalysis("analysis_emfreload", null, false);
IRepositoryViewObject object = null;
try {
object = ProxyRepositoryFactory.getInstance().getLastVersion(anaItem.getProperty().getId());
} catch (PersistenceException e1) {
// $NON-NLS-1$
fail("testReloadModelElementInNode fail: " + e1.getMessage());
}
anaNode = new AnalysisRepNode(object, node, ENodeType.REPOSITORY_ELEMENT, currentProject);
anaNode.setProperties(EProperties.LABEL, ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT);
anaNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT);
URI uri = anaItem.eResource().getURI();
String fileExtension = anaItem.getFileExtension();
// $NON-NLS-1$
String removeEnd = StringUtils.removeEnd(uri.path(), "." + FactoriesUtil.PROPERTIES_EXTENSION);
Analysis analysis = ((TDQAnalysisItem) anaItem).getAnalysis();
try {
// $NON-NLS-1$ //$NON-NLS-2$
ProxyRepositoryFactory.getInstance().unloadResources(uri.scheme() + ":" + removeEnd + "." + fileExtension);
} catch (PersistenceException e) {
// $NON-NLS-1$
fail("testReloadModelElementInNode fail: " + e.getMessage());
}
// ModelElement modelElement = PropertyHelper.getModelElement(anaItem.getProperty());
assertTrue(analysis.eIsProxy());
ModelElement reloadModelElement = EMFSharedResources.getInstance().reloadModelElementInNode(anaNode);
assertFalse(reloadModelElement.eIsProxy());
}
use of org.talend.dq.nodes.AnalysisRepNode in project tdq-studio-se by Talend.
the class ModelElementTreeMenuProvider method createTreeMenu.
/**
* DOC qzhang Comment method "createTreeMenu". MOD qiongli bug 16252.Add a param of 'isColumnSetMenu'
*
* @param newTree
* @param containEdit
*/
public void createTreeMenu(boolean isColumnSetMenu) {
Menu oldMenu = tree.getMenu();
if (oldMenu != null && !oldMenu.isDisposed()) {
oldMenu.dispose();
}
Menu menu = new Menu(tree);
if (isSelectedColumn(tree.getSelection())) {
if (!isMetadataColumnSelected(tree.getSelection())) {
MenuItem previewMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
previewMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.previewDQElement"));
previewMenuItem.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
previewMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected (org.eclipse
* .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
previewSelectedElements(tree);
}
});
}
if (isColumnSetMenu) {
MenuItem createColumnAnalysisMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
createColumnAnalysisMenuItem.setText(DefaultMessagesImpl.getString("CreateColumnAnalysisAction.columnAnalysis"));
createColumnAnalysisMenuItem.setImage(ImageLib.getImage(ImageLib.ACTION_NEW_ANALYSIS));
createColumnAnalysisMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
createColumnAnalysis(tree);
}
});
}
MenuItem showLocationMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
showLocationMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.showDQElement"));
showLocationMenuItem.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
showLocationMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @seeorg.eclipse.swt.events.SelectionAdapter# widgetSelected(org.eclipse .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
showSelectedElements(tree);
}
});
}
if (isSelectedIndicator(tree.getSelection()) && !isMetadataColumnIndicatorSelected(tree.getSelection())) {
// MOD 2009-01-04 mzhao
MenuItem showQueryMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
showQueryMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.viewQuery"));
showQueryMenuItem.setImage(ImageLib.getImage(ImageLib.EXPLORE_IMAGE));
showQueryMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected (org.eclipse .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
viewQueryForSelectedElement(tree);
}
});
}
if (isSelectedPatternIndicator(tree.getSelection())) {
MenuItem editPatternMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
editPatternMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.editPattern"));
editPatternMenuItem.setImage(ImageLib.getImage(ImageLib.PATTERN_REG));
editPatternMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @seeorg.eclipse.swt.events.SelectionAdapter# widgetSelected(org .eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
editPattern(tree);
}
});
}
// judge to indicator whether is frequency
if (isSelectedFrequencyIndicator(tree.getSelection()) && PluginChecker.isTDCPLoaded()) {
MenuItem editPatternMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
editPatternMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.generateJob"));
editPatternMenuItem.setImage(ImageLib.getImage(ImageLib.ICON_PROCESS));
editPatternMenuItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final IDatabaseJobService service = (IDatabaseJobService) GlobalServiceRegister.getDefault().getService(IJobService.class);
if (service != null) {
service.setIndicator(getSelectedIndicator(tree.getSelection()));
IRepositoryNode anaNode = getAnalysis2();
Analysis ana;
if (anaNode instanceof ReportAnalysisRepNode) {
ana = ((ReportAnalysisRepNode) anaNode).getAnalysis();
} else {
ana = ((AnalysisRepNode) anaNode).getAnalysis();
}
service.setAnalysis(ana);
service.executeJob();
}
}
});
}
if (isSelectedUDIndicator(tree.getSelection())) {
MenuItem editPatternMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
editPatternMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.editUDIndicator"));
editPatternMenuItem.setImage(ImageLib.getImage(ImageLib.IND_DEFINITION));
editPatternMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @seeorg.eclipse.swt.events.SelectionAdapter# widgetSelected(org .eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
editUDIndicator(tree);
}
});
}
// add common menu to the tree
MenuItem addTaskItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
addTaskItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.AddTask"));
addTaskItem.setImage(ImageLib.getImage(ImageLib.ADD_ACTION));
addTaskItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org .eclipse .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem[] selection = tree.getSelection();
if (selection.length > 0) {
IRepositoryNode ana = getAnalysis2();
// MOD qiongli 2011-1-12 feature 16796 :handle the case of ModelElement name is null
(new TdAddTaskAction(tree.getShell(), ana)).run();
}
}
});
MenuItem deleteMenuItem = new MenuItem(menu, SWT.CASCADE);
// $NON-NLS-1$
deleteMenuItem.setText(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.removeElement"));
deleteMenuItem.setImage(ImageLib.getImage(ImageLib.DELETE_ACTION));
deleteMenuItem.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org .eclipse .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
removeSelectedElements2(tree);
}
});
tree.setMenu(menu);
}
Aggregations