use of org.talend.dataquality.analysis.category.util.CategorySwitch in project tdq-studio-se by Talend.
the class CategoryHandler method loadFromFile.
/**
* DOC bZhou Comment method "loadFromFile".
*
* @return
*/
private static AnalysisCategories loadFromFile() {
EMFUtil util = new EMFUtil();
// $NON-NLS-1$
String pathName = "/org.talend.cwm.management/My.category";
URI uri = URI.createPlatformPluginURI(pathName, false);
Resource catFile = null;
try {
catFile = util.getResourceSet().getResource(uri, true);
} catch (RuntimeException e) {
log.error(e.getMessage());
}
if (catFile == null) {
// try to load from a local file
// $NON-NLS-1$
catFile = util.getResourceSet().getResource(URI.createFileURI(".." + File.separator + pathName), true);
}
if (catFile == null) {
// $NON-NLS-1$
log.error(Messages.getString("CategoryHandler.NORESOUTCEFOUND", pathName, uri));
return null;
}
EList<EObject> contents = catFile.getContents();
if (contents == null) {
// $NON-NLS-1$
log.error(Messages.getString("CategoryHandler.NOCATALOGFOUND", uri));
return null;
}
CategorySwitch<AnalysisCategories> catSwitch = new CategorySwitch<AnalysisCategories>() {
@Override
public AnalysisCategories caseAnalysisCategories(AnalysisCategories object) {
return object;
}
};
return catSwitch.doSwitch(contents.get(0));
}
Aggregations