use of org.talend.dataquality.indicators.definition.util.DefinitionSwitch in project tdq-studio-se by Talend.
the class DefinitionHandler method getIndicatorModelElement.
private final ModelElement getIndicatorModelElement(File file) {
DefinitionSwitch<IndicatorDefinition> definitionSwitch = new DefinitionSwitch<IndicatorDefinition>() {
@Override
public IndicatorDefinition caseIndicatorDefinition(IndicatorDefinition object) {
return object;
}
};
if (file != null) {
Resource resource = EmfFileResourceUtil.getInstance().getFileResource(file.getAbsolutePath());
EList<EObject> contents = resource.getContents();
if (contents.isEmpty()) {
// $NON-NLS-1$
log.error("no content in: " + resource);
}
for (EObject object : contents) {
ModelElement switchObject = definitionSwitch.doSwitch(object);
if (switchObject != null) {
return switchObject;
}
}
}
return null;
}
use of org.talend.dataquality.indicators.definition.util.DefinitionSwitch in project tdq-studio-se by Talend.
the class DefinitionHandler method loadDefinitionsFromFile.
/**
* DOC mzhao feature 13676 split system indicators.
*
* @return
*/
public IndicatorsDefinitions loadDefinitionsFromFile() {
Resource definitionsFile = getDefCategoryResourceFromFile();
EList<EObject> contents = definitionsFile.getContents();
if (contents == null || contents.isEmpty()) {
// $NON-NLS-1$
log.error(Messages.getString("DefinitionHandler.NoContentFound", definitionsFile.getURI()));
return null;
}
DefinitionSwitch<IndicatorsDefinitions> catSwitch = new DefinitionSwitch<IndicatorsDefinitions>() {
@Override
public IndicatorsDefinitions caseIndicatorsDefinitions(IndicatorsDefinitions object) {
return object;
}
};
return catSwitch.doSwitch(contents.get(0));
}
Aggregations