private Resource toResource(String clusterName,
      AlertDefinitionEntity entity, Set<String> requestedIds) {
    Resource resource = new ResourceImpl(Resource.Type.AlertDefinition);
    resource.setProperty(ALERT_DEF_ID, entity.getDefinitionId());
    resource.setProperty(ALERT_DEF_CLUSTER_NAME, clusterName);
    resource.setProperty(ALERT_DEF_NAME, entity.getDefinitionName());
    resource.setProperty(ALERT_DEF_LABEL, entity.getLabel());

    setResourceProperty(resource, ALERT_DEF_DESCRIPTION, entity.getDescription(), requestedIds);
    setResourceProperty(resource, ALERT_DEF_INTERVAL, entity.getScheduleInterval(), requestedIds);
    setResourceProperty(resource, ALERT_DEF_SERVICE_NAME, entity.getServiceName(), requestedIds);
    setResourceProperty(resource, ALERT_DEF_COMPONENT_NAME, entity.getComponentName(), requestedIds);
    setResourceProperty(resource, ALERT_DEF_ENABLED, Boolean.valueOf(entity.getEnabled()), requestedIds);
    setResourceProperty(resource, ALERT_DEF_IGNORE_HOST, Boolean.valueOf(entity.isHostIgnored()), requestedIds);
    setResourceProperty(resource, ALERT_DEF_SCOPE, entity.getScope(), requestedIds);
    setResourceProperty(resource, ALERT_DEF_HELP_URL, entity.getHelpURL(), requestedIds);
    setResourceProperty(resource, ALERT_DEF_REPEAT_TOLERANCE, entity.getRepeatTolerance(), requestedIds);
    setResourceProperty(resource, ALERT_DEF_REPEAT_TOLERANCE_ENABLED, Boolean.valueOf(entity.isRepeatToleranceEnabled()), requestedIds);

    boolean sourceTypeRequested = setResourceProperty(resource,
        ALERT_DEF_SOURCE_TYPE, entity.getSourceType(), requestedIds);

    if (sourceTypeRequested
        && null != resource.getPropertyValue(ALERT_DEF_SOURCE_TYPE)) {
      try {
        Map<String, String> map = gson.<Map<String, String>> fromJson(
            entity.getSource(), Map.class);

        for (Entry<String, String> entry : map.entrySet()) {
          String subProp = PropertyHelper.getPropertyId(ALERT_DEF_SOURCE, entry.getKey());
          resource.setProperty(subProp, entry.getValue());
        }
      } catch (Exception e) {
        LOG.error("Could not coerce alert JSON into a type");
      }
    }

    return resource;
  }
Gets a {@link JsonObject} that the specified flattened property should be
set on, creating all parent {@link JsonObject} instances as needed. This
will turn {code AlertDefinition/source/reporting/critical/text} into

<pre>
AlertDefinition/source: {
  reporting: {
    critical: {
      text
    }
  }
}
</pre>

Where the the following {@link JsonObject} instances are created:

<pre>
AlertDefinition/source
  Reporting
    Critical
      property 'text',
      property 'value',
      etc
</pre>

@param root
         the flattened property which will be considered the root.
@param jsonObjectMapping
         a mapping of flattened property to {@link JsonObject}.
@param propertyKey
         the key to get the {@link JsonObject} for.
@return the {@link JsonObject} that cooresponds to the specified key.
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java