Search in sources :

Example 16 with Relation

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

the class HCatalogUpdateManager method updateHCatalogConnection.

/**
 * DOC ycbai Comment method "updateHCatalogConnection".
 *
 * @param connectionItem
 * @param show
 * @param onlySimpleShow
 * @return
 */
public static boolean updateHCatalogConnection(ConnectionItem connectionItem, boolean show, final boolean onlySimpleShow) {
    List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(connectionItem.getProperty().getId(), RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.PROPERTY_RELATION);
    RepositoryUpdateManager repositoryUpdateManager = new RepositoryUpdateManager(connectionItem, relations) {

        @Override
        public Set<EUpdateItemType> getTypes() {
            Set<EUpdateItemType> types = new HashSet<EUpdateItemType>();
            types.add(EUpdateItemType.NODE_PROPERTY);
            return types;
        }
    };
    return repositoryUpdateManager.doWork(true, false);
}
Also used : RepositoryUpdateManager(org.talend.core.model.update.RepositoryUpdateManager) Relation(org.talend.core.model.relationship.Relation) EUpdateItemType(org.talend.core.model.update.EUpdateItemType) HashSet(java.util.HashSet)

Example 17 with Relation

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

the class HadoopClusterPropertyTypeParameterRelationshipHandler method collect.

/*
     * (non-Javadoc)
     *
     * @see org.talend.core.model.relationship.AbstractParameterRelationshipHandler#collect(java.util.Map,
     * java.util.Map)
     */
@Override
protected Set<Relation> collect(Map<String, ElementParameterType> parametersMap, Map<?, ?> options) {
    if (parametersMap == null || parametersMap.isEmpty()) {
        return Collections.emptySet();
    }
    Set<Relation> relationSet = new HashSet<Relation>();
    ElementParameterType repositoryTypeParam = parametersMap.get(PropertyTypeParameterRelationshipHandler.PROPERTY_PROPERTY_TYPE);
    if (repositoryTypeParam != null && AbstractJobParameterInRepositoryRelationshipHandler.IN_REPOSITORY.equals(repositoryTypeParam.getValue())) {
        ElementParameterType repositoryTypeValueParam = parametersMap.get(PropertyTypeParameterRelationshipHandler.PROPERTY_REPOSITORY_PROPERTY_TYPE);
        if (repositoryTypeValueParam != null) {
            String repositoryIdOrValue = repositoryTypeValueParam.getValue();
            if (StringUtils.isNotEmpty(repositoryIdOrValue)) {
                Item hadoopClusterItem = HCRepositoryUtil.getHadoopClusterItemBySubitemId(repositoryIdOrValue);
                if (hadoopClusterItem != null) {
                    String hcId = hadoopClusterItem.getProperty().getId();
                    Relation addedRelation = new Relation();
                    addedRelation.setId(hcId);
                    addedRelation.setType(RelationshipItemBuilder.PROPERTY_RELATION);
                    addedRelation.setVersion(RelationshipItemBuilder.LATEST_VERSION);
                    relationSet.add(addedRelation);
                }
            }
        }
    }
    for (ElementParameterType eleParamType : parametersMap.values()) {
        if (EParameterFieldType.HADOOP_DISTRIBUTION.name().equals(eleParamType.getField())) {
            String name = eleParamType.getName();
            if (StringUtils.isNotEmpty(name)) {
                ComponentType componentType = ComponentType.getComponentType(name);
                if (componentType != null) {
                    String versionParam = componentType.getVersionParameter();
                    if (StringUtils.isNotEmpty(versionParam)) {
                        ElementParameterType elemParam = parametersMap.get(versionParam);
                        if (elemParam != null) {
                            String value = elemParam.getValue();
                            if (StringUtils.isNotEmpty(value)) {
                                if (DynamicDistributionManager.getInstance().isUsersDynamicDistribution(value)) {
                                    Relation addedRelation = new Relation();
                                    addedRelation.setId(value);
                                    addedRelation.setType(RelationshipItemBuilder.DYNAMIC_DISTRIBUTION_RELATION);
                                    addedRelation.setVersion(RelationshipItemBuilder.LATEST_VERSION);
                                    relationSet.add(addedRelation);
                                }
                            }
                        }
                    }
                }
            }
            break;
        }
    }
    return relationSet;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) Item(org.talend.core.model.properties.Item) Relation(org.talend.core.model.relationship.Relation) ComponentType(org.talend.hadoop.distribution.ComponentType) HashSet(java.util.HashSet)

Example 18 with Relation

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

the class CreateNewJobAction method addToMergeRelationship.

/**
 * Add relation from job to service, without save action
 *
 * @param processItem
 * @param serviceItem
 */
private void addToMergeRelationship(final ProcessItem processItem, ServiceItem serviceItem) {
    Set<Relation> relationSet = new HashSet<Relation>();
    Relation addedRelation = new Relation();
    addedRelation.setId(serviceItem.getProperty().getId());
    addedRelation.setType(RelationshipItemBuilder.SERVICES_RELATION);
    addedRelation.setVersion(serviceItem.getProperty().getVersion());
    relationSet.add(addedRelation);
    Map<Relation, Set<Relation>> merge = new HashMap<Relation, Set<Relation>>();
    Relation processRelation = new Relation();
    processRelation.setId(processItem.getProperty().getId());
    processRelation.setType(RelationshipItemBuilder.JOB_RELATION);
    processRelation.setVersion(processItem.getProperty().getVersion());
    merge.put(processRelation, relationSet);
    RelationshipItemBuilder.mergeRelationship(RelationshipItemBuilder.getInstance().getCurrentProjectItemsRelations(), merge);
}
Also used : Relation(org.talend.core.model.relationship.Relation) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Example 19 with Relation

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

the class ServiceRelationshipHandler method collect.

@Override
protected Set<Relation> collect(Item baseItem) {
    if (!(baseItem instanceof ProcessItem)) {
        return Collections.emptySet();
    }
    List<IRepositoryViewObject> serviceRepoList = null;
    try {
        IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        serviceRepoList = factory.getAll(ESBRepositoryNodeType.SERVICES);
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    Set<Relation> relationSet = new HashSet<Relation>();
    for (IRepositoryViewObject obj : serviceRepoList) {
        ServiceItem serviceItem = (ServiceItem) obj.getProperty().getItem();
        List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(serviceItem.getProperty().getId(), RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.SERVICES_RELATION);
        for (Relation repId : relations) {
            if (repId.getId().equals(baseItem.getProperty().getId())) {
                Relation addedRelation = new Relation();
                addedRelation.setId(serviceItem.getProperty().getId());
                addedRelation.setType(RelationshipItemBuilder.SERVICES_RELATION);
                addedRelation.setVersion(serviceItem.getProperty().getVersion());
                relationSet.add(addedRelation);
            }
        }
    }
    return relationSet;
}
Also used : Relation(org.talend.core.model.relationship.Relation) ProcessItem(org.talend.core.model.properties.ProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ServiceItem(org.talend.repository.services.model.services.ServiceItem) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) HashSet(java.util.HashSet)

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