use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class SpagicDeployWizardPage 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
*/
@Override
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("SpagicDeployWizardPage.exportResourceError"), //$NON-NLS-1$
Messages.getString("SpagicDeployWizardPage.chooseResource"));
return false;
}
if (!ensureTargetIsValid()) {
return false;
}
manager = new //$NON-NLS-1$
SpagicJavaDeployManager(//$NON-NLS-1$
exportChoiceMap, //$NON-NLS-1$
contextCombo.getText(), //$NON-NLS-1$
"all", //$NON-NLS-1$
IProcessor.NO_STATISTICS, IProcessor.NO_TRACES);
String topFolder = getRootFolderName();
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));
// File file = createSapgicProperty();
ArchiveFileExportOperationFullPath exporterOperation = getExporterOperation(resourcesToExport);
// exportResource(topFolder, "", "", 1);
boolean ok = executeExportOperation(exporterOperation);
// path can like name/name
manager.deleteTempFiles();
ProcessorUtilities.resetExportConfig();
String projectName = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLabel();
List<JobResource> jobResources = new ArrayList<JobResource>();
for (ExportFileResource proces : process) {
try {
proces.setProcess((ProcessItem) ProxyRepositoryFactory.getInstance().getUptodateProperty(proces.getItem().getProperty()).getItem());
} catch (PersistenceException e) {
e.printStackTrace();
}
ProcessItem processItem = (ProcessItem) proces.getItem();
JobInfo jobInfo = new JobInfo(processItem, processItem.getProcess().getDefaultContext());
jobResources.add(new JobResource(projectName, jobInfo));
Set<JobInfo> jobInfos = ProcessorUtilities.getChildrenJobInfo(processItem);
for (JobInfo subjobInfo : jobInfos) {
jobResources.add(new JobResource(projectName, subjobInfo));
}
}
JobResourceManager reManager = JobResourceManager.getInstance();
for (JobResource r : jobResources) {
if (reManager.isProtected(r)) {
try {
ProcessorUtilities.generateCode(r.getJobInfo().getJobId(), r.getJobInfo().getContextName(), r.getJobInfo().getJobVersion(), false, false);
} catch (ProcessorException e) {
ExceptionHandler.process(e);
}
} else {
reManager.deleteResource(r);
}
}
return ok;
}
use of org.talend.core.model.properties.ProcessItem in project tesb-studio-se by Talend.
the class AssignJobAction method assign.
public boolean assign(IRepositoryNode jobNode) {
if (jobNode == null) {
return false;
}
IRepositoryViewObject repositoryObject = jobNode.getObject();
final Item item = repositoryObject.getProperty().getItem();
// judge the job whether had T_ESB_PROVIDER_REQUEST
ProcessItem processItem = (ProcessItem) item;
NodeType providerNode = null;
for (Object obj : processItem.getProcess().getNode()) {
NodeType node = (NodeType) obj;
if (CreateNewJobAction.T_ESB_PROVIDER_REQUEST.equals(node.getComponentName())) {
providerNode = node;
break;
}
}
if (null == providerNode) {
MessageDialog.openWarning(Display.getCurrent().getActiveShell(), Messages.AssignJobAction_WarningTitle, Messages.AssignJobAction_WarningMessage);
return false;
}
try {
String jobID = item.getProperty().getId();
String jobName = item.getProperty().getLabel();
String operationName = repositoryNode.getObject().getLabel();
String portName = repositoryNode.getParent().getObject().getLabel();
ServiceItem serviceItem = (ServiceItem) repositoryNode.getParent().getParent().getObject().getProperty().getItem();
List<ServicePort> listPort = ((ServiceConnection) serviceItem.getConnection()).getServicePort();
for (ServicePort port : listPort) {
if (port.getName().equals(portName)) {
List<ServiceOperation> listOperation = port.getServiceOperation();
for (ServiceOperation operation : listOperation) {
if (operation.getLabel().equals(operationName)) {
// should not change the job name
// String jobNewName = port.getName() + "_" + operation.getName();
// if (resetJobname(item, jobNewName)) {
// jobName = jobNewName;
// }
operation.setReferenceJobId(jobID);
operation.setLabel(operation.getName() + "-" + jobName);
break;
}
}
break;
}
}
IFile wsdlPath = WSDLUtils.getWsdlFile(serviceItem);
Map<String, String> serviceParameters = WSDLUtils.getServiceOperationParameters(wsdlPath, ((OperationRepositoryObject) repositoryNode.getObject()).getName(), portName);
for (Object paramObj : providerNode.getElementParameter()) {
ElementParameterType param = (ElementParameterType) paramObj;
String name = param.getName();
if (serviceParameters.containsKey(name)) {
param.setValue(serviceParameters.get(name));
}
}
IProcess2 process = null;
IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
List<IProcess2> processes = RepositoryPlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
for (IProcess2 processOpen : processes) {
if (processOpen.getProperty().getItem() == processItem) {
process = processOpen;
break;
}
}
if (process == null) {
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
IProcess proc = service.getProcessFromProcessItem(processItem);
if (proc instanceof IProcess2) {
process = (IProcess2) proc;
}
}
if (process != null) {
List<? extends INode> nodelist = process.getGraphicalNodes();
for (INode node : nodelist) {
if (node.getComponent().getName().equals("tESBProviderRequest")) {
repositoryChange(repositoryNode, node);
}
}
processItem.setProcess(process.saveXmlFile());
}
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
factory.save(processItem);
factory.save(serviceItem);
return true;
} catch (Exception e) {
ExceptionHandler.process(e);
}
return false;
}
use of org.talend.core.model.properties.ProcessItem in project tesb-studio-se by Talend.
the class ESBService method changeOtherJobSchemaValue.
// private void changenewOperationLabel(RepositoryNode newNode, INode node, ServiceConnection serConn) {
// String operationName = newNode.getObject().getLabel();
// String parentPortName = newNode.getParent().getObject().getLabel();
//
// String wsdlPath = serConn.getWSDLPath();
// try {
// Map<String, String> serviceParameters = WSDLUtils.getServiceParameters(wsdlPath);
// IRepositoryViewObject newObj = newNode.getObject();
// if (newObj instanceof OperationRepositoryObject) {
// ServiceOperation newOpe = (ServiceOperation) ((OperationRepositoryObject) newObj).getAbstractMetadataObject();
//
// IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
//
// if (newOpe.getReferenceJobId() != null) {
// changeOtherJobSchemaValue(factory, newOpe, serConn);
// MessageDialog.openWarning(new Shell(), "warning",
// "This other job which based on the Operation will be unset!");
// }
//
// IEditorPart activeEditor =
// PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
// IEditorInput input = activeEditor.getEditorInput();
// if (input instanceof ProcessEditorInput) {
// Item jobItem = ((ProcessEditorInput) input).getItem();
// String jobID = jobItem.getProperty().getId();
// String jobName = jobItem.getProperty().getLabel();
//
// newOpe.setReferenceJobId(jobID);
// newOpe.setLabel(newOpe.getName() + "-" + jobName);
//
// serviceParameters.put(WSDLUtils.PORT_NAME, parentPortName);
// serviceParameters.put(WSDLUtils.OPERATION_NAME, operationName);
//
// CreateNewJobAction.setProviderRequestComponentConfiguration(node, serviceParameters);
//
// try {
// factory.save(jobItem);
// } catch (PersistenceException e) {
// e.printStackTrace();
// }
// try {
// factory.save(newNode.getParent().getParent().getObject().getProperty().getItem());
// } catch (PersistenceException e) {
// e.printStackTrace();
// }
// RepositoryManager.refreshSavedNode(newNode);
// }
// }
//
// } catch (CoreException e1) {
// ExceptionHandler.process(e1);
// } catch (PersistenceException e) {
// ExceptionHandler.process(e);
// }
// }
private void changeOtherJobSchemaValue(IProxyRepositoryFactory factory, ServiceOperation newOpe, /*
* ServiceConnection
* serConn,
*/
RepositoryNode selectNode) throws PersistenceException, CoreException {
IRepositoryViewObject jobObj = factory.getLastVersion(newOpe.getReferenceJobId());
if (jobObj == null) {
return;
}
ProcessItem processItem = (ProcessItem) jobObj.getProperty().getItem();
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
boolean foundInOpen = false;
IProcess2 process = null;
IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
List<IProcess2> processes = RepositoryPlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
for (IProcess2 processOpen : processes) {
if (processOpen.getProperty().getItem() == processItem) {
foundInOpen = true;
process = processOpen;
break;
}
}
if (!foundInOpen) {
IProcess proc = service.getProcessFromProcessItem(processItem);
if (proc instanceof IProcess2) {
process = (IProcess2) proc;
}
}
newOpe.setReferenceJobId(null);
newOpe.setLabel(newOpe.getName());
if (process != null) {
List<? extends INode> nodelist = process.getGraphicalNodes();
for (INode node : nodelist) {
if (node.getComponent().getName().equals("tESBProviderRequest")) {
repositoryChange(selectNode, node, process);
break;
}
}
try {
if (!foundInOpen) {
processItem.setProcess(process.saveXmlFile());
factory.save(processItem);
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
} catch (IOException e) {
ExceptionHandler.process(e);
}
}
// ProcessType process = item.getProcess();
// EList<NodeType> nodeList = process.getNode();
//
// for (NodeType node : nodeList) {
// EList parameters = node.getElementParameter();
// for (Object paramObj : parameters) {
// ElementParameterType param = (ElementParameterType) paramObj;
// String name = param.getName();
// if (name.equals(WSDLUtils.OPERATION_NAME)) {
// if (!newOpe.getName().equals(param.getValue())) {
// break;
// }
// param.setValue(null);
// }
// if (name.equals("SCHEMA:SCHEMA_TYPE")) {
// param.setValue("BUILT_IN");
// break;
// }
//
// }
//
// }
// factory.save(item);
}
use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class JavaJobScriptsExportWSWizardPage method createExportTypeGroup.
protected void createExportTypeGroup(Composite parent) {
// options group
Group optionsGroup = new Group(parent, SWT.NONE);
GridLayout layout = new GridLayout();
optionsGroup.setLayout(layout);
optionsGroup.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
//$NON-NLS-1$
optionsGroup.setText(Messages.getString("JavaJobScriptsExportWSWizardPage.BuildType"));
optionsGroup.setFont(parent.getFont());
optionsGroup.setLayout(new GridLayout(1, true));
Composite left = new Composite(optionsGroup, SWT.NONE);
left.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false));
left.setLayout(new GridLayout(3, false));
Label label = new Label(left, SWT.NONE);
//$NON-NLS-1$
label.setText(Messages.getString("JavaJobScriptsExportWSWizardPage.BuildLabel"));
exportTypeCombo = new Combo(left, SWT.PUSH);
GridData gd = new GridData();
gd.horizontalSpan = 1;
exportTypeCombo.setLayoutData(gd);
for (JobExportType exportType : extractExportJobTypes()) {
if (!Boolean.getBoolean("talend.export.job.2." + exportType.toString() + ".hide")) {
//$NON-NLS-1$//$NON-NLS-2$
exportTypeCombo.add(exportType.label);
}
}
String label2 = getCurrentExportType1().label;
// if the build type was set, try to select by default
if (nodes != null && nodes.length == 1) {
// deal with one node only.
ProcessItem item = getProcessItem();
final Object buildType = item.getProperty().getAdditionalProperties().get(TalendProcessArgumentConstant.ARG_BUILD_TYPE);
if (buildType != null) {
Map<JobExportType, String> map = BuildJobFactory.oldBuildTypeMap;
for (JobExportType t : map.keySet()) {
if (buildType.toString().equals(map.get(t))) {
// same build type
label2 = t.label;
break;
}
}
}
}
exportTypeCombo.setText(label2);
if (exportTypeFixed != null) {
left.setVisible(false);
optionsGroup.setVisible(false);
exportTypeCombo.setText(exportTypeFixed.label);
}
chkButton = new Button(left, SWT.CHECK);
//$NON-NLS-1$
chkButton.setText(Messages.getString("JavaJobScriptsExportWSWizardPage.extractZipFile"));
JobExportType comboType = JobExportType.getTypeFromString(exportTypeCombo.getText());
if (comboType.equals(JobExportType.WSWAR) || comboType.equals(JobExportType.OSGI)) {
chkButton.setVisible(false);
zipOption = null;
} else {
chkButton.setVisible(true);
zipOption = String.valueOf(chkButton.getSelection());
}
chkButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
chkButton.setSelection(chkButton.getSelection());
zipOption = String.valueOf(chkButton.getSelection());
}
});
exportTypeCombo.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
@Override
public void widgetSelected(SelectionEvent e) {
destinationNameFieldInnerComposite.dispose();
destinationNameFieldInnerComposite = new Composite(destinationNameFieldComposite, SWT.NONE);
GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
destinationNameFieldInnerComposite.setLayoutData(gridData);
destinationNameFieldInnerComposite.setLayout(new GridLayout());
createDestinationGroup(destinationNameFieldInnerComposite);
destinationNameFieldComposite.layout();
optionsGroupComposite.dispose();
createOptionsGroupButtons(pageComposite);
pageComposite.setSize(pageComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
pageComposite.layout();
JobExportType comboType = JobExportType.getTypeFromString(exportTypeCombo.getText());
if (comboType.equals(JobExportType.WSWAR) || comboType.equals(JobExportType.OSGI)) {
chkButton.setVisible(false);
zipOption = null;
} else {
chkButton.setVisible(true);
zipOption = String.valueOf(chkButton.getSelection());
}
checkExport();
}
});
}
use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.
the class BuildJobManager method buildJobs.
public boolean buildJobs(String destinationPath, List<? extends IRepositoryNode> nodes, List<String> topNames, String version, String context, Map<ExportChoice, Object> exportChoiceMap, JobExportType jobExportType, IProgressMonitor monitor) throws Exception {
IProgressMonitor pMonitor = new NullProgressMonitor();
if (monitor != null) {
pMonitor = monitor;
}
final List<ProcessItem> processes = getProcesses(nodes);
if (processes.size() == 1) {
ProcessItem item = processes.get(0);
buildJob(destinationPath, item, version, context, exportChoiceMap, jobExportType, pMonitor);
} else {
int scale = 1000;
int steps = 3;
pMonitor.beginTask(Messages.getString("JobScriptsExportWizardPage.newExportJobScript", jobExportType), //$NON-NLS-1$
steps * scale * nodes.size());
String topName = null;
if (topNames != null && !topNames.isEmpty()) {
topName = topNames.get(0);
} else {
topName = ProjectManager.getInstance().getCurrentProject().getLabel();
}
File desFile = new File(destinationPath);
//$NON-NLS-1$ //$NON-NLS-2$
File createTempFile = File.createTempFile("building_job", "");
createTempFile.delete();
File tempFolder = new File(desFile.getParent() + File.separator + createTempFile.getName());
if (tempFolder.exists()) {
tempFolder.delete();
}
File tempProFolder = new File(tempFolder, topName);
tempProFolder.mkdirs();
for (int i = 0; i < processes.size(); i++) {
ProcessItem processItem = processes.get(i);
//$NON-NLS-1$
pMonitor.setTaskName(Messages.getString("BuildJobManager.building", processItem.getProperty().getLabel()));
IBuildJobHandler buildJobHandler = BuildJobFactory.createBuildJobHandler(processItem, context, processItem.getProperty().getVersion(), exportChoiceMap, jobExportType);
buildJobHandler.generateItemFiles(true, new SubProgressMonitor(pMonitor, scale));
buildJobHandler.generateJobFiles(new SubProgressMonitor(pMonitor, scale));
buildJobHandler.build(new SubProgressMonitor(pMonitor, scale));
IFile jobTargetFile = buildJobHandler.getJobTargetFile();
if (jobTargetFile != null && jobTargetFile.exists()) {
// unzip to temp folder
FilesUtils.unzip(jobTargetFile.getLocation().toPortableString(), tempProFolder.getAbsolutePath());
String zipPath = jobTargetFile.getLocation().toPortableString();
if (needClasspathJar(exportChoiceMap)) {
JavaJobExportReArchieveCreator creator = new JavaJobExportReArchieveCreator(zipPath, processItem.getProperty().getLabel());
creator.setTempFolder(tempFolder.getAbsolutePath());
creator.buildNewJar();
}
}
pMonitor.worked(scale);
}
FilesUtils.zip(tempFolder.getAbsolutePath(), destinationPath);
FilesUtils.deleteFile(tempFolder, true);
pMonitor.done();
}
return true;
}
Aggregations