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);
}
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);
}
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;
}
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;
}
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;
}
Aggregations