use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.
the class CreateNewJobAction method createNewProcess.
private boolean createNewProcess(RepositoryNode nodeOperation, final ProcessItem process) {
if (process == null) {
return false;
}
try {
// Set readonly to false since created job will always be editable.
ProcessEditorInput fileEditorInput = new ProcessEditorInput(process, false, true, false);
IRepositoryNode repositoryNode = RepositorySeekerManager.getInstance().searchRepoViewNode(fileEditorInput.getItem().getProperty().getId());
fileEditorInput.setRepositoryNode(repositoryNode);
IEditorPart openEditor = getActivePage().openEditor(fileEditorInput, MultiPageTalendEditor.ID, true);
CommandStack commandStack = (CommandStack) openEditor.getAdapter(CommandStack.class);
final Node nodeProviderRequest = new Node(ComponentsFactoryProvider.getInstance().get(T_ESB_PROVIDER_REQUEST, ComponentCategory.CATEGORY_4_DI.getName()), fileEditorInput.getLoadedProcess());
final RepositoryNode portNode = nodeOperation.getParent();
ServiceItem serviceItem = (ServiceItem) portNode.getParent().getObject().getProperty().getItem();
IFile wsdlPath = WSDLUtils.getWsdlFile(serviceItem);
Map<String, String> serviceParameters = WSDLUtils.getServiceOperationParameters(wsdlPath, ((OperationRepositoryObject) nodeOperation.getObject()).getName(), portNode.getObject().getLabel());
setProviderRequestComponentConfiguration(nodeProviderRequest, serviceParameters);
CreateNodeContainerCommand cNcc = new CreateNodeContainerCommand(fileEditorInput.getLoadedProcess(), new NodeContainer(nodeProviderRequest), new Point(3 * Node.DEFAULT_SIZE, 4 * Node.DEFAULT_SIZE));
commandStack.execute(cNcc);
if (!WSDLUtils.ONE_WAY.equals(serviceParameters.get(WSDLUtils.COMMUNICATION_STYLE))) {
Node node = new Node(ComponentsFactoryProvider.getInstance().get(T_ESB_PROVIDER_RESPONSE, ComponentCategory.CATEGORY_4_DI.getName()), fileEditorInput.getLoadedProcess());
cNcc = new CreateNodeContainerCommand(fileEditorInput.getLoadedProcess(), new NodeContainer(node), new Point(9 * Node.DEFAULT_SIZE, 4 * Node.DEFAULT_SIZE));
commandStack.execute(cNcc);
}
String faults = serviceParameters.get(WSDLUtils.FAULTS);
if (null != faults) {
int horMultiplier = 15;
for (String fault : faults.split(",")) {
Node node = new Node(ComponentsFactoryProvider.getInstance().get(T_ESB_PROVIDER_FAULT, ComponentCategory.CATEGORY_4_DI.getName()), fileEditorInput.getLoadedProcess());
cNcc = new CreateNodeContainerCommand(fileEditorInput.getLoadedProcess(), new NodeContainer(node), new Point(horMultiplier * Node.DEFAULT_SIZE, 4 * Node.DEFAULT_SIZE));
commandStack.execute(cNcc);
//$NON-NLS-1$
node.getElementParameter("ESB_FAULT_TITLE").setValue('\"' + fault + '\"');
horMultiplier += 6;
}
}
ServiceConnection serviceConnection = (ServiceConnection) serviceItem.getConnection();
final String parentPortName = portNode.getObject().getLabel();
for (ServicePort port : serviceConnection.getServicePort()) {
if (port.getName().equals(parentPortName)) {
for (ServiceOperation operation : port.getServiceOperation()) {
if (operation.getLabel().equals(nodeOperation.getObject().getLabel())) {
String jobName = process.getProperty().getLabel();
String jobID = process.getProperty().getId();
operation.setReferenceJobId(jobID);
operation.setLabel(operation.getName() + "-" + jobName);
break;
}
}
break;
}
}
repositoryChange(nodeOperation, nodeProviderRequest);
ProxyRepositoryFactory.getInstance().save(serviceItem);
return true;
} catch (PartInitException e) {
ExceptionHandler.process(e);
} catch (PersistenceException e) {
MessageBoxExceptionHandler.process(e);
} catch (Exception e) {
ExceptionHandler.process(e);
}
return false;
}
use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.
the class OpenJobAction method init.
@Override
public void init(TreeViewer viewer, IStructuredSelection selection) {
if (selection.size() != 1) {
setEnabled(false);
return;
}
IRepositoryNode node = (IRepositoryNode) selection.getFirstElement();
if (!ERepositoryObjectType.SERVICESOPERATION.equals((ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE)) || !WSDLUtils.isOperationInBinding(node)) {
// not enabled if the operation doesn't define in binding
setEnabled(false);
return;
}
String jobId = getReferenceJobId(node);
if (jobId == null) {
setEnabled(false);
return;
}
IRepositoryNode repoNode = RepositorySeekerManager.getInstance().searchRepoViewNode(jobId, false);
jobNode = repoNode == null ? null : (RepositoryNode) repoNode;
if (jobNode == null) {
removeReferenecJobId(node);
setEnabled(false);
return;
}
final IStructuredSelection jobSelection = new StructuredSelection(jobNode);
setSpecialSelection(new ISelectionProvider() {
public void setSelection(ISelection arg0) {
}
public void removeSelectionChangedListener(ISelectionChangedListener arg0) {
}
public ISelection getSelection() {
return jobSelection;
}
public void addSelectionChangedListener(ISelectionChangedListener arg0) {
}
});
super.init(viewer, jobSelection);
}
use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.
the class SaveAsRoutesAction method run.
@Override
public void run() {
SaveAsRoutesWizard processWizard = new SaveAsRoutesWizard((JobEditorInput) editorPart.getEditorInput());
WizardDialog dlg = new WizardDialog(editorPart.getSite().getShell(), processWizard);
if (dlg.open() == Window.OK) {
try {
// Set readonly to false since created routes will always be editable.
JobEditorInput newRoutesEditorInput = new CamelProcessEditorInput(processWizard.getProcess(), true, true, false);
IWorkbenchPage page = editorPart.getSite().getPage();
IRepositoryNode repositoryNode = RepositorySeekerManager.getInstance().searchRepoViewNode(newRoutesEditorInput.getItem().getProperty().getId(), false);
newRoutesEditorInput.setRepositoryNode(repositoryNode);
// close the old editor
page.closeEditor(editorPart, false);
// open the new editor, because at the same time, there will update the routes view
page.openEditor(newRoutesEditorInput, CamelMultiPageTalendEditor.ID, true);
} catch (Exception e) {
MessageDialog.openError(editorPart.getSite().getShell(), "Error", "Routes could not be saved" + " : " + e.getMessage());
ExceptionHandler.process(e);
}
}
}
use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.
the class ExporCameltJobScriptAction method init.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
* org.eclipse.jface.viewers.IStructuredSelection)
*/
public void init(TreeViewer viewer, IStructuredSelection selection) {
setEnabled(false);
if (selection.isEmpty() || selection.size() != 1) {
return;
}
IRepositoryNode node = (IRepositoryNode) selection.getFirstElement();
if (node.getType() == ENodeType.REPOSITORY_ELEMENT && node.getProperties(EProperties.CONTENT_TYPE) == CamelRepositoryNodeType.repositoryRoutesType && ERepositoryStatus.DELETED != ProxyRepositoryFactory.getInstance().getStatus(node.getObject())) {
shell = viewer.getTree().getShell();
setEnabled(true);
}
}
use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.
the class OpenCamelExistVersionProcessAction method doRun.
@Override
protected void doRun() {
ISelection selection = getSelection();
Object obj = ((IStructuredSelection) selection).getFirstElement();
IRepositoryNode node = (IRepositoryNode) obj;
IPath path = RepositoryNodeUtilities.getPath(node);
String originalName = node.getObject().getLabel();
RepositoryObject repositoryObj = new RepositoryObject(node.getObject().getProperty());
repositoryObj.setRepositoryNode(node.getObject().getRepositoryNode());
OpenCamelExistVersionProcessWizard wizard = new OpenCamelExistVersionProcessWizard(repositoryObj);
WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
dialog.setHelpAvailable(false);
dialog.setPageSize(300, 250);
//$NON-NLS-1$
dialog.setTitle(Messages.getString("OpenExistVersionProcess.open.dialog"));
if (dialog.open() == Dialog.OK) {
refresh(node);
// refresh the corresponding editor's name
IEditorPart part = getCorrespondingEditor(node);
if (part != null && part instanceof IUIRefresher) {
((IUIRefresher) part).refreshName();
} else {
processRoutineRenameOperation(originalName, node, path);
}
}
}
Aggregations