use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.
the class PatternRepNode method getChildren.
@Override
public List<IRepositoryNode> getChildren() {
List<IRepositoryNode> languageElement = new ArrayList<IRepositoryNode>();
IRepositoryViewObject object = this.getObject();
TDQPatternItem patternItem = (TDQPatternItem) object.getProperty().getItem();
Pattern pattern = patternItem.getPattern();
EList<PatternComponent> components = pattern.getComponents();
for (PatternComponent component : components) {
RegularExpression re = (RegularExpression) component;
Expression expression = re.getExpression();
String language = expression.getLanguage();
PatternLanguageRepNode plrn = new PatternLanguageRepNode(this, ENodeType.TDQ_REPOSITORY_ELEMENT, getProject());
plrn.setRegularExpression(re);
plrn.setId(language);
plrn.setLabel(language);
languageElement.add(plrn);
}
// MOD gdbu 2011-7-11 bug : 22204
return filterResultsIfAny(languageElement);
// ~22204
}
use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.
the class ResultSetHelper method getResultSet.
public static ResultSet getResultSet(MetadataTable metadataTable, java.sql.Connection sqlConn, String whereExpression, int maxRows) throws SQLException {
Connection tdDataProvider = ConnectionHelper.getTdDataProvider(metadataTable);
if (sqlConn == null) {
IMetadataConnection metadataBean = ConvertionHelper.convert(tdDataProvider);
TypedReturnCode<java.sql.Connection> createConnection = MetadataConnectionUtils.createConnection(metadataBean, false);
if (!createConnection.isOk()) {
return null;
}
sqlConn = createConnection.getObject();
}
DbmsLanguage dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(tdDataProvider);
Statement createStatement = null;
if (maxRows != 0) {
// TOPN algorithm, it has row limited,no need the fetch size.
createStatement = dbmsLanguage.createStatement(sqlConn);
} else {
// Resevoir Sample algorithm
createStatement = dbmsLanguage.createStatement(sqlConn, 1000);
}
createStatement.setMaxRows(maxRows);
Expression columnQueryExpression = dbmsLanguage.getTableQueryExpression(metadataTable, whereExpression);
return createStatement.executeQuery(columnQueryExpression.getBody());
}
use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.
the class ExportFactory method getRelatedValueFromIndicatorDefinition.
private static Map<PatternToExcelEnum, String> getRelatedValueFromIndicatorDefinition(IndicatorDefinition indicatorDefinition, IFolder folder) {
Map<PatternToExcelEnum, String> idMap = new HashMap<PatternToExcelEnum, String>();
if (folder != null) {
IFile file = ResourceFileMap.findCorrespondingFile(indicatorDefinition);
URI relativeURI = folder.getLocationURI().relativize(file.getParent().getLocationURI());
// get the basic information
idMap.put(PatternToExcelEnum.Label, relpaceTempHasEscapeCharactor(indicatorDefinition.getName()));
idMap.put(PatternToExcelEnum.Purpose, relpaceTempHasEscapeCharactor(MetadataHelper.getPurpose(indicatorDefinition)));
idMap.put(PatternToExcelEnum.Description, relpaceTempHasEscapeCharactor(MetadataHelper.getDescription(indicatorDefinition)));
idMap.put(PatternToExcelEnum.Author, relpaceTempHasEscapeCharactor(MetadataHelper.getAuthor(indicatorDefinition)));
idMap.put(PatternToExcelEnum.RelativePath, relativeURI.toString());
idMap.put(PatternToExcelEnum.Category, UDIHelper.getUDICategory(indicatorDefinition).getLabel());
TaggedValue tagValue = TaggedValueHelper.getTaggedValue(TaggedValueHelper.CLASS_NAME_TEXT, indicatorDefinition.getTaggedValue());
idMap.put(PatternToExcelEnum.JavaClassName, tagValue == null ? null : tagValue.getValue());
tagValue = TaggedValueHelper.getTaggedValue(TaggedValueHelper.JAR_FILE_PATH, indicatorDefinition.getTaggedValue());
idMap.put(PatternToExcelEnum.JavaJarPath, tagValue == null ? null : tagValue.getValue());
for (PatternLanguageType languagetype : PatternLanguageType.values()) {
for (Expression expression : indicatorDefinition.getSqlGenericExpression()) {
if (expression != null && expression.getLanguage().equalsIgnoreCase(languagetype.getLiteral())) {
idMap.put(languagetype.getExcelEnum(), expression.getBody());
}
}
if (!idMap.containsKey(languagetype.getExcelEnum())) {
// $NON-NLS-1$
idMap.put(languagetype.getExcelEnum(), "");
}
}
// put the IndicatorDefinitionParameter into Map
StringBuffer strBuf = new StringBuffer();
EList<IndicatorDefinitionParameter> indDefParas = indicatorDefinition.getIndicatorDefinitionParameter();
for (IndicatorDefinitionParameter indDefPara : indDefParas) {
strBuf.append(indDefPara.getKey() + UDIHelper.PARA_SEPARATE_1 + indDefPara.getValue() + UDIHelper.PARA_SEPARATE_2);
}
idMap.put(PatternToExcelEnum.IndicatorDefinitionParameter, strBuf.toString());
}
return idMap;
}
use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.
the class DomainHelper method getExpression.
/**
* Method "getExpression".
*
* @param patternComponent
* @param language a language (see DbmsLanguage)
* @return the expression for the given language or null
*/
public static Expression getExpression(PatternComponent patternComponent, String language) {
if (patternComponent != null && patternComponent.eClass().equals(PatternPackage.eINSTANCE.getRegularExpression())) {
RegularExpression regExp = (RegularExpression) patternComponent;
Expression expr = regExp.getExpression();
if (expr != null && language != null && language.equalsIgnoreCase(regExp.getExpression().getLanguage())) {
return expr;
}
}
// not a regular expression
return null;
}
use of orgomg.cwm.objectmodel.core.Expression in project tdq-studio-se by Talend.
the class UDIHelper method validate.
public static ReturnCode validate(IndicatorDefinition indicatorDefinition) {
ReturnCode rc = new ReturnCode(true);
List<String> errorList = new ArrayList<String>();
// MOD mzhao feature 11128, In case of Java UDI, No expression is allowed to be saved.
if (!containsJavaUDI(indicatorDefinition)) {
if (0 == indicatorDefinition.getSqlGenericExpression().size()) {
// $NON-NLS-1$
errorList.add(Messages.getString("UDIHelper.validateNoExpression"));
rc.setOk(false);
}
}
if (PluginConstant.EMPTY_STRING.equals(indicatorDefinition.getName())) {
// $NON-NLS-1$
errorList.add(Messages.getString("UDIHelper.validateNoName"));
rc.setOk(false);
}
for (Expression exp : indicatorDefinition.getSqlGenericExpression()) {
if (null == exp.getBody() || exp.getBody().length() + 1 < MIN_EXPRESSION_LENGTH) {
// $NON-NLS-1$
errorList.add(Messages.getString("UDIHelper.validateTooShort"));
rc.setOk(false);
}
}
// $NON-NLS-1$
String message = Messages.getString("UDIHelper.validateCannotSave");
// $NON-NLS-1$
String wrap = System.getProperty("line.separator");
for (int i = 0; i < errorList.size(); i++) {
message += wrap + (i + 1) + org.talend.dataquality.PluginConstant.DOT_STRING + errorList.get(i);
}
rc.setMessage(message);
return rc;
}
Aggregations