use of org.talend.repository.services.model.services.ServiceItem 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.ServiceItem in project tesb-studio-se by Talend.
the class OpenWSDLWizard method addPages.
@Override
public void addPages() {
super.addPages();
IPath pathToSave;
switch(repositoryNode.getType()) {
case SIMPLE_FOLDER:
case REPOSITORY_ELEMENT:
pathToSave = RepositoryNodeUtilities.getPath(repositoryNode);
break;
//case SYSTEM_FOLDER:
default:
//$NON-NLS-1$
pathToSave = new Path("");
break;
}
wsdlPage = new OpenWSDLPage(repositoryNode, pathToSave, (ServiceItem) repositoryNode.getObject().getProperty().getItem(), false);
addPage(wsdlPage);
}
use of org.talend.repository.services.model.services.ServiceItem in project tesb-studio-se by Talend.
the class ServiceMetadataAction method isLocked.
private static boolean isLocked(IRepositoryViewObject object) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
ICoreService coreService = (ICoreService) GlobalServiceRegister.getDefault().getService(ICoreService.class);
boolean isOpened = coreService.isOpenedItemInEditor(object);
if (isOpened) {
return true;
}
}
ServiceItem serviceItem = (ServiceItem) object.getProperty().getItem();
return serviceItem.getState().isLocked();
}
use of org.talend.repository.services.model.services.ServiceItem 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.ServiceItem in project tesb-studio-se by Talend.
the class OpenWSDLEditorAction method init.
@Override
protected void init(RepositoryNode node) {
// set to true for service node and service port node
final boolean isServicesNode = ESBRepositoryNodeType.SERVICES == node.getObjectType() || ESBRepositoryNodeType.SERVICEPORT == node.getObjectType();
setEnabled(isServicesNode);
// anyway initialize for double-click
if (isServicesNode && null != node.getObject()) {
Item item = node.getObject().getProperty().getItem();
if (item instanceof ServiceItem) {
serviceItem = (ServiceItem) item;
}
}
}
Aggregations