Search in sources :

Example 81 with IRepositoryViewObject

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

the class ExportServiceAction method addRequiredFeatures.

private void addRequiredFeatures(FeaturesModel features) {
    // add correlation feature
    ServiceConnection connection = (ServiceConnection) serviceItem.getConnection();
    String useRegistry = connection.getAdditionalInfo().get(ServiceMetadataDialog.USE_SERVICE_REGISTRY);
    if (!"true".equals(useRegistry)) {
        String useCorrelation = connection.getAdditionalInfo().get(ServiceMetadataDialog.USE_BUSINESS_CORRELATION);
        if ("true".equals(useCorrelation)) {
            features.addFeature(new FeatureModel(FeaturesModel.CORRELATION_FEATURE_NAME));
        }
    }
    // add talend-data-mapper feature
    for (IRepositoryViewObject node : nodes) {
        ProcessItem processItem = (ProcessItem) node.getProperty().getItem();
        if (null != EmfModelUtils.getComponentByName(processItem, THMAP_COMPONENT_NAME)) {
            features.addFeature(new FeatureModel(FeaturesModel.TALEND_DATA_MAPPER_FEATURE_NAME));
            break;
        }
    }
}
Also used : ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) ProcessItem(org.talend.core.model.properties.ProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) FeatureModel(org.talend.designer.publish.core.models.FeatureModel)

Example 82 with IRepositoryViewObject

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

the class ExportServiceAction method init.

private void init(String targetPath) throws InvocationTargetException {
    serviceName = serviceItem.getProperty().getLabel();
    serviceVersion = serviceItem.getProperty().getVersion();
    serviceWsdl = WSDLUtils.getWsdlFile(serviceItem);
    ServiceConnection serviceConnection = (ServiceConnection) serviceItem.getConnection();
    additionalInfo = serviceConnection.getAdditionalInfo().map();
    EList<ServicePort> listPort = serviceConnection.getServicePort();
    List<IRepositoryViewObject> jobs;
    try {
        jobs = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.PROCESS);
    } catch (PersistenceException e) {
        throw new InvocationTargetException(e);
    }
    for (ServicePort port : listPort) {
        List<ServiceOperation> listOperation = port.getServiceOperation();
        Map<String, String> operations = new HashMap<String, String>(listOperation.size());
        for (ServiceOperation operation : listOperation) {
            String jobId = operation.getReferenceJobId();
            if (jobId != null && !jobId.equals("")) {
                String operationName = operation.getName();
                IRepositoryViewObject jobNode = null;
                for (IRepositoryViewObject job : jobs) {
                    if (job.getId().equals(jobId)) {
                        jobNode = job;
                        break;
                    }
                }
                if (jobNode == null) {
                    continue;
                }
                String jobName = jobNode.getLabel();
                operations.put(operationName, jobName);
                nodes.add(jobNode);
                contextValues.putAll(JobContextUtils.getContextsMap((ProcessItem) jobNode.getProperty().getItem()));
            }
        }
        ports.put(port, operations);
    }
    if (this.serviceManager == null) {
        this.serviceManager = new ServiceExportManager(exportChoiceMap);
    }
    serviceManager.setDestinationPath(targetPath);
    tempFolder = getTmpFolderPath();
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) HashMap(java.util.HashMap) ServiceExportManager(org.talend.repository.services.ui.scriptmanager.ServiceExportManager) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) InvocationTargetException(java.lang.reflect.InvocationTargetException) ProcessItem(org.talend.core.model.properties.ProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 83 with IRepositoryViewObject

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

the class VersionSection method createControls.

@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {
    super.createControls(parent, aTabbedPropertySheetPage);
    composite = getWidgetFactory().createFlatFormComposite(parent);
    tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    final Table table = tableViewer.getTable();
    TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    final String[] columnProperties = new String[] { //$NON-NLS-1$
    Messages.getString("VersionSection.Version"), //$NON-NLS-1$
    Messages.getString("VersionSection.CreationDate"), Messages.getString("VersionSection.ModificationDate"), //$NON-NLS-1$ //$NON-NLS-2$ 
    Messages.getString("VersionSection.Status") };
    final TableColumn column1 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column1.setText(columnProperties[0]);
    final TableColumn column2 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column2.setText(columnProperties[1]);
    final TableColumn column3 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnPixelData(125, true));
    column3.setText(columnProperties[2]);
    final TableColumn column4 = new TableColumn(table, SWT.NONE);
    tableLayout.addColumnData(new ColumnWeightData(1, 150, true));
    column4.setText(columnProperties[3]);
    tableViewer.setColumnProperties(columnProperties);
    Object layoutData = parent.getLayoutData();
    if (layoutData instanceof GridData) {
        GridData gridData = (GridData) layoutData;
        gridData.grabExcessVerticalSpace = true;
        gridData.verticalAlignment = SWT.FILL;
    }
    FormData formData = new FormData();
    formData.left = new FormAttachment(0);
    formData.top = new FormAttachment(0);
    formData.right = new FormAttachment(100);
    formData.bottom = new FormAttachment(100);
    table.setLayoutData(formData);
    tableViewer.setContentProvider(new IStructuredContentProvider() {

        public Object[] getElements(Object inputElement) {
            IRepositoryViewObject repositoryObject = ((IRepositoryViewObject) inputElement);
            if (repositoryObject.getProperty() == null) {
                return null;
            }
            RepositoryNode parentRepositoryNode = RepositoryNodeUtilities.getParentRepositoryNodeFromSelection(repositoryObject);
            try {
                List<IRepositoryViewObject> allVersion = ProxyRepositoryFactory.getInstance().getAllVersion(repositoryObject.getId());
                Collections.sort(allVersion, new IRepositoryObjectComparator());
                Object[] objects = new Object[allVersion.size()];
                for (int i = 0; i < objects.length; i++) {
                    IRepositoryViewObject repositoryObjectVersion = allVersion.get(i);
                    RepositoryNode repositoryNode = createRepositoryNode(parentRepositoryNode, repositoryObjectVersion);
                    objects[i] = repositoryNode;
                }
                return objects;
            } catch (PersistenceException e) {
                return null;
            }
        }

        private RepositoryNode createRepositoryNode(RepositoryNode parentRepositoryNode, IRepositoryViewObject repositoryObjectVersion) {
            ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(repositoryObjectVersion.getProperty().getItem());
            RepositoryNode repositoryNode = new RepositoryNode(repositoryObjectVersion, parentRepositoryNode, ENodeType.REPOSITORY_ELEMENT);
            repositoryNode.setProperties(EProperties.CONTENT_TYPE, itemType);
            repositoryNode.setProperties(EProperties.LABEL, repositoryObjectVersion.getLabel());
            return repositoryNode;
        }

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
    });
    tableViewer.setLabelProvider(new ITableLabelProvider() {

        public Image getColumnImage(Object element, int columnIndex) {
            return null;
        }

        public String getColumnText(Object element, int columnIndex) {
            RepositoryNode repositoryNode = (RepositoryNode) element;
            switch(columnIndex) {
                case 0:
                    return repositoryNode.getObject().getVersion();
                case 1:
                    if (repositoryNode.getObject().getCreationDate() != null) {
                        return FORMATTER.format(repositoryNode.getObject().getCreationDate());
                    } else {
                        return null;
                    }
                case 2:
                    if (repositoryNode.getObject().getModificationDate() != null) {
                        return FORMATTER.format(repositoryNode.getObject().getModificationDate());
                    } else {
                        return null;
                    }
                case 3:
                    if (repositoryNode.getObject().getStatusCode() != null) {
                        return repositoryNode.getObject().getStatusCode();
                    } else {
                        return null;
                    }
                default:
                    return null;
            }
        }

        public void addListener(ILabelProviderListener listener) {
        }

        public void dispose() {
        }

        public boolean isLabelProperty(Object element, String property) {
            return false;
        }

        public void removeListener(ILabelProviderListener listener) {
        }
    });
    //$NON-NLS-1$
    MenuManager menuMgr = new MenuManager("#PopUp");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager mgr) {
            ISelection selection = tableViewer.getSelection();
            if (selection instanceof IStructuredSelection) {
                IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                List<ITreeContextualAction> contextualsActions = ActionsHelper.getRepositoryContextualsActions();
                for (ITreeContextualAction action : contextualsActions) {
                    if (action.isReadAction() || action.isEditAction() || action.isPropertiesAction()) {
                        action.init(null, structuredSelection);
                        if (action.isVisible()) {
                            mgr.add(action);
                        }
                    }
                }
            }
        }
    });
    Menu menu = menuMgr.createContextMenu(tableViewer.getControl());
    tableViewer.getControl().setMenu(menu);
    Listener sortListener = new Listener() {

        private int direction = 1;

        public void handleEvent(Event e) {
            final TableColumn column = (TableColumn) e.widget;
            if (column == table.getSortColumn()) {
                direction = -direction;
            }
            if (direction == 1) {
                table.setSortDirection(SWT.DOWN);
            } else {
                table.setSortDirection(SWT.UP);
            }
            table.setSortColumn(column);
            tableViewer.setSorter(new ViewerSorter() {

                int index = 0;

                @Override
                public void sort(Viewer viewer, Object[] elements) {
                    while (index < table.getColumns().length && table.getColumn(index) != column) {
                        index++;
                    }
                    super.sort(viewer, elements);
                }

                @Override
                public int compare(Viewer viewer, Object e1, Object e2) {
                    ITableLabelProvider labelProvider = (ITableLabelProvider) tableViewer.getLabelProvider();
                    String columnText = labelProvider.getColumnText(e1, index) != null ? labelProvider.getColumnText(e1, index) : //$NON-NLS-1$
                    "";
                    String columnText2 = labelProvider.getColumnText(e2, index) != null ? labelProvider.getColumnText(e2, index) : //$NON-NLS-1$
                    "";
                    return getComparator().compare(columnText, columnText2) * direction;
                }
            });
        }
    };
    column1.addListener(SWT.Selection, sortListener);
    column2.addListener(SWT.Selection, sortListener);
    column3.addListener(SWT.Selection, sortListener);
    column4.addListener(SWT.Selection, sortListener);
    table.setSortColumn(column1);
    table.setSortDirection(SWT.DOWN);
    aTabbedPropertySheetPage.getSite().setSelectionProvider(this);
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Listener(org.eclipse.swt.widgets.Listener) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) IMenuListener(org.eclipse.jface.action.IMenuListener) ViewerSorter(org.eclipse.jface.viewers.ViewerSorter) TableViewer(org.eclipse.jface.viewers.TableViewer) Viewer(org.eclipse.jface.viewers.Viewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ITreeContextualAction(org.talend.commons.ui.swt.actions.ITreeContextualAction) Image(org.eclipse.swt.graphics.Image) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) ISelection(org.eclipse.jface.viewers.ISelection) List(java.util.List) Menu(org.eclipse.swt.widgets.Menu) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) TableLayout(org.eclipse.jface.viewers.TableLayout) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormData(org.eclipse.swt.layout.FormData) Table(org.eclipse.swt.widgets.Table) ColumnPixelData(org.eclipse.jface.viewers.ColumnPixelData) RepositoryNode(org.talend.repository.model.RepositoryNode) TableColumn(org.eclipse.swt.widgets.TableColumn) IMenuListener(org.eclipse.jface.action.IMenuListener) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Event(org.eclipse.swt.widgets.Event) IRepositoryObject(org.talend.core.model.repository.IRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IMenuManager(org.eclipse.jface.action.IMenuManager) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 84 with IRepositoryViewObject

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

the class JobJavaScriptsManager method collectRoutinesFromRepository.

private Collection<IRepositoryViewObject> collectRoutinesFromRepository(Set<String> allRoutinesNames, ERepositoryObjectType type) {
    IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
    List<IRepositoryViewObject> toReturn = new ArrayList<IRepositoryViewObject>();
    try {
        List<IRepositoryViewObject> availableRoutines = factory.getAll(ProjectManager.getInstance().getCurrentProject(), type);
        for (IRepositoryViewObject object : availableRoutines) {
            if (allRoutinesNames.contains(object.getLabel())) {
                allRoutinesNames.remove(object.getLabel());
                toReturn.add(object);
            }
        }
        if (allRoutinesNames.isEmpty()) {
            return toReturn;
        }
        for (org.talend.core.model.general.Project project : ProjectManager.getInstance().getAllReferencedProjects()) {
            for (IRepositoryViewObject object : factory.getAll(project, type)) {
                if (allRoutinesNames.contains(object.getLabel())) {
                    allRoutinesNames.remove(object.getLabel());
                    toReturn.add(object);
                }
            }
            if (allRoutinesNames.isEmpty()) {
                return toReturn;
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
        toReturn.addAll(RoutinesUtil.getCurrentSystemRoutines());
    }
    return toReturn;
}
Also used : ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 85 with IRepositoryViewObject

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

the class SQLBuilderDialog method deleteNoUseTable.

private void deleteNoUseTable() {
    // add for bug TDI-17097
    connection = (DatabaseConnection) SQLBuilderRepositoryNodeManager.getItem(SQLBuilderRepositoryNodeManager.getRoot(nodeInEditor)).getConnection();
    if (SQLBuilderRepositoryNodeManager.tList instanceof List) {
        if (SQLBuilderRepositoryNodeManager.tList.size() == 0) {
            SQLBuilderRepositoryNodeManager.tList.addAll(ConnectionHelper.getTables(connection));
        }
    } else {
        SQLBuilderRepositoryNodeManager.tList = new ArrayList<MetadataTable>();
        SQLBuilderRepositoryNodeManager.tList.addAll(ConnectionHelper.getTables(connection));
    }
    if (SQLBuilderRepositoryNodeManager.tList == null || SQLBuilderRepositoryNodeManager.tList.size() == 0) {
        return;
    }
    // changed for bug TDI-19892
    if (node == null) {
        SQLBuilderRepositoryNodeManager.tList = null;
        return;
    }
    IRepositoryViewObject repositoryObject = node.getObject();
    Item item = repositoryObject.getProperty().getItem();
    if (item instanceof DatabaseConnectionItem) {
        manager.deleteNouseTables(((DatabaseConnectionItem) item).getConnection());
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) CTabItem(org.eclipse.swt.custom.CTabItem) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) List(java.util.List) ArrayList(java.util.ArrayList) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

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