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;
}
use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method addXmlMapping.
protected void addXmlMapping(ExportFileResource resource, boolean needSource) {
try {
boolean hasDynamicMetadata = false;
if (resource.getItem() instanceof ProcessItem) {
List<JobInfo> list = new ArrayList<JobInfo>();
hasDynamicMetadata = LastGenerationInfo.getInstance().isUseDynamic(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
}
if (hasDynamicMetadata) {
needMappingInSystemRoutine = true;
if (needSource) {
IRunProcessService service = CorePlugin.getDefault().getRunProcessService();
ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
if (talendProcessJavaProject == null) {
return;
}
// for db mapping xml
IFolder xmlMappingFolder = talendProcessJavaProject.getResourcesFolder().getFolder(JavaUtils.JAVA_XML_MAPPING);
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
ICoreService coreService = (ICoreService) GlobalServiceRegister.getDefault().getService(ICoreService.class);
coreService.synchronizeMapptingXML();
coreService.syncLog4jSettings();
}
List<URL> xmlMappingFileUrls = new ArrayList<URL>();
if (xmlMappingFolder.exists()) {
for (IResource fileResource : xmlMappingFolder.members()) {
if (XmlUtil.isXMLFile(fileResource.getName())) {
xmlMappingFileUrls.add(fileResource.getLocationURI().toURL());
}
}
resource.addResources(JOB_SOURCE_FOLDER_NAME + PATH_SEPARATOR + JavaUtils.JAVA_XML_MAPPING, xmlMappingFileUrls);
}
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class JobJavaScriptOSGIForESBManager method getExportResources.
@Override
public List<ExportFileResource> getExportResources(ExportFileResource[] processes, String... codeOptions) throws ProcessorException {
List<ExportFileResource> list = new ArrayList<ExportFileResource>();
//$NON-NLS-1$;
ExportFileResource osgiResource = new ExportFileResource(null, "");
//$NON-NLS-1$
ExportFileResource jobScriptResource = new ExportFileResource(null, "");
list.add(osgiResource);
list.add(jobScriptResource);
// 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, "", "");
// set export type as osgi
ProcessorUtilities.setExportAsOSGI(true);
try {
ProcessItem processItem = null;
for (ExportFileResource process : processes) {
processItem = (ProcessItem) process.getItem();
if (processItem.eIsProxy() || processItem.getProcess().eIsProxy()) {
try {
Property property = ProxyRepositoryFactory.getInstance().getUptodateProperty(processItem.getProperty());
processItem = (ProcessItem) property.getItem();
} catch (PersistenceException e) {
throw new ProcessorException(e);
}
}
String jobVersion = processItem.getProperty().getVersion();
if (!isMultiNodes() && getSelectedJobVersion() != null) {
jobVersion = getSelectedJobVersion();
}
ProcessorUtilities.setExportConfig(process.getDirectoryName(), true);
String processId = processItem.getProperty().getId();
if (null == contextName) {
contextName = processItem.getProcess().getDefaultContext();
}
IProcess iProcess = generateJobFiles(processItem, contextName, jobVersion, statisticPort != IProcessor.NO_STATISTICS, tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren), progressMonitor);
analysisModules(processId, jobVersion);
analysisMavenModule(processItem);
// generate jar file for job
getJobScriptsUncompressed(jobScriptResource, processItem);
// dynamic DB XML mapping
addXmlMapping(process, isOptionChoosed(ExportChoice.needSourceCode));
generateConfig(osgiResource, processItem, iProcess);
addResources(osgiResource, processItem);
/*
* export current item's dependencies. this used for TDM components specially and need more discussion
* about then
*/
BuildExportManager.getInstance().exportOSGIDependencies(osgiResource, processItem);
}
ExportFileResource libResource = getCompiledLibExportFileResource(processes);
list.add(libResource);
// generate the META-INFO folder
ExportFileResource metaInfoFolder = genMetaInfoFolder(libResource, processItem);
list.add(0, metaInfoFolder);
ExportFileResource providedLibResources = getProvidedLibExportFileResource(processes);
if (providedLibResources != null) {
list.add(providedLibResources);
}
} catch (ProcessorException e) {
throw e;
} catch (Exception e) {
throw new ProcessorException(e);
}
return list;
}
use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class MapReduceJobJavaScriptsManager method getExportResources.
@Override
public List<ExportFileResource> getExportResources(ExportFileResource[] processes, String... codeOptions) throws ProcessorException {
List<ExportFileResource> exportResources = super.getExportResources(processes, codeOptions);
ProcessItem processItem = null;
for (ExportFileResource process : processes) {
if (process.getItem() instanceof ProcessItem) {
// Explicitly add TDM's resources to the MapReduce process item.
BuildExportManager.getInstance().exportDependencies(process, process.getItem());
}
}
return exportResources;
}
use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class PublishOnSpagoExportWizardPage method finish.
/**
* The Finish button was pressed. Try to do the required work now and answer a boolean indicating success. If false
* is returned then the wizard will not close.
*
* @returns boolean
*/
public boolean finish() {
Map<ExportChoice, Object> exportChoiceMap = getExportChoiceMap();
boolean canExport = false;
for (ExportChoice choice : ExportChoice.values()) {
if (exportChoiceMap.get(choice) != null && exportChoiceMap.get(choice) instanceof Boolean && (Boolean) exportChoiceMap.get(choice)) {
canExport = true;
break;
}
}
if (!canExport) {
MessageDialog.openInformation(getContainer().getShell(), //$NON-NLS-1$
Messages.getString("PublishOnSpagoExportWizardPage.publishResourceError"), //$NON-NLS-1$
Messages.getString("PublishOnSpagoExportWizardPage.chooseResource"));
return false;
}
if (!ensureTargetIsValid()) {
return false;
}
String topFolder = getRootFolderName();
manager = new //$NON-NLS-1$
JobJavaScriptsManager(//$NON-NLS-1$
exportChoiceMap, //$NON-NLS-1$
contextCombo.getText(), //$NON-NLS-1$
"all", //$NON-NLS-1$
IProcessor.NO_STATISTICS, IProcessor.NO_TRACES);
List<ExportFileResource> resourcesToExport = null;
try {
resourcesToExport = getExportResources();
} catch (ProcessorException e) {
MessageBoxExceptionHandler.process(e);
return false;
}
setTopFolder(resourcesToExport, topFolder);
// Save dirty editors if possible but do not stop if not all are saved
saveDirtyEditors();
// about to invoke the operation so save our state
saveWidgetValues();
// boolean ok = executeExportOperation(new ArchiveFileExportOperationFullPath(process));
ArchiveFileExportOperationFullPath exporterOperation = getExporterOperation(resourcesToExport);
boolean ok = executeExportOperation(exporterOperation);
// path can like name/name
manager.deleteTempFiles();
ProcessorUtilities.resetExportConfig();
for (int i = 0; i < process.length; i++) {
ProcessItem processItem = (ProcessItem) process[i].getItem();
try {
ProcessorUtilities.generateCode(processItem, processItem.getProcess().getDefaultContext(), false, false);
} catch (ProcessorException e) {
ExceptionHandler.process(e);
}
}
// cantoine : connection to SpagoBiEngineClient to publish Job.
try {
Project project = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject();
// retrieve user, password, host, port from selected SpagoBiServer
String selectedSpagoBiEngineName = serverSpagoBi.getItem(serverSpagoBi.getSelectionIndex());
SpagoBiServer spagoBiServer = null;
List<SpagoBiServer> listServerSapgo = null;
// ProxyRepositoryFactory proxyRepositoryFactory = ProxyRepositoryFactory.getInstance();
// try {
listServerSapgo = SpagoBiServerHelper.parse(new SpagoBiPreferencePage().getPreferenceStore().getString(SpagoBiServer.SPAGOBI_SERVER));
if (listServerSapgo != null && !listServerSapgo.isEmpty()) {
Iterator<SpagoBiServer> iterator = listServerSapgo.iterator();
while (iterator.hasNext()) {
spagoBiServer = iterator.next();
if (spagoBiServer.getEngineName().equals(selectedSpagoBiEngineName)) {
break;
}
}
}
// } catch (PersistenceException e) {
// displayErrorDialog(e.getMessage());
// }
// "biadmin";
String user = spagoBiServer.getLogin();
// "biadmin";
String password = spagoBiServer.getPassword();
String host = spagoBiServer.getHost();
String port = spagoBiServer.getPort();
// create the client
//$NON-NLS-1$
ISpagoBITalendEngineClient client = new SpagoBITalendEngineClient(user, password, host, port, "SpagoBITalendEngine");
// get some informations about the engine instance referenced by the client
//$NON-NLS-1$
System.out.println("Engine version: " + client.getEngineVersion());
//$NON-NLS-1$
System.out.println("Engine fullname: " + client.getEngineName());
// prepare parameters used during deployment
JobDeploymentDescriptor jobDeploymentDescriptor = new JobDeploymentDescriptor(project.getLabel(), project.getLanguage().getName());
File zipFile = new File(getDestinationValue());
// deploy job on engine runtime
boolean result = client.deployJob(jobDeploymentDescriptor, zipFile);
if (result)
//$NON-NLS-1$
System.out.println("Jobs deployed succesfully");
else
//$NON-NLS-1$
System.out.println("Jobs not deployed");
} catch (EngineUnavailableException e) {
//$NON-NLS-1$
System.err.println("ERROR: " + e.getMessage());
} catch (AuthenticationFailedException e) {
//$NON-NLS-1$
System.err.println("ERROR: " + e.getMessage());
} catch (UnsupportedEngineVersionException e) {
//$NON-NLS-1$
System.err.println("ERROR: Unsupported engine version");
System.err.println(//$NON-NLS-1$
"You are using TalendEngineClientAPI version " + SpagoBITalendEngineClient.CLIENTAPI_VERSION_NUMBER + //$NON-NLS-1$
". " + //$NON-NLS-1$
"The TalendEngine instance you are trying to connect to require TalendEngineClientAPI version " + e.getComplianceVersion() + //$NON-NLS-1$
" or grater.");
} catch (ServiceInvocationFailedException e) {
//$NON-NLS-1$
System.err.println("ERROR: " + e.getMessage());
//$NON-NLS-1$ //$NON-NLS-2$
System.err.println("StatusLine: " + e.getStatusLine() + "responseBody: " + e.getResponseBody());
}
return ok;
// return true;
}
Aggregations