Search in sources :

Example 1 with JobletDocumentationItem

use of org.talend.core.model.properties.JobletDocumentationItem 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

IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 ZipException (java.util.zip.ZipException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1 TarException (org.eclipse.ui.internal.wizards.datatransfer.TarException)1 LoginException (org.talend.commons.exception.LoginException)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 ERepositoryStatus (org.talend.commons.runtime.model.repository.ERepositoryStatus)1 Item (org.talend.core.model.properties.Item)1 JobDocumentationItem (org.talend.core.model.properties.JobDocumentationItem)1 JobletDocumentationItem (org.talend.core.model.properties.JobletDocumentationItem)1 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)1 RepositoryViewObject (org.talend.core.model.repository.RepositoryViewObject)1