use of org.talend.repository.services.model.services.ServiceOperation 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.services.model.services.ServiceOperation in project tesb-studio-se by Talend.
the class ExportServiceAction method init.
private void init(String targetPath) throws InvocationTargetException {
serviceName = serviceItem.getProperty().getLabel();
serviceVersion = serviceItem.getProperty().getVersion();
serviceWsdl = WSDLUtils.getWsdlFile(serviceItem);
ServiceConnection serviceConnection = (ServiceConnection) serviceItem.getConnection();
additionalInfo = serviceConnection.getAdditionalInfo().map();
EList<ServicePort> listPort = serviceConnection.getServicePort();
List<IRepositoryViewObject> jobs;
try {
jobs = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.PROCESS);
} catch (PersistenceException e) {
throw new InvocationTargetException(e);
}
for (ServicePort port : listPort) {
List<ServiceOperation> listOperation = port.getServiceOperation();
Map<String, String> operations = new HashMap<String, String>(listOperation.size());
for (ServiceOperation operation : listOperation) {
String jobId = operation.getReferenceJobId();
if (jobId != null && !jobId.equals("")) {
String operationName = operation.getName();
IRepositoryViewObject jobNode = null;
for (IRepositoryViewObject job : jobs) {
if (job.getId().equals(jobId)) {
jobNode = job;
break;
}
}
if (jobNode == null) {
continue;
}
String jobName = jobNode.getLabel();
operations.put(operationName, jobName);
nodes.add(jobNode);
contextValues.putAll(JobContextUtils.getContextsMap((ProcessItem) jobNode.getProperty().getItem()));
}
}
ports.put(port, operations);
}
if (this.serviceManager == null) {
this.serviceManager = new ServiceExportManager(exportChoiceMap);
}
serviceManager.setDestinationPath(targetPath);
tempFolder = getTmpFolderPath();
}
use of org.talend.repository.services.model.services.ServiceOperation in project tesb-studio-se by Talend.
the class OpenJobAction method removeReferenecJobId.
protected static void removeReferenecJobId(IRepositoryNode node) {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
String parentPortName = node.getParent().getObject().getLabel();
ServiceItem serviceItem = (ServiceItem) node.getParent().getParent().getObject().getProperty().getItem();
List<ServicePort> listPort = ((ServiceConnection) serviceItem.getConnection()).getServicePort();
for (ServicePort port : listPort) {
if (port.getName().equals(parentPortName)) {
List<ServiceOperation> listOperation = port.getServiceOperation();
for (ServiceOperation operation : listOperation) {
if (operation.getLabel().equals(node.getObject().getLabel())) {
operation.setReferenceJobId(null);
operation.setLabel(operation.getName());
factory.save(node.getObject().getProperty().getItem());
}
}
break;
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
use of org.talend.repository.services.model.services.ServiceOperation in project tesb-studio-se by Talend.
the class ESBService method updateOperation.
@Override
public void updateOperation(INode node, String linkedRepository, RepositoryNode selectNode) {
String[] ids = linkedRepository.split(" - ");
if (ids.length == 3) {
try {
IRepositoryViewObject reViewObject = ProxyRepositoryFactory.getInstance().getLastVersion(ids[0]);
ServiceItem servicesItem = (ServiceItem) reViewObject.getProperty().getItem();
ServiceConnection serConn = (ServiceConnection) servicesItem.getConnection();
String portName = "";
EList<ServicePort> portList = serConn.getServicePort();
ServiceOperation operation = null;
for (ServicePort port : portList) {
if (port.getId().equals(ids[1])) {
portName = port.getName();
EList<ServiceOperation> opeList = port.getServiceOperation();
for (ServiceOperation ope : opeList) {
if (ope.getId().equals(ids[2])) {
operation = ope;
break;
}
}
break;
}
}
if (operation == null) {
return;
}
RepositoryNode topParent = getServicesTopNode(selectNode);
changeOldOperationLabel(topParent, node, operation);
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
IProcess2 process = (IProcess2) RepositoryPlugin.getDefault().getDesignerCoreService().getCurrentProcess();
Item jobItem = process.getProperty().getItem();
String jobID = jobItem.getProperty().getId();
String jobName = jobItem.getProperty().getLabel();
if (operation.getReferenceJobId() != null && !operation.getReferenceJobId().equals(jobID)) {
changeOtherJobSchemaValue(factory, operation, /* serConn, */
selectNode);
MessageDialog.openWarning(new Shell(), Messages.ESBService_DisconnectWarningTitle, Messages.ESBService_DisconnectWarningMsg);
}
operation.setReferenceJobId(jobID);
operation.setLabel(operation.getName() + '-' + jobName);
IFile wsdlPath = WSDLUtils.getWsdlFile(selectNode);
Map<String, String> serviceParameters = WSDLUtils.getServiceOperationParameters(wsdlPath, operation.getName(), portName);
CreateNewJobAction.setProviderRequestComponentConfiguration(node, serviceParameters);
factory.save(servicesItem);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
}
use of org.talend.repository.services.model.services.ServiceOperation in project tesb-studio-se by Talend.
the class ESBService method changeOldOperationLabel.
// public AbstractMetadataObject getServicesOperation(Connection connection, String operationName) {
// List<ServiceOperation> list = new ArrayList<ServiceOperation>();
// if (connection instanceof ServiceConnection) {
// ServiceConnection serConnection = (ServiceConnection) connection;
// EList<ServicePort> serPort = serConnection.getServicePort();
// for (ServicePort port : serPort) {
// list.addAll(port.getServiceOperation());
// }
// }
// for (ServiceOperation ope : list) {
// if (ope.getLabel().equals(operationName)) {
// return ope;
// }
// }
// return null;
// }
// public void changeOperationLabel(RepositoryNode newNode, INode node, Connection connection) {
// if (!(connection instanceof ServiceConnection)) {
// return;
// }
// ServiceConnection serConn = (ServiceConnection) connection;
// changeOldOperationLabel(serConn, node);
// changenewOperationLabel(newNode, node, serConn);
// }
private void changeOldOperationLabel(RepositoryNode topParent, INode node, ServiceOperation newOperation) {
// here should be all the ports, not just ports of one connection
List<IRepositoryNode> nodeList = topParent.getChildren();
IElementParameter elePara = node.getElementParameter("PROPERTY:" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
if (elePara == null) {
return;
}
ServiceConnection serConn = null;
ServiceItem servicesItem = null;
String paraValue = (String) elePara.getValue();
if (paraValue == null || "".equals(paraValue)) {
return;
}
String connID = null;
if (paraValue.contains(" - ")) {
connID = paraValue.split(" - ")[0];
} else {
connID = paraValue;
}
for (IRepositoryNode repNode : nodeList) {
String id = repNode.getObject().getProperty().getId();
if (id.equals(connID)) {
servicesItem = (ServiceItem) repNode.getObject().getProperty().getItem();
serConn = (ServiceConnection) servicesItem.getConnection();
break;
}
}
if (serConn == null) {
return;
}
EList<ServicePort> portList = serConn.getServicePort();
IElementParameter portPara = node.getElementParameter(WSDLUtils.PORT_NAME);
IElementParameter opePara = node.getElementParameter(WSDLUtils.OPERATION_NAME);
if (portPara != null && opePara != null) {
String portValue = (String) portPara.getValue();
String opeValue = (String) opePara.getValue();
if (portValue != null && !"".equals(portValue) && opeValue != null && !"".equals(opeValue)) {
out: for (ServicePort port : portList) {
if (port.getName().equals(portValue)) {
for (ServiceOperation ope : port.getServiceOperation()) {
if (ope.getName().equals(opeValue) && newOperation != null && !ope.getId().equals(newOperation.getId())) {
ope.setLabel(opeValue);
ope.setReferenceJobId(null);
if (servicesItem != null) {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
factory.save(servicesItem);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
break out;
}
}
}
}
}
}
}
Aggregations