use of org.talend.repository.services.model.services.ServiceOperation 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