<commit_before>package de.frosner.broccoli.models

import de.frosner.broccoli.models.InstanceStatus.InstanceStatus
import play.api.libs.json.{JsValue, Json}

@volatile
case class Instance(id: String,
                    template: Template,
                    parameterValues: Map[String, String],
                    var status: InstanceStatus,
                    var services: Map[String, Service]) {

  require(template.parameters == parameterValues.keySet, s"The given parameters (${parameterValues.keySet}) " +
    s"need to match the ones in the template (${template.parameters}).")

  // TODO inject parameter values
  // TODO avoid JSON injection (escape the shit out of it)
  val templateJson: JsValue = {
    val replacedTemplate = parameterValues.foldLeft(template.template){
      case (intermediateTemplate, (parameter, value)) => intermediateTemplate.replaceAll("\\{\\{" + parameter + "\\}\\}", value)<commit_msg>remove done TODO<commit_after>package de.frosner.broccoli.models

import de.frosner.broccoli.models.InstanceStatus.InstanceStatus
import play.api.libs.json.{JsValue, Json}

@volatile
case class Instance(id: String,
                    template: Template,
                    parameterValues: Map[String, String],
                    var status: InstanceStatus,
                    var services: Map[String, Service]) {

  require(template.parameters == parameterValues.keySet, s"The given parameters (${parameterValues.keySet}) " +
    s"need to match the ones in the template (${template.parameters}).")

  // TODO avoid JSON injection (escape the shit out of it)
  val templateJson: JsValue = {
    val replacedTemplate = parameterValues.foldLeft(template.template){
      case (intermediateTemplate, (parameter, value)) => intermediateTemplate.replaceAll("\\{\\{" + parameter + "\\}\\}", value)
{'fraction_non_alphanumeric': 0.11616438356164384, 'fraction_numerical': 0.0, 'mean_word_length': 3.2863849765258215, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 2, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5619535', 'n_tokens_mistral': 484, 'n_tokens_neox': 464, 'n_words': 129}