use of org.talend.dataquality.properties.TDQReportItem in project tdq-studio-se by Talend.
the class AElementPersistanceRealTest method testSaveWithoutDependenciesReport.
/**
* Test method for
* {@link org.talend.dq.writer.AElementPersistance#saveWithoutDependencies(org.talend.core.model.properties.Item, orgomg.cwm.objectmodel.core.ModelElement)}
* .
*
* @throws PersistenceException
*/
@Test
public void testSaveWithoutDependenciesReport() throws PersistenceException {
ReportWriter createReportWriter = ElementWriterFactory.getInstance().createReportWriter();
// create analysis
Analysis createAnalysis = AnalysisFactory.eINSTANCE.createAnalysis();
AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
createAnalysis.setResults(createAnalysisResult);
// $NON-NLS-1$
createAnalysis.setName("AElementPersistanceRealTestanalysis6");
// create analysis item
TDQAnalysisItem createTDQAnalysisItem = PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
createTDQAnalysisItem.setAnalysis(createAnalysis);
Property createAnalysisProperty = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
// $NON-NLS-1$
createAnalysisProperty.setLabel("AElementPersistanceRealTestanalysis6");
createAnalysisProperty.setId(EcoreUtil.generateUUID());
createTDQAnalysisItem.setProperty(createAnalysisProperty);
ProxyRepositoryFactory.getInstance().create(createTDQAnalysisItem, Path.EMPTY, false);
// create report
TdReport createTdReport = ReportsFactory.eINSTANCE.createTdReport();
TDQReportItem createTDQReportItem = PropertiesFactory.eINSTANCE.createTDQReportItem();
createTDQReportItem.setReport(createTdReport);
Property createReportProperty = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
// $NON-NLS-1$
createReportProperty.setLabel("AElementPersistanceRealTestreport6");
createTDQReportItem.setProperty(createReportProperty);
createReportProperty.setId(EcoreUtil.generateUUID());
ProxyRepositoryFactory.getInstance().create(createTDQReportItem, Path.EMPTY, false);
createTdReport.addAnalysis(createAnalysis);
// $NON-NLS-1$
String repName = "rep61";
// $NON-NLS-1$
String exceptedFileName = repName + "_0.1.rep";
createTdReport.setName(repName);
ReturnCode create = createReportWriter.saveWithoutDependencies(createTDQReportItem, createTdReport);
assertTrue(create.isOk());
Assert.assertEquals(exceptedFileName, createTDQReportItem.getFilename());
// $NON-NLS-1$
String repName2 = "rep62";
// $NON-NLS-1$
String exceptedFileName2 = repName2 + "_0.1.rep";
createTdReport.setName(repName2);
create = createReportWriter.saveWithDependencies(createTDQReportItem, createTdReport);
assertTrue(create.isOk());
Assert.assertEquals(exceptedFileName2, createTDQReportItem.getFilename());
}
use of org.talend.dataquality.properties.TDQReportItem in project tdq-studio-se by Talend.
the class UnitTestBuildHelper method createRealReport.
/**
* DOC talend Comment method "createRealReport".
*
* @param name the name of report
* @param folder the path which report location
* @param isDelete the report whether is logic delate
*/
public static Report createRealReport(String name, IFolder folder, Boolean isDelete) {
IPath createPath = Path.EMPTY;
if (folder != null) {
createPath = new Path(folder.getFullPath().lastSegment());
}
Report report1 = ReportHelper.createReport(name);
TDQReportItem item1 = PropertiesFactoryImpl.eINSTANCE.createTDQReportItem();
org.talend.core.model.properties.Property property1 = PropertiesFactory.eINSTANCE.createProperty();
property1.setId(EcoreUtil.generateUUID());
property1.setItem(item1);
property1.setLabel(report1.getName());
item1.setProperty(property1);
item1.setReport(report1);
ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
itemState.setDeleted(isDelete);
item1.setState(itemState);
try {
ProxyRepositoryFactory.getInstance().create(item1, createPath, false);
} catch (PersistenceException e) {
Assert.fail(e.getMessage());
}
return report1;
}
use of org.talend.dataquality.properties.TDQReportItem 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.dataquality.properties.TDQReportItem in project tdq-studio-se by Talend.
the class ResourceViewLabelProviderTest method createReport.
private void createReport(String name, IPath createPath, Boolean isDelete) {
Report report1 = ReportHelper.createReport(name);
TDQReportItem item1 = PropertiesFactoryImpl.eINSTANCE.createTDQReportItem();
org.talend.core.model.properties.Property property1 = PropertiesFactory.eINSTANCE.createProperty();
property1.setId(EcoreUtil.generateUUID());
property1.setItem(item1);
property1.setLabel(report1.getName());
item1.setProperty(property1);
item1.setReport(report1);
ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
itemState.setDeleted(isDelete);
item1.setState(itemState);
try {
ProxyRepositoryFactory.getInstance().create(item1, createPath, false);
} catch (PersistenceException e) {
Assert.fail(e.getMessage());
}
}
use of org.talend.dataquality.properties.TDQReportItem in project tdq-studio-se by Talend.
the class PropertyHelper method getModelElement.
/**
* DOC bZhou Comment method "getModelElement".
*
* Get model element from property recognized by current system.
*
* @param property
* @return
*/
public static ModelElement getModelElement(Property property) {
Item item = property.getItem();
assert item != null;
ModelElement element = (ModelElement) new org.talend.core.model.properties.util.PropertiesSwitch() {
@Override
public Object caseDatabaseConnectionItem(DatabaseConnectionItem object) {
return object.getConnection();
}
@Override
public Object caseMDMConnectionItem(MDMConnectionItem object) {
return object.getConnection();
}
@Override
public Object caseDelimitedFileConnectionItem(DelimitedFileConnectionItem object) {
return object.getConnection();
}
}.doSwitch(item);
if (element == null) {
element = new org.talend.dataquality.properties.util.PropertiesSwitch<ModelElement>() {
@Override
public ModelElement caseTDQReportItem(TDQReportItem object) {
return object.getReport();
}
@Override
public ModelElement caseTDQAnalysisItem(TDQAnalysisItem object) {
return object.getAnalysis();
}
@Override
public ModelElement caseTDQBusinessRuleItem(TDQBusinessRuleItem object) {
return object.getDqrule();
}
/*
* (non-Javadoc)
*
* @see
* org.talend.dataquality.properties.util.PropertiesSwitch#caseTDQMatchRuleItem(org.talend.dataquality
* .properties.TDQMatchRuleItem)
*/
@Override
public ModelElement caseTDQMatchRuleItem(TDQMatchRuleItem object) {
return object.getMatchRule();
}
@Override
public ModelElement caseTDQIndicatorDefinitionItem(TDQIndicatorDefinitionItem object) {
return object.getIndicatorDefinition();
}
@Override
public ModelElement caseTDQPatternItem(TDQPatternItem object) {
return object.getPattern();
}
}.doSwitch(item);
}
return element;
}
Aggregations