4SOIL::Object::Object(std::shared_ptr<Element> parent, std::string uuid, std::string name, std::string description, std::string ontology) :
Element(parent, uuid, name, description, ontology)
6 if (
uuid.substr(0, 3) !=
"OBJ")
8 throw std::logic_error(
"UUIDs for objects must start with OBJ!");
10 allowed_methods = { HTTP::Methods::GET, HTTP::Methods::OPTIONS, HTTP::Methods::HEAD, HTTP::Methods::PUT };
18std::shared_ptr<SOIL::Object>
SOIL::Object::create(std::shared_ptr<Element> parent, std::string uuid, std::string name, std::string description, std::string ontology)
20 Object*
object =
new Object(parent, uuid, name, description, ontology);
28 json_root[U(
"children")] = HTTP::Json::array();
30 for (
auto& child : children)
33 json_root[U(
"children")][i][U(
"uuid")] = HTTP::Json::string(utility::conversions::to_string_t(child.first));
34 json_root[U(
"children")][i][U(
"name")] = HTTP::Json::string(utility::conversions::to_string_t(child.second->name));
46 throw std::logic_error(
"This function has not been implemented!");
58 response.set_body(this->wjson());
59 response.set_status_code(HTTP::Status::OK);
65 auto task = message.extract_json();
70 response.set_body(
json);
71 response.set_status_code(HTTP::Status::Created);
78 parent->remove(this->uuid);
80 response.set_status_code(HTTP::Status::OK);
std::vector< web::http::method > allowed_methods
Allowed methods.
std::string uuid
Local UUID.
virtual HTTP::Json wjson(void)
HTTP JSON.
virtual void read(void)
Read callback.
HTTP::Response handle_get(HTTP::Request message, std::smatch match=std::smatch()) override
HTTP GET Handler.
static std::shared_ptr< Object > create(std::shared_ptr< Element > parent, std::string uuid, std::string name, std::string description, std::string ontology="")
Create new Object.
HTTP::Response handle_delete(HTTP::Request message, std::smatch match=std::smatch()) override
HTTP DELETE Handler.
virtual void remove(void)
Remove callback.
virtual HTTP::Json insert(HTTP::Json body)
Insert callback.
HTTP::Response handle_put(HTTP::Request message, std::smatch match=std::smatch()) override
HTTP PUT Handler.
Object(std::shared_ptr< Element > parent, std::string uuid, std::string name, std::string description, std::string ontology="")
Constructor.
web::json::value wjson(void)
HTTP JSON.
web::json::value Json
HTTP JSON.
web::http::http_request Request
HTTP Request.
web::http::http_response Response
HTTP Response.