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);
}
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;
}
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);
}
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;
}
Aggregations