/* ****************************************************************************
*
* EntID::toJson -
*/
std::string EntID::toJson()
{
    JsonHelper jh;

    jh.addString("id", this->id);
    jh.addString("idPattern", this->idPattern);
    jh.addString("type", this->type);

    return jh.str();
}
/* ****************************************************************************
*
* Subscription::toJson -
*/
std::string Subscription::toJson()
{
    JsonHelper jh;

    jh.addString("id", this->id);
    if (this->expires > 0)
    {
        jh.addDate("expires", this->expires);
    }
    jh.addString("status", this->status);
    jh.addRaw("subject", this->subject.toJson());
    jh.addRaw("notification", this->notification.toJson());

    return jh.str();
}
/* ****************************************************************************
*
* Condition::toJson -
*/
std::string Condition::toJson()
{
    JsonHelper jh;

    jh.addRaw("attributes", vectorToJson(this->attributes));

    {
        JsonHelper jhe;

        jhe.addString("q", this->expression.q);
        jhe.addString("geometry", this->expression.geometry);
        jhe.addString("coords", this->expression.coords);

        jh.addRaw("expression", jhe.str());
    }

    return jh.str();
}
예제 #4
0
  /* ****************************************************************************
  *
  * Condition::toJson -
  */
  std::string Condition::toJson()
  {
    JsonHelper jh;

    jh.addRaw("attrs", vectorToJson(this->attributes));

    JsonHelper jhe;

    if (this->expression.q        != "")  jhe.addString("q",        this->expression.q);
    if (this->expression.mq       != "")  jhe.addString("mq",       this->expression.mq);
    if (this->expression.geometry != "")  jhe.addString("geometry", this->expression.geometry);
    if (this->expression.coords   != "")  jhe.addString("coords",   this->expression.coords);
    if (this->expression.georel   != "")  jhe.addString("georel",   this->expression.georel);

    std::string expressionString = jhe.str();

    if (expressionString != "{}")         jh.addRaw("expression", expressionString);

    return jh.str();
  }
예제 #5
0
  /* ****************************************************************************
  *
  * EntID::toJson -
  */
  std::string EntID::toJson()
  {
    JsonHelper jh;

    if (!this->id.empty())
    {
        jh.addString("id", this->id);
    }
    if (!this->idPattern.empty())
    {
      jh.addString("idPattern", this->idPattern);
    }
    if (!this->type.empty())
    {
      jh.addString("type", this->type);
    }
    if (!this->typePattern.empty())
    {
      jh.addString("typePattern", this->typePattern);
    }

    return jh.str();
  }
예제 #6
0
  /* ****************************************************************************
  *
  * Subscription::toJson -
  */
  std::string Subscription::toJson()
  {
    JsonHelper jh;

    jh.addString("id", this->id);
    if (this->description != "")
    {
      jh.addString("description", this->description);
    }
    if (this->expires != PERMANENT_SUBS_DATETIME)
    {
      jh.addDate("expires", this->expires);
    }
    jh.addString("status", this->status);
    jh.addRaw("subject", this->subject.toJson());
    jh.addRaw("notification", this->notification.toJson(renderFormatToString(this->attrsFormat, true, true)));

    if (this->throttling > 0)
    {
      jh.addNumber("throttling", this->throttling);
    }

    return jh.str();
  }
/* ****************************************************************************
*
* Notification::toJson -
*/
std::string Notification::toJson()
{
    JsonHelper jh;

    jh.addString("callback", this->callback);
    if (this->throttling > 0)
    {
        jh.addNumber("throttling", this->throttling);
    }
    if (this->timesSent > 0)
    {
        jh.addNumber("timesSent", this->timesSent);
    }
    if (this->lastNotification > 0)
    {
        jh.addDate("lastNotification", this->lastNotification);
    }
    jh.addRaw("attributes", vectorToJson(this->attributes));

    return jh.str();
}
예제 #8
0
  /* ****************************************************************************
  *
  * Notification::toJson -
  *
  * FIXME P2: we should move 'attrsFormat' from Subject class to Notification
  * class, to avoid passing attrsFormat as argument
  *
  */
  std::string Notification::toJson(const std::string& attrsFormat)
  {
    JsonHelper jh;

    if (this->timesSent > 0)
    {
      jh.addNumber("timesSent", this->timesSent);
    }
    if (this->lastNotification > 0)
    {
      jh.addDate("lastNotification", this->lastNotification);
    }

    if (!this->blacklist)
    {
      jh.addRaw("attrs", vectorToJson(this->attributes));
    }
    else
    {
      jh.addRaw("exceptAttrs", vectorToJson(this->attributes));
    }

    jh.addString("attrsFormat", attrsFormat);

    if (this->httpInfo.custom)
    {
      jh.addRaw("httpCustom", this->httpInfo.toJson());
    }
    else
    {
      jh.addRaw("http", this->httpInfo.toJson());
    }

    if (this->metadata.size() > 0)
    {
      jh.addRaw("metadata", vectorToJson(this->metadata));
    }

    return jh.str();
  }