class ClusterBlueprintRenderer extends BaseRenderer implements Renderer {

  @Override
  public TreeNode<Set<String>> finalizeProperties(
      TreeNode<QueryInfo> queryProperties, boolean isCollection) {

    Set<String> properties = new HashSet<>(queryProperties.getObject().getProperties());
    TreeNode<Set<String>> resultTree = new TreeNodeImpl<>(
      null, properties, queryProperties.getName());

    copyPropertiesToResult(queryProperties, resultTree);

    String configType = Resource.Type.Configuration.name();
    if (resultTree.getChild(configType) == null) {
      resultTree.addChild(new HashSet<>(), configType);
    }

    String serviceType = Resource.Type.Service.name();
    if (resultTree.getChild(serviceType) == null) {
      resultTree.addChild(new HashSet<>(), serviceType);
    }
    TreeNode<Set<String>> serviceNode = resultTree.getChild(serviceType);
    if (serviceNode == null) {
      serviceNode = resultTree.addChild(new HashSet<>(), serviceType);
    }
    String serviceComponentType = Resource.Type.Component.name();
    TreeNode<Set<String>> serviceComponentNode = resultTree.getChild(
      serviceType + "/" + serviceComponentType);
    if (serviceComponentNode == null) {
      serviceComponentNode = serviceNode.addChild(new HashSet<>(), serviceComponentType);
    }
    serviceComponentNode.getObject().add("ServiceComponentInfo/cluster_name");
    serviceComponentNode.getObject().add("ServiceComponentInfo/service_name");
    serviceComponentNode.getObject().add("ServiceComponentInfo/component_name");
    serviceComponentNode.getObject().add("ServiceComponentInfo/recovery_enabled");

    String hostType = Resource.Type.Host.name();
    String hostComponentType = Resource.Type.HostComponent.name();
    TreeNode<Set<String>> hostComponentNode = resultTree.getChild(
        hostType + "/" + hostComponentType);

    if (hostComponentNode == null) {
      TreeNode<Set<String>> hostNode = resultTree.getChild(hostType);
      if (hostNode == null) {
        hostNode = resultTree.addChild(new HashSet<>(), hostType);
      }
      hostComponentNode = hostNode.addChild(new HashSet<>(), hostComponentType);
    }
    resultTree.getChild(configType).getObject().add("properties");
    hostComponentNode.getObject().add("HostRoles/component_name");

    return resultTree;
  }

}