Search in sources :

Example 96 with IRepositoryViewObject

use of org.talend.core.model.repository.IRepositoryViewObject in project tesb-studio-se by Talend.

the class ESBService method changeOtherJobSchemaValue.

// private void changenewOperationLabel(RepositoryNode newNode, INode node, ServiceConnection serConn) {
// String operationName = newNode.getObject().getLabel();
// String parentPortName = newNode.getParent().getObject().getLabel();
//
// String wsdlPath = serConn.getWSDLPath();
// try {
// Map<String, String> serviceParameters = WSDLUtils.getServiceParameters(wsdlPath);
// IRepositoryViewObject newObj = newNode.getObject();
// if (newObj instanceof OperationRepositoryObject) {
// ServiceOperation newOpe = (ServiceOperation) ((OperationRepositoryObject) newObj).getAbstractMetadataObject();
//
// IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
//
// if (newOpe.getReferenceJobId() != null) {
// changeOtherJobSchemaValue(factory, newOpe, serConn);
// MessageDialog.openWarning(new Shell(), "warning",
// "This other job which based on the Operation will be unset!");
// }
//
// IEditorPart activeEditor =
// PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
// IEditorInput input = activeEditor.getEditorInput();
// if (input instanceof ProcessEditorInput) {
// Item jobItem = ((ProcessEditorInput) input).getItem();
// String jobID = jobItem.getProperty().getId();
// String jobName = jobItem.getProperty().getLabel();
//
// newOpe.setReferenceJobId(jobID);
// newOpe.setLabel(newOpe.getName() + "-" + jobName);
//
// serviceParameters.put(WSDLUtils.PORT_NAME, parentPortName);
// serviceParameters.put(WSDLUtils.OPERATION_NAME, operationName);
//
// CreateNewJobAction.setProviderRequestComponentConfiguration(node, serviceParameters);
//
// try {
// factory.save(jobItem);
// } catch (PersistenceException e) {
// e.printStackTrace();
// }
// try {
// factory.save(newNode.getParent().getParent().getObject().getProperty().getItem());
// } catch (PersistenceException e) {
// e.printStackTrace();
// }
// RepositoryManager.refreshSavedNode(newNode);
// }
// }
//
// } catch (CoreException e1) {
// ExceptionHandler.process(e1);
// } catch (PersistenceException e) {
// ExceptionHandler.process(e);
// }
// }
private void changeOtherJobSchemaValue(IProxyRepositoryFactory factory, ServiceOperation newOpe, /*
                                                                                                      * ServiceConnection
                                                                                                      * serConn,
                                                                                                      */
RepositoryNode selectNode) throws PersistenceException, CoreException {
    IRepositoryViewObject jobObj = factory.getLastVersion(newOpe.getReferenceJobId());
    if (jobObj == null) {
        return;
    }
    ProcessItem processItem = (ProcessItem) jobObj.getProperty().getItem();
    IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
    boolean foundInOpen = false;
    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) {
            foundInOpen = true;
            process = processOpen;
            break;
        }
    }
    if (!foundInOpen) {
        IProcess proc = service.getProcessFromProcessItem(processItem);
        if (proc instanceof IProcess2) {
            process = (IProcess2) proc;
        }
    }
    newOpe.setReferenceJobId(null);
    newOpe.setLabel(newOpe.getName());
    if (process != null) {
        List<? extends INode> nodelist = process.getGraphicalNodes();
        for (INode node : nodelist) {
            if (node.getComponent().getName().equals("tESBProviderRequest")) {
                repositoryChange(selectNode, node, process);
                break;
            }
        }
        try {
            if (!foundInOpen) {
                processItem.setProcess(process.saveXmlFile());
                factory.save(processItem);
            }
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        } catch (IOException e) {
            ExceptionHandler.process(e);
        }
    }
// ProcessType process = item.getProcess();
// EList<NodeType> nodeList = process.getNode();
//
// for (NodeType node : nodeList) {
// EList parameters = node.getElementParameter();
// for (Object paramObj : parameters) {
// ElementParameterType param = (ElementParameterType) paramObj;
// String name = param.getName();
// if (name.equals(WSDLUtils.OPERATION_NAME)) {
// if (!newOpe.getName().equals(param.getValue())) {
// break;
// }
// param.setValue(null);
// }
// if (name.equals("SCHEMA:SCHEMA_TYPE")) {
// param.setValue("BUILT_IN");
// break;
// }
//
// }
//
// }
// factory.save(item);
}
Also used : INode(org.talend.core.model.process.INode) IOException(java.io.IOException) IEditorReference(org.eclipse.ui.IEditorReference) ProcessItem(org.talend.core.model.properties.ProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IProcess2(org.talend.core.model.process.IProcess2) PersistenceException(org.talend.commons.exception.PersistenceException) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess)

Example 97 with IRepositoryViewObject

use of org.talend.core.model.repository.IRepositoryViewObject 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);
    }
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ServiceItem(org.talend.repository.services.model.services.ServiceItem) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 98 with IRepositoryViewObject

use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method getProcessItemPath.

protected IPath getProcessItemPath(ProcessItem processItem, String path, boolean flag, String... selectedJobVersion) throws Exception {
    String processPath = processItem.getState().getPath();
    if (path != null) {
        processPath = path;
    }
    //$NON-NLS-1$ //$NON-NLS-2$
    processPath = processPath == null || processPath.equals("") ? "" : processPath;
    IPath emfFileRootPath = getEmfFileRootPath(processItem);
    String jobName = processItem.getProperty().getLabel();
    String jobVersion = processItem.getProperty().getVersion();
    if (!isMultiNodes() && selectedJobVersion != null && selectedJobVersion.length == 1) {
        jobVersion = selectedJobVersion[0];
    }
    IPath itemPath = emfFileRootPath.append(processPath).append(jobName + '_' + jobVersion + '.' + FileConstants.ITEM_EXTENSION);
    File itemFile = itemPath.toFile();
    if (!flag && !itemFile.exists()) {
        IRepositoryViewObject specificVersion = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().getSpecificVersion(processItem.getProperty().getId(), jobVersion, true);
        if (specificVersion != null) {
            Property property = specificVersion.getProperty();
            URI uri = property.eResource().getURI();
            IPath fullPath = URIHelper.convert(uri);
            IPath relativePath = fullPath.makeRelativeTo(emfFileRootPath);
            String realProcessPath = relativePath.removeLastSegments(1).removeFirstSegments(2).toString();
            return getProcessItemPath(processItem, realProcessPath, true, selectedJobVersion);
        }
    }
    return itemPath;
}
Also used : IPath(org.eclipse.core.runtime.IPath) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IFile(org.eclipse.core.resources.IFile) File(java.io.File) Property(org.talend.core.model.properties.Property) URI(org.eclipse.emf.common.util.URI)

Example 99 with IRepositoryViewObject

use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method addRoutinesSourceCodes.

protected void addRoutinesSourceCodes(ExportFileResource[] process, ExportFileResource resource, ITalendProcessJavaProject talendProcessJavaProject, boolean useBeans) throws Exception {
    List<IRepositoryViewObject> collectRoutines = new ArrayList<IRepositoryViewObject>();
    String include;
    if (useBeans) {
        include = USER_BEANS_PATH;
    } else {
        include = USER_ROUTINES_PATH;
    }
    collectRoutines.addAll(collectRoutines(process, include));
    collectRoutines.addAll(collectRoutines(process, USER_PIGUDF_PATH));
    Set<String> dependedRoutines = new HashSet<String>();
    for (IRepositoryViewObject obj : collectRoutines) {
        dependedRoutines.add(//$NON-NLS-1$
        obj.getLabel() + "." + ECodeLanguage.JAVA.getExtension());
    }
    IFolder srcFolder = talendProcessJavaProject.getSrcFolder();
    IFolder folder = null;
    if (useBeans) {
        folder = srcFolder.getFolder(USER_BEANS_PATH);
    } else {
        folder = srcFolder.getFolder(JavaUtils.JAVA_ROUTINES_DIRECTORY);
    }
    List<URL> userRoutinesFileUrls = new ArrayList<URL>();
    if (folder.exists()) {
        for (IResource fileResource : folder.members()) {
            if (fileResource instanceof IFile && ((IFile) fileResource).getFileExtension().equals(ECodeLanguage.JAVA.getExtension()) && dependedRoutines.contains(((IFile) fileResource).getName())) {
                userRoutinesFileUrls.add(fileResource.getLocationURI().toURL());
            }
        }
        if (useBeans) {
            resource.addResources(JOB_SOURCE_FOLDER_NAME + PATH_SEPARATOR + USER_BEANS_PATH, userRoutinesFileUrls);
        } else {
            resource.addResources(JOB_SOURCE_FOLDER_NAME + PATH_SEPARATOR + JavaUtils.JAVA_ROUTINES_DIRECTORY, userRoutinesFileUrls);
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) URL(java.net.URL) IResource(org.eclipse.core.resources.IResource) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet) IFolder(org.eclipse.core.resources.IFolder)

Example 100 with IRepositoryViewObject

use of org.talend.core.model.repository.IRepositoryViewObject in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method collectRoutines.

protected Collection<IRepositoryViewObject> collectRoutines(ExportFileResource[] process, String type) {
    List<IRepositoryViewObject> toReturn = new ArrayList<IRepositoryViewObject>();
    if (USER_BEANS_PATH.equals(type)) {
        ERepositoryObjectType beansType = null;
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
            ICamelDesignerCoreService service = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
            beansType = service.getBeansType();
        }
        try {
            toReturn = ProxyRepositoryFactory.getInstance().getAll(beansType);
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            toReturn = Collections.emptyList();
        }
    } else {
        Set<String> allRoutinesNames = new HashSet<String>();
        ERepositoryObjectType objectType = ERepositoryObjectType.ROUTINES;
        if (USER_PIGUDF_PATH.equals(type)) {
            objectType = ERepositoryObjectType.PIG_UDF;
        }
        if (ERepositoryObjectType.ROUTINES == objectType) {
            for (ExportFileResource resource : process) {
                if (resource.getItem() instanceof ProcessItem) {
                    Set<String> routinesNeededForJob = LastGenerationInfo.getInstance().getRoutinesNeededWithSubjobPerJob(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
                    if (routinesNeededForJob != null) {
                        allRoutinesNames.addAll(routinesNeededForJob);
                    }
                }
            }
        } else {
            for (ExportFileResource resource : process) {
                if (resource.getItem() instanceof ProcessItem) {
                    Set<String> routinesNeededForJob = LastGenerationInfo.getInstance().getPigudfNeededWithSubjobPerJob(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
                    if (routinesNeededForJob != null) {
                        allRoutinesNames.addAll(routinesNeededForJob);
                    }
                }
            }
        }
        if (allRoutinesNames.isEmpty()) {
            toReturn.addAll(RoutinesUtil.getCurrentSystemRoutines());
        } else {
            toReturn.addAll(collectRoutinesFromRepository(allRoutinesNames, objectType));
        }
    }
    return toReturn;
}
Also used : ICamelDesignerCoreService(org.talend.designer.core.ICamelDesignerCoreService) ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet)

Aggregations

IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)222 PersistenceException (org.talend.commons.exception.PersistenceException)115 Item (org.talend.core.model.properties.Item)86 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)67 ArrayList (java.util.ArrayList)63 ConnectionItem (org.talend.core.model.properties.ConnectionItem)54 ProcessItem (org.talend.core.model.properties.ProcessItem)54 RepositoryNode (org.talend.repository.model.RepositoryNode)50 IElementParameter (org.talend.core.model.process.IElementParameter)43 Property (org.talend.core.model.properties.Property)43 IRepositoryNode (org.talend.repository.model.IRepositoryNode)33 List (java.util.List)32 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)32 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)31 INode (org.talend.core.model.process.INode)30 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)25 Node (org.talend.designer.core.ui.editor.nodes.Node)25 Connection (org.talend.core.model.metadata.builder.connection.Connection)23 CoreException (org.eclipse.core.runtime.CoreException)17 RoutineItem (org.talend.core.model.properties.RoutineItem)17