use of org.talend.repository.services.model.services.ServicePort in project tesb-studio-se by Talend.
the class WSDLUtils method isValidService.
public static boolean isValidService(ServiceItem serviceItem) {
boolean isValid = false;
List<ServicePort> listPort = ((ServiceConnection) serviceItem.getConnection()).getServicePort();
for (ServicePort port : listPort) {
List<ServiceOperation> listOperation = port.getServiceOperation();
for (ServiceOperation operation : listOperation) {
if (operation.getReferenceJobId() != null) {
isValid = true;
break;
}
}
}
return isValid;
}
use of org.talend.repository.services.model.services.ServicePort in project tesb-studio-se by Talend.
the class ESBService method getValue.
@Override
public Object getValue(Item connItem, String value, INode node) {
if (connItem instanceof ServiceItem) {
ServiceItem serviceItem = ((ServiceItem) connItem);
if (WSDLUtils.ENDPOINT_URI.equals(value) || WSDLUtils.OPERATION_NAME.equals(value) || WSDLUtils.OPERATION_NS.equals(value) || WSDLUtils.PORT_NAME.equals(value) || WSDLUtils.PORT_NS.equals(value) || WSDLUtils.SERVICE_NAME.equals(value) || WSDLUtils.SERVICE_NS.equals(value) || WSDLUtils.WSDL_LOCATION.equals(value)) {
String wsdlPortTypeName = null;
String wsdlOperationName = null;
// find operation that job is bind to
String processId = node.getProcess().getId();
ServiceConnection connection = (ServiceConnection) serviceItem.getConnection();
for (ServicePort port : connection.getServicePort()) {
for (ServiceOperation operation : port.getServiceOperation()) {
if (processId.equals(operation.getReferenceJobId())) {
wsdlOperationName = operation.getName();
wsdlPortTypeName = port.getName();
break;
}
}
if (null != wsdlOperationName) {
break;
}
}
if (null == wsdlOperationName) {
// job is not bind to any data service operation -> no need any updates
return null;
}
if (WSDLUtils.OPERATION_NAME.equals(value)) {
return wsdlOperationName;
}
IFile wsdl = WSDLUtils.getWsdlFile(serviceItem);
if (WSDLUtils.WSDL_LOCATION.equals(value)) {
return wsdl.getLocation().toPortableString();
}
try {
return WSDLUtils.getServiceOperationParameters(wsdl, wsdlOperationName, wsdlPortTypeName).get(value);
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
}
return null;
}
use of org.talend.repository.services.model.services.ServicePort in project tesb-studio-se by Talend.
the class AssignJobAction method changeOldJob.
public void changeOldJob() {
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();
String oldJobID = null;
for (ServicePort port : listPort) {
if (port.getName().equals(portName)) {
List<ServiceOperation> listOperation = port.getServiceOperation();
for (ServiceOperation operation : listOperation) {
if (operation.getLabel().equals(operationName)) {
oldJobID = operation.getReferenceJobId();
break;
}
}
break;
}
}
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
if (oldJobID != null) {
IRepositoryViewObject object = factory.getLastVersion(oldJobID);
Item item = object.getProperty().getItem();
ProcessItem processItem = (ProcessItem) item;
//
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
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) {
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")) {
repositoryChangeToBuildIn(repositoryNode, node);
}
}
processItem.setProcess(process.saveXmlFile());
factory.save(processItem);
}
}
} catch (PersistenceException | IOException e) {
ExceptionHandler.process(e);
}
}
use of org.talend.repository.services.model.services.ServicePort in project tesb-studio-se by Talend.
the class ESBService method getServiceLabel.
@Override
public String getServiceLabel(Item item, String linkedRepository) {
String serviceName = item.getProperty().getLabel();
if (item instanceof ServiceItem) {
String[] ids = linkedRepository.split(" - ");
ServiceConnection serConn = (ServiceConnection) ((ServiceItem) item).getConnection();
if (ids.length == 3) {
String portName = "";
String operationName = "";
EList<ServicePort> portList = serConn.getServicePort();
out: 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])) {
operationName = ope.getName();
return serviceName + " - " + portName + " - " + operationName;
}
}
}
}
}
}
return serviceName;
}
use of org.talend.repository.services.model.services.ServicePort in project tesb-studio-se by Talend.
the class ESBService method copyDataServiceRelateJob.
@Override
public void copyDataServiceRelateJob(Item newItem) {
if (newItem instanceof ServiceItem) {
ServiceItem serviceItem = (ServiceItem) newItem;
ServiceConnection serviceConnection = (ServiceConnection) serviceItem.getConnection();
List<ServicePort> ports = serviceConnection.getServicePort();
for (ServicePort port : ports) {
List<ServiceOperation> operations = port.getServiceOperation();
for (ServiceOperation operation : operations) {
String referenceJobId = operation.getReferenceJobId();
if (referenceJobId != null && !referenceJobId.equals("")) {
IRepositoryViewObject jobObj = null;
try {
jobObj = ProxyRepositoryFactory.getInstance().getLastVersion(referenceJobId);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (jobObj == null) {
continue;
}
ProcessItem processItem = (ProcessItem) jobObj.getProperty().getItem();
String initNameValue = "Copy_of_" + processItem.getProperty().getLabel();
final IPath path = RepositoryNodeUtilities.getPath(processItem.getProperty().getId());
String jobNameValue = null;
try {
jobNameValue = getDuplicateName(RepositoryNodeUtilities.getRepositoryNode(jobObj), initNameValue);
} catch (BusinessException e) {
//$NON-NLS-1$
jobNameValue = "";
}
Item newProcessItem = copyJobForService(processItem, path, jobNameValue);
String operationLabel = operation.getLabel();
if (operationLabel.contains("-")) {
String[] array = operationLabel.split("-");
operation.setLabel(array[0] + "-" + jobNameValue);
}
// update nodes in newProcessItem
updateNodesInNewProcessItem(newProcessItem, serviceItem, port, operation);
operation.setReferenceJobId(newProcessItem.getProperty().getId());
try {
ProxyRepositoryFactory.getInstance().save(serviceItem);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
}
}
}
Aggregations