use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.
the class DbmsLanguageTest method testSetFunctionReturnValueCase1.
/**
* {@link org.talend.dq.dbms.DbmsLanguage#setFunctionReturnValue(Expression)}.
*
* case 1:The body of expression is null
*/
@Test
public void testSetFunctionReturnValueCase1() {
// $NON-NLS-1$
DbmsLanguage dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(DbmsLanguage.MSSQL, "1.0");
Expression createExpression = CoreFactory.eINSTANCE.createExpression();
// $NON-NLS-1$
dbmsLanguage.setFunctionReturnValue(dbmsLanguage.extractRegularExpressionFunctionReturnValue(createExpression, "***"));
String regularfunctionReturnValue = dbmsLanguage.getFunctionReturnValue();
Assert.assertEquals(StringUtils.EMPTY, regularfunctionReturnValue);
}
use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.
the class DbmsLanguageTest method testSetFunctionReturnValueCase6.
/**
* {@link org.talend.dq.dbms.DbmsLanguage#setFunctionReturnValue(Expression)}.
*
* case 6: dbmsLanguage is sql
*/
@Test
public void testSetFunctionReturnValueCase6() {
// $NON-NLS-1$ //$NON-NLS-2$
DbmsLanguage dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage("sql", "1.0");
Expression createExpression = CoreFactory.eINSTANCE.createExpression();
// default Database
// $NON-NLS-1$
createExpression.setBody("**** WHEN RegularFunctionName(***)returnValue THEN **)****");
// $NON-NLS-1$
dbmsLanguage.setFunctionReturnValue(dbmsLanguage.extractRegularExpressionFunctionReturnValue(createExpression, "***"));
String regularfunctionReturnValue = dbmsLanguage.getFunctionReturnValue();
// $NON-NLS-1$
Assert.assertEquals("RETURNVALUE", regularfunctionReturnValue);
}
use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.
the class DbmsLanguageTest method testExtractRegularExpressionFunctionForOthers.
/**
* {@link org.talend.dq.dbms.DbmsLanguage#extractRegularExpressionFunction(Expression)}.
*
* case 7:Other database expression
*/
@Test
public void testExtractRegularExpressionFunctionForOthers() {
// $NON-NLS-1$ //$NON-NLS-2$
DbmsLanguage netezzaDbmsLanguage = DbmsLanguageFactory.createDbmsLanguage("SQL", "0.1");
Expression createExpression = CoreFactory.eINSTANCE.createExpression();
// default case
// $NON-NLS-1$
createExpression.setBody("**** WHEN RegularFunctionName(***)returnValue THEN **)****");
try {
// $NON-NLS-1$
netezzaDbmsLanguage.extractRegularExpressionFunction(createExpression, "***");
} catch (UnsupportedOperationException e) {
// $NON-NLS-1$
Assert.fail("Default DbmsLanguage don't should call extractRegularExpressionFunction method should thorw UnsupportedOperationException.");
}
}
use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.
the class AnalysisColumnTreeViewer method isExpressionNull.
private String isExpressionNull(TreeItem item) {
String expressContent = null;
ModelElement me = null;
IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
ModelElementIndicator meIndicator = (ModelElementIndicator) item.getData(MODELELEMENT_INDICATOR_KEY);
if (indicatorUnit != null) {
IRepositoryViewObject reposViewObj = meIndicator.getModelElementRepositoryNode().getObject();
// MetadataXmlElementTypeRepositoryObject
if (reposViewObj instanceof MetadataColumnRepositoryObject) {
me = ((MetadataColumnRepositoryObject) reposViewObj).getTdColumn();
}
Connection dataprovider = ModelElementHelper.getTdDataProvider(me);
DbmsLanguage dbmsLang = DbmsLanguageFactory.createDbmsLanguage(dataprovider);
Expression expression = dbmsLang.getInstantiatedExpression(indicatorUnit.getIndicator());
if (expression != null) {
expressContent = expression.getBody();
}
} else {
IRepositoryNode parentNodeForColumnNode = RepositoryNodeHelper.getParentNodeForColumnNode(meIndicator.getModelElementRepositoryNode());
expressContent = DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.columnParent", // $NON-NLS-1$ //;
parentNodeForColumnNode.getObject().getLabel());
}
return expressContent;
}
use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.
the class RegexPatternExplorer method initRegularExpressionParameter.
@Override
protected void initRegularExpressionParameter() {
// MOD gdbu 2011-12-5 TDQ-4087 get function name from sql sentence when use MSSQL
EList<Expression> instantiatedExpressions = indicator.getInstantiatedExpressions();
if (instantiatedExpressions.size() > 0) {
Expression expression = instantiatedExpressions.get(0);
String regexp = dbmsLanguage.getRegexPatternString(indicator);
dbmsLanguage.setRegularExpressionFunction(dbmsLanguage.extractRegularExpressionFunction(expression, regexp));
dbmsLanguage.setFunctionReturnValue(dbmsLanguage.extractRegularExpressionFunctionReturnValue(expression, regexp));
}
}
Aggregations