use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class BuildJobFactoryTest method test_createBuildJobHandler_String_standalone.
@Test
public void test_createBuildJobHandler_String_standalone() {
Property property = PropertiesFactory.eINSTANCE.createProperty();
property.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
property.setLabel("ABC");
property.setVersion(VersionUtils.DEFAULT_VERSION);
//$NON-NLS-1$
property.setStatusCode("");
ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
processItem.setProperty(property);
IBuildJobHandler handler = BuildJobFactory.createBuildJobHandler(processItem, "Default", property.getVersion(), JobScriptsManagerFactory.getDefaultExportChoiceMap(), "STANDALONE");
Assert.assertNotNull("Can't build job for standalone job", handler);
Assert.assertEquals(BuildJobHandler.class.getName(), handler.getClass().getName());
}
use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class JobVersionUtilsTest method createRepositoryObject.
private IRepositoryViewObject createRepositoryObject(String lable) throws PersistenceException {
// create item
itemPath = new Path(folderName);
Property property = PropertiesFactory.eINSTANCE.createProperty();
property.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
property.setVersion(VersionUtils.DEFAULT_VERSION);
//$NON-NLS-1$
property.setStatusCode("");
ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
processItem.setProperty(property);
repositoryFactory = RepositoryPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
property.setId(repositoryFactory.getNextId());
property.setLabel(lable);
ProcessType process = TalendFileFactory.eINSTANCE.createProcessType();
ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
// add depended routines.
List<RoutinesParameterType> dependenciesInPreference = RoutinesUtil.createDependenciesInPreference();
parameterType.getRoutinesParameter().addAll(dependenciesInPreference);
process.setParameters(parameterType);
processItem.setProcess(process);
repositoryFactory.create(processItem, itemPath);
return new RepositoryObject(property);
}
use of org.talend.core.model.properties.ProcessItem in project tesb-studio-se by Talend.
the class LocalESBRunContainerServiceTest method testCreateJavaProcessor.
/**
* Test method for
* {@link org.talend.designer.esb.runcontainer.core.LocalESBRunContainerService#createJavaProcessor(org.talend.core.model.process.IProcess, Property, boolean)}
*/
@Test
public void testCreateJavaProcessor() {
IESBRunContainerService service = (IESBRunContainerService) GlobalServiceRegister.getDefault().getService(IESBRunContainerService.class);
String[] esbComponents = { "tESBProviderRequest", "tRESTClient", "tRESTRequest", "tRESTResponse", "tESBConsumer", "tESBProviderFault", "tESBProviderRequest", "tESBProviderResponse" };
for (String esbComponent : esbComponents) {
Property property = PropertiesFactory.eINSTANCE.createProperty();
property.setVersion("0.1");
property.setId("property1");
property.setLabel("ESBArtifact");
ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
processItem.setProperty(property);
property.setItem(processItem);
ProcessType process = TalendFileFactory.eINSTANCE.createProcessType();
processItem.setProcess(process);
NodeType node = TalendFileFactory.eINSTANCE.createNodeType();
process.getNode().add(node);
node.setComponentName(esbComponent);
IComponent tESBComponent = ComponentsFactoryProvider.getInstance().get(esbComponent, ComponentCategory.CATEGORY_4_DI.getName());
Process esbJob = new Process(property);
Node tESBComponent_1 = new Node(tESBComponent, esbJob);
esbJob.addNodeContainer(new NodeContainer(tESBComponent_1));
Assert.assertNotNull(service.createJavaProcessor(esbJob, property, false));
}
}
use of org.talend.core.model.properties.ProcessItem 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;
}
use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method getExportResources.
/*
* (non-Javadoc)
*
* @see
* org.talend.repository.ui.wizards.exportjob.JobScriptsManager#getExportResources(org.talend.core.model.properties
* .ProcessItem[], boolean, boolean, boolean, boolean, boolean, boolean, boolean, java.lang.String)
*/
@Override
public List<ExportFileResource> getExportResources(ExportFileResource[] process, String... codeOptions) throws ProcessorException {
exportFileResource = process;
for (int i = 0; i < process.length; i++) {
ProcessItem processItem = (ProcessItem) process[i].getItem();
String selectedJobVersion = processItem.getProperty().getVersion();
selectedJobVersion = preExportResource(process, i, selectedJobVersion);
IProcess jobProcess = null;
// code is just kept like this to avoid too big changes right now.
if (!isOptionChoosed(ExportChoice.doNotCompileCode)) {
if (contextName != null) {
jobProcess = generateJobFiles(processItem, contextName, selectedJobVersion, statisticPort != IProcessor.NO_STATISTICS || isOptionChoosed(ExportChoice.addStatistics), tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren), progressMonitor);
}
analysisModules(processItem.getProperty().getId(), selectedJobVersion);
} else {
LastGenerationInfo.getInstance().setModulesNeededWithSubjobPerJob(processItem.getProperty().getId(), processItem.getProperty().getVersion(), Collections.<ModuleNeeded>emptySet());
LastGenerationInfo.getInstance().setLastMainJob(null);
}
List<URL> resources = new ArrayList<URL>();
List<URL> childrenList = new ArrayList<URL>();
if (CommonsPlugin.isHeadless()) {
childrenList = posExportResource(process, exportChoice, contextName, launcher, statisticPort, tracePort, i, jobProcess, processItem, selectedJobVersion, resources, codeOptions);
} else {
String log4jOption = getLog4jLevel() != null ? TalendProcessArgumentConstant.CMD_ARG_LOG4J_LEVEL + getLog4jLevel().toLowerCase() : null;
String[] newCodeOptions = codeOptions;
if (!ArrayUtils.contains(codeOptions, log4jOption)) {
newCodeOptions = (String[]) ArrayUtils.add(codeOptions, log4jOption);
}
childrenList = posExportResource(process, exportChoice, contextName, launcher, statisticPort, tracePort, i, jobProcess, processItem, selectedJobVersion, resources, newCodeOptions);
}
resources.addAll(childrenList);
process[i].addResources(resources);
// Gets job designer resouce
// List<URL> srcList = getSource(processItem, exportChoice.get(ExportChoice.needSource));
// process[i].addResources(JOB_SOURCE_FOLDER_NAME, srcList);
}
// Exports the system libs
List<ExportFileResource> list = new ArrayList<ExportFileResource>(Arrays.asList(process));
// Add the java system libraries
ExportFileResource libResource = getCompiledLibExportFileResource(process);
list.add(libResource);
// Gets jobInfo.properties
// only addClasspathJar not check in preferences ,then export the jobInfo.properties
boolean addClasspathJar = false;
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
addClasspathJar = designerCoreUIService.getPreferenceStore().getBoolean(IRepositoryPrefConstants.ADD_CLASSPATH_JAR);
}
if (!addClasspathJar) {
if (!(process.length > 1)) {
for (ExportFileResource pro : process) {
ExportFileResource jobInfoResource = new ExportFileResource(null, PATH_SEPARATOR);
if (CommonsPlugin.isHeadless()) {
jobInfoResource = new ExportFileResource();
}
list.add(jobInfoResource);
List<URL> jobInfoList = getJobInfoFile(pro, contextName);
jobInfoResource.addResources(jobInfoList);
}
}
}
if (PluginChecker.isRulesPluginLoaded()) {
// hywang add for 6484,add final drl files or xls files to exported job script
//$NON-NLS-1$
ExportFileResource ruleFileResource = new ExportFileResource(null, "Rules/rules/final");
list.add(ruleFileResource);
try {
Map<String, List<URL>> map = initUrlForRulesFiles(process);
Object[] keys = map.keySet().toArray();
for (Object key : keys) {
List<URL> talendDrlFiles = map.get(key.toString());
ruleFileResource.addResources(key.toString(), talendDrlFiles);
}
} catch (CoreException e) {
ExceptionHandler.process(e);
} catch (MalformedURLException e) {
ExceptionHandler.process(e);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
return list;
}
Aggregations