use of org.talend.dataquality.domain.JavaUDIIndicatorParameter in project tdq-studio-se by Talend.
the class MyAndRegexIndicator method prepare.
@Override
public boolean prepare() {
this.reset();
String paramValue;
Pattern pattern;
if (parameters != null) {
final Domain dataValidDomain = parameters.getIndicatorValidDomain();
if (dataValidDomain != null) {
patternList.clear();
for (JavaUDIIndicatorParameter param : dataValidDomain.getJavaUDIIndicatorParameter()) {
if (param != null) {
if (param.getKey().startsWith("pattern")) {
paramValue = param.getValue();
pattern = Pattern.compile(paramValue);
patternList.add(pattern);
}
}
}
}
}
return !patternList.isEmpty();
}
use of org.talend.dataquality.domain.JavaUDIIndicatorParameter in project tdq-studio-se by Talend.
the class UDIUtils method createIndicatorUnit.
public static IndicatorUnit[] createIndicatorUnit(IndicatorDefinition udid, ModelElementIndicator meIndicator, Analysis analysis) throws Throwable {
List<IndicatorUnit> addIndicatorUnits = new ArrayList<IndicatorUnit>();
// can't add the same user defined indicator
for (Indicator indicator : meIndicator.getIndicators()) {
// MOD xwang 2011-08-01 bug TDQ-2730
if (udid.getName().equals(indicator.getName()) && indicator instanceof UserDefIndicator) {
// $NON-NLS-1$
MessageUI.openWarning(DefaultMessagesImpl.getString("UDIUtils.UDISelected", udid.getName()));
return null;
}
}
Indicator udi = UDIFactory.createUserDefIndicator(udid);
udi.setIndicatorDefinition(udid);
// MOD mzhao feature 11128, Handle Java User Defined Indicator.
Indicator judi = UDIHelper.adaptToJavaUDI(udi);
if (judi != null) {
udi = judi;
}
IEditorPart activeEditor = CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (activeEditor == null || !(activeEditor instanceof AnalysisEditor)) {
return null;
}
ExecutionLanguage executionLanguage = ((AnalysisEditor) activeEditor).getUIExecuteEngin();
boolean isJavaEngin = ExecutionLanguage.JAVA.equals(executionLanguage);
DbmsLanguage dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(analysis, executionLanguage);
Expression returnExpression = dbmsLanguage.getExpression(udi);
String executeType = isJavaEngin ? executionLanguage.getName() : dbmsLanguage.getDbmsName();
// MOD qiongli 2013.5.22 TDQ-7282.if don't find a valid java expression for JUDI,should also pop this dialog.
boolean finddExpression = true;
if (isJavaEngin && judi == null || !isJavaEngin && returnExpression == null) {
finddExpression = false;
}
if (!finddExpression) {
// open the editor
boolean openUDI = MessageDialog.openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DefaultMessagesImpl.getString("PatternUtilities.Warning"), // $NON-NLS-1$ //$NON-NLS-2$
DefaultMessagesImpl.getString("UDIUtils.NoExpression", executeType));
if (openUDI) {
RepositoryNode node = RepositoryNodeHelper.recursiveFind(udid);
if (RepositoryNodeHelper.canOpenEditor(node)) {
new OpenItemEditorAction(new IRepositoryNode[] { node }).run();
}
}
return null;
}
// dbmsLanguage
IndicatorParameters parameters = udi.getParameters();
if (parameters == null) {
parameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
udi.setParameters(parameters);
}
Domain indicatorValidDomain = parameters.getIndicatorValidDomain();
if (indicatorValidDomain == null) {
// $NON-NLS-1$
indicatorValidDomain = DomainHelper.createDomain("JAVA_UDI_PARAMETERS");
parameters.setIndicatorValidDomain(indicatorValidDomain);
}
List<IndicatorDefinitionParameter> indicatorDefs = udid.getIndicatorDefinitionParameter();
for (IndicatorDefinitionParameter idp : indicatorDefs) {
JavaUDIIndicatorParameter judip = DomainHelper.createJavaUDIIndicatorParameter(idp.getKey(), idp.getValue());
indicatorValidDomain.getJavaUDIIndicatorParameter().add(judip);
}
IndicatorEnum indicatorType = IndicatorEnum.findIndicatorEnum(udi.eClass());
addIndicatorUnits.add(meIndicator.addSpecialIndicator(indicatorType, udi));
DependenciesHandler.getInstance().setUsageDependencyOn(analysis, udid);
return addIndicatorUnits.toArray(new IndicatorUnit[addIndicatorUnits.size()]);
}
use of org.talend.dataquality.domain.JavaUDIIndicatorParameter in project tdq-studio-se by Talend.
the class JavaUDIParametersForm method initialize.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.ui.wizard.indicator.forms.AbstractForm#initialize()
*/
@Override
protected void initialize() {
EList<JavaUDIIndicatorParameter> javaUDIIndicatorParameter = parameters.getIndicatorValidDomain().getJavaUDIIndicatorParameter();
for (JavaUDIIndicatorParameter judip : javaUDIIndicatorParameter) {
content.add(judip);
}
viewer.refresh(content);
}
use of org.talend.dataquality.domain.JavaUDIIndicatorParameter in project tdq-studio-se by Talend.
the class EMailValidationIndicator method initParameters.
boolean initParameters() {
// Check prerequisite
IndicatorParameters param = this.getParameters();
if (param == null) {
// $NON-NLS-1$
log.error("No parameter set in the user defined indicator " + this.getName());
return false;
}
Domain indicatorValidDomain = param.getIndicatorValidDomain();
if (indicatorValidDomain == null) {
// $NON-NLS-1$
log.error("No parameter set in the user defined indicator " + this.getName());
return false;
}
// else retrieve email from parameter
EList<JavaUDIIndicatorParameter> javaUDIIndicatorParameter = indicatorValidDomain.getJavaUDIIndicatorParameter();
for (JavaUDIIndicatorParameter p : javaUDIIndicatorParameter) {
if (EMAIL_PARAM.equalsIgnoreCase(p.getKey())) {
this.emailAddress = p.getValue();
} else if (INVALID_PARAM.equalsIgnoreCase(p.getKey())) {
this.storeInvalidData = true;
// TODO add more checks on the file
try {
this.tempInvalidData = new StringBuffer();
this.os = new FileOutputStream(new File(p.getValue()));
} catch (FileNotFoundException e) {
// $NON-NLS-1$
log.error("Invalid file path in the user defined indicator: " + this.getName(), e);
return false;
}
} else if (BUFFER_SIZE_PARAM.equalsIgnoreCase(p.getKey())) {
try {
this.buffSize = Integer.valueOf(p.getValue());
} catch (Exception e) {
// $NON-NLS-1$
log.error("Invalid buffer size: " + p.getValue(), e);
return false;
}
} else {
// log warn but keep running (don't return false)
if (!NAMING_PARAM.equalsIgnoreCase(p.getKey())) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
log.warn("Unknown parameter given to UDI: " + this.getName() + ": " + p.getKey() + " = " + p.getValue());
}
}
}
if (!this.isAddressValid(emailAddress)) {
log.error(// $NON-NLS-1$ //$NON-NLS-2$
"Invalid sender email set in parameters of the user defined indicator \"" + this.getName() + "\": " + emailAddress);
return false;
}
return true;
}
use of org.talend.dataquality.domain.JavaUDIIndicatorParameter in project tdq-studio-se by Talend.
the class MyOrRegexIndicator method prepare.
@Override
public boolean prepare() {
String paramValue;
Pattern pattern;
if (parameters != null) {
final Domain dataValidDomain = parameters.getIndicatorValidDomain();
if (dataValidDomain != null) {
patternList.clear();
for (JavaUDIIndicatorParameter param : dataValidDomain.getJavaUDIIndicatorParameter()) {
if (param != null) {
if (param.getKey().startsWith("pattern")) {
paramValue = param.getValue();
pattern = Pattern.compile(paramValue);
patternList.add(pattern);
}
}
}
}
}
return super.prepare();
}
Aggregations