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

VocabularyProperty => VocabProperty #1724

Merged
merged 1 commit into from
Jan 7, 2025
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
3 changes: 2 additions & 1 deletion CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
#1707: Support for local=true in the type discovery endpoints (GET /ngsi-ld/v1/types[/{typeName}]
#XXXX: Support for local=true in the ATTRIBUTE discovery endpoints (GET /ngsi-ld/v1/attributes}]
#1708: Reloaded hosted contexts were not persisted in mongo, only the context cache
#XXXX: Using "VocabProperty" and not "VocabularyProperty" (old name still accepted as input)

## New Features:
* Support for ...
*

## Notes
14 changes: 10 additions & 4 deletions src/lib/orionld/dbModel/dbModelToApiAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ void dbModelToApiAttribute(KjNode* dbAttrP, bool sysAttrs, bool eqsForDots)
if (strcmp(typeP->value.s, "Relationship") == 0) valueP->name = (char*) "object";
else if (strcmp(typeP->value.s, "LanguageProperty") == 0) valueP->name = (char*) "languageMap";
else if (strcmp(typeP->value.s, "JsonProperty") == 0) valueP->name = (char*) "json";
else if (strcmp(typeP->value.s, "VocabularyProperty") == 0)
else if ((strcmp(typeP->value.s, "VocabularyProperty") == 0) || (strcmp(typeP->value.s, "VocabProperty") == 0))
{
valueP->name = (char*) "vocab";
typeP->value.s = (char*) "VocabProperty";
valueP->name = (char*) "vocab";

if (valueP->type == KjString)
valueP->value.s = orionldContextItemAliasLookup(orionldState.contextP, valueP->value.s, NULL, NULL);
Expand Down Expand Up @@ -354,7 +355,10 @@ KjNode* dbModelToApiAttribute2(KjNode* dbAttrP, KjNode* datasetP, bool sysAttrs,
// And call dbModelToApiSubAttribute2 with Concise
//
bool conciseAsKeyValues = false;
KjNode* attrTypeNodeP = NULL;
KjNode* attrTypeNodeP = kjLookup(dbAttrP, "type");

if ((attrTypeNodeP != NULL) && (strcmp(attrTypeNodeP->value.s, "VocabularyProperty") == 0))
attrTypeNodeP->value.s = (char*) "VocabProperty";

if ((renderFormat == RF_CONCISE) && (sysAttrs == false))
{
Expand All @@ -377,7 +381,7 @@ KjNode* dbModelToApiAttribute2(KjNode* dbAttrP, KjNode* datasetP, bool sysAttrs,
dbModelToApiLangPropertySimplified(dbAttrP, lang);
attrP = dbAttrP;
}
else if (strcmp(attrTypeNodeP->value.s, "VocabularyProperty") == 0)
else if (strcmp(attrTypeNodeP->value.s, "VocabProperty") == 0)
{
KjNode* valueP = kjLookup(dbAttrP, "value");

Expand All @@ -392,6 +396,8 @@ KjNode* dbModelToApiAttribute2(KjNode* dbAttrP, KjNode* datasetP, bool sysAttrs,
}
}

attrTypeNodeP->value.s = (char*) "VocabProperty";

// Remove everything except the value, and change its name to "vocab"
dbAttrP->value.firstChildP = valueP;
dbAttrP->lastChild = valueP;
Expand Down
3 changes: 2 additions & 1 deletion src/lib/orionld/dbModel/dbModelToApiSubAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ void dbModelToApiSubAttribute(KjNode* dbSubAttrP)
{
if (strcmp(typeP->value.s, "Relationship") == 0) valueP->name = (char*) "object";
else if (strcmp(typeP->value.s, "LanguageProperty") == 0) valueP->name = (char*) "languageMap";
else if (strcmp(typeP->value.s, "VocabularyProperty") == 0) valueP->name = (char*) "vocab";
else if (strcmp(typeP->value.s, "VocabularyProperty") == 0) { valueP->name = (char*) "vocab"; typeP->value.s = (char*) "VocabProperty"; }
else if (strcmp(typeP->value.s, "VocabProperty") == 0) valueP->name = (char*) "vocab";
else if (strcmp(typeP->value.s, "JsonProperty") == 0) valueP->name = (char*) "json";
}
}
Expand Down
42 changes: 24 additions & 18 deletions src/lib/orionld/payloadCheck/pCheckAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,48 +70,48 @@ static const char* attrTypeChangeTitle(OrionldAttributeType oldType, OrionldAttr
if (oldType == Relationship) return "Attempt to transform a Relationship into a Property";
if (oldType == GeoProperty) return "Attempt to transform a GeoProperty into a Property";
if (oldType == LanguageProperty) return "Attempt to transform a LanguageProperty into a Property";
if (oldType == VocabularyProperty) return "Attempt to transform a VocabularyProperty into a Property";
if (oldType == VocabularyProperty) return "Attempt to transform a VocabProperty into a Property";
if (oldType == JsonProperty) return "Attempt to transform a JsonProperty into a Property";
}
else if (newType == Relationship)
{
if (oldType == Property) return "Attempt to transform a Property into a Relationship";
if (oldType == GeoProperty) return "Attempt to transform a GeoProperty into a Relationship";
if (oldType == LanguageProperty) return "Attempt to transform a LanguageProperty into a Relationship";
if (oldType == VocabularyProperty) return "Attempt to transform a VocabularyProperty into a Relationship";
if (oldType == VocabularyProperty) return "Attempt to transform a VocabProperty into a Relationship";
if (oldType == JsonProperty) return "Attempt to transform a JsonProperty into a Relationship";
}
else if (newType == GeoProperty)
{
if (oldType == Property) return "Attempt to transform a Property into a GeoProperty";
if (oldType == Relationship) return "Attempt to transform a Relationship into a GeoProperty";
if (oldType == LanguageProperty) return "Attempt to transform a LanguageProperty into a GeoProperty";
if (oldType == VocabularyProperty) return "Attempt to transform a VocabularyProperty into a GeoProperty";
if (oldType == VocabularyProperty) return "Attempt to transform a VocabProperty into a GeoProperty";
if (oldType == JsonProperty) return "Attempt to transform a JsonProperty into a GeoProperty";
}
else if (newType == LanguageProperty)
{
if (oldType == Property) return "Attempt to transform a Property into a LanguageProperty";
if (oldType == Relationship) return "Attempt to transform a Relationship into a LanguageProperty";
if (oldType == GeoProperty) return "Attempt to transform a GeoProperty into a LanguageProperty";
if (oldType == VocabularyProperty) return "Attempt to transform a VocabularyProperty into a LanguageProperty";
if (oldType == VocabularyProperty) return "Attempt to transform a VocabProperty into a LanguageProperty";
if (oldType == JsonProperty) return "Attempt to transform a JsonProperty into a LanguageProperty";
}
else if (newType == VocabularyProperty)
{
if (oldType == Property) return "Attempt to transform a Property into a VocabularyProperty";
if (oldType == Relationship) return "Attempt to transform a Relationship into a VocabularyProperty";
if (oldType == GeoProperty) return "Attempt to transform a GeoProperty into a VocabularyProperty";
if (oldType == LanguageProperty) return "Attempt to transform a LanguageProperty into a VocabularyProperty";
if (oldType == JsonProperty) return "Attempt to transform a JsonProperty into a VocabularyProperty";
if (oldType == Property) return "Attempt to transform a Property into a VocabProperty";
if (oldType == Relationship) return "Attempt to transform a Relationship into a VocabProperty";
if (oldType == GeoProperty) return "Attempt to transform a GeoProperty into a VocabProperty";
if (oldType == LanguageProperty) return "Attempt to transform a LanguageProperty into a VocabProperty";
if (oldType == JsonProperty) return "Attempt to transform a JsonProperty into a VocabProperty";
}
else if (newType == JsonProperty)
{
if (oldType == Property) return "Attempt to transform a Property into a JsonProperty";
if (oldType == Relationship) return "Attempt to transform a Relationship into a JsonProperty";
if (oldType == GeoProperty) return "Attempt to transform a GeoProperty into a JsonProperty";
if (oldType == LanguageProperty) return "Attempt to transform a LanguageProperty into a JsonProperty";
if (oldType == VocabularyProperty) return "Attempt to transform a VocabularyProperty into a JsonProperty";
if (oldType == VocabularyProperty) return "Attempt to transform a VocabProperty into a JsonProperty";
}

return "Attribute type inconsistency";
Expand Down Expand Up @@ -547,27 +547,27 @@ bool valueAndTypeCheck(KjNode* attrP, OrionldAttributeType attributeType, bool a
{
if (valueP != NULL)
{
orionldError(OrionldBadRequestData, "Forbidden field for a VocabularyProperty: value", attrP->name, 400);
orionldError(OrionldBadRequestData, "Forbidden field for a VocabProperty: value", attrP->name, 400);
return false;
}
else if (objectP != NULL)
{
orionldError(OrionldBadRequestData, "Forbidden field for a VocabularyProperty: object", attrP->name, 400);
orionldError(OrionldBadRequestData, "Forbidden field for a VocabProperty: object", attrP->name, 400);
return false;
}
else if (languageMapP != NULL)
{
orionldError(OrionldBadRequestData, "Forbidden field for a VocabularyProperty: languageMap", attrP->name, 400);
orionldError(OrionldBadRequestData, "Forbidden field for a VocabProperty: languageMap", attrP->name, 400);
return false;
}
else if (jsonP != NULL)
{
orionldError(OrionldBadRequestData, "Forbidden field for a VocabularyProperty: json", attrP->name, 400);
orionldError(OrionldBadRequestData, "Forbidden field for a VocabProperty: json", attrP->name, 400);
return false;
}
else if ((vocabP == NULL) && (attributeExisted == false)) // Attribute is new but the value is missing
{
orionldError(OrionldBadRequestData, "Missing /vocab/ field for VocabularyProperty at creation time", attrP->name, 400);
orionldError(OrionldBadRequestData, "Missing /vocab/ field for VocabProperty at creation time", attrP->name, 400);
return false;
}

Expand Down Expand Up @@ -737,7 +737,7 @@ static bool pCheckVocabulary(KjNode* vocabP, const char* attrName)
{
if (wordP->type != KjString)
{
orionldError(OrionldBadRequestData, "Invalid VocabularyProperty vocab array item - not a string", attrName, 400);
orionldError(OrionldBadRequestData, "Invalid VocabProperty vocab array item - not a string", attrName, 400);
return false;
}

Expand All @@ -746,7 +746,7 @@ static bool pCheckVocabulary(KjNode* vocabP, const char* attrName)
}
else
{
orionldError(OrionldBadRequestData, "Invalid VocabularyProperty vocab - not a string nor an array", attrName, 400);
orionldError(OrionldBadRequestData, "Invalid VocabProperty vocab - not a string nor an array", attrName, 400);
return false;
}

Expand Down Expand Up @@ -898,8 +898,10 @@ bool deletionWithTypePresent(KjNode* attrP, KjNode* typeP)
return true;
}
}
else if (strcmp(typeP->value.s, "VocabularyProperty") == 0)
else if ((strcmp(typeP->value.s, "VocabularyProperty") == 0) || (strcmp(typeP->value.s, "VocabProperty") == 0))
{
typeP->value.s = (char*) "VocabProperty";

valueP = kjLookup(attrP, "vocab");
if ((valueP != NULL) && (valueP->type == KjString) && (strcmp(valueP->value.s, "urn:ngsi-ld:null") == 0))
{
Expand Down Expand Up @@ -1091,6 +1093,10 @@ static bool pCheckAttributeObject
bool geoJsonValue = false;

attributeType = orionldAttributeType(typeP->value.s);

if (strcmp(typeP->value.s, "VocabularyProperty") == 0)
typeP->value.s = (char*) "VocabProperty";

if (attributeType == NoAttributeType)
{
if (isGeoJsonValue(attrP))
Expand Down
2 changes: 1 addition & 1 deletion src/lib/orionld/troe/pgAttributeBuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ bool pgAttributeBuild
skip = (char*) "RelationshipArray";
}
else if (strcmp(nodeP->name, "languageMap") == 0) skip = (char*) "LanguageProperty";
else if (strcmp(nodeP->name, "vocab") == 0) skip = (char*) "VocabularyProperty";
else if (strcmp(nodeP->name, "vocab") == 0) skip = (char*) "VocabProperty";
else if (strcmp(nodeP->name, "createdAt") == 0) {} // skip = (char*) "BuiltinTimestamp";
else if (strcmp(nodeP->name, "modifiedAt") == 0) {} // skip = (char*) "BuiltinTimestamp";
else if (strcmp(nodeP->name, "https://uri.etsi.org/ngsi-ld/createdAt") == 0) {} // Skipping
Expand Down
3 changes: 2 additions & 1 deletion src/lib/orionld/types/OrionldAttributeType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const char* orionldAttributeTypeName(OrionldAttributeType attributeType)
case Relationship: return "Relationship";
case GeoProperty: return "GeoProperty";
case LanguageProperty: return "LanguageProperty";
case VocabularyProperty: return "VocabularyProperty";
case VocabularyProperty: return "VocabProperty";
case JsonProperty: return "JsonProperty";
}

Expand All @@ -62,6 +62,7 @@ OrionldAttributeType orionldAttributeType(const char* typeString)
else if (strcmp(typeString, "Relationship") == 0) return Relationship;
else if (strcmp(typeString, "GeoProperty") == 0) return GeoProperty;
else if (strcmp(typeString, "LanguageProperty") == 0) return LanguageProperty;
else if (strcmp(typeString, "VocabProperty") == 0) return VocabularyProperty;
else if (strcmp(typeString, "VocabularyProperty") == 0) return VocabularyProperty;
else if (strcmp(typeString, "JsonProperty") == 0) return JsonProperty;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ payload='{
"type": "Point",
"coordinates": [ 31.0, 32.77 ]
},
"expiresAt": "2024-12-31T10:00:19.975Z",
"expiresAt": "2029-12-31T10:00:19.975Z",
"endpoint": "http://my.other.csource.org:1099",
"P1": [ 1, 2, 3, 4 ]
}'
Expand Down Expand Up @@ -1685,7 +1685,7 @@ Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
32.77
]
},
"expiresAt": "2024-12-31T10:00:19.975Z",
"expiresAt": "2029-12-31T10:00:19.975Z",
"status": "active",
"endpoint": "http://my.other.csource.org:1099",
"P1": [
Expand Down Expand Up @@ -1769,7 +1769,7 @@ MongoDB server version: REGEX(.*)
32.77
]
},
"expiration" : 1735639219.975,
"expiration" : 1893405619.975,
"properties" : {
"https://uri=etsi=org/ngsi-ld/default-context/P1" : [
1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ payload='{
"type": "Point",
"coordinates": [ 31.0, 32.77 ]
},
"expiresAt": "2024-12-31T10:00:19.975Z",
"expiresAt": "2029-12-31T10:00:19.975Z",
"endpoint": "http://my.other.csource.org:1099",
"P1": [ 1, 2, 3, 4 ]
}'
Expand Down Expand Up @@ -1622,7 +1622,7 @@ Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
"type": "ContextSourceRegistration",
"name": "R1-bis",
"description": "description of reg R1-bis",
"expiresAt": "2024-12-31T10:00:19.975Z",
"expiresAt": "2029-12-31T10:00:19.975Z",
"endpoint": "http://my.other.csource.org:1099",
"information": [
{
Expand Down Expand Up @@ -1691,7 +1691,7 @@ MongoDB server version: REGEX(.*)
"_id" : "urn:ngsi-ld:ContextSourceRegistration:R1",
"description" : "description of reg R1-bis",
"name" : "R1-bis",
"expiration" : 1735639219.975,
"expiration" : 1893405619.975,
"servicePath" : "/",
"contextRegistration" : [
{
Expand Down
Loading
Loading