Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NGSIv1 regs isDomain/metadta removal and render() to toJsonv1() renaming #3324

Merged
merged 6 commits into from
Oct 1, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/manuals/devel/sourceCode.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ The **ngsi** library contains a collection of classes for the different payloads

These classes (as well as the classes in the libraries `ngsi9`, `ngsi10`, `convenience`) all have a standard set of methods:

* `render()`, to render the object to a JSON string (mainly for NGSIv1)
* `toJson()`, to render the object to a JSON string (for NGSIv2)
* `toJsonV1()`, to render the object to a JSON string (for NGSIv1)
* `present()`, for debugging (the object is dumped as text to the log file)
* `release()`, to release all allocated resources of the object
* `check()`, to make sure the object follows the rules, i.e. about no forbidden characters, or mandatory fields missing, etc.
Expand All @@ -222,7 +222,7 @@ The classes follow a hierarchy, e.g. `UpdateContextRequest` (top hierarchy class
* `ContextAttributeVector`
* `MetadataVector` (this field `MetadataVector domainMetadataVector` is part of NGSIv1 but Orion doesn't make use of it)

The methods `render()`, `check()`, `release()`, etc. are called in a tree-like fashion, starting from the top hierarchy class, e.g. `UpdateContextRequest`:
The methods `toJson()`, `check()`, `release()`, etc. are called in a tree-like fashion, starting from the top hierarchy class, e.g. `UpdateContextRequest`:

* `UpdateContextRequest::check()` calls:
* `ContextElementVector::check()` calls (for each item in the vector):
Expand Down
4 changes: 2 additions & 2 deletions src/lib/apiTypesV2/Attribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@

/* ****************************************************************************
*
* Attribute::render -
* Attribute::toJson -
*/
std::string Attribute::render
std::string Attribute::toJson
(
bool acceptedTextPlain, // in parameter (pass-through)
bool acceptedJson, // in parameter (pass-through)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/apiTypesV2/Attribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Attribute

Attribute(): pcontextAttribute(0) {}

std::string render(bool acceptedTextPlain,
std::string toJson(bool acceptedTextPlain,
bool acceptedJson,
MimeType outFormatSelection,
MimeType* outMimeTypeP,
Expand Down
6 changes: 3 additions & 3 deletions src/lib/apiTypesV2/Entities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ Entities::~Entities()

/* ****************************************************************************
*
* Entities::render -
* Entities::toJson -
*
*/
std::string Entities::render
std::string Entities::toJson
(
RenderFormat renderFormat,
const std::vector<std::string>& attrsFilter,
bool blacklist,
const std::vector<std::string>& metadataFilter
)
{
return vec.render(renderFormat, attrsFilter, blacklist, metadataFilter);
return vec.toJson(renderFormat, attrsFilter, blacklist, metadataFilter);
}


Expand Down
2 changes: 1 addition & 1 deletion src/lib/apiTypesV2/Entities.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Entities
Entities();
~Entities();

std::string render(RenderFormat renderFormat,
std::string toJson(RenderFormat renderFormat,
const std::vector<std::string>& attrsFilter,
bool blacklist,
const std::vector<std::string>& metadataFilter);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/apiTypesV2/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ std::string Entity::toJsonV1
filterAndOrderAttrs(attrsFilter, blacklist, &orderedAttrs);

EntityId en(id, type, isPattern);
out += en.render(contextAttributeVectorRendered, false);
out += attributeVector.render(asJsonObject, requestType, orderedAttrs, metadataFilter, false, omitAttributeValues);
out += en.toJsonV1(contextAttributeVectorRendered, false);
out += attributeVector.toJsonV1(asJsonObject, requestType, orderedAttrs, metadataFilter, false, omitAttributeValues);

out += endTag(comma, false);

Expand Down
4 changes: 2 additions & 2 deletions src/lib/apiTypesV2/EntityVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@

/* ****************************************************************************
*
* EntityVector::render -
* EntityVector::toJson -
*/
std::string EntityVector::render
std::string EntityVector::toJson
(
RenderFormat renderFormat,
const std::vector<std::string>& attrsFilter,
Expand Down
8 changes: 4 additions & 4 deletions src/lib/apiTypesV2/EntityVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ typedef struct EntityVector
{
std::vector<Entity*> vec;

std::string render(RenderFormat renderFormat,
const std::vector<std::string>& attrsFilter,
bool blacklist,
const std::vector<std::string>& metadataFilter);
std::string toJson(RenderFormat renderFormat,
const std::vector<std::string>& attrsFilter,
bool blacklist,
const std::vector<std::string>& metadataFilter);


std::string check(RequestType requestType);
Expand Down
10 changes: 5 additions & 5 deletions src/lib/convenience/AppendContextElementRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ AppendContextElementRequest::AppendContextElementRequest()

/* ****************************************************************************
*
* render -
* toJsonV1 -
*/
std::string AppendContextElementRequest::render
std::string AppendContextElementRequest::toJsonV1
(
bool asJsonObject,
RequestType requestType
Expand All @@ -60,14 +60,14 @@ std::string AppendContextElementRequest::render

if (entity.id != "")
{
out += entity.render(false);
out += entity.toJsonV1(false);
}

// No metadata filter in this case, an empty vector is used to fulfil method signature.
// For attribute filter, we use the ContextAttributeVector itself
std::vector<std::string> emptyMdV;

out += contextAttributeVector.render(asJsonObject, requestType, contextAttributeVector.vec, emptyMdV);
out += contextAttributeVector.toJsonV1(asJsonObject, requestType, contextAttributeVector.vec, emptyMdV);
out += endTag();

return out;
Expand Down Expand Up @@ -104,7 +104,7 @@ std::string AppendContextElementRequest::check
return "OK";
}

return response.render(asJsonObject, requestType);
return response.toJsonV1(asJsonObject, requestType);
}


Expand Down
2 changes: 1 addition & 1 deletion src/lib/convenience/AppendContextElementRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ typedef struct AppendContextElementRequest

AppendContextElementRequest();

std::string render(bool asJsonObject, RequestType requestType);
std::string toJsonV1(bool asJsonObject, RequestType requestType);
void release();
std::string check(ApiVersion apiVersion,
bool asJsonObject,
Expand Down
12 changes: 6 additions & 6 deletions src/lib/convenience/AppendContextElementResponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ AppendContextElementResponse::AppendContextElementResponse() : errorCode("errorC

/* ****************************************************************************
*
* AppendContextElementResponse::render -
* AppendContextElementResponse::toJsonV1 -
*/
std::string AppendContextElementResponse::render
std::string AppendContextElementResponse::toJsonV1
(
bool asJsonObject,
RequestType requestType
Expand All @@ -64,16 +64,16 @@ std::string AppendContextElementResponse::render

if ((errorCode.code != SccNone) && (errorCode.code != SccOk))
{
out += errorCode.render(false);
out += errorCode.toJsonV1(false);
}
else
{
if (entity.id != "")
{
out += entity.render(true);
out += entity.toJsonV1(true);
}

out += contextAttributeResponseVector.render(asJsonObject, requestType);
out += contextAttributeResponseVector.toJsonV1(asJsonObject, requestType);
}

out += endTag();
Expand Down Expand Up @@ -110,7 +110,7 @@ std::string AppendContextElementResponse::check
return "OK";
}

return render(asJsonObject, requestType);
return toJsonV1(asJsonObject, requestType);
}


Expand Down
3 changes: 1 addition & 2 deletions src/lib/convenience/AppendContextElementResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ typedef struct AppendContextElementResponse

AppendContextElementResponse();

std::string render(bool asJsonObject,
RequestType requestType);
std::string toJsonV1(bool asJsonObject, RequestType requestType);
void release(void);
std::string check(ApiVersion apiVersion,
bool asJsonObject,
Expand Down
10 changes: 5 additions & 5 deletions src/lib/convenience/ContextAttributeResponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@

/* ****************************************************************************
*
* render -
* toJsonV1 -
*/
std::string ContextAttributeResponse::render
std::string ContextAttributeResponse::toJsonV1
(
bool asJsonObject,
RequestType request
Expand All @@ -55,8 +55,8 @@ std::string ContextAttributeResponse::render
std::vector<std::string> emptyMdV;

out += startTag();
out += contextAttributeVector.render(asJsonObject, request, contextAttributeVector.vec, emptyMdV, true);
out += statusCode.render(false);
out += contextAttributeVector.toJsonV1(asJsonObject, request, contextAttributeVector.vec, emptyMdV, true);
out += statusCode.toJsonV1(false);
out += endTag();

return out;
Expand Down Expand Up @@ -102,7 +102,7 @@ std::string ContextAttributeResponse::check
return "OK";
}

return render(asJsonObject, requestType);
return toJsonV1(asJsonObject, requestType);
}


Expand Down
3 changes: 1 addition & 2 deletions src/lib/convenience/ContextAttributeResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ typedef struct ContextAttributeResponse
ContextAttributeVector contextAttributeVector; // Mandatory
StatusCode statusCode; // Mandatory

std::string render(bool asJsonObject,
RequestType request);
std::string toJsonV1(bool asJsonObject, RequestType request);
void release(void);
std::string check(ApiVersion apiVersion,
bool asJsonObject,
Expand Down
6 changes: 3 additions & 3 deletions src/lib/convenience/ContextAttributeResponseVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@

/* ****************************************************************************
*
* ContextAttributeResponseVector::render -
* ContextAttributeResponseVector::toJsonV1 -
*/
std::string ContextAttributeResponseVector::render
std::string ContextAttributeResponseVector::toJsonV1
(
bool asJsonObject,
RequestType request
Expand All @@ -55,7 +55,7 @@ std::string ContextAttributeResponseVector::render
out += startTag(key, true);
for (unsigned int ix = 0; ix < vec.size(); ++ix)
{
out += vec[ix]->render(asJsonObject, request);
out += vec[ix]->toJsonV1(asJsonObject, request);
}
out += endTag(false, true);

Expand Down
3 changes: 1 addition & 2 deletions src/lib/convenience/ContextAttributeResponseVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ typedef struct ContextAttributeResponseVector
{
std::vector<ContextAttributeResponse*> vec;

std::string render(bool asJsonObject,
RequestType request);
std::string toJsonV1(bool asJsonObject, RequestType request);
void push_back(ContextAttributeResponse* item);
unsigned int size(void);
void release(void);
Expand Down
8 changes: 4 additions & 4 deletions src/lib/convenience/UpdateContextAttributeRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ UpdateContextAttributeRequest::UpdateContextAttributeRequest()

/* ****************************************************************************
*
* render -
* toJsonV1 -
*/
std::string UpdateContextAttributeRequest::render(void)
std::string UpdateContextAttributeRequest::toJsonV1(void)
{
std::string out = "";

Expand All @@ -69,7 +69,7 @@ std::string UpdateContextAttributeRequest::render(void)
out += JSON_STR("value") + ":" + compoundValueP->toJson(true);
}

out += metadataVector.render(metadataVector.vec, false);
out += metadataVector.toJsonV1(metadataVector.vec, false);
out += endTag();

return out;
Expand Down Expand Up @@ -103,7 +103,7 @@ std::string UpdateContextAttributeRequest::check
return "OK";
}

std::string out = response.render(false);
std::string out = response.toJsonV1(false);

out = "{" + out + "}";

Expand Down
2 changes: 1 addition & 1 deletion src/lib/convenience/UpdateContextAttributeRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ typedef struct UpdateContextAttributeRequest
orion::CompoundValueNode* compoundValueP;

UpdateContextAttributeRequest();
std::string render(void);
std::string toJsonV1(void);
std::string check(ApiVersion apiVersion, const std::string& preError);
void release();
} UpdateContextAttributeRequest;
Expand Down
8 changes: 4 additions & 4 deletions src/lib/convenience/UpdateContextElementRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@

/* ****************************************************************************
*
* render -
* toJsonV1 -
*
*/
std::string UpdateContextElementRequest::render(bool asJsonObject, RequestType requestType)
std::string UpdateContextElementRequest::toJsonV1(bool asJsonObject, RequestType requestType)
{
std::string out = "";

Expand All @@ -48,7 +48,7 @@ std::string UpdateContextElementRequest::render(bool asJsonObject, RequestType r
std::vector<std::string> emptyMdV;

out += startTag();
out += contextAttributeVector.render(asJsonObject, requestType, contextAttributeVector.vec, emptyMdV);
out += contextAttributeVector.toJsonV1(asJsonObject, requestType, contextAttributeVector.vec, emptyMdV);
out += endTag();

return out;
Expand Down Expand Up @@ -85,7 +85,7 @@ std::string UpdateContextElementRequest::check
return "OK";
}

return response.render(asJsonObject, requestType);
return response.toJsonV1(asJsonObject, requestType);
}


Expand Down
2 changes: 1 addition & 1 deletion src/lib/convenience/UpdateContextElementRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ typedef struct UpdateContextElementRequest
{
ContextAttributeVector contextAttributeVector; // Optional

std::string render(bool asJsonObject, RequestType requestType);
std::string toJsonV1(bool asJsonObject, RequestType requestType);
void release(void);
std::string check(ApiVersion apiVersion,
bool asJsonObject,
Expand Down
10 changes: 5 additions & 5 deletions src/lib/convenience/UpdateContextElementResponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ UpdateContextElementResponse::UpdateContextElementResponse()

/* ****************************************************************************
*
* render -
* toJsonV1 -
*/
std::string UpdateContextElementResponse::render
std::string UpdateContextElementResponse::toJsonV1
(
bool asJsonObject,
RequestType requestType
Expand All @@ -62,11 +62,11 @@ std::string UpdateContextElementResponse::render

if ((errorCode.code != SccNone) && (errorCode.code != SccOk))
{
out += errorCode.render(false);
out += errorCode.toJsonV1(false);
}
else
{
out += contextAttributeResponseVector.render(asJsonObject, requestType);
out += contextAttributeResponseVector.toJsonV1(asJsonObject, requestType);
}

out += endTag();
Expand Down Expand Up @@ -103,7 +103,7 @@ std::string UpdateContextElementResponse::check
return "OK";
}

return render(asJsonObject, requestType);
return toJsonV1(asJsonObject, requestType);
}


Expand Down
Loading