use of org.talend.dataquality.indicators.definition.IndicatorDefinitionParameter in project tdq-studio-se by Talend.
the class ExportFactoryTest method testExportFileIFolderIndicatorDefinitionArray.
/**
* Test method for
* {@link org.talend.dataprofiler.core.pattern.ExportFactory#export(java.io.File, org.eclipse.core.resources.IFolder, org.talend.dataquality.indicators.definition.IndicatorDefinition[])}
* normal condition: exportFile is a file(not a folder).
*/
@Test
public void testExportFileIFolderIndicatorDefinitionArray() throws Exception {
File exportFile = new File(// $NON-NLS-1$ //$NON-NLS-2$
System.getProperty("java.io.tmpdir") + File.separator + StringUtilities.getRandomString(8) + ".csv");
IFolder udiFolder = ResourceManager.getUDIFolder();
IndicatorDefinition indDef = createExportIndicaorDefinition(udiFolder, getRandomUdiName());
ExportFactory.export(exportFile, udiFolder, indDef);
assertTrue(exportFile.exists());
assertTrue(exportFile.isFile());
assertTrue(exportFile.length() > 0);
CSVReader reader = FileUtils.createCSVReader(exportFile, FileUtils.TEXT_QUAL, FileUtils.TEXT_QUAL);
reader.setSkipEmptyRecords(true);
reader.readHeaders();
boolean haveRecord = false;
while (reader.readNext()) {
haveRecord = true;
String name = reader.get(PatternToExcelEnum.Label.getLiteral());
assertEquals(name, indDef.getName());
String paraString = reader.get(PatternToExcelEnum.IndicatorDefinitionParameter.getLiteral());
EList<IndicatorDefinitionParameter> indDefParas = indDef.getIndicatorDefinitionParameter();
for (IndicatorDefinitionParameter indDefPara : indDefParas) {
String temp = indDefPara.getKey() + UDIHelper.PARA_SEPARATE_1 + indDefPara.getValue() + UDIHelper.PARA_SEPARATE_2;
assertTrue(paraString.indexOf(temp) > -1);
}
}
reader.close();
assertTrue(haveRecord);
exportFile.delete();
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinitionParameter in project tdq-studio-se by Talend.
the class UDIMasterPage method attachDefiniationParameterCellEditors.
/**
* attach Definiation Parameter Cell Editors.
*
* @param table
* @param titles
*/
private void attachDefiniationParameterCellEditors(Composite table, String[] titles) {
parameterTableViewer.setCellModifier(new ICellModifier() {
public boolean canModify(Object element, String property) {
return true;
}
public Object getValue(Object element, String property) {
if (PARAMETERS_KEY.equals(property)) {
return ((IndicatorDefinitionParameter) element).getKey();
} else if (PARAMETERS_VALUE.equals(property)) {
return ((IndicatorDefinitionParameter) element).getValue();
}
return null;
}
public void modify(Object element, String property, Object value) {
TableItem tableItem = (TableItem) element;
IndicatorDefinitionParameter data = (IndicatorDefinitionParameter) tableItem.getData();
if (PARAMETERS_KEY.equals(property)) {
if (!data.getKey().equals(value.toString())) {
data.setKey(value.toString());
parameterTableViewer.refresh(data);
setDirty(true);
}
} else if (PARAMETERS_VALUE.equals(property)) {
if (!data.getValue().equals(value)) {
data.setValue((String) value);
parameterTableViewer.refresh(data);
setDirty(true);
}
}
}
});
parameterTableViewer.setColumnProperties(titles);
parameterTableViewer.setCellEditors(new CellEditor[] { new TextCellEditor(table), new TextCellEditor(table) });
}
Aggregations