Search in sources :

Example 1 with CharactersMapping

use of org.talend.dataquality.indicators.definition.CharactersMapping in project tdq-studio-se by Talend.

the class DbmsLanguageTest method testGetPatternFinderFunctionStringEListOfCharactersMappingCase1.

/**
 * Test method for
 * {@link org.talend.dq.dbms.DbmsLanguage#getPatternFinderFunction(java.lang.String, org.eclipse.emf.common.util.EList)}
 * .
 *
 * case 1 : netezza case
 */
@Test
public void testGetPatternFinderFunctionStringEListOfCharactersMappingCase1() {
    // $NON-NLS-1$
    String expectedResult = "TRANSLATE(name , \'abcdefghijklmnopqrstuvwxyzçâêîôûéèùïöüABCDEFGHIJKLMNOPQRSTUVWXYZÇÂÊÎÔÛÉÈÙÏÖÜ0123456789Netezza\' , \'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9999999999Netezza\')";
    NetezzaDbmsLanguage netezzaDbmsLanguage = (NetezzaDbmsLanguage) DbmsLanguageFactory.createDbmsLanguage(SupportDBUrlType.NETEZZADEFAULTURL);
    IndicatorDefinition createIndicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    EList<CharactersMapping> charactersMapping = createIndicatorDefinition.getCharactersMapping();
    CharactersMapping createCharactersMapping = DefinitionFactory.eINSTANCE.createCharactersMapping();
    // mysql
    createCharactersMapping.setLanguage(SupportDBUrlType.MYSQLDEFAULTURL.getLanguage());
    createCharactersMapping.setCharactersToReplace(// $NON-NLS-1$
    "abcdefghijklmnopqrstuvwxyzçâêîôûéèùïöüABCDEFGHIJKLMNOPQRSTUVWXYZÇÂÊÎÔÛÉÈÙÏÖÜ0123456789MySql");
    createCharactersMapping.setReplacementCharacters(// $NON-NLS-1$
    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9999999999MySql");
    charactersMapping.add(createCharactersMapping);
    // ~mysql
    // default
    createCharactersMapping.setLanguage(DbmsLanguage.SQL);
    createCharactersMapping.setCharactersToReplace(// $NON-NLS-1$
    "abcdefghijklmnopqrstuvwxyzçâêîôûéèùïöüABCDEFGHIJKLMNOPQRSTUVWXYZÇÂÊÎÔÛÉÈÙÏÖÜ0123456789Default");
    createCharactersMapping.setReplacementCharacters(// $NON-NLS-1$
    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9999999999Default");
    charactersMapping.add(createCharactersMapping);
    // ~default
    // netezza
    createCharactersMapping.setLanguage(SupportDBUrlType.NETEZZADEFAULTURL.getLanguage());
    createCharactersMapping.setCharactersToReplace(// $NON-NLS-1$
    "abcdefghijklmnopqrstuvwxyzçâêîôûéèùïöüABCDEFGHIJKLMNOPQRSTUVWXYZÇÂÊÎÔÛÉÈÙÏÖÜ0123456789Netezza");
    createCharactersMapping.setReplacementCharacters(// $NON-NLS-1$
    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9999999999Netezza");
    charactersMapping.add(createCharactersMapping);
    // ~netezza
    // $NON-NLS-1$
    String patternFinderFunction = netezzaDbmsLanguage.getPatternFinderFunction("name", charactersMapping);
    Assert.assertEquals(expectedResult, patternFinderFunction);
}
Also used : CharactersMapping(org.talend.dataquality.indicators.definition.CharactersMapping) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) Test(org.junit.Test)

Example 2 with CharactersMapping

use of org.talend.dataquality.indicators.definition.CharactersMapping in project tdq-studio-se by Talend.

the class DbmsLanguageTest method testGetPatternFinderFunctionStringEListOfCharactersMappingCase3.

/**
 * Test method for
 * {@link org.talend.dq.dbms.DbmsLanguage#getPatternFinderFunction(java.lang.String, org.eclipse.emf.common.util.EList)}
 * .
 *
 * case 3 : no default and no netezza
 */
@Test
public void testGetPatternFinderFunctionStringEListOfCharactersMappingCase3() {
    String expectedResult = null;
    NetezzaDbmsLanguage netezzaDbmsLanguage = (NetezzaDbmsLanguage) DbmsLanguageFactory.createDbmsLanguage(SupportDBUrlType.NETEZZADEFAULTURL);
    IndicatorDefinition createIndicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    EList<CharactersMapping> charactersMapping = createIndicatorDefinition.getCharactersMapping();
    CharactersMapping createCharactersMapping = DefinitionFactory.eINSTANCE.createCharactersMapping();
    // mysql
    createCharactersMapping.setLanguage(SupportDBUrlType.MYSQLDEFAULTURL.getLanguage());
    createCharactersMapping.setCharactersToReplace(// $NON-NLS-1$
    "abcdefghijklmnopqrstuvwxyzçâêîôûéèùïöüABCDEFGHIJKLMNOPQRSTUVWXYZÇÂÊÎÔÛÉÈÙÏÖÜ0123456789MySql");
    createCharactersMapping.setReplacementCharacters(// $NON-NLS-1$
    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9999999999MySql");
    charactersMapping.add(createCharactersMapping);
    // ~mysql
    // $NON-NLS-1$
    String patternFinderFunction = netezzaDbmsLanguage.getPatternFinderFunction("name", charactersMapping);
    Assert.assertEquals(expectedResult, patternFinderFunction);
}
Also used : CharactersMapping(org.talend.dataquality.indicators.definition.CharactersMapping) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) Test(org.junit.Test)

Example 3 with CharactersMapping

use of org.talend.dataquality.indicators.definition.CharactersMapping in project tdq-studio-se by Talend.

the class IndicatorDefinitionMaterPage method checkCorrectForCharacterMapping.

/**
 * DOC talend Comment method "checkDuplicateLanguage".
 *
 * @param rc
 * @return
 */
private ReturnCode checkCorrectForCharacterMapping() {
    ReturnCode rc = new ReturnCode();
    Map<String, Integer> languageCountMap = new HashMap<String, Integer>();
    Iterator<CharactersMapping> charMappIterator = charactersMappingMapTemp.values().iterator();
    while (charMappIterator.hasNext()) {
        CharactersMapping cm = charMappIterator.next();
        String language = cm.getLanguage();
        Integer languageCount = languageCountMap.get(language);
        if (languageCount == null) {
            languageCount = 1;
        } else {
            languageCount++;
        }
        languageCountMap.put(language, languageCount);
    }
    Iterator<String> iterator = languageCountMap.keySet().iterator();
    while (iterator.hasNext()) {
        String key = iterator.next();
        Integer integer = languageCountMap.get(key);
        if (integer > 1) {
            rc.setOk(false);
            // $NON-NLS-1$
            rc.setMessage(DefaultMessagesImpl.getString("IndicatorDefinitionMaterPage.isRepeatedCharMapp", key));
            return rc;
        }
    }
    return rc;
}
Also used : CharactersMapping(org.talend.dataquality.indicators.definition.CharactersMapping) ReturnCode(org.talend.utils.sugars.ReturnCode) HashMap(java.util.HashMap)

Example 4 with CharactersMapping

use of org.talend.dataquality.indicators.definition.CharactersMapping in project tdq-studio-se by Talend.

the class IndicatorDefinitionMaterPage method cloneCharactersMapping.

/**
 * DOC xqliu Comment method "cloneCharactersMapping".
 *
 * @param charactersMapping
 * @return
 */
private CharactersMapping cloneCharactersMapping(CharactersMapping charactersMapping) {
    if (charactersMapping != null) {
        CharactersMapping newCharactersMapping = DefinitionFactory.eINSTANCE.createCharactersMapping();
        newCharactersMapping.setLanguage(charactersMapping.getLanguage());
        newCharactersMapping.setCharactersToReplace(charactersMapping.getCharactersToReplace());
        newCharactersMapping.setReplacementCharacters(charactersMapping.getReplacementCharacters());
        return newCharactersMapping;
    }
    return null;
}
Also used : CharactersMapping(org.talend.dataquality.indicators.definition.CharactersMapping)

Example 5 with CharactersMapping

use of org.talend.dataquality.indicators.definition.CharactersMapping in project tdq-studio-se by Talend.

the class IndicatorDefinitionMaterPage method updateCharactersMapping.

private boolean updateCharactersMapping() {
    EList<CharactersMapping> charactersMappings = getCurrentModelElement().getCharactersMapping();
    charactersMappings.clear();
    for (CharactersMapping cm : charactersMappingMapTemp.values()) {
        String c = cm.getCharactersToReplace();
        String r = cm.getReplacementCharacters();
        if (checkMappingString(c, r)) {
            charactersMappings.add(cm);
        } else {
            MessageUI.openError(// $NON-NLS-1$
            "[" + cm.getLanguage() + // $NON-NLS-1$
            "] INPUT ERROR:\nThe length of two inputed strings are not equal.");
            return false;
        }
    }
    return true;
}
Also used : CharactersMapping(org.talend.dataquality.indicators.definition.CharactersMapping)

Aggregations

CharactersMapping (org.talend.dataquality.indicators.definition.CharactersMapping)12 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)4 Test (org.junit.Test)3 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)3 GridData (org.eclipse.swt.layout.GridData)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 TdColumn (org.talend.cwm.relational.TdColumn)1 ReturnCode (org.talend.utils.sugars.ReturnCode)1 Expression (orgomg.cwm.objectmodel.core.Expression)1