Search in sources :

Example 1 with DefinitionSwitch

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;
}
Also used : DefinitionSwitch(org.talend.dataquality.indicators.definition.util.DefinitionSwitch) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) EObject(org.eclipse.emf.ecore.EObject) CwmResource(org.talend.model.emf.CwmResource) Resource(org.eclipse.emf.ecore.resource.Resource) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)

Example 2 with DefinitionSwitch

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));
}
Also used : DefinitionSwitch(org.talend.dataquality.indicators.definition.util.DefinitionSwitch) EObject(org.eclipse.emf.ecore.EObject) CwmResource(org.talend.model.emf.CwmResource) Resource(org.eclipse.emf.ecore.resource.Resource) IndicatorsDefinitions(org.talend.dataquality.indicators.definition.IndicatorsDefinitions)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)2 Resource (org.eclipse.emf.ecore.resource.Resource)2 DefinitionSwitch (org.talend.dataquality.indicators.definition.util.DefinitionSwitch)2 CwmResource (org.talend.model.emf.CwmResource)2 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)1 IndicatorsDefinitions (org.talend.dataquality.indicators.definition.IndicatorsDefinitions)1 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)1 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)1