use of org.talend.dataquality.analysis.category.AnalysisCategories in project tdq-studio-se by Talend.
the class ViewerDataFactory method createTreeData.
public static Object createTreeData() {
List<AnalysisTypeNode> returnList = new ArrayList<AnalysisTypeNode>();
// use CategoryHandler
AnalysisCategories analysisCategories = CategoryHandler.getAnalysisCategories();
// use this tree (use label attribute of each Category instance)
EList<AnalysisCategory> categories = analysisCategories.getCategories();
for (AnalysisCategory category : categories) {
AnalysisTypeNode typeNode = new AnalysisTypeNode(category.getLabel(), category.getAnalysisType().getLiteral(), null);
if (category.getSubCategories() != null) {
List<AnalysisTypeNode> subCategories = new ArrayList<AnalysisTypeNode>();
for (AnalysisCategory subCategory : category.getSubCategories()) {
// the Semantic analysis must not appear in TOS DQ.
String label = subCategory.getLabel();
if (org.talend.commons.utils.platform.PluginChecker.isOnlyTopLoaded()) {
if (label.equals("Semantic-aware Analysis")) {
// $NON-NLS-1$
continue;
}
}
subCategories.add(new AnalysisTypeNode(label, label, typeNode));
}
typeNode.setChildren(subCategories.toArray());
}
returnList.add(typeNode);
}
return returnList;
}
use of org.talend.dataquality.analysis.category.AnalysisCategories in project tdq-studio-se by Talend.
the class CategoryHandlerTest method testGetAnalysisCategories.
/**
* Test method for {@link org.talend.dq.analysis.category.CategoryHandler#getAnalysisCategories()}.
*/
@Test
public void testGetAnalysisCategories() {
AnalysisCategories analysisCategories = CategoryHandler.getAnalysisCategories();
Assert.assertNotNull(analysisCategories);
EList<AnalysisCategory> categories = analysisCategories.getCategories();
Assert.assertNotNull(categories);
Assert.assertFalse(categories.isEmpty());
for (AnalysisCategory analysisCategory : categories) {
// $NON-NLS-1$
System.out.println("-" + analysisCategory.getLabel());
if (!analysisCategory.getSubCategories().isEmpty()) {
for (AnalysisCategory subCategory : analysisCategory.getSubCategories()) {
// $NON-NLS-1$
System.out.println("\t+--" + subCategory.getLabel());
}
}
}
}
use of org.talend.dataquality.analysis.category.AnalysisCategories 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