use of org.talend.dataquality.properties.TDQIndicatorDefinitionItem 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.properties.TDQIndicatorDefinitionItem 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.properties.TDQIndicatorDefinitionItem 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;
}
use of org.talend.dataquality.properties.TDQIndicatorDefinitionItem in project tdq-studio-se by Talend.
the class UpdateSybaseLanguageNameForMedianIndicatorTask method saveMedianIndicator.
/**
* save the System Indicator Definition: Median.
*
* @param medianInd
* @return
*/
private boolean saveMedianIndicator(IndicatorDefinition medianInd) {
URI uriItem = medianInd.eResource().getURI();
File fileItem = null;
if (uriItem.isPlatform()) {
fileItem = WorkspaceUtils.ifileToFile(ModelElementHelper.getIFile(medianInd));
} else {
fileItem = new File(uriItem.toFileString());
}
File fileProp = WorkspaceUtils.ifileToFile(PropertyHelper.getPropertyFile(medianInd));
Property property = PropertyHelper.getProperty(medianInd);
Item item = property.getItem();
// save TDQIndicatorDefinitionItem
TDQIndicatorDefinitionItem indDefItem = (TDQIndicatorDefinitionItem) item;
indDefItem.setIndicatorDefinition(medianInd);
Resource itemResource = getResource(fileItem);
EMFUtil.saveResource(itemResource);
// save the property
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);
return true;
}
use of org.talend.dataquality.properties.TDQIndicatorDefinitionItem in project tdq-studio-se by Talend.
the class InidcatorUnitTest method testGetIndicatorNameCase3.
/**
* Test method for {@link org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit#getIndicatorName()}.
*
* test case 3: Get Indicator Name from TableIndicatorUnit
*/
@Test
public void testGetIndicatorNameCase3() {
RowCountIndicator rowCountIndicator = IndicatorsFactory.eINSTANCE.createRowCountIndicator();
IRepositoryViewObject rowCountRepositoryViewObject = null;
try {
List<IRepositoryViewObject> all = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.SYSTEM_INDICATORS_SIMPLE_STATISTICS);
Assert.assertEquals(10, all.size());
rowCountRepositoryViewObject = all.get(7);
} catch (PersistenceException e) {
Assert.fail(e.getMessage());
}
Assert.assertNotNull(rowCountRepositoryViewObject);
TDQIndicatorDefinitionItem rowCountItem = (TDQIndicatorDefinitionItem) rowCountRepositoryViewObject.getProperty().getItem();
rowCountIndicator.setIndicatorDefinition(rowCountItem.getIndicatorDefinition());
TableIndicatorUnit TableIndicatorUnit = new TableIndicatorUnit(IndicatorEnum.RowCountIndicatorEnum, rowCountIndicator, null);
Assert.assertEquals(org.talend.cwm.management.i18n.Messages.getString(rowCountItem.getProperty().getLabel()), TableIndicatorUnit.getIndicatorName());
}
Aggregations