use of org.talend.repository.services.model.services.ServiceOperation in project tesb-studio-se by Talend.
the class ESBService method getAllTheJObNames.
@Override
public StringBuffer getAllTheJObNames(IRepositoryNode jobObject) {
StringBuffer jobNames = null;
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
List<IRepositoryNode> jobList = new ArrayList<IRepositoryNode>();
if (jobObject.getObjectType() == ERepositoryObjectType.PROCESS) {
jobList.add(jobObject);
} else if (jobObject.getObjectType() == ERepositoryObjectType.FOLDER) {
jobList = getJobObject(jobObject);
}
try {
List<IRepositoryViewObject> repList = factory.getAll(getServicesType());
for (IRepositoryNode node : jobList) {
ERepositoryObjectType repositoryObjectType = node.getObjectType();
if (repositoryObjectType != ERepositoryObjectType.PROCESS) {
continue;
}
String jobID = node.getObject().getProperty().getId();
for (IRepositoryViewObject obj : repList) {
ServiceItem item = (ServiceItem) obj.getProperty().getItem();
ServiceConnection conn = (ServiceConnection) item.getConnection();
middle: for (ServicePort port : conn.getServicePort()) {
for (ServiceOperation operation : port.getServiceOperation()) {
if (operation.getReferenceJobId() != null && operation.getReferenceJobId().endsWith(jobID)) {
if (jobNames == null) {
jobNames = new StringBuffer(node.getObject().getProperty().getLabel());
} else {
jobNames.append(",");
jobNames.append(node.getObject().getProperty().getLabel());
}
break middle;
}
}
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
return jobNames;
}
use of org.talend.repository.services.model.services.ServiceOperation 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.repository.services.model.services.ServiceOperation in project tesb-studio-se by Talend.
the class CreateNewJobAction method init.
@Override
protected void init(RepositoryNode node) {
ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
if (!ERepositoryObjectType.SERVICESOPERATION.equals(nodeType)) {
return;
}
boolean flag = true;
ServiceItem serviceItem = (ServiceItem) node.getParent().getParent().getObject().getProperty().getItem();
for (ServicePort port : ((ServiceConnection) serviceItem.getConnection()).getServicePort()) {
for (ServiceOperation operation : port.getServiceOperation()) {
if (operation.getLabel().equals(node.getLabel()) && operation.getReferenceJobId() != null && !operation.getReferenceJobId().equals("")) {
flag = false;
}
}
}
setEnabled(flag);
}
use of org.talend.repository.services.model.services.ServiceOperation in project tesb-studio-se by Talend.
the class AssignJobAction method getAllReferenceJobId.
private List<String> getAllReferenceJobId(RepositoryNode repositoryNode) {
repositoryNode = getTopParent(repositoryNode);
List<IRepositoryNode> nodeList = repositoryNode.getChildren();
List<ServiceOperation> operaList = new ArrayList<ServiceOperation>();
List<String> jobIDList = new ArrayList<String>();
for (IRepositoryNode node : nodeList) {
if (node.getObject().getProperty().getItem() instanceof ServiceItem) {
ServiceItem item = (ServiceItem) node.getObject().getProperty().getItem();
ServiceConnection conn = (ServiceConnection) item.getConnection();
EList<ServicePort> portList = conn.getServicePort();
for (ServicePort port : portList) {
operaList.addAll(port.getServiceOperation());
}
}
}
for (ServiceOperation operation : operaList) {
String jobID = operation.getReferenceJobId();
if (jobID != null) {
jobIDList.add(jobID);
}
}
return jobIDList;
}
use of org.talend.repository.services.model.services.ServiceOperation in project tesb-studio-se by Talend.
the class ESBService method refreshOperationLabel.
@Override
public void refreshOperationLabel(String jobID) {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
List<IRepositoryViewObject> repList = factory.getAll(getServicesType());
for (IRepositoryViewObject obj : repList) {
ServiceItem item = (ServiceItem) obj.getProperty().getItem();
ServiceConnection conn = (ServiceConnection) item.getConnection();
for (ServicePort port : conn.getServicePort()) {
for (ServiceOperation operation : port.getServiceOperation()) {
if (operation.getReferenceJobId() != null && operation.getReferenceJobId().endsWith(jobID)) {
operation.setLabel(operation.getName());
operation.setReferenceJobId(null);
factory.save(item);
return;
}
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
Aggregations