use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class AbstractAnalysisMetadataPage method getDqRules.
/**
* ADD gdbu 2011-6-1 bug : 19833
*
* DOC gdbu Comment method "getDqRules". Get all DQRule from analysis.
*
* @param analysis
* @return
*/
public List<DQRule> getDqRules(Analysis analysis) {
List<DQRule> result = new ArrayList<DQRule>();
EList<Indicator> indicators = analysis.getResults().getIndicators();
for (Indicator indicator : indicators) {
IndicatorDefinition indicatorDefinition = indicator.getIndicatorDefinition();
if (indicatorDefinition instanceof DQRule) {
result.add((DQRule) indicatorDefinition);
}
}
return result;
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class IndicatorDefinitionActionProvider method fillContextMenu.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
*/
@Override
public void fillContextMenu(IMenuManager menu) {
// MOD mzhao user readonly role on svn repository mode.
if (!isShowMenu()) {
return;
}
TreeSelection currentSelection = ((TreeSelection) this.getContext().getSelection());
List<IndicatorDefinition> list = new ArrayList<IndicatorDefinition>();
Object[] objs = currentSelection.toArray();
for (Object obj : objs) {
if (obj instanceof RepositoryNode) {
RepositoryNode node = (RepositoryNode) obj;
if (ERepositoryObjectType.TDQ_INDICATOR_ELEMENT.equals(node.getContentType())) {
TDQIndicatorDefinitionItem item = (TDQIndicatorDefinitionItem) node.getObject().getProperty().getItem();
list.add(item.getIndicatorDefinition());
}
}
}
if (!list.isEmpty()) {
menu.add(new OpenIndicatorDefinitionAction(list.toArray(new IndicatorDefinition[list.size()])));
}
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class ImportFactoryTest method testImportIndicatorToStucture.
/**
* Test method for
* {@link org.talend.dataprofiler.core.pattern.ImportFactory#importIndicatorToStucture(org.talend.dataprofiler.core.ui.action.actions.ImportObject, org.eclipse.core.resources.IFolder, boolean, boolean, java.lang.String)}
* normal condition: the import file's extension is csv.
*/
@Test
public void testImportIndicatorToStucture() throws Exception {
// $NON-NLS-1$
File importFile = createImportFile(UDI_NAME, StringUtilities.getRandomString(8) + ".csv");
assertTrue(importFile.exists());
assertTrue(importFile.isFile());
assertTrue(importFile.length() > 0);
List<File> pJarfiles = new ArrayList<File>();
ImportObject importObject = ImportObject.createImportObject(importFile, pJarfiles);
IFolder udiFolder = ResourceManager.getUDIFolder();
boolean skip = false;
boolean rename = true;
List<ReturnCode> rc = ImportFactory.importIndicatorToStucture(importObject, udiFolder, skip, rename, UDI_NAME);
assertTrue(rc.size() == 1);
assertTrue(rc.get(0).isOk());
IndicatorDefinition indicatorDefinition = null;
RootContainer<String, IRepositoryViewObject> tdqViewObjects = ProxyRepositoryFactory.getInstance().getTdqRepositoryViewObjects(ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS, ERepositoryObjectType.getFolderName(ERepositoryObjectType.TDQ_USERDEFINE_INDICATORS));
for (IRepositoryViewObject viewObject : tdqViewObjects.getMembers()) {
IndicatorDefinition indDefTemp = ((TDQIndicatorDefinitionItem) viewObject.getProperty().getItem()).getIndicatorDefinition();
if (UDI_NAME.equals(indDefTemp.getName())) {
indicatorDefinition = indDefTemp;
break;
}
}
assertNotNull(indicatorDefinition);
if (indicatorDefinition != null) {
EList<IndicatorDefinitionParameter> indDefParas = indicatorDefinition.getIndicatorDefinitionParameter();
assertFalse(indDefParas.isEmpty());
// String paraString = StringUtils.replace(IND_DEF_PARA_STRING, "\"\"", "\""); //$NON-NLS-1$ //$NON-NLS-2$
for (IndicatorDefinitionParameter indDefPara : indDefParas) {
String temp = indDefPara.getKey() + UDIHelper.PARA_SEPARATE_1 + indDefPara.getValue() + UDIHelper.PARA_SEPARATE_2;
assertTrue(IND_DEF_PARA_STRING.indexOf(temp) > -1);
}
}
importFile.delete();
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class SplitSysIndicatorTask method updateIndDefinition.
private void updateIndDefinition(Indicator ind) {
if (ind == null) {
return;
}
IndicatorDefinition indicatorDefinition = ind.getIndicatorDefinition();
if (indicatorDefinition == null) {
return;
}
// ADD xqliu 2010-07-28 13676 don't update UserDefIndicator
if (ind instanceof UserDefIndicator) {
return;
}
// ~ 13676
CwmResource indDefResource = (CwmResource) indicatorDefinition.eResource();
if (indDefResource == null) {
// MOD scorreia 2010-10-05 16030 set the link between indicators and their definition
if (DefinitionHandler.getInstance().setDefaultIndicatorDefinition(ind)) {
if (log.isDebugEnabled()) {
log.debug(// $NON-NLS-1$//$NON-NLS-2$
"MIGRATING: indicator definition " + indicatorDefinition.getName() + " in indicator " + ind.getName() + " in analysis " + // $NON-NLS-1$
ind.eResource());
}
} else {
log.error(DefaultMessagesImpl.getString("SplitSysIndicatorTask_LogErr", indicatorDefinition.getName(), ind.getName(), // $NON-NLS-1$
ind.eResource()));
}
// ~ 16030
} else {
// Find updated indicator definition
IndicatorDefinition updatedDefinition = DefinitionHandler.getInstance().getDefinitionById(indDefResource.getID(ind.getIndicatorDefinition()));
ind.setIndicatorDefinition(updatedDefinition);
}
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class UpdateModeIndicatorDefinitionForAS400Task method doExecute.
@Override
protected boolean doExecute() throws Exception {
boolean result = true;
try {
IndicatorDefinition indicatorDefinition = DefinitionHandler.getInstance().getIndicatorDefinition(MODE_INDICATOR_LABEL);
URI uriItem = indicatorDefinition.eResource().getURI();
File fileItem = null;
if (uriItem.isPlatform()) {
fileItem = WorkspaceUtils.ifileToFile(getIFile(indicatorDefinition));
} else {
fileItem = new File(uriItem.toFileString());
}
File fileProp = WorkspaceUtils.ifileToFile(PropertyHelper.getPropertyFile(indicatorDefinition));
Property property = PropertyHelper.getProperty(indicatorDefinition);
Item item = property.getItem();
if (indicatorDefinition != null) {
EList<TdExpression> sqlGenericExpression = indicatorDefinition.getSqlGenericExpression();
boolean addAS400Expression = true;
for (TdExpression expression : sqlGenericExpression) {
if (SupportDBUrlType.AS400DEFAULTURL.getLanguage().equals(expression.getLanguage())) {
addAS400Expression = false;
break;
}
}
if (addAS400Expression) {
TDQIndicatorDefinitionItem indDefItem = (TDQIndicatorDefinitionItem) item;
Resource itemResource = getResource(fileItem);
IndicatorDefinition indDef = null;
for (EObject object : itemResource.getContents()) {
if (object instanceof IndicatorDefinition) {
indDef = (IndicatorDefinition) object;
IndicatorDefinitionFileHelper.addSqlExpression(indDef, SupportDBUrlType.AS400DEFAULTURL.getLanguage(), BODY_MODE_AS400);
String relationPropPath = ReponsitoryContextBridge.getRootProject().getFullPath().append(new Path(fileProp.getPath()).makeRelativeTo(this.getWorkspacePath())).toOSString();
MetadataHelper.setPropertyPath(relationPropPath, indDef);
indDefItem.setIndicatorDefinition(indDef);
}
}
EMFUtil.saveResource(itemResource);
Resource propResource = getResource(fileProp);
Property newProperty = (Property) EcoreUtil.getObjectByType(propResource.getContents(), PropertiesPackage.eINSTANCE.getProperty());
newProperty.setAuthor(property.getAuthor());
newProperty.setLabel(indDefItem.getIndicatorDefinition().getName());
newProperty.setItem(item);
item.setProperty(newProperty);
propResource.getContents().clear();
propResource.getContents().add(newProperty);
propResource.getContents().add(item);
propResource.getContents().add(item.getState());
EMFUtil.saveResource(propResource);
}
}
} catch (Exception e) {
result = false;
e.printStackTrace();
}
return result;
}
Aggregations