use of org.talend.dataquality.properties.TDQIndicatorDefinitionItem in project tdq-studio-se by Talend.
the class InidcatorUnitTest method testGetFormsCase2.
/**
* Test method for {@link org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit#getForms()}.
*
* test case 2: Get Forms from TableIndicatorUnit
*/
@Test
public void testGetFormsCase2() {
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());
ColumnIndicatorUnit columnIndicatorUnit = new ColumnIndicatorUnit(IndicatorEnum.RowCountIndicatorEnum, rowCountIndicator, null);
FormEnum[] forms = new FormEnum[] { FormEnum.IndicatorThresholdsForm };
FormEnum[] resultforms = columnIndicatorUnit.getForms();
Assert.assertEquals(forms.length, resultforms.length);
for (int index = 0; index < forms.length; index++) {
Assert.assertEquals(forms[index], resultforms[index]);
}
}
use of org.talend.dataquality.properties.TDQIndicatorDefinitionItem in project tdq-studio-se by Talend.
the class InidcatorUnitTest method testGetIndicatorNameCase1.
/**
* Test method for {@link org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit#getIndicatorName()}.
*
* test case 1: Get Indicator Name from ColumnSetIndicatorUnit
*/
@Test
public void testGetIndicatorNameCase1() {
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());
ColumnSetIndicatorUnit columnSetIndicatorUnit = new ColumnSetIndicatorUnit(IndicatorEnum.RowCountIndicatorEnum, rowCountIndicator);
Assert.assertEquals(org.talend.cwm.management.i18n.Messages.getString(rowCountItem.getProperty().getLabel()), columnSetIndicatorUnit.getIndicatorName());
}
use of org.talend.dataquality.properties.TDQIndicatorDefinitionItem in project tdq-studio-se by Talend.
the class InidcatorUnitTest method testGetFormsCase3.
/**
* Test method for {@link org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit#getForms()}.
*
* test case 3: Get Forms from ColumnIndicatorUnit
*/
@Test
public void testGetFormsCase3() {
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);
FormEnum[] forms = new FormEnum[] { FormEnum.IndicatorThresholdsForm };
FormEnum[] resultforms = TableIndicatorUnit.getForms();
Assert.assertEquals(forms.length, resultforms.length);
for (int index = 0; index < forms.length; index++) {
Assert.assertEquals(forms[index], resultforms[index]);
}
}
use of org.talend.dataquality.properties.TDQIndicatorDefinitionItem in project tdq-studio-se by Talend.
the class AElementPersistanceRealTest method testCreateItemIndicatorDefinition.
/**
* Test method for
* {@link org.talend.dq.writer.AElementPersistance#createItem(orgomg.cwm.objectmodel.core.ModelElement)}.
*/
@Test
public void testCreateItemIndicatorDefinition() {
IndicatorDefinitionWriter createIndicatorDefinitionWriter = ElementWriterFactory.getInstance().createIndicatorDefinitionWriter();
// test normal name
// $NON-NLS-1$
String indDefName = "indDef1";
// $NON-NLS-1$
String exceptedFileName = indDefName + "_0.1.definition";
IndicatorDefinition createIndicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
createIndicatorDefinition.setName(indDefName);
Item createItem = createIndicatorDefinitionWriter.createItem(createIndicatorDefinition);
assertTrue(createItem instanceof TDQIndicatorDefinitionItem);
TDQIndicatorDefinitionItem indDefItem = (TDQIndicatorDefinitionItem) createItem;
assertTrue(indDefItem.getFilename().equals(exceptedFileName));
// test special name
// $NON-NLS-1$
String indDefName2 = "indDef1'¥‘”、《,》<> ";
// $NON-NLS-1$
String exceptedFileName2 = "indDef1____________0.1.definition";
IndicatorDefinition createIndicatorDefinition2 = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
createIndicatorDefinition2.setName(indDefName2);
Item createItem2 = createIndicatorDefinitionWriter.createItem(createIndicatorDefinition2);
assertTrue(createItem2 instanceof TDQIndicatorDefinitionItem);
TDQIndicatorDefinitionItem indDefItem2 = (TDQIndicatorDefinitionItem) createItem2;
assertTrue(indDefItem2.getFilename().equals(exceptedFileName2));
}
use of org.talend.dataquality.properties.TDQIndicatorDefinitionItem in project tdq-studio-se by Talend.
the class IndicatorDefinitionMaterPage method doSave.
/*
* (non-Javadoc)
*
* @see
* org.talend.dataprofiler.core.ui.editor.AbstractMetadataFormPage#doSave(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public void doSave(IProgressMonitor monitor) {
ReturnCode rc = canSave();
if (!rc.isOk()) {
return;
}
boolean needReloadJUDIJar = false;
// ADD xqliu 2010-02-25 feature 11201
rc = checkBeforeSave();
if (rc.isOk()) {
CCombo javaUDICombo = updateExpressions();
saveUDIValues(javaUDICombo);
if (hasAggregateExpression) {
updateAggregateExpression();
}
if (hasDateExpression) {
updateDateExpression();
}
if (hasCharactersMapping) {
if (!updateCharactersMapping()) {
return;
}
}
rc = UDIHelper.validate(getCurrentModelElement());
}
if (rc.isOk()) {
super.doSave(monitor);
this.isDirty = false;
// Mod TDQ-7474, only when rc is ok, should save the definition
// MOD yyi 2012-02-08 TDQ-4621:Explicitly set true for updating dependencies.
TDQIndicatorDefinitionItem indicatorDefinitionItem = (TDQIndicatorDefinitionItem) getCurrentRepNode().getObject().getProperty().getItem();
ElementWriterFactory.getInstance().createIndicatorDefinitionWriter().save(indicatorDefinitionItem, true);
if (UDIHelper.isJUDIValid(getCurrentModelElement()) && needReloadJUDIJar) {
UDIHelper.clearJAVAUDIMAPByIndicatorDefinition(getCurrentModelElement());
}
} else {
MessageUI.openError(rc.getMessage());
}
}
Aggregations