/**
  * Get IndexedRelationshipType in a topology
  *
  * @param topology the topology to find all relationship types
  * @return the map containing rel
  */
 public Map<String, IndexedRelationshipType> getIndexedRelationshipTypesFromTopology(
     Topology topology) {
   Map<String, IndexedRelationshipType> relationshipTypes = Maps.newHashMap();
   if (topology.getNodeTemplates() == null) {
     return relationshipTypes;
   }
   for (Map.Entry<String, NodeTemplate> templateEntry : topology.getNodeTemplates().entrySet()) {
     NodeTemplate template = templateEntry.getValue();
     if (template.getRelationships() != null) {
       for (Map.Entry<String, RelationshipTemplate> relationshipEntry :
           template.getRelationships().entrySet()) {
         RelationshipTemplate relationship = relationshipEntry.getValue();
         if (!relationshipTypes.containsKey(relationship.getType())) {
           IndexedRelationshipType relationshipType =
               csarRepoSearchService.getRequiredElementInDependencies(
                   IndexedRelationshipType.class,
                   relationship.getType(),
                   topology.getDependencies());
           relationshipTypes.put(relationship.getType(), relationshipType);
         }
       }
     }
   }
   return relationshipTypes;
 }
  /**
   * Get all the relationships in which a given node template is a target
   *
   * @param nodeTemplateName the name of the node template which is target for relationship
   * @param nodeTemplates all topology's node templates
   * @return all relationships which have nodeTemplateName as target
   */
  public List<RelationshipTemplate> getTargetRelatedRelatonshipsTemplate(
      String nodeTemplateName, Map<String, NodeTemplate> nodeTemplates) {
    List<RelationshipTemplate> toReturn = Lists.newArrayList();
    for (String key : nodeTemplates.keySet()) {
      NodeTemplate nodeTemp = nodeTemplates.get(key);
      if (nodeTemp.getRelationships() == null) {
        continue;
      }
      for (String key2 : nodeTemp.getRelationships().keySet()) {
        RelationshipTemplate relTemp = nodeTemp.getRelationships().get(key2);
        if (relTemp == null) {
          continue;
        }
        if (relTemp.getTarget() != null && relTemp.getTarget().equals(nodeTemplateName)) {
          toReturn.add(relTemp);
        }
      }
    }

    return toReturn;
  }
 public Map<String, String> getKeywordMap(
     NodeTemplate nodeTemplate, RelationshipTemplate relationshipTemplate) {
   ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
   String nodeTemplateName = nodeTemplate.getName();
   if (nodeTemplateName != null) {
     builder.put("SOURCE", nodeTemplateName);
   }
   String target = relationshipTemplate.getTarget();
   if (target != null) {
     builder.put("TARGET", target);
   }
   return builder.build();
 }