/**
   * Extracts the values for the configured properties from the specified ControllerService.
   *
   * @param controllerService service
   * @param controllerServiceDTO dto
   * @return properties
   */
  private Map<String, String> extractConfiguredPropertyValues(
      ControllerServiceNode controllerService, ControllerServiceDTO controllerServiceDTO) {
    Map<String, String> values = new HashMap<>();

    if (controllerServiceDTO.getName() != null) {
      values.put(NAME, controllerService.getName());
    }
    if (controllerServiceDTO.getAnnotationData() != null) {
      values.put(ANNOTATION_DATA, controllerService.getAnnotationData());
    }
    if (controllerServiceDTO.getProperties() != null) {
      // for each property specified, extract its configured value
      Map<String, String> properties = controllerServiceDTO.getProperties();
      Map<PropertyDescriptor, String> configuredProperties = controllerService.getProperties();
      for (String propertyName : properties.keySet()) {
        // build a descriptor for getting the configured value
        PropertyDescriptor propertyDescriptor =
            new PropertyDescriptor.Builder().name(propertyName).build();
        String configuredPropertyValue = configuredProperties.get(propertyDescriptor);

        // if the configured value couldn't be found, use the default value from the actual
        // descriptor
        if (configuredPropertyValue == null) {
          propertyDescriptor =
              locatePropertyDescriptor(configuredProperties.keySet(), propertyDescriptor);
          configuredPropertyValue = propertyDescriptor.getDefaultValue();
        }
        values.put(propertyName, configuredPropertyValue);
      }
    }
    if (controllerServiceDTO.getComments() != null) {
      values.put(COMMENTS, controllerService.getComments());
    }

    return values;
  }