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

Remove obsolete location medadata in NGSIv1 #4048

Merged
merged 24 commits into from
Jan 24, 2024

Conversation

fgalan
Copy link
Member

@fgalan fgalan commented Jan 28, 2022

  • Remove support in code
  • deprecated.md
  • Check & fix script
  • 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)
  • CNR

@fgalan fgalan force-pushed the remove/ngsiv1-location-metadata branch from 93fc5c6 to 27d4e5a Compare February 3, 2022 07:56
@fgalan
Copy link
Member Author

fgalan commented Feb 3, 2022

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.

@fgalan fgalan changed the title [WIP] Remove obsolete location medadata in NGSIv1 Remove obsolete location medadata in NGSIv1 Jan 24, 2024
@fgalan fgalan requested a review from mapedraza January 24, 2024 14:26
Copy link
Collaborator

@mapedraza mapedraza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mapedraza mapedraza merged commit f5dfae6 into master Jan 24, 2024
12 checks passed
@mapedraza mapedraza deleted the remove/ngsiv1-location-metadata branch January 24, 2024 14:56
@fgalan
Copy link
Member Author

fgalan commented Jan 24, 2024

@fisuda this PR does some modifications to the English documentation. It would be great if you could sync the Japanese translation, please. Thanks!

fisuda added a commit to fisuda/fiware-orion that referenced this pull request Jan 25, 2024
@fisuda
Copy link
Contributor

fisuda commented Jan 25, 2024

I sent the PR #4492. Thanks.

Comment on lines +128 to +240
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);
}
Copy link
Member Author

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)

fgalan added a commit that referenced this pull request Jan 25, 2024
(JP) Remove documentation about location medadata in NGSIv1 (#4048)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants