/** * Get all incoming relationships of a node that match the requested type. * * @param template The node template for which to get relationships. * @param type The expected type. * @return */ public static RelationshipTemplate getRelationshipFromType(NodeTemplate template, String type) { return getRelationshipFromType(template, type, id -> ToscaContext.getOrFail(RelationshipType.class, id)); }
/** * Utility method to find the immediate host template of the current given template. * * @param template The template for wich to get the immediate host. * @return */ public static NodeTemplate getImmediateHostTemplate(Topology topology, NodeTemplate template) { RelationshipTemplate host = getRelationshipFromType(template, NormativeRelationshipConstants.HOSTED_ON); if (host == null) { return null; } return topology.getNodeTemplates().get(host.getTarget()); }
public static NodeTemplate getImmediateHostTemplate(Topology topology, NodeTemplate template, IToscaTypeFinder toscaTypeFinder) { RelationshipTemplate host = getRelationshipFromType(template, NormativeRelationshipConstants.HOSTED_ON, id -> toscaTypeFinder.findElement(RelationshipType.class, id)); if (host == null) { return null; } return topology.getNodeTemplates().get(host.getTarget()); }