Search in sources :

Example 6 with ModuleNeeded

use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.

the class JobJavaScriptsWSManager method getExportResources.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobJavaScriptsManager#getExportResources
     * (org.talend.repository.ui.wizards.exportjob.ExportFileResource[], java.util.Map, java.lang.String,
     * java.lang.String, int, int, java.lang.String[])
     */
@Override
public List<ExportFileResource> getExportResources(ExportFileResource[] process, String... codeOptions) throws ProcessorException {
    List<ExportFileResource> list = new ArrayList<ExportFileResource>();
    boolean needJob = true;
    boolean needSource = isOptionChoosed(ExportChoice.needSourceCode);
    boolean needContext = isOptionChoosed(ExportChoice.needContext);
    //$NON-NLS-1$
    ExportFileResource libResource = new ExportFileResource(null, "WEB-INF/lib");
    //$NON-NLS-1$
    ExportFileResource contextResource = new ExportFileResource(null, "WEB-INF/classes");
    //$NON-NLS-1$
    ExportFileResource srcResource = new ExportFileResource(null, "WEB-INF");
    if (needJob) {
        list.add(libResource);
    }
    if (needContext) {
        list.add(contextResource);
    }
    if (needSource) {
        list.add(srcResource);
    }
    copyServerConfigFileToTempDir();
    // set export config mode now only to be sure that the libraries will be setup for an export mode, and not
    // editor mode.
    //$NON-NLS-1$
    ProcessorUtilities.setExportConfig("java", "", "");
    for (ExportFileResource exportResource : process) {
        ProcessItem processItem = (ProcessItem) exportResource.getItem();
        String selectedJobVersion = processItem.getProperty().getVersion();
        if (!isMultiNodes() && this.getSelectedJobVersion() != null) {
            selectedJobVersion = this.getSelectedJobVersion();
        }
        if (!isOptionChoosed(ExportChoice.doNotCompileCode)) {
            generateJobFiles(processItem, contextName, selectedJobVersion, statisticPort != IProcessor.NO_STATISTICS, tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren), progressMonitor);
        }
    }
    // Gets talend libraries
    List<URL> talendLibraries = getExternalLibraries(true, process);
    libResource.addResources(talendLibraries);
    // Add log4j files if needed
    if (Log4jPrefsSettingManager.getInstance().isLog4jEnable()) {
        addLog4jXmlToRes(contextResource);
    }
    for (ExportFileResource proces : process) {
        ProcessItem processItem = (ProcessItem) proces.getItem();
        String selectedJobVersion = processItem.getProperty().getVersion();
        if (!isMultiNodes() && this.getSelectedJobVersion() != null) {
            selectedJobVersion = this.getSelectedJobVersion();
        }
        ProcessorUtilities.setExportConfig(proces.getDirectoryName(), true);
        // if (!isOptionChoosed(ExportChoice.doNotCompileCode)) {
        // generateJobFiles(processItem, contextName, selectedJobVersion, statisticPort != IProcessor.NO_STATISTICS,
        // tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren), progressMonitor);
        // }
        // generate the WSDL file
        ExportFileResource wsdlFile = getWSDLFile(processItem, isOptionChoosed(ExportChoice.needWSDL), talendLibraries);
        list.add(wsdlFile);
        // edit the WSDD file
        editWSDDFile(processItem);
        // add children jobs
        boolean needChildren = true;
        addSubJobResources(process, processItem, needChildren, exportChoice, libResource, contextResource, srcResource, selectedJobVersion);
        // generate the context file
        getContextScripts(processItem, needContext, contextResource, selectedJobVersion);
        // generate jar file for job
        libResource.addResources(getJobScripts(processItem, selectedJobVersion, needJob));
        // dynamic db xml mapping
        addXmlMapping(proces, isOptionChoosed(ExportChoice.needSourceCode));
    }
    // generate Server Config file
    ExportFileResource serverConfigFile = getServerConfigFile(isOptionChoosed(ExportChoice.needCONFIGFILE));
    list.add(serverConfigFile);
    // generate the WSDD file
    ExportFileResource wsddFile = getWSDDFile(isOptionChoosed(ExportChoice.needWSDD));
    list.add(wsddFile);
    // generate the WEB-INFO folder
    ExportFileResource webInfoFolder = getWebXMLFile(isOptionChoosed(ExportChoice.needWEBXML));
    list.add(webInfoFolder);
    // generate the META-INFO folder
    ExportFileResource metaInfoFolder = genMetaInfoFolder(isOptionChoosed(ExportChoice.needMetaInfo));
    list.add(metaInfoFolder);
    // Gets system routines
    List<URL> systemRoutineList = getSystemRoutine(process);
    libResource.addResources(systemRoutineList);
    // Gets user routines
    List<URL> userRoutineList = getUserRoutine(process);
    libResource.addResources(userRoutineList);
    // Gets axis libraries
    List<ModuleNeeded> newAxisLib = new ArrayList<ModuleNeeded>(axisLib);
    for (URL libUrl : talendLibraries) {
        if (libUrl.getFile() != null) {
            newAxisLib.remove(new File(libUrl.getFile()).getName());
        }
    }
    List<URL> axisLibList = getLib(newAxisLib, isOptionChoosed(ExportChoice.needAXISLIB));
    libResource.addResources(axisLibList);
    return list;
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) ArrayList(java.util.ArrayList) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) File(java.io.File) URL(java.net.URL)

Example 7 with ModuleNeeded

use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method addMavenDependencyElements.

protected void addMavenDependencyElements(Document pomDocument, Set<ModuleNeeded> neededModules, String libFolder) {
    Element rootElement = pomDocument.getRootElement();
    Element parentEle = rootElement.element(IMavenProperties.ELE_DEPENDENCIES);
    if (parentEle == null) {
        parentEle = rootElement.addElement(IMavenProperties.ELE_DEPENDENCIES);
    }
    removeComments(parentEle);
    List<ModuleNeeded> modelesList = new ArrayList<ModuleNeeded>();
    modelesList.addAll(neededModules);
    Collections.sort(modelesList, new Comparator<ModuleNeeded>() {

        @Override
        public int compare(ModuleNeeded m1, ModuleNeeded m2) {
            return m1.getModuleName().compareToIgnoreCase(m2.getModuleName());
        }
    });
    for (ModuleNeeded module : modelesList) {
        addMavenDependencyElement(parentEle, module.getModuleName(), libFolder);
    }
}
Also used : Element(org.dom4j.Element) ArrayList(java.util.ArrayList) ModuleNeeded(org.talend.core.model.general.ModuleNeeded)

Example 8 with ModuleNeeded

use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.

the class ModuleNeededComparatorTest method setUp.

@Before
public void setUp() {
    //$NON-NLS-1$
    ModuleNeeded m1 = new ModuleNeeded("c1", MODULE1, EMPTY, false);
    m1.setBundleName(EMPTY);
    //$NON-NLS-1$
    ModuleNeeded m2 = new ModuleNeeded("c2", MODULE1, EMPTY, false);
    m2.setBundleName(BUNDLE_NAME);
    //$NON-NLS-1$
    ModuleNeeded m3 = new ModuleNeeded("c3", MODULE1, EMPTY, true);
    //$NON-NLS-1$
    ModuleNeeded m4 = new ModuleNeeded("c4", MODULE1, EMPTY, true);
    m4.setBundleName(BUNDLE_NAME);
    //$NON-NLS-1$
    ModuleNeeded m5 = new ModuleNeeded("c5", MODULE1, EMPTY, true);
    //$NON-NLS-1$
    ModuleNeeded m6 = new ModuleNeeded("c6", MODULE1, EMPTY, true);
    m6.setMrRequired(true);
    //$NON-NLS-1$
    ModuleNeeded m11 = new ModuleNeeded("c11", MODULE2, EMPTY, false);
    m11.setBundleName(EMPTY);
    //$NON-NLS-1$
    ModuleNeeded m12 = new ModuleNeeded("c12", MODULE2, EMPTY, false);
    m12.setBundleName(BUNDLE_NAME);
    //$NON-NLS-1$
    ModuleNeeded m13 = new ModuleNeeded("c13", MODULE2, EMPTY, true);
    //$NON-NLS-1$
    ModuleNeeded m14 = new ModuleNeeded("c14", MODULE2, EMPTY, true);
    m14.setBundleName(BUNDLE_NAME);
    //$NON-NLS-1$
    ModuleNeeded m15 = new ModuleNeeded("c15", MODULE2, EMPTY, true);
    //$NON-NLS-1$
    ModuleNeeded m16 = new ModuleNeeded("c16", MODULE2, EMPTY, true);
    m16.setMrRequired(true);
    neededModules.add(m11);
    neededModules.add(m3);
    neededModules.add(m2);
    neededModules.add(m12);
    neededModules.add(m16);
    neededModules.add(m5);
    neededModules.add(m4);
    neededModules.add(m1);
    neededModules.add(m15);
    neededModules.add(m13);
    neededModules.add(m6);
    neededModules.add(m14);
    refNeededModules.add(m4);
    refNeededModules.add(m2);
    refNeededModules.add(m1);
    refNeededModules.add(m6);
    refNeededModules.add(m3);
    refNeededModules.add(m5);
    refNeededModules.add(m14);
    refNeededModules.add(m12);
    refNeededModules.add(m11);
    refNeededModules.add(m16);
    refNeededModules.add(m15);
    refNeededModules.add(m13);
    //$NON-NLS-1$
    refMap.put(1, "c4");
    //$NON-NLS-1$
    refMap.put(2, "c2");
    //$NON-NLS-1$
    refMap.put(3, "c1");
    //$NON-NLS-1$
    refMap.put(4, "c6");
    //$NON-NLS-1$
    refMap.put(5, "c3");
    //$NON-NLS-1$
    refMap.put(6, "c5");
    //$NON-NLS-1$
    refMap.put(7, "c14");
    //$NON-NLS-1$
    refMap.put(8, "c12");
    //$NON-NLS-1$
    refMap.put(9, "c11");
    //$NON-NLS-1$
    refMap.put(10, "c16");
    //$NON-NLS-1$
    refMap.put(11, "c15");
    //$NON-NLS-1$
    refMap.put(12, "c13");
}
Also used : ModuleNeeded(org.talend.core.model.general.ModuleNeeded) Before(org.junit.Before)

Example 9 with ModuleNeeded

use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.

the class JavaProcessUtilTest method testFindMoreLibraries.

@Test
public void testFindMoreLibraries() {
    // ensure the CAMEL is not added as jar dependency
    DummyComponent comp = mock(DummyComponent.class);
    when(comp.getType()).thenReturn(ComponentCategory.CATEGORY_4_CAMEL.getName());
    //$NON-NLS-1$
    INode node = new DataNode(comp, "");
    IElementParameter param = new ElementParameter(node);
    param.setName("HOTLIBS");
    List<Map<String, Object>> table = new ArrayList<Map<String, Object>>();
    Map<String, Object> line = new HashMap<String, Object>();
    line.put("LIBPATH", "CAMEL");
    table.add(line);
    param.setValue(table);
    List<ModuleNeeded> modulesNeeded = new ArrayList<ModuleNeeded>();
    JavaProcessUtil.findMoreLibraries(null, modulesNeeded, param);
    assertTrue(modulesNeeded.isEmpty());
    table = new ArrayList<Map<String, Object>>();
    line = new HashMap<String, Object>();
    line.put("LIBPATH", "\"camel.jar\"");
    table.add(line);
    param.setValue(table);
    modulesNeeded = new ArrayList<ModuleNeeded>();
    JavaProcessUtil.findMoreLibraries(null, modulesNeeded, param);
    assertEquals(1, modulesNeeded.size());
    assertEquals("camel.jar", modulesNeeded.get(0).getModuleName());
}
Also used : INode(org.talend.core.model.process.INode) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) DummyComponent(org.talend.designer.core.model.components.DummyComponent) DataNode(org.talend.designer.core.model.process.DataNode) IElementParameter(org.talend.core.model.process.IElementParameter) HashMap(java.util.HashMap) Map(java.util.Map) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) Test(org.junit.Test)

Example 10 with ModuleNeeded

use of org.talend.core.model.general.ModuleNeeded in project tdi-studio-se by Talend.

the class JavaProcessUtilTest method testGetChildrenModules_noChildren.

@Test
public void testGetChildrenModules_noChildren() {
    INode node = mock(INode.class);
    IComponent component = mock(IComponent.class);
    when(node.getComponent()).thenReturn(component);
    when(component.getName()).thenReturn("tLogRow");
    List<ModuleNeeded> childrenModules = JavaProcessUtil.getChildrenModules(node, Collections.emptySet(), false);
    assertTrue(childrenModules.isEmpty());
}
Also used : INode(org.talend.core.model.process.INode) IComponent(org.talend.core.model.components.IComponent) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) Test(org.junit.Test)

Aggregations

ModuleNeeded (org.talend.core.model.general.ModuleNeeded)38 ArrayList (java.util.ArrayList)17 IElementParameter (org.talend.core.model.process.IElementParameter)11 HashSet (java.util.HashSet)9 File (java.io.File)8 Map (java.util.Map)8 List (java.util.List)5 Test (org.junit.Test)5 IComponent (org.talend.core.model.components.IComponent)5 ProcessItem (org.talend.core.model.properties.ProcessItem)5 ElementParameter (org.talend.designer.core.model.components.ElementParameter)5 Node (org.talend.designer.core.ui.editor.nodes.Node)5 IOException (java.io.IOException)4 URL (java.net.URL)4 INode (org.talend.core.model.process.INode)4 HashMap (java.util.HashMap)3 TreeSet (java.util.TreeSet)3 IPath (org.eclipse.core.runtime.IPath)3 Path (org.eclipse.core.runtime.Path)3 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)3