-
Notifications
You must be signed in to change notification settings - Fork 266
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
Remove obsolete location medadata in NGSIv1 #4048
Conversation
93fc5c6
to
27d4e5a
Compare
3c188d...27d4e5a show the code simplification we can achieve with the removal. It can be even higher if the "FIXME PR" mark is also taken into account. |
…caid/fiware-orion into remove/ngsiv1-location-metadata
…caid/fiware-orion into remove/ngsiv1-location-metadata
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@fisuda this PR does some modifications to the English documentation. It would be great if you could sync the Japanese translation, please. Thanks! |
I sent the PR #4492. Thanks. |
ca.type = getStringFieldF(attr, ENT_ATTRS_TYPE); | ||
|
||
// Skip attribute if the attribute is in the list (or attrL is empty or includes "*") | ||
if (!includedAttribute(ca.name, attrL)) | ||
{ | ||
continue; | ||
} | ||
|
||
/* It could happen (although very rarely) that the value field is missing in the | ||
* DB for the attribute. The following is a safety check measure to protect against that */ | ||
if (!attr.hasField(ENT_ATTRS_VALUE)) | ||
{ | ||
caP = new ContextAttribute(ca.name, ca.type, ""); | ||
} | ||
else | ||
{ | ||
switch(getFieldF(attr, ENT_ATTRS_VALUE).type()) | ||
{ | ||
case orion::String: | ||
ca.stringValue = getStringFieldF(attr, ENT_ATTRS_VALUE); | ||
if (!includeEmpty && ca.stringValue.empty()) | ||
{ | ||
continue; | ||
} | ||
caP = new ContextAttribute(ca.name, ca.type, ca.stringValue); | ||
break; | ||
|
||
case orion::NumberDouble: | ||
ca.numberValue = getNumberFieldF(attr, ENT_ATTRS_VALUE); | ||
caP = new ContextAttribute(ca.name, ca.type, ca.numberValue); | ||
break; | ||
|
||
case orion::NumberInt: | ||
ca.numberValue = (double) getIntFieldF(attr, ENT_ATTRS_VALUE); | ||
caP = new ContextAttribute(ca.name, ca.type, ca.numberValue); | ||
break; | ||
|
||
case orion::Bool: | ||
ca.boolValue = getBoolFieldF(attr, ENT_ATTRS_VALUE); | ||
caP = new ContextAttribute(ca.name, ca.type, ca.boolValue); | ||
break; | ||
|
||
case orion::jstNULL: | ||
caP = new ContextAttribute(ca.name, ca.type, ""); | ||
caP->valueType = orion::ValueTypeNull; | ||
break; | ||
|
||
case orion::Object: | ||
caP = new ContextAttribute(ca.name, ca.type, ""); | ||
caP->compoundValueP = new orion::CompoundValueNode(orion::ValueTypeObject); | ||
caP->valueType = orion::ValueTypeObject; | ||
compoundObjectResponse(caP->compoundValueP, getFieldF(attr, ENT_ATTRS_VALUE)); | ||
break; | ||
|
||
case orion::Array: | ||
caP = new ContextAttribute(ca.name, ca.type, ""); | ||
caP->compoundValueP = new orion::CompoundValueNode(orion::ValueTypeVector); | ||
caP->valueType = orion::ValueTypeVector; | ||
compoundVectorResponse(caP->compoundValueP, getFieldF(attr, ENT_ATTRS_VALUE)); | ||
break; | ||
|
||
default: | ||
LM_E(("Runtime Error (unknown attribute value type in DB: %d)", getFieldF(attr, ENT_ATTRS_VALUE).type())); | ||
} | ||
} | ||
|
||
/* dateExpires is managed like a regular attribute in DB, but it is a builtin and it is shadowed */ | ||
if (caP->name == DATE_EXPIRES) | ||
{ | ||
caP->shadowed = true; | ||
} | ||
|
||
/* Setting custom metadata (if any) */ | ||
if (attr.hasField(ENT_ATTRS_MD)) | ||
{ | ||
orion::BSONObj mds = getObjectFieldF(attr, ENT_ATTRS_MD); | ||
std::set<std::string> mdsSet; | ||
|
||
mds.getFieldNames(&mdsSet); | ||
for (std::set<std::string>::iterator i = mdsSet.begin(); i != mdsSet.end(); ++i) | ||
{ | ||
std::string currentMd = *i; | ||
Metadata* md = new Metadata(dbDecode(currentMd), getObjectFieldF(mds, currentMd)); | ||
caP->metadataVector.push_back(md); | ||
} | ||
} | ||
|
||
/* Set creDate and modDate at attribute level */ | ||
if (attr.hasField(ENT_ATTRS_CREATION_DATE)) | ||
{ | ||
caP->creDate = getNumberFieldF(attr, ENT_ATTRS_CREATION_DATE); | ||
} | ||
|
||
if (attr.hasField(ENT_ATTRS_MODIFICATION_DATE)) | ||
{ | ||
caP->modDate = getNumberFieldF(attr, ENT_ATTRS_MODIFICATION_DATE); | ||
} | ||
|
||
entity.attributeVector.push_back(caP); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be a big block of duplicated code. The changes done PR #4491 confirm and fix it.
NTC (post-merge comment)
(JP) Remove documentation about location medadata in NGSIv1 (#4048)
Migrate script to Python 3(we are going to use at the end entities_consistency.py script + info in release notes)Check & fix script documentation(we are going to use at the end entities_consistency.py script + info in release notes)Check & fix script and documentation definitive Orion version (currently we use "3.5.0" as placeholder)(we are going to use at the end entities_consistency.py script + info in release notes)