Skip to content

Commit

Permalink
Merge pull request #4329 from chetan-NEC/return-ServicePath-in-the-en…
Browse files Browse the repository at this point in the history
…tity-response

Fix return servicePath in the entity response
  • Loading branch information
fgalan authored Aug 9, 2023
2 parents 19c1a37 + 9e92496 commit afb0b3b
Show file tree
Hide file tree
Showing 8 changed files with 1,003 additions and 0 deletions.
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

0 comments on commit afb0b3b

Please sign in to comment.