use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.
the class RespositoryDetailView method createFileDetail.
private boolean createFileDetail(boolean is, IRepositoryViewObject reposViewObj) {
// MOD klliu 2001-02-28 bug 19154
if (reposViewObj.getProperty() != null) {
Item item = reposViewObj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
createDataProviderDetail(conn);
is = false;
}
if (item instanceof TDQAnalysisItem) {
Analysis analysis = ((TDQAnalysisItem) item).getAnalysis();
createAnaysisDetail(analysis);
is = false;
}
if (item instanceof TDQPatternItem) {
Pattern pattern = ((TDQPatternItem) item).getPattern();
createPatternDetail(pattern);
is = false;
}
if (item instanceof TDQReportItem) {
Report report = ((TDQReportItem) item).getReport();
createReportDetail(report);
is = false;
}
}
return is;
}
use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.
the class FileSystemImportWriter method mergePattern.
/**
* when imported pattern is from lower version, even if it is modified, the "modify date" is still null, so, even if
* the modify date is null ,still do the comparation. [for Pattern matadata(Purpose, Description, Author, Status):
* 1) will replace old value with new value if new value is not blank; 2) will keep old value if new value is blank]
*
* @param record
* @param patternItem
*/
protected void mergePattern(ItemRecord record, TDQPatternItem patternItem) {
// only when the Si is modified, do the save
boolean isModified = false;
// old objects
Pattern pattern = patternItem.getPattern();
Property patternProp = patternItem.getProperty();
// new objects
Pattern recordPattern = (Pattern) record.getElement();
Property recordProp = record.getProperty();
// get expression list from record
EList<PatternComponent> importComponents = recordPattern.getComponents();
// for each expression:
for (PatternComponent component : importComponents) {
// if the modify date ==null, maybe it is from lower version, still do the compare
TdExpression importEx = ((RegularExpression) component).getExpression();
PatternComponent replaced = null;
for (PatternComponent pComp : pattern.getComponents()) {
TdExpression pex = ((RegularExpression) pComp).getExpression();
if (importEx.getLanguage().equals(pex.getLanguage())) {
replaced = pComp;
break;
}
}
// if new, add to SI
if (replaced == null) {
pattern.getComponents().add(createPatternComponent(component));
isModified = true;
} else {
// if the expression are different: compare the modify date, make the SI keep the new one
if (replaceExpression(((RegularExpression) replaced).getExpression(), importEx)) {
pattern.getComponents().remove(replaced);
pattern.getComponents().add(createPatternComponent(component));
isModified = true;
}
}
}
// for Pattern Metadata
if (patternProp != null && recordProp != null) {
if (!StringUtils.isBlank(recordProp.getPurpose())) {
patternProp.setPurpose(recordProp.getPurpose());
}
if (!StringUtils.isBlank(recordProp.getDescription())) {
patternProp.setDescription(recordProp.getDescription());
}
patternProp.setAuthor(recordProp.getAuthor());
patternProp.setStatusCode(recordProp.getStatusCode());
isModified = true;
}
if (isModified) {
ElementWriterFactory.getInstance().createPatternWriter().save(patternItem, false);
}
}
use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.
the class USStateCodesPatternRegexTest method setUpBeforeClass.
@BeforeClass
public static void setUpBeforeClass() throws Exception {
DQStructureManager.getInstance().createDQStructure();
IFolder patternRegexFolder = ResourceManager.getPatternRegexFolder();
// $NON-NLS-1$
IFolder folder = patternRegexFolder.getFolder("address");
// $NON-NLS-1$
IFile file = folder.getFile("US_State_Codes_0.1.pattern");
Assert.assertTrue(file.exists());
ModelElement modelElement = PatternResourceFileHelper.getInstance().getModelElement(file);
if (Pattern.class.isInstance(modelElement)) {
regexp = DomainHelper.getRegexp((Pattern) modelElement, DbmsLanguage.SQL);
if (regexp.charAt(0) == '\'') {
regexp = regexp.substring(1);
}
if (regexp.charAt(regexp.length() - 1) == '\'') {
regexp = regexp.substring(0, regexp.length() - 2);
}
}
}
use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.
the class AnalysisHandleTest method addPatternToDomain.
private static void addPatternToDomain(Domain domain, RegularExpression filter, String patternName) {
Pattern pattern = PatternFactory.eINSTANCE.createPattern();
pattern.setName(patternName);
pattern.getComponents().add(filter);
domain.getPatterns().add(pattern);
domain.getOwnedElement().add(pattern);
}
use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.
the class IndicatorHelperTest method testGetPattern_1.
/**
* Test method for get pattern based on indicator.
*/
@Test
public void testGetPattern_1() {
Indicator indicator = IndicatorsFactory.eINSTANCE.createRegexpMatchingIndicator();
IndicatorParameters parameters = IndicatorsFactory.eINSTANCE.createIndicatorParameters();
Domain validData = DomainFactory.eINSTANCE.createDomain();
Pattern pattern = PatternFactory.eINSTANCE.createPattern();
// $NON-NLS-1$
pattern.setName("Blank Text");
validData.getPatterns().add(pattern);
parameters.setDataValidDomain(validData);
indicator.setParameters(parameters);
Pattern pattern2 = IndicatorHelper.getPattern(indicator);
assert (pattern2 != null);
assert (pattern2.equals(pattern));
}
Aggregations