Search in sources :

Example 11 with Relation

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

the class HadoopClusterConnectionRelationshipHandler method collect.

@Override
protected Set<Relation> collect(Item baseItem) {
    if (baseItem instanceof HadoopClusterConnectionItem) {
        HadoopClusterConnectionItem hcItem = (HadoopClusterConnectionItem) baseItem;
        HadoopClusterConnection connection = (HadoopClusterConnection) hcItem.getConnection();
        if (connection != null) {
            String version = connection.getDfVersion();
            if (StringUtils.isNotEmpty(version)) {
                if (DynamicDistributionManager.getInstance().isUsersDynamicDistribution(version)) {
                    Set<Relation> relationSet = new HashSet<Relation>();
                    Relation addedRelation = new Relation();
                    addedRelation.setId(version);
                    addedRelation.setType(RelationshipItemBuilder.DYNAMIC_DISTRIBUTION_RELATION);
                    addedRelation.setVersion(RelationshipItemBuilder.LATEST_VERSION);
                    relationSet.add(addedRelation);
                    return relationSet;
                }
            }
        }
    }
    if (baseItem instanceof DatabaseConnectionItem) {
        Connection connection = ((DatabaseConnectionItem) baseItem).getConnection();
        if (connection != null) {
            Object value = RepositoryToComponentProperty.getValue(connection, EParameterName.DB_VERSION.getName(), null);
            if (value instanceof String) {
                String version = (String) value;
                if (DynamicDistributionManager.getInstance().isUsersDynamicDistribution(version)) {
                    Set<Relation> relationSet = new HashSet<Relation>();
                    Relation addedRelation = new Relation();
                    addedRelation.setId(version);
                    addedRelation.setType(RelationshipItemBuilder.DYNAMIC_DISTRIBUTION_RELATION);
                    addedRelation.setVersion(RelationshipItemBuilder.LATEST_VERSION);
                    relationSet.add(addedRelation);
                    return relationSet;
                }
            }
        }
    }
    return Collections.emptySet();
}
Also used : Relation(org.talend.core.model.relationship.Relation) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) HashSet(java.util.HashSet) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Example 12 with Relation

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

the class NoSQLUpdateManager method updateNoSQLConnection.

/**
 * DOC ycbai Comment method "updateHadoopClusterConnection".
 *
 * @param connectionItem
 * @param show
 * @param onlySimpleShow
 * @return
 */
public static boolean updateNoSQLConnection(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 13 with Relation

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

the class MapperSchemaTypeItemRelationshipHandler method collect.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.core.model.relationship.AbstractItemRelationshipHandler#collect(org.talend.core.model.properties.Item)
     */
@Override
protected Set<Relation> collect(Item baseItem) {
    ProcessType processType = getProcessType(baseItem);
    if (processType == null) {
        return Collections.emptySet();
    }
    Set<Relation> relationSet = new HashSet<Relation>();
    // handle tMap schema relations...
    if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerMapperService.class)) {
        IDesignerMapperService service = (IDesignerMapperService) GlobalServiceRegister.getDefault().getService(IDesignerMapperService.class);
        for (Object o : processType.getNode()) {
            if (o instanceof NodeType) {
                NodeType currentNode = (NodeType) o;
                AbstractExternalData nodeData = currentNode.getNodeData();
                if (nodeData != null) {
                    List<String> schemaIds = service.getRepositorySchemaIds(nodeData);
                    if (schemaIds != null && schemaIds.size() > 0) {
                        for (String schemaId : schemaIds) {
                            Relation addedRelation = new Relation();
                            addedRelation.setId(schemaId);
                            addedRelation.setType(RelationshipItemBuilder.SCHEMA_RELATION);
                            addedRelation.setVersion(RelationshipItemBuilder.LATEST_VERSION);
                            relationSet.add(addedRelation);
                        }
                    }
                }
            }
        }
    }
    return relationSet;
}
Also used : IDesignerMapperService(org.talend.core.service.IDesignerMapperService) AbstractExternalData(org.talend.designer.core.model.utils.emf.talendfile.AbstractExternalData) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) Relation(org.talend.core.model.relationship.Relation) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) HashSet(java.util.HashSet)

Example 14 with Relation

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

the class SqlTemplateParameterRelationshipHandler 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) {
    Set<Relation> relationSet = new HashSet<Relation>();
    //$NON-NLS-1$
    ElementParameterType sqlpatternParamType = parametersMap.get("SQLPATTERN_VALUE");
    // only for SQL Patterns
    if (sqlpatternParamType != null) {
        for (Object o3 : sqlpatternParamType.getElementValue()) {
            if (o3 instanceof ElementValueType && "SQLPATTERNLIST".equals(((ElementValueType) o3).getElementRef())) {
                //$NON-NLS-1$
                Relation addedRelation = new Relation();
                addedRelation.setId(((ElementValueType) o3).getValue());
                addedRelation.setType(RelationshipItemBuilder.SQLPATTERN_RELATION);
                addedRelation.setVersion(RelationshipItemBuilder.LATEST_VERSION);
                relationSet.add(addedRelation);
            }
        }
    }
    return relationSet;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) Relation(org.talend.core.model.relationship.Relation) ElementValueType(org.talend.designer.core.model.utils.emf.talendfile.ElementValueType) HashSet(java.util.HashSet)

Example 15 with Relation

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

the class HDFSUpdateManager method updateHDFSConnection.

/**
 * DOC ycbai Comment method "updateHDFSConnection".
 *
 * @param connectionItem
 * @param show
 * @param onlySimpleShow
 * @return
 */
public static boolean updateHDFSConnection(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);
            types.add(EUpdateItemType.JOB_PROPERTY_STORM);
            types.add(EUpdateItemType.JOB_PROPERTY_MAPREDUCE);
            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)

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