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

Fix return servicePath in the entity response #4329

Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Add: servicePath field to builtin attributes (#2877)
- Fix: logDeprecate not working correctly (`geo:json` wrongly considered as deprecated)
1 change: 1 addition & 0 deletions src/lib/common/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
#define DATE_MODIFIED "dateModified"
#define DATE_EXPIRES "dateExpires"
#define ALTERATION_TYPE "alterationType"
#define SERVICE_PATH "servicePath"
#define ALL_ATTRS "*"


Expand Down
10 changes: 10 additions & 0 deletions src/lib/mongoBackend/MongoGlobal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,11 @@ static std::string sortCriteria(const std::string& sortToken)
return ENT_MODIFICATION_DATE;
}

if (sortToken == SERVICE_PATH)
{
return std::string("_id.") + ENT_SERVICE_PATH;
}

if (sortToken == ENT_ENTITY_ID)
{
return std::string("_id.") + ENT_ENTITY_ID;
Expand Down Expand Up @@ -1313,6 +1318,11 @@ void addBuiltins(ContextElementResponse* cerP, const std::string& alterationType
addIfNotPresentAttr(&cerP->entity, ALTERATION_TYPE, DEFAULT_ATTR_STRING_TYPE, alterationType);
}

// servicePath
if (!cerP->entity.servicePath.empty())
{
addIfNotPresentAttr(&cerP->entity, SERVICE_PATH, DEFAULT_ATTR_STRING_TYPE, cerP->entity.servicePath);
}

for (unsigned int ix = 0; ix < cerP->entity.attributeVector.size(); ix++)
{
Expand Down
4 changes: 4 additions & 0 deletions src/lib/rest/StringFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1835,6 +1835,10 @@ bool StringFilter::mongoFilterPopulate(std::string* errorStringP)
{
k = ENT_MODIFICATION_DATE;
}
else if (left == SERVICE_PATH)
{
k = std::string("_id.") + ENT_SERVICE_PATH;
}
else if (left == itemP->attributeName + "." + ENT_ATTRS_MD "." + NGSI_MD_DATECREATED)
{
k = std::string(ENT_ATTRS) + "." + itemP->attributeName + "." + ENT_ATTRS_CREATION_DATE;
Expand Down
Loading
Loading