Search in sources :

Example 6 with ItemVersionObject

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

the class AbstractVersionManagementProjectSettingPage method selectSubjob.

protected void selectSubjob() {
    List<ItemVersionObject> jobList = new ArrayList<ItemVersionObject>();
    for (ItemVersionObject object : checkedObjects) {
        if (MavenVersionUtils.isHasSubjobType(ERepositoryObjectType.getItemType(object.getItem()))) {
            jobList.add(object);
        }
    }
    for (ItemVersionObject object : jobList) {
        if (object.getRepositoryNode() != null) {
            List<Relation> relations = builder.getItemsJobRelatedTo(object.getRepositoryNode().getId(), object.getItem().getProperty().getVersion(), RelationshipItemBuilder.JOB_RELATION);
            for (Relation relation : relations) {
                try {
                    IRepositoryViewObject obj = FACTORY.getLastVersion(relation.getId());
                    if (obj != null) {
                        for (ItemVersionObject obj2 : versionObjects) {
                            if (obj2.getItem() == obj.getProperty().getItem()) {
                                ItemVersionObject relat = obj2;
                                if (!checkedObjects.contains(relat)) {
                                    checkedObjects.add(relat);
                                    checkAllVerSionLatest(checkedObjects, relat);
                                }
                                break;
                            }
                        }
                    }
                } catch (PersistenceException et) {
                    ExceptionHandler.process(et);
                }
            }
        }
    }
    refreshTableItems();
    refreshCheckedTreeView();
}
Also used : Relation(org.talend.core.model.relationship.Relation) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ItemVersionObject(org.talend.repository.model.ItemVersionObject)

Example 7 with ItemVersionObject

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

the class AbstractVersionManagementProjectSettingPage method checkAllVerSionLatest.

protected void checkAllVerSionLatest(List<ItemVersionObject> tableList, ItemVersionObject object) {
    if (object.getRepositoryNode() != null) {
        List<Relation> relations = builder.getItemsJobRelatedTo(object.getRepositoryNode().getId(), object.getItem().getProperty().getVersion(), RelationshipItemBuilder.JOB_RELATION);
        for (Relation relation : relations) {
            try {
                IRepositoryViewObject obj = FACTORY.getLastVersion(relation.getId());
                if (obj != null) {
                    for (ItemVersionObject obj2 : versionObjects) {
                        if (obj2.getItem() == obj.getProperty().getItem()) {
                            ItemVersionObject relat = obj2;
                            if (!tableList.contains(relat)) {
                                tableList.add(relat);
                                checkAllVerSionLatest(tableList, relat);
                            }
                            break;
                        }
                    }
                }
            } catch (PersistenceException et) {
                ExceptionHandler.process(et);
            }
        }
    }
}
Also used : Relation(org.talend.core.model.relationship.Relation) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ItemVersionObject(org.talend.repository.model.ItemVersionObject)

Example 8 with ItemVersionObject

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

the class AbstractVersionManagementProjectSettingPage method refreshCheckedTreeView.

protected void refreshCheckedTreeView() {
    List<RepositoryNode> nodes = new ArrayList<RepositoryNode>();
    for (TableItem item : itemTable.getItems()) {
        Object data = item.getData();
        if (data instanceof ItemVersionObject) {
            nodes.add(((ItemVersionObject) data).getRepositoryNode());
        }
    }
    treeViewer.setCheckedElements(nodes.toArray());
// treeViewer.refresh();
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ItemVersionObject(org.talend.repository.model.ItemVersionObject) ItemVersionObject(org.talend.repository.model.ItemVersionObject) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 9 with ItemVersionObject

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

the class AbstractVersionManagementProjectSettingPage method processItems.

protected void processItems(List<ItemVersionObject> objects, RepositoryNode node) {
    if (node == null) {
        return;
    }
    // if the root node of type is not init, force init.
    IProjectRepositoryNode root = node.getRoot();
    if (root instanceof ProjectRepositoryNode) {
        ((ProjectRepositoryNode) root).initNode(node);
    }
    if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
        if (node.getObject() != null) {
            Property property = node.getObject().getProperty();
            Item item = property.getItem();
            if (item != null && filterRepositoryNode(node)) {
                // must be item
                ItemVersionObject object = createItemVersionObject(node, property);
                objects.add(object);
            }
        }
    } else {
        IContentProvider contentProvider = treeViewer.getContentProvider();
        if (contentProvider instanceof NavigatorContentServiceContentProvider) {
            NavigatorContentServiceContentProvider navigatorProvider = (NavigatorContentServiceContentProvider) contentProvider;
            Object[] children = navigatorProvider.getChildren(node);
            for (Object child : children) {
                if (child instanceof RepositoryNode) {
                    processItems(objects, (RepositoryNode) child);
                }
            }
        } else {
            for (IRepositoryNode child : node.getChildren()) {
                processItems(objects, (RepositoryNode) child);
            }
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) TableItem(org.eclipse.swt.widgets.TableItem) IContentProvider(org.eclipse.jface.viewers.IContentProvider) IRepositoryNode(org.talend.repository.model.IRepositoryNode) NavigatorContentServiceContentProvider(org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ItemVersionObject(org.talend.repository.model.ItemVersionObject) ItemVersionObject(org.talend.repository.model.ItemVersionObject) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Property(org.talend.core.model.properties.Property) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode)

Example 10 with ItemVersionObject

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

the class AbstractVersionManagementProjectSettingPage method okPressed.

protected void okPressed() {
    if (fixedVersionText == null) {
        return;
    }
    boolean modified = false;
    String newVersion = null;
    for (ItemVersionObject object : checkedObjects) {
        newVersion = getNewVersionWithOption(object);
        if (!newVersion.equals(object.getOldVersion())) {
            isApplied = false;
            modified = true;
            break;
        }
    }
    if (modified) {
        boolean confirm = false;
        if (fixedVersionButton.getSelection()) {
            confirm = //$NON-NLS-1$
            MessageDialog.openConfirm(//$NON-NLS-1$
            getShell(), //$NON-NLS-1$
            Messages.getString("VersionManagementDialog.ConfirmTitle"), //$NON-NLS-1$
            Messages.getString("VersionManagementDialog.ConfirmMessage", newVersion));
            if (confirm && newVersion != null) {
                // set all items for new version
                for (ItemVersionObject object : checkedObjects) {
                    object.setNewVersion(newVersion);
                }
            }
        } else {
            ItemsVersionConfirmDialog chanedDialog = new ItemsVersionConfirmDialog(getShell(), checkedObjects);
            confirm = (chanedDialog.open() == Window.OK);
        }
        if (confirm) {
            updateItemsVersion();
        }
    } else {
        if (!checkedObjects.isEmpty() && !isApplied) {
            //$NON-NLS-1$
            MessageDialog.openWarning(//$NON-NLS-1$
            getShell(), //$NON-NLS-1$
            Messages.getString("VersionManagementDialog.WarningTitle"), //$NON-NLS-1$
            Messages.getString("VersionManagementDialog.WarningMessages"));
        }
    }
}
Also used : ItemsVersionConfirmDialog(org.talend.repository.ui.dialog.ItemsVersionConfirmDialog) ItemVersionObject(org.talend.repository.model.ItemVersionObject)

Aggregations

ItemVersionObject (org.talend.repository.model.ItemVersionObject)15 TableItem (org.eclipse.swt.widgets.TableItem)8 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)7 PersistenceException (org.talend.commons.exception.PersistenceException)6 ArrayList (java.util.ArrayList)5 Item (org.talend.core.model.properties.Item)5 Relation (org.talend.core.model.relationship.Relation)4 Image (org.eclipse.swt.graphics.Image)3 GridData (org.eclipse.swt.layout.GridData)3 Composite (org.eclipse.swt.widgets.Composite)3 Property (org.talend.core.model.properties.Property)3 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)3 IRepositoryNode (org.talend.repository.model.IRepositoryNode)3 RepositoryNode (org.talend.repository.model.RepositoryNode)3 IProjectRepositoryNode (org.talend.repository.model.nodes.IProjectRepositoryNode)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IWorkspace (org.eclipse.core.resources.IWorkspace)2 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)2 CoreException (org.eclipse.core.runtime.CoreException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2