/** * Deeply explore the hosted_on hierarchy of the given node to find a node of the given type. */ public static NodeTemplate getHostOfTypeInHostingHierarchy(Topology topology, NodeTemplate nodeTemplate, String hostType) { if (nodeTemplate.getRelationships() != null) { for (RelationshipTemplate relationshipTemplate : nodeTemplate.getRelationships().values()) { RelationshipType relationshipType = ToscaContext.get(RelationshipType.class, relationshipTemplate.getType()); if (isOfType(relationshipType, NormativeRelationshipConstants.HOSTED_ON)) { NodeTemplate hostNode = topology.getNodeTemplates().get(relationshipTemplate.getTarget()); NodeType hostNodeType = ToscaContext.get(NodeType.class, hostNode.getType()); if (isOfType(hostNodeType, hostType)) { return hostNode; } else { return getHostOfTypeInHostingHierarchy(topology, hostNode, hostType); } } } } return null; }