use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.
the class PatternLabelProvider method getPatternRepNodesByIndicator.
/**
* get the repository nodes corresponding to the indicator.
*
* @param meIndicator
* @return
*/
public static Object[] getPatternRepNodesByIndicator(ModelElementIndicator meIndicator) {
List<IRepositoryNode> patternRepNodes = RepositoryNodeHelper.getPatternsRepositoryNodes(false);
ArrayList<Object> ret = new ArrayList<Object>();
for (Indicator indicator : meIndicator.getPatternIndicators()) {
Pattern patternInAnalysis = IndicatorHelper.getPattern(indicator);
for (IRepositoryNode patternRepNode : patternRepNodes) {
Pattern pattern = ((PatternRepNode) patternRepNode).getPattern();
if (StringUtils.equals(ResourceHelper.getUUID(patternInAnalysis), ResourceHelper.getUUID(pattern))) {
ret.add(patternRepNode);
}
}
}
return ret.toArray();
}
use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.
the class PatternLabelProvider method createPatternCheckedTreeSelectionDialog.
/**
* create CheckedTreeSelectionDialog for patterns.
*
* @param node Pattern root RepositoryNode.
* @return
*/
public static CheckedTreeSelectionDialog createPatternCheckedTreeSelectionDialog(IRepositoryNode node) {
CheckedTreeSelectionDialog dialog = new CheckedTreeSelectionDialog(null, new DQRepositoryViewLabelProvider(), new ResourceViewContentProvider());
dialog.setInput(node);
dialog.setValidator(new ISelectionStatusValidator() {
public IStatus validate(Object[] selection) {
for (Object patte : selection) {
if (patte instanceof PatternRepNode) {
PatternRepNode patternNode = (PatternRepNode) patte;
Pattern findPattern = patternNode.getPattern();
boolean validStatus = TaggedValueHelper.getValidStatus(findPattern);
if (!validStatus) {
return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, DefaultMessagesImpl.getString(// $NON-NLS-1$
"AnalysisColumnTreeViewer.chooseValidPatterns"));
}
}
}
return new // $NON-NLS-1$
Status(// $NON-NLS-1$
IStatus.OK, // $NON-NLS-1$
PlatformUI.PLUGIN_ID, // $NON-NLS-1$
IStatus.OK, // $NON-NLS-1$
"", null);
}
});
dialog.setContainerMode(true);
// $NON-NLS-1$
dialog.setTitle(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.patternSelector"));
// $NON-NLS-1$
dialog.setMessage(DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.patterns"));
dialog.setSize(80, 30);
return dialog;
}
use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.
the class PatternLabelProvider method getText.
@Override
public String getText(Object element) {
if (element instanceof IFile) {
IFile file = (IFile) element;
Pattern pattern = PatternResourceFileHelper.getInstance().findPattern(file);
if (pattern != null) {
return pattern.getName();
}
}
if (element instanceof IFolder) {
return ((IFolder) element).getName();
}
// $NON-NLS-1$
return "";
}
use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.
the class UpdateStartWithBlankPatternTask method doExecute.
/*
* (non-Jsdoc) update the regular express for java
*/
@Override
protected boolean doExecute() throws Exception {
IPath realtivePath = // $NON-NLS-1$
ResourceManager.getPatternRegexFolder().getFullPath().append("/text").makeRelativeTo(ResourceManager.getRootProject().getFullPath());
RootContainer<String, IRepositoryViewObject> tdqViewObjects = ProxyRepositoryFactory.getInstance().getTdqRepositoryViewObjects(ERepositoryObjectType.TDQ_PATTERN_REGEX, realtivePath.toString());
for (IRepositoryViewObject viewObject : tdqViewObjects.getMembers()) {
Item item = viewObject.getProperty().getItem();
Pattern pattern = null;
if (item != null && item instanceof TDQPatternItem) {
TDQPatternItem patternItem = (TDQPatternItem) item;
pattern = patternItem.getPattern();
boolean isFound = false;
if (PATTERN_NAME.equals(pattern.getName())) {
EList<PatternComponent> components = pattern.getComponents();
for (PatternComponent pComponet : components) {
RegularExpressionImpl regularExpress = (RegularExpressionImpl) pComponet;
if (JAVA_LANGUAGE.equals(regularExpress.getExpression().getLanguage())) {
regularExpress.getExpression().setBody(JAVA_REGULAR_EXPRESSION);
patternItem.setPattern(pattern);
// MOD yyi 2012-02-08 TDQ-4621:Explicitly set true for updating dependencies.
ElementWriterFactory.getInstance().createPatternWriter().save(patternItem, true);
isFound = true;
break;
}
}
}
if (isFound) {
break;
}
}
}
return true;
}
use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.
the class UpdateSomePatternToMatchMysql method doExecute.
@Override
protected boolean doExecute() throws Exception {
if (updateFile == null) {
updateFile = getWorkspacePath().append(UPDATE_FILE_NAME).toFile();
}
if (!updateFile.exists()) {
// if International_phone_number.pattern don't exsit.
return true;
}
URI uri = URI.createFileURI(updateFile.getAbsolutePath());
Resource patternResource = EMFSharedResources.getInstance().reloadResource(uri);
if (patternResource != null) {
Pattern thePattern = retirePattern(patternResource);
for (PatternComponent currentExpression : thePattern.getComponents()) {
if (currentExpression instanceof RegularExpression) {
if (PatternLanguageType.MYSQL.getLiteral().equals(((RegularExpression) currentExpression).getExpression().getLanguage())) {
// if the case of Mysql has been added.
return true;
}
}
}
String language = PatternLanguageType.MYSQL.getLiteral();
RegularExpression newRegularExpress = BooleanExpressionHelper.createRegularExpression(language, EXPRESSIONBODY);
String expressionType = DomainHelper.getExpressionType(thePattern);
newRegularExpress.setExpressionType(expressionType);
List<PatternComponent> componentsList = new ArrayList<PatternComponent>();
componentsList.add(newRegularExpress);
componentsList.addAll(thePattern.getComponents());
thePattern.getComponents().clear();
thePattern.getComponents().addAll(componentsList);
ReturnCode rc = PatternResourceFileHelper.getInstance().save(thePattern);
uri = URI.createFileURI(updateFile.getAbsolutePath());
EMFSharedResources.getInstance().reloadResource(uri);
return rc.isOk();
} else {
// $NON-NLS-1$
log.error(DefaultMessagesImpl.getString("UpdateSomePatternToMatchMysql_logErr", patternResource));
return false;
}
}
Aggregations