Search in sources :

Example 11 with IndicatorDefinitionParameter

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();
}
Also used : CSVReader(com.talend.csv.CSVReader) IndicatorDefinitionParameter(org.talend.dataquality.indicators.definition.IndicatorDefinitionParameter) File(java.io.File) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Example 12 with IndicatorDefinitionParameter

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) });
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) ICellModifier(org.eclipse.jface.viewers.ICellModifier) IndicatorDefinitionParameter(org.talend.dataquality.indicators.definition.IndicatorDefinitionParameter) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor)

Aggregations

IndicatorDefinitionParameter (org.talend.dataquality.indicators.definition.IndicatorDefinitionParameter)12 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)5 IFolder (org.eclipse.core.resources.IFolder)4 TdExpression (org.talend.cwm.relational.TdExpression)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 CSVReader (com.talend.csv.CSVReader)2 HashMap (java.util.HashMap)2 IFile (org.eclipse.core.resources.IFile)2 CoreException (org.eclipse.core.runtime.CoreException)2 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)2 ReturnCode (org.talend.utils.sugars.ReturnCode)2 Expression (orgomg.cwm.objectmodel.core.Expression)2 IOException (java.io.IOException)1 URI (java.net.URI)1 ICellModifier (org.eclipse.jface.viewers.ICellModifier)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1