Search in sources :

Example 1 with Relation

use of org.talend.core.model.relationship.Relation in project tdi-studio-se by Talend.

the class GenericUpdateManager method updateGenericConnection.

public static boolean updateGenericConnection(ConnectionItem connectionItem, List<IMetadataTable> oldMetadataTable, boolean show, final boolean onlySimpleShow) {
    List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(connectionItem.getProperty().getId(), RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.PROPERTY_RELATION);
    RepositoryUpdateManager repositoryUpdateManager = new GenericUpdateManager(connectionItem, oldMetadataTable, relations);
    return repositoryUpdateManager.doWork(true, false);
}
Also used : RepositoryUpdateManager(org.talend.core.model.update.RepositoryUpdateManager) Relation(org.talend.core.model.relationship.Relation)

Example 2 with Relation

use of org.talend.core.model.relationship.Relation 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 3 with Relation

use of org.talend.core.model.relationship.Relation 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 4 with Relation

use of org.talend.core.model.relationship.Relation in project tdi-studio-se by Talend.

the class SQLPatternComposite method getAllSqlPatterns.

private List<SQLPatternInfor> getAllSqlPatterns(List<Map> tableInput, boolean modifySQL) {
    IElementParameter elementParam = element.getElementParameter(EParameterName.SQLPATTERN_DB_NAME.getName());
    if (elementParam == null) {
        return Collections.EMPTY_LIST;
    }
    // String dbName = (String) elementParam.getValue();
    List<SQLPatternInfor> patternInfor = new ArrayList<SQLPatternInfor>();
    try {
        List<IRepositoryViewObject> list = null;
        if (isItemIndexChecked() && modifySQL) {
            List<Relation> relations = new ArrayList<Relation>();
            IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
            List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
            for (Map map : tableInput) {
                String id = (String) map.get(SQLPatternUtils.SQLPATTERNLIST);
                relations.addAll(RelationshipItemBuilder.getInstance().getItemsRelatedTo(id, ItemCacheManager.LATEST_VERSION, RelationshipItemBuilder.SQLPATTERN_RELATION));
            }
            for (Relation relation : relations) {
                try {
                    IRepositoryViewObject obj = factory.getLastVersion(relation.getId());
                    if (obj != null) {
                        updateList.add(obj);
                    }
                } catch (PersistenceException e) {
                    ExceptionHandler.process(e);
                }
            }
            list = updateList;
        } else {
            list = DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().getAll(ERepositoryObjectType.SQLPATTERNS, false);
            // add reference sql pattern
            addReferencedSQLTemplate(list, ProjectManager.getInstance().getCurrentProject());
        }
        for (IRepositoryViewObject repositoryObject : list) {
            Item item = repositoryObject.getProperty().getItem();
            if (item instanceof SQLPatternItem) {
                SQLPatternItem sqlitem = (SQLPatternItem) repositoryObject.getProperty().getItem();
                // disable this test as there is now only Generic ELT components
                // if (item.getEltName().equals(dbName)) {
                patternInfor.add(new SQLPatternInfor(sqlitem.getProperty().getId() + SQLPatternUtils.ID_SEPARATOR + sqlitem.getProperty().getLabel(), sqlitem.getProperty().getLabel()));
            // }
            }
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    return patternInfor;
}
Also used : ArrayList(java.util.ArrayList) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) PartInitException(org.eclipse.ui.PartInitException) PersistenceException(org.talend.commons.exception.PersistenceException) Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) TableItem(org.eclipse.swt.widgets.TableItem) Relation(org.talend.core.model.relationship.Relation) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) Map(java.util.Map) HashMap(java.util.HashMap) BidiMap(org.apache.commons.collections.BidiMap) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 5 with Relation

use of org.talend.core.model.relationship.Relation in project tdi-studio-se by Talend.

the class VersionManagementPage method versionLatest.

private void versionLatest() {
    List<ItemVersionObject> tableList = new ArrayList<ItemVersionObject>();
    tableList.addAll(checkedObjects);
    for (ItemVersionObject object : checkedObjects) {
        if (object.getRepositoryNode() != null) {
            List<Relation> relations = builder.getItemsJobRelatedTo(object.getRepositoryNode().getId(), object.getOldVersion(), 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);
                }
            }
        }
    }
    removeItemElements(checkedObjects);
    checkedObjects.clear();
    checkedObjects.addAll(tableList);
    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)

Aggregations

Relation (org.talend.core.model.relationship.Relation)19 HashSet (java.util.HashSet)12 PersistenceException (org.talend.commons.exception.PersistenceException)8 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)7 ArrayList (java.util.ArrayList)5 RepositoryUpdateManager (org.talend.core.model.update.RepositoryUpdateManager)5 EUpdateItemType (org.talend.core.model.update.EUpdateItemType)4 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)4 ItemVersionObject (org.talend.repository.model.ItemVersionObject)4 HashMap (java.util.HashMap)3 Item (org.talend.core.model.properties.Item)3 Set (java.util.Set)2 ConnectionItem (org.talend.core.model.properties.ConnectionItem)2 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)2 SQLPatternItem (org.talend.core.model.properties.SQLPatternItem)2 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)2 Map (java.util.Map)1 BidiMap (org.apache.commons.collections.BidiMap)1 TableItem (org.eclipse.swt.widgets.TableItem)1 PartInitException (org.eclipse.ui.PartInitException)1