use of org.talend.dq.nodes.ReportRepNode in project tdq-studio-se by Talend.
the class OpenItemEditorProvider method fillContextMenu.
@Override
public void fillContextMenu(IMenuManager menu) {
if (!isSelectionSameType()) {
return;
}
Object[] array = ((TreeSelection) this.getContext().getSelection()).toArray();
List<IRepositoryNode> selectedItemsList = new ArrayList<IRepositoryNode>();
for (Object obj : array) {
if (obj instanceof IRepositoryNode) {
IRepositoryNode node = (IRepositoryNode) obj;
if (RepositoryNodeHelper.canOpenEditor(node) && !(node instanceof ReportRepNode)) {
selectedItemsList.add((IRepositoryNode) obj);
}
}
}
if (!selectedItemsList.isEmpty()) {
menu.add(new OpenItemEditorAction(selectedItemsList.toArray(new IRepositoryNode[selectedItemsList.size()])));
}
}
use of org.talend.dq.nodes.ReportRepNode in project tdq-studio-se by Talend.
the class UnitTestBuildHelper method createRealReportNode.
/**
* create a real ReportRepNode.
*
* @param name report name
* @param folder report's parent folder
* @param isDelete delete flag
* @return
*/
public static ReportRepNode createRealReportNode(String name, RepositoryNode parentNode, IPath createPath, Boolean isDelete) {
ReportRepNode reportRepNode = null;
Report report = ReportHelper.createReport(name);
TDQReportItem reportItem = PropertiesFactoryImpl.eINSTANCE.createTDQReportItem();
org.talend.core.model.properties.Property reportProperty = PropertiesFactory.eINSTANCE.createProperty();
reportProperty.setId(EcoreUtil.generateUUID());
reportProperty.setItem(reportItem);
reportProperty.setLabel(report.getName());
reportItem.setProperty(reportProperty);
reportItem.setReport(report);
ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
itemState.setDeleted(isDelete);
reportItem.setState(itemState);
try {
ProxyRepositoryFactory.getInstance().create(reportItem, createPath, false);
IRepositoryViewObject reportViewObject = new RepositoryViewObject(reportProperty);
reportRepNode = new ReportRepNode(reportViewObject, parentNode, ENodeType.REPOSITORY_ELEMENT, null);
} catch (PersistenceException e) {
Assert.fail(e.getMessage());
}
return reportRepNode;
}
use of org.talend.dq.nodes.ReportRepNode in project tdq-studio-se by Talend.
the class RepNodeUtilsTest method setUp.
/**
* can not use the real project to test, because the method RepositoryNodeHelper.getDataProfilingFolderNode will use
* the UI view to fetch the node. so , can only mock for this test. The report and its analysismap with jrxml is
* real created, not mocked object.
*
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
// create a report with user defined jrxml
// $NON-NLS-1$
realReport = ReportHelper.createReport("report20130124");
AnalysisMap analysisMap = ReportsFactory.eINSTANCE.createAnalysisMap();
analysisMap.setReportType(ReportHelper.ReportType.USER_MADE.getLabel());
// $NON-NLS-1$
analysisMap.setAnalysis(AnalysisHelper.createAnalysis("analysis20130124"));
analysisMap.setJrxmlSource(oldJrxmlPath);
realReport.getAnalysisMap().add(analysisMap);
List<ReportRepNode> repNodes = new ArrayList<ReportRepNode>();
ReportRepNode repNode = mock(ReportRepNode.class);
repNodes.add(repNode);
IRepositoryViewObject view = mock(IRepositoryViewObject.class);
Property prop = mock(Property.class);
Item item = mock(Item.class);
when(prop.getItem()).thenReturn(item);
when(view.getProperty()).thenReturn(prop);
when(repNode.getObject()).thenReturn(view);
when(repNode.getReport()).thenReturn(realReport);
ProjectManager manager = mock(ProjectManager.class);
// $NON-NLS-1$
stub(method(ProjectManager.class, "getInstance")).toReturn(manager);
Project project = mock(Project.class);
when(manager.getCurrentProject()).thenReturn(project);
PowerMockito.mock(ResourceManager.class);
IProject iproject = mock(IProject.class);
// $NON-NLS-1$
when(iproject.getLocation()).thenReturn(new Path("/opt/runtime/tdqee/a1/"));
// $NON-NLS-1$
stub(method(ResourceManager.class, "getRootProject")).toReturn(iproject);
IFile ifile = mock(IFile.class);
when(iproject.getFile(newJrxmlPath)).thenReturn(ifile);
// $NON-NLS-1$
when(ifile.getLocation()).thenReturn(new Path("/opt/runtime/tdqee/a1/" + newJrxmlPath));
PowerMockito.mockStatic(ModelElementHelper.class);
IFile ifile2 = mock(IFile.class);
when(ModelElementHelper.getIFile(realReport)).thenReturn(ifile2);
when(ifile2.getLocation()).thenReturn(// $NON-NLS-1$
new Path("/opt/runtime/tdqee/a1/TDQ_Data Profiling/Reports/report20130124_0.1.rep"));
IFile ifile3 = mock(IFile.class);
when(iproject.getFile(moveJrxmlPath)).thenReturn(ifile3);
// $NON-NLS-1$
when(ifile3.getLocation()).thenReturn(new Path("/opt/runtime/tdqee/a1/" + moveJrxmlPath));
PowerMockito.mock(RepositoryNodeHelper.class);
IRepositoryNode ReportRootFolderNode = mock(IRepositoryNode.class);
// $NON-NLS-1$
stub(method(RepositoryNodeHelper.class, "getDataProfilingFolderNode", EResourceConstant.class)).toReturn(ReportRootFolderNode);
// $NON-NLS-1$
stub(method(RepositoryNodeHelper.class, "getReportRepNodes", IRepositoryNode.class, boolean.class, boolean.class)).toReturn(repNodes);
ProxyRepositoryFactory repFactory = mock(ProxyRepositoryFactory.class);
PowerMockito.mockStatic(ProxyRepositoryFactory.class);
when(ProxyRepositoryFactory.getInstance()).thenReturn(repFactory);
// $NON-NLS-1$
stub(method(ProxyRepositoryFactory.class, "save", Project.class, Item.class, boolean.class));
}
use of org.talend.dq.nodes.ReportRepNode in project tdq-studio-se by Talend.
the class RepNodeUtils method updateJrxmlRelatedReport.
/**
* when the report's user defined template(Jrxml file) changed its name, or be moved, the path info in the report's
* anaMap: jrxml source should also be updated. This method is used to update the related reports when the jrxml
* name or path is changed.
*
* @param jrxmlFileNames : the whole path with whole name of the jrxml, e.g./TDQ_Libraries/JRXML
* Template/columnset/column_set_basic_0.1.jrxml
* @param jrxmlFileNamesAfterMove
*/
public static void updateJrxmlRelatedReport(List<String> jrxmlFileNames, List<String> jrxmlFileNamesAfterMove) {
if (jrxmlFileNames.size() == 0 || jrxmlFileNamesAfterMove.size() == 0 || jrxmlFileNamesAfterMove.size() < jrxmlFileNames.size()) {
return;
}
Project project = ProjectManager.getInstance().getCurrentProject();
// get all reports
IRepositoryNode ReportRootFolderNode = RepositoryNodeHelper.getDataProfilingFolderNode(EResourceConstant.REPORTS);
List<ReportRepNode> repNodes = RepositoryNodeHelper.getReportRepNodes(ReportRootFolderNode, true, true);
// go through every report to :if any one used current jrxml-->modify its jrxml resource name
for (ReportRepNode report : repNodes) {
boolean isUpdated = false;
EList<AnalysisMap> analysisMap = ((TdReport) report.getReport()).getAnalysisMap();
for (AnalysisMap anaMap : analysisMap) {
for (int i = 0; i < jrxmlFileNames.size(); i++) {
String oldPath = jrxmlFileNames.get(i);
if (isUsedByJrxml(new Path(oldPath), anaMap)) {
// like: ../../../TDQ_Libraries/JRXML Template/column1/b01_column_basic_0.1.jrxml
String newPath = getRelativeJrxmlPath(report.getReport(), jrxmlFileNamesAfterMove.get(i));
// Added 20130128, using event/listener to refresh the page if opening
EventManager.getInstance().publish(report, EventEnum.DQ_JRXML_RENAME, newPath);
// save the new jrxml path.
anaMap.setJrxmlSource(newPath);
isUpdated = true;
}
}
}
if (isUpdated) {
try {
ProxyRepositoryFactory.getInstance().save(project, report.getObject().getProperty().getItem());
} catch (PersistenceException e) {
// $NON-NLS-1$
MessageUI.openError(DefaultMessagesImpl.getString("RepNodeUtils.updateReport.fail", report.getLabel()));
}
}
}
}
use of org.talend.dq.nodes.ReportRepNode in project tdq-studio-se by Talend.
the class ImageLib method getImageNameByRepositoryNode.
public static String getImageNameByRepositoryNode(IRepositoryNode node) {
String imageName = null;
IRepositoryViewObject viewObject = node.getObject();
ENodeType type = node.getType();
if (node instanceof ReportAnalysisRepNode) {
imageName = ImageLib.ANALYSIS_OBJECT;
} else if (node instanceof RecycleBinRepNode) {
imageName = ImageLib.RECYCLEBIN_EMPTY;
} else if (type.equals(ENodeType.SYSTEM_FOLDER)) {
String label = viewObject.getLabel();
if (label.equals(EResourceConstant.DATA_PROFILING.getName())) {
imageName = ImageLib.DATA_PROFILING;
} else if (label.equals(EResourceConstant.METADATA.getName())) {
imageName = ImageLib.METADATA;
} else if (node instanceof DBConnectionFolderRepNode) {
imageName = ImageLib.CONNECTION;
} else if (label.equals(EResourceConstant.FILEDELIMITED.getName())) {
imageName = ImageLib.FILE_DELIMITED;
} else if (label.equals(EResourceConstant.HADOOP_CLUSTER.getName())) {
imageName = ImageLib.HADOOP_CLUSTER;
} else if (label.equals(EResourceConstant.LIBRARIES.getName())) {
imageName = ImageLib.LIBRARIES;
} else if (label.equals(EResourceConstant.EXCHANGE.getName())) {
imageName = ImageLib.EXCHANGE;
} else {
imageName = ImageLib.FOLDERNODE_IMAGE;
}
} else if (type.equals(ENodeType.SIMPLE_FOLDER)) {
imageName = ImageLib.FOLDERNODE_IMAGE;
} else if (type.equals(ENodeType.REPOSITORY_ELEMENT)) {
if (node instanceof DBConnectionRepNode) {
imageName = ImageLib.TD_DATAPROVIDER;
} else if (node instanceof DFConnectionRepNode) {
imageName = ImageLib.FILE_DELIMITED;
} else if (node instanceof AnalysisRepNode) {
imageName = ImageLib.ANALYSIS_OBJECT;
} else if (node instanceof ReportRepNode) {
imageName = ImageLib.REPORT_OBJECT;
} else if (node instanceof SysIndicatorDefinitionRepNode) {
imageName = ImageLib.IND_DEFINITION;
} else if (node instanceof PatternRepNode) {
imageName = ImageLib.PATTERN_REG;
} else if (node instanceof RuleRepNode) {
imageName = ImageLib.DQ_RULE;
} else if (node instanceof SourceFileRepNode) {
imageName = ImageLib.SOURCE_FILE;
} else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
imageName = ImageLib.EXCHANGE;
} else if (node instanceof JrxmlTempleteRepNode) {
imageName = ImageLib.JRXML_ICON;
}
} else if (type.equals(ENodeType.TDQ_REPOSITORY_ELEMENT)) {
if (node instanceof DBCatalogRepNode) {
imageName = ImageLib.CATALOG;
} else if (node instanceof DBSchemaRepNode) {
imageName = ImageLib.SCHEMA;
} else if (node instanceof DBTableFolderRepNode) {
imageName = ImageLib.FOLDERNODE_IMAGE;
} else if (node instanceof DBViewFolderRepNode) {
imageName = ImageLib.FOLDERNODE_IMAGE;
} else if (node instanceof DBTableRepNode || node instanceof DFTableRepNode) {
imageName = ImageLib.TABLE;
} else if (node instanceof DBViewRepNode) {
imageName = ImageLib.VIEW;
} else if (node instanceof DBColumnRepNode) {
if (((DBColumnRepNode) node).isKey()) {
imageName = ImageLib.PK_COLUMN;
} else {
imageName = ImageLib.TD_COLUMN;
}
} else if (node instanceof DFColumnRepNode) {
imageName = ImageLib.TD_COLUMN;
} else if (node instanceof DBColumnFolderRepNode || node instanceof DFColumnFolderRepNode) {
imageName = ImageLib.FOLDERNODE_IMAGE;
}
}
return imageName;
}
Aggregations