use of org.talend.repository.services.model.services.ServiceConnection 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.ServiceConnection 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);
}
}
use of org.talend.repository.services.model.services.ServiceConnection in project tesb-studio-se by Talend.
the class ESBService method editJobName.
@Override
public void editJobName(String originaleObjectLabel, String newLabel) {
IProxyRepositoryFactory proxyRepositoryFactory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
Project project = ProjectManager.getInstance().getCurrentProject();
List<IRepositoryViewObject> service = null;
try {
service = proxyRepositoryFactory.getAll(project, ESBRepositoryNodeType.SERVICES, true);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (service != null && service.size() > 0) {
for (IRepositoryViewObject Object : service) {
boolean flag = false;
ServiceItem item = (ServiceItem) Object.getProperty().getItem();
ServiceConnection serviceConnection = (ServiceConnection) item.getConnection();
List<ServicePort> servicePorts = serviceConnection.getServicePort();
for (ServicePort port : servicePorts) {
List<ServiceOperation> serviceOperations = port.getServiceOperation();
for (ServiceOperation operation : serviceOperations) {
String originaleItemLabel = operation.getLabel();
if (originaleItemLabel.contains("-")) {
String[] array = originaleItemLabel.split("-");
if (originaleObjectLabel.equals(array[1])) {
operation.setLabel(array[0] + "-" + newLabel);
flag = true;
}
}
}
}
if (flag) {
try {
proxyRepositoryFactory.save(item);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
}
// RepositoryManager.refresh(ESBRepositoryNodeType.SERVICES);
}
use of org.talend.repository.services.model.services.ServiceConnection in project tesb-studio-se by Talend.
the class ESBService method deleteOldRelation.
@Override
public void deleteOldRelation(String jobID) {
boolean portBreak = false;
boolean serviceBreak = false;
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
for (IRepositoryViewObject viewObject : factory.getAll(ERepositoryObjectType.SERVICESOPERATION)) {
ServiceItem serviceItem = (ServiceItem) viewObject.getProperty().getItem();
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 (jobID.equals(referenceJobId)) {
operation.setLabel(operation.getName());
operation.setReferenceJobId(null);
portBreak = true;
break;
}
}
if (portBreak) {
serviceBreak = true;
break;
}
}
if (serviceBreak) {
factory.save(serviceItem, null);
break;
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
use of org.talend.repository.services.model.services.ServiceConnection in project tesb-studio-se by Talend.
the class LocalWSDLEditor method saveModel.
private void saveModel() throws CoreException {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
Definition definition = WSDLUtils.getDefinition(serviceItem);
// changed for TDI-18005
Map<String, String> portNameIdMap = new HashMap<String, String>();
Map<String, EMap<String, String>> portAdditionalMap = new HashMap<String, EMap<String, String>>();
Map<String, String> operNameIdMap = new HashMap<String, String>();
Map<String, String> operJobMap = new HashMap<String, String>();
EList<ServicePort> oldServicePorts = ((ServiceConnection) serviceItem.getConnection()).getServicePort();
// get old service port item names and operation names under them
HashMap<String, ArrayList<String>> oldPortItemNames = new HashMap<String, ArrayList<String>>();
for (ServicePort servicePort : oldServicePorts) {
// keep id
portNameIdMap.put(servicePort.getName(), servicePort.getId());
// keep additional infos
portAdditionalMap.put(servicePort.getId(), servicePort.getAdditionalInfo());
EList<ServiceOperation> operations = servicePort.getServiceOperation();
ArrayList<String> operationNames = new ArrayList<String>();
for (ServiceOperation operation : operations) {
operNameIdMap.put(operation.getName(), operation.getId());
operationNames.add(operation.getLabel());
// record assigned job
operJobMap.put(operation.getId(), operation.getReferenceJobId());
}
oldPortItemNames.put(servicePort.getName(), operationNames);
}
((ServiceConnection) serviceItem.getConnection()).getServicePort().clear();
for (Object obj : definition.getAllPortTypes().values()) {
PortType portType = (PortType) obj;
if (portType.isUndefined()) {
continue;
}
ServicePort port = ServicesFactory.eINSTANCE.createServicePort();
String portName = portType.getQName().getLocalPart();
port.setName(portName);
// set port id
String id = portNameIdMap.get(portName);
if (id != null) {
port.setId(id);
// restore additional infos
port.getAdditionalInfo().putAll(portAdditionalMap.get(id));
} else {
port.setId(factory.getNextId());
}
@SuppressWarnings("unchecked") List<Operation> list = portType.getOperations();
for (Operation operation : list) {
if (operation.isUndefined()) {
// means the operation has been removed already ,why ?
continue;
}
ServiceOperation serviceOperation = ServicesFactory.eINSTANCE.createServiceOperation();
serviceOperation.setName(operation.getName());
Iterator<String> operationIterator = operNameIdMap.keySet().iterator();
while (operationIterator.hasNext()) {
String oldOperationName = operationIterator.next();
String operationId = operNameIdMap.get(oldOperationName);
if (oldOperationName.equals(operation.getName())) {
serviceOperation.setId(operationId);
// re-assign job
String jobId = operJobMap.get(operationId);
if (jobId != null) {
serviceOperation.setReferenceJobId(jobId);
}
}
}
if (serviceOperation.getId() == null || serviceOperation.getId().equals("")) {
serviceOperation.setId(factory.getNextId());
}
if (operation.getDocumentationElement() != null) {
serviceOperation.setDocumentation(operation.getDocumentationElement().getTextContent());
}
boolean hasAssignedjob = false;
ArrayList<String> operationNames = oldPortItemNames.get(portName);
String referenceJobId = serviceOperation.getReferenceJobId();
if (operationNames != null && referenceJobId != null) {
IRepositoryViewObject repObj = null;
try {
repObj = factory.getLastVersion(referenceJobId);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (repObj != null) {
for (String name : operationNames) {
if (name.equals(operation.getName() + '-' + repObj.getLabel())) {
serviceOperation.setLabel(name);
hasAssignedjob = true;
break;
}
}
}
}
if (!hasAssignedjob) {
serviceOperation.setLabel(operation.getName());
}
serviceOperation.setInBinding(WSDLUtils.isOperationInBinding(definition, portName, operation.getName()));
port.getServiceOperation().add(serviceOperation);
}
((ServiceConnection) serviceItem.getConnection()).getServicePort().add(port);
}
}
Aggregations