Search in sources :

Example 1 with InternalNodeComponentHandler

use of org.talend.core.ui.documentation.generation.InternalNodeComponentHandler in project tdi-studio-se by Talend.

the class HTMLDocGenerator method handleXMLFile.

/**
     * Generates the xml file base on an instance of <code>ExportFileResource</code> and the temporary folder path.
     * 
     * @param resource
     * @param tempFolderPath
     * @param version
     */
private void handleXMLFile(ExportFileResource resource, String tempFolderPath, String... version) throws Exception {
    Item item = resource.getItem();
    // Check if generate Job Extra / Stats&Logs Setting Info
    if (item instanceof ProcessItem) {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
            IMRProcessService mrProcessService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
            generateExtraSetting = !mrProcessService.isMapReduceItem(item);
            generateStatsLogsSetting = generateExtraSetting;
        } else if (isRouteProcess(item)) {
            generateStatsLogsSetting = generateExtraSetting = !isRouteProcess(item);
        }
    } else if (item instanceof JobletProcessItem) {
        generateStatsLogsSetting = false;
    }
    targetConnectionMap = new HashMap<String, List>();
    sourceConnectionMap = new HashMap<String, List>();
    getSourceAndTargetConnection(item);
    Document document = DocumentHelper.createDocument();
    Element projectElement = generateProjectInfo(document);
    Element jobElement = generateJobInfo(item, projectElement, version);
    // This two element see feature 4162
    generateContextInfo(item, jobElement);
    generateJobSettingInfo(item, jobElement);
    List<List> allList = seperateNodes(item);
    if (allList == null || allList.size() != 3) {
        return;
    }
    List<INode> allComponentsList = allList.get(0);
    List<INode> internalNodeComponentsList = allList.get(1);
    List<INode> externalNodeComponentsList = allList.get(2);
    if (allComponentsList.size() > 0) {
        // Generates information for 'Component List' part in exported HTML file.
        generateAllComponentsSummaryInfo(item, jobElement, allComponentsList);
    }
    //$NON-NLS-1$
    Element internalNodeElement = jobElement.addElement("internalNodeComponents");
    //$NON-NLS-1$
    Element externalNodeElement = jobElement.addElement("externalNodeComponents");
    if (internalNodeComponentsList.size() > 0) {
        InternalNodeComponentHandler internalNodeComponentHandler = new InternalNodeComponentHandler(this.picFilePathMap, internalNodeElement, internalNodeComponentsList, this.sourceConnectionMap, this.targetConnectionMap, this.designerCoreService, this.repositoryConnectionItemMap, this.repositoryDBIdAndNameMap, externalNodeHTMLMap);
        // Generates internal node components information.
        internalNodeComponentHandler.generateComponentInfo();
    }
    if (externalNodeComponentsList.size() > 0) {
        ExternalNodeComponentHandler externalNodeComponentHandler = new ExternalNodeComponentHandler(this.picFilePathMap, externalNodeElement, externalNodeComponentsList, this.sourceConnectionMap, this.targetConnectionMap, this.designerCoreService, this.repositoryConnectionItemMap, this.repositoryDBIdAndNameMap, externalNodeHTMLMap);
        // Generates external node components(tMap etc.) information.
        externalNodeComponentHandler.generateComponentInfo();
    }
    // Generates all connection information(include internal node and external node).
    EList connectionList = null;
    if (item instanceof ProcessItem) {
        connectionList = ((ProcessItem) item).getProcess().getConnection();
    } else if (item instanceof JobletProcessItem) {
        connectionList = (((JobletProcessItem) item).getJobletProcess().getConnection());
    }
    if (connectionList != null && connectionList.size() != 0) {
        generateConnectionsInfo(jobElement, connectionList);
    }
    //$NON-NLS-1$
    String versionPath = "_";
    if (version != null && version.length == 1) {
        versionPath = versionPath + version[0];
    } else {
        versionPath = versionPath + item.getProperty().getVersion();
    }
    String filePath = tempFolderPath + File.separatorChar + item.getProperty().getLabel() + versionPath + IHTMLDocConstants.XML_FILE_SUFFIX;
    // This element see feature 4382
    if (item instanceof ProcessItem) {
        generateSourceCodeInfo((ProcessItem) item, jobElement);
    }
    XMLHandler.generateXMLFile(tempFolderPath, filePath, document);
}
Also used : INode(org.talend.core.model.process.INode) InternalNodeComponentHandler(org.talend.core.ui.documentation.generation.InternalNodeComponentHandler) IMRProcessService(org.talend.core.service.IMRProcessService) Element(org.dom4j.Element) Document(org.dom4j.Document) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) EList(org.eclipse.emf.common.util.EList) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ExternalNodeComponentHandler(org.talend.core.ui.documentation.generation.ExternalNodeComponentHandler) CSSRuleList(org.w3c.dom.css.CSSRuleList) ArrayList(java.util.ArrayList) List(java.util.List) NodeList(org.w3c.dom.NodeList) EList(org.eclipse.emf.common.util.EList)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Document (org.dom4j.Document)1 Element (org.dom4j.Element)1 EList (org.eclipse.emf.common.util.EList)1 INode (org.talend.core.model.process.INode)1 ConnectionItem (org.talend.core.model.properties.ConnectionItem)1 ContextItem (org.talend.core.model.properties.ContextItem)1 Item (org.talend.core.model.properties.Item)1 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)1 ProcessItem (org.talend.core.model.properties.ProcessItem)1 IMRProcessService (org.talend.core.service.IMRProcessService)1 ExternalNodeComponentHandler (org.talend.core.ui.documentation.generation.ExternalNodeComponentHandler)1 InternalNodeComponentHandler (org.talend.core.ui.documentation.generation.InternalNodeComponentHandler)1 NodeList (org.w3c.dom.NodeList)1 CSSRuleList (org.w3c.dom.css.CSSRuleList)1