Search in sources :

Example 1 with AnalysisCategories

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;
}
Also used : AnalysisTypeNode(org.talend.dataprofiler.core.model.nodes.analysis.AnalysisTypeNode) AnalysisCategory(org.talend.dataquality.analysis.category.AnalysisCategory) ArrayList(java.util.ArrayList) AnalysisCategories(org.talend.dataquality.analysis.category.AnalysisCategories)

Example 2 with AnalysisCategories

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());
            }
        }
    }
}
Also used : AnalysisCategory(org.talend.dataquality.analysis.category.AnalysisCategory) AnalysisCategories(org.talend.dataquality.analysis.category.AnalysisCategories) Test(org.junit.Test)

Example 3 with AnalysisCategories

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));
}
Also used : EMFUtil(org.talend.commons.emf.EMFUtil) EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource) AnalysisCategories(org.talend.dataquality.analysis.category.AnalysisCategories) CategorySwitch(org.talend.dataquality.analysis.category.util.CategorySwitch) URI(org.eclipse.emf.common.util.URI)

Aggregations

AnalysisCategories (org.talend.dataquality.analysis.category.AnalysisCategories)3 AnalysisCategory (org.talend.dataquality.analysis.category.AnalysisCategory)2 ArrayList (java.util.ArrayList)1 URI (org.eclipse.emf.common.util.URI)1 EObject (org.eclipse.emf.ecore.EObject)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 Test (org.junit.Test)1 EMFUtil (org.talend.commons.emf.EMFUtil)1 AnalysisTypeNode (org.talend.dataprofiler.core.model.nodes.analysis.AnalysisTypeNode)1 CategorySwitch (org.talend.dataquality.analysis.category.util.CategorySwitch)1