Search in sources :

Example 6 with RepositoryViewObject

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

the class OpenWSDLPage method populateModelFromWsdl.

@SuppressWarnings({ "unchecked" })
private static void populateModelFromWsdl(IProxyRepositoryFactory factory, Definition definition, ServiceItem serviceItem, RepositoryNode serviceRepositoryNode) throws CoreException {
    serviceRepositoryNode.getChildren().clear();
    ((ServiceConnection) serviceItem.getConnection()).getServicePort().clear();
    for (PortType portType : (Collection<PortType>) definition.getAllPortTypes().values()) {
        ServicePort port = ServicesFactory.eINSTANCE.createServicePort();
        port.setId(factory.getNextId());
        port.setName(portType.getQName().getLocalPart());
        for (Operation operation : (Collection<Operation>) portType.getOperations()) {
            String operationName = operation.getName();
            ServiceOperation serviceOperation = ServicesFactory.eINSTANCE.createServiceOperation();
            serviceOperation.setId(factory.getNextId());
            RepositoryNode operationNode = new RepositoryNode(new RepositoryViewObject(serviceItem.getProperty()), serviceRepositoryNode, ENodeType.REPOSITORY_ELEMENT);
            operationNode.setProperties(EProperties.LABEL, serviceItem.getProperty().getLabel());
            operationNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.SERVICESOPERATION);
            serviceOperation.setName(operationName);
            if (operation.getDocumentationElement() != null) {
                serviceOperation.setDocumentation(operation.getDocumentationElement().getTextContent());
            }
            serviceOperation.setLabel(operationName);
            serviceOperation.setInBinding(WSDLUtils.isOperationInBinding(definition, port.getName(), operationName));
            port.getServiceOperation().add(serviceOperation);
        }
        ((ServiceConnection) serviceItem.getConnection()).getServicePort().add(port);
    }
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) Collection(java.util.Collection) Operation(javax.wsdl.Operation) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) RepositoryNode(org.talend.repository.model.RepositoryNode) PortType(javax.wsdl.PortType) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 7 with RepositoryViewObject

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

the class ImportItemWizardPage method populateItems.

/**
     * DOC hcw Comment method "populateItems".
     */
private void populateItems() {
    selectedItems.clear();
    final Collection<ItemRecord> items = new ArrayList<ItemRecord>();
    IRunnableWithProgress op = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            repositoryUtil.clearAllData();
            items.addAll(totalItemRecords = repositoryUtil.populateItems(manager, overwrite, monitor));
        }
    };
    try {
        new ProgressMonitorDialog(getShell()).run(true, true, op);
    } catch (Exception e) {
    // ignore me
    }
    errors.clear();
    for (ItemRecord itemRecord : items) {
        // bug 21738
        if (itemRecord.getExistingItemWithSameId() != null && itemRecord.getExistingItemWithSameId() instanceof RepositoryViewObject) {
            RepositoryViewObject reObject = (RepositoryViewObject) itemRecord.getExistingItemWithSameId();
            if (itemRecord.getProperty() != null && reObject != null) {
                if (itemRecord.getProperty().getId().equals(reObject.getId()) && itemRecord.getProperty().getLabel().equals(reObject.getLabel()) && itemRecord.getProperty().getVersion().equals(reObject.getVersion())) {
                    for (String error : itemRecord.getErrors()) {
                        //$NON-NLS-1$ //$NON-NLS-2$
                        errors.add("'" + itemRecord.getItemName() + "' " + error);
                    }
                } else if (itemRecord.getProperty().getId().equals(reObject.getId()) && itemRecord.getProperty().getLabel().equals(reObject.getLabel()) && !itemRecord.getProperty().getVersion().equals(reObject.getVersion())) {
                    for (String error : itemRecord.getErrors()) {
                        //$NON-NLS-1$ //$NON-NLS-2$
                        errors.add("'" + itemRecord.getItemName() + "' " + Messages.getString("ImportItemWizardPage.ErrorsMessage", reObject.getVersion()));
                    }
                } else {
                    // TDI-21399,TDI-21401
                    // if item is locked, cannot overwrite
                    ERepositoryStatus status = reObject.getRepositoryStatus();
                    if (status == ERepositoryStatus.LOCK_BY_OTHER || status == ERepositoryStatus.LOCK_BY_USER) {
                        for (String error : itemRecord.getErrors()) {
                            //$NON-NLS-1$ //$NON-NLS-2$
                            errors.add("'" + itemRecord.getItemName() + "' " + error);
                        }
                    }
                }
            }
        } else {
            if (itemRecord.getProperty() != null) {
                Item item = itemRecord.getProperty().getItem();
                if (item != null && (item instanceof JobDocumentationItem || item instanceof JobletDocumentationItem)) {
                    continue;
                }
                for (String error : itemRecord.getErrors()) {
                    //$NON-NLS-1$ //$NON-NLS-2$
                    errors.add("'" + itemRecord.getItemName() + "' " + error);
                }
            }
        }
    }
    if (errorsList != null) {
        errorsList.refresh();
    }
    selectedItems.addAll(items);
    checkTreeViewer.refresh(true);
    checkTreeViewer.expandAll();
    filteredCheckboxTree.resetCheckedElements();
    checkValidItems();
    updateFinishStatus();
// see feature 0004170: Unselect all items to import
// itemsList.setCheckedElements(checkValidItems());
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ArrayList(java.util.ArrayList) CoreException(org.eclipse.core.runtime.CoreException) ZipException(java.util.zip.ZipException) LoginException(org.talend.commons.exception.LoginException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TarException(org.eclipse.ui.internal.wizards.datatransfer.TarException) IOException(java.io.IOException) PersistenceException(org.talend.commons.exception.PersistenceException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) JobletDocumentationItem(org.talend.core.model.properties.JobletDocumentationItem) JobDocumentationItem(org.talend.core.model.properties.JobDocumentationItem) Item(org.talend.core.model.properties.Item) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) TreeItem(org.eclipse.swt.widgets.TreeItem) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) JobDocumentationItem(org.talend.core.model.properties.JobDocumentationItem) JobletDocumentationItem(org.talend.core.model.properties.JobletDocumentationItem) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Aggregations

RepositoryViewObject (org.talend.core.model.repository.RepositoryViewObject)7 RepositoryNode (org.talend.repository.model.RepositoryNode)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ZipException (java.util.zip.ZipException)2 IFile (org.eclipse.core.resources.IFile)2 CoreException (org.eclipse.core.runtime.CoreException)2 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)2 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)2 TarException (org.eclipse.ui.internal.wizards.datatransfer.TarException)2 PersistenceException (org.talend.commons.exception.PersistenceException)2 RepositoryObject (org.talend.core.model.repository.RepositoryObject)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1 Collection (java.util.Collection)1