use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.
the class CreatePatternWizard method initCWMResourceBuilder.
public ModelElement initCWMResourceBuilder() {
patternBuilder = new PatternBuilder();
boolean patternInitialized = patternBuilder.initializePattern(parameter.getName());
if (patternInitialized) {
Pattern pattern = patternBuilder.getPattern();
String lang = PatternLanguageType.findLanguageByName(parameter.getLanguage());
String express = parameter.getExpression();
RegularExpression regularExpr = BooleanExpressionHelper.createRegularExpression(lang, express);
regularExpr.setExpressionType(type.getLiteral());
pattern.getComponents().add(regularExpr);
return pattern;
}
return null;
}
use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.
the class CreatePatternWizard method performFinish.
/**
* mzhao TDQ-4734 refresh the parent node of newly created pattern.
*/
@Override
public boolean performFinish() {
Boolean ret = super.performFinish();
if (modelElement instanceof Pattern) {
RepositoryNode patternNode = RepositoryNodeHelper.recursiveFindPattern((Pattern) modelElement);
CorePlugin.getDefault().refreshDQView(patternNode.getParent());
}
return ret;
}
use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.
the class ExportPatternsWizard method performFinish.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
@Override
public boolean performFinish() {
String targetFile = page.getTargetFile();
Object[] elements = page.getSelectedPatternsTree().getCheckedElements();
List<Pattern> seletedPatterns = new ArrayList<Pattern>();
for (Object element : elements) {
// MOD klliu 2011-03-08 bug 18657
if (element instanceof PatternRepNode) {
PatternRepNode patternNode = (PatternRepNode) element;
Pattern pattern = patternNode.getPattern();
seletedPatterns.add(pattern);
}
}
if ("".equals(targetFile)) {
// $NON-NLS-1$
MessageDialog.openError(getShell(), DefaultMessagesImpl.getString("ExportPatternsWizard.Error"), // $NON-NLS-1$ //$NON-NLS-2$
DefaultMessagesImpl.getString("ExportPatternsWizard.SpecifyValidResource"));
return false;
} else {
File resource = new File(targetFile);
if (isForExchange) {
ExportFactory.export(resource, folder, seletedPatterns.toArray(new Pattern[seletedPatterns.size()]));
for (Iterator<Pattern> iterator = seletedPatterns.iterator(); iterator.hasNext(); ) {
Pattern pattern = iterator.next();
// $NON-NLS-1$
File patternFile = new File(resource, ExportFactory.toLocalFileName(pattern.getName() + ".csv"));
if (patternFile.isFile() && patternFile.exists()) {
try {
// $NON-NLS-1$
FilesUtils.zip(patternFile, patternFile.getPath() + ".zip");
patternFile.delete();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
} else {
boolean isContinue = true;
if (resource.exists()) {
isContinue = MessageDialogWithToggle.openConfirm(null, // $NON-NLS-1$
DefaultMessagesImpl.getString("ExportPatternsWizard.waring"), // $NON-NLS-1$
DefaultMessagesImpl.getString("ExportPatternsWizard.fileAlreadyExist"));
}
if (!isContinue) {
return false;
}
ExportFactory.export(resource, folder, seletedPatterns.toArray(new Pattern[seletedPatterns.size()]));
}
CorePlugin.getDefault().refreshDQView(RepositoryNodeHelper.getLibrariesFolderNode(EResourceConstant.PATTERNS));
CorePlugin.getDefault().refreshWorkSpace();
return true;
}
}
use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.
the class ImportFactory method createAndStorePattern.
private static TypedReturnCode<Object> createAndStorePattern(PatternParameters parameters, IFolder selectionFolder, ExpressionType type) throws TalendInternalPersistenceException {
Pattern pattern = createPattern(parameters.name, parameters.auther, parameters.description, parameters.purpose, parameters.status);
for (String key : parameters.regex.keySet()) {
RegularExpression regularExpr = BooleanExpressionHelper.createRegularExpression(key, parameters.regex.get(key), type);
pattern.getComponents().add(regularExpr);
}
boolean validStatus = PatternUtilities.isPatternValid(pattern);
TaggedValueHelper.setValidStatus(validStatus, pattern);
try {
String relativePath = parameters.relativePath;
if (EResourceConstant.PATTERN_REGEX.getName().equals(relativePath) || EResourceConstant.PATTERN_SQL.getName().equals(relativePath)) {
relativePath = PluginConstant.EMPTY_STRING;
}
// $NON-NLS-1$
String[] folderNames = relativePath.split("/");
for (String folderName : folderNames) {
IFolder folder = selectionFolder.getFolder(folderName);
if (!folder.exists()) {
folder.create(false, true, null);
}
selectionFolder = folder;
}
} catch (CoreException e) {
log.error(e, e);
}
return ElementWriterFactory.getInstance().createPatternWriter().create(pattern, selectionFolder);
}
use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.
the class ImportFactory method createPattern.
/**
* DOC qzhang Comment method "createPattern".
*
* @param name
* @param author
* @param description
* @param purpose
* @param status
* @return
*/
private static Pattern createPattern(String name, String author, String description, String purpose, String status) {
Pattern pattern = PatternFactory.eINSTANCE.createPattern();
pattern.setName(name);
// $NON-NLS-1$
MetadataHelper.setAuthor(pattern, author == null ? "" : author);
// $NON-NLS-1$
MetadataHelper.setDescription(description == null ? "" : description, pattern);
// $NON-NLS-1$
MetadataHelper.setPurpose(purpose == null ? "" : purpose, pattern);
// MOD mzhao feature 7479 2009-10-16
// $NON-NLS-1$
MetadataHelper.setDevStatus(pattern, status == null ? "" : status);
return pattern;
}
Aggregations