diff --git a/src/lib/orionld/troe/CMakeLists.txt b/src/lib/orionld/troe/CMakeLists.txt index f2385927a0..b7ac0a365d 100644 --- a/src/lib/orionld/troe/CMakeLists.txt +++ b/src/lib/orionld/troe/CMakeLists.txt @@ -44,30 +44,6 @@ SET (SOURCES pgTransactionBegin.cpp pgTransactionCommit.cpp pgTransactionRollback.cpp - pgEntityTreat.cpp - pgEntityPush.cpp - pgAttributeTreat.cpp - pgAttributePush.cpp - pgSubAttributePush.cpp - pgRelationshipPush.cpp - pgStringPropertyPush.cpp - pgNumberPropertyPush.cpp - pgCompoundPropertyPush.cpp - pgBoolPropertyPush.cpp - pgSubAttributeTreat.cpp - pgSubRelationshipPush.cpp - pgStringSubPropertyPush.cpp - pgBoolSubPropertyPush.cpp - pgCompoundSubPropertyPush.cpp - pgNumberSubPropertyPush.cpp - pgEntityDelete.cpp - pgAttributeDelete.cpp - pgGeoPropertyPush.cpp - pgGeoPointPush.cpp - pgGeoPolygonPush.cpp - pgGeoMultiPolygonPush.cpp - pgGeoLineStringPush.cpp - pgGeoMultiLineStringPush.cpp kjGeoPointExtract.cpp kjGeoPolygonExtract.cpp kjGeoMultiPolygonExtract.cpp @@ -119,27 +95,6 @@ SET (HEADERS pgTransactionBegin.h pgTransactionCommit.h pgTransactionRollback.h - pgEntityTreat.h - pgEntityPush.h - pgAttributeTreat.h - pgAttributePush.h - pgSubAttributePush.h - pgRelationshipPush.h - pgNumberPropertyPush.h - pgCompoundPropertyPush.h - pgBoolPropertyPush.h - pgStringSubPropertyPush.h - pgBoolSubPropertyPush.h - pgCompoundSubPropertyPush.h - pgNumberSubPropertyPush.h - pgEntityDelete.h - pgAttributeDelete.h - pgGeoPropertyPush.h - pgGeoPointPush.h - pgGeoPolygonPush.h - pgGeoMultiPolygonPush.h - pgGeoLineStringPush.h - pgGeoMultiLineStringPush.h kjGeoPointExtract.h kjGeoPolygonExtract.h kjGeoMultiPolygonExtract.h diff --git a/src/lib/orionld/troe/pgAttributeDelete.cpp b/src/lib/orionld/troe/pgAttributeDelete.cpp deleted file mode 100644 index 8466f4a322..0000000000 --- a/src/lib/orionld/troe/pgAttributeDelete.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/troe/pgAttributeDelete.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgAttributeDelete - mark an attribute as deleted in the database -// -bool pgAttributeDelete -( - PGconn* connectionP, - const char* entityId, - const char* instanceId, - const char* attributeName, - const char* datasetId, - const char* deletedAt -) -{ - char sql[512]; - PGresult* res; - - if (datasetId == NULL) - datasetId = (char*) "None"; - - snprintf(sql, sizeof(sql), "INSERT INTO attributes(opMode, instanceId, id, entityId, datasetId, ts) VALUES ('Delete', '%s', '%s', '%s', '%s', '%s')", - instanceId, attributeName, entityId, datasetId, deletedAt); - - // LM_TMP(("SQL[%p]: %s", connectionP, sql)); - res = PQexec(connectionP, sql); - if (res == NULL) - LM_RE(false, ("Database Error (%s)", PQresStatus(PQresultStatus(res)))); - PQclear(res); - - return true; -} diff --git a/src/lib/orionld/troe/pgAttributeDelete.h b/src/lib/orionld/troe/pgAttributeDelete.h deleted file mode 100644 index 777e508e21..0000000000 --- a/src/lib/orionld/troe/pgAttributeDelete.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGATTRIBUTEDELETE_H_ -#define SRC_LIB_ORIONLD_TROE_PGATTRIBUTEDELETE_H_ - -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - - - -// ----------------------------------------------------------------------------- -// -// pgAttributeDelete - mark an attribute as deleted in the database -// -extern bool pgAttributeDelete -( - PGconn* connectionP, - const char* entityId, - const char* instanceId, - const char* attributeName, - const char* datasetId, - const char* deletedAt -); - -#endif // SRC_LIB_ORIONLD_TROE_PGATTRIBUTEDELETE_H_ diff --git a/src/lib/orionld/troe/pgAttributePush.cpp b/src/lib/orionld/troe/pgAttributePush.cpp deleted file mode 100644 index 38e7b9e5cf..0000000000 --- a/src/lib/orionld/troe/pgAttributePush.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/troe/pgStringPropertyPush.h" // pgStringPropertyPush -#include "orionld/troe/pgNumberPropertyPush.h" // pgNumberPropertyPush -#include "orionld/troe/pgCompoundPropertyPush.h" // pgCompoundPropertyPush -#include "orionld/troe/pgBoolPropertyPush.h" // pgBoolPropertyPush -#include "orionld/troe/pgRelationshipPush.h" // pgRelationshipPush -#include "orionld/troe/pgGeoPropertyPush.h" // pgGeoPropertyPush -#include "orionld/troe/pgAttributePush.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgAttributePush - add an attribute to the DB -// -bool pgAttributePush -( - PGconn* connectionP, - KjNode* valueNodeP, - const char* attributeType, - const char* entityId, - const char* id, - const char* instanceId, - const char* datasetId, - const char* observedAt, - bool subAttrs, - const char* unitCode, - const char* opMode -) -{ - // - // Property - // - if (strcmp(attributeType, "Property") == 0) - { - if (valueNodeP->type == KjString) - { - if (pgStringPropertyPush(connectionP, opMode, valueNodeP->value.s, entityId, id, instanceId, datasetId, observedAt, subAttrs) == false) - LM_RE(false, ("pgStringPropertyPush failed")); - } - else if (valueNodeP->type == KjInt) - { - if (pgNumberPropertyPush(connectionP, opMode, valueNodeP->value.i, entityId, id, instanceId, datasetId, observedAt, subAttrs, unitCode) == false) - LM_RE(false, ("pgIntPropertyPush failed")); - } - else if (valueNodeP->type == KjFloat) - { - if (pgNumberPropertyPush(connectionP, opMode, valueNodeP->value.f, entityId, id, instanceId, datasetId, observedAt, subAttrs, unitCode) == false) - LM_RE(false, ("pgIntPropertyPush failed")); - } - else if ((valueNodeP->type == KjArray) || (valueNodeP->type == KjObject)) - { - if (pgCompoundPropertyPush(connectionP, opMode, valueNodeP, entityId, id, instanceId, datasetId, observedAt, subAttrs) == false) - LM_RE(false, ("pgCompoundPropertyPush failed")); - } - else if (valueNodeP->type == KjBoolean) - { - if (pgBoolPropertyPush(connectionP, opMode, valueNodeP->value.b, entityId, id, instanceId, datasetId, observedAt, subAttrs) == false) - LM_RE(false, ("pgBoolPropertyPush failed")); - } - else - { - LM_E(("Internal Error (invalid value type for the Property '%s')", id)); - return false; - } - } - // - // Relationship - // - else if (strcmp(attributeType, "Relationship") == 0) - { - if (pgRelationshipPush(connectionP, opMode, valueNodeP->value.s, entityId, id, instanceId, datasetId, observedAt, subAttrs) == false) - LM_RE(false, ("pgRelationshipPush failed")); - } - // - // GeoProperty - // - else if (strcmp(attributeType, "GeoProperty") == 0) - { - if (pgGeoPropertyPush(connectionP, opMode, valueNodeP, entityId, id, instanceId, datasetId, observedAt, subAttrs) == false) - LM_RE(false, ("pgGeoPropertyPush failed")); - } - else - { - LM_E(("Internal Error (invalid type (%s) for the attribute '%s')", attributeType, id)); - return false; - } - - return true; -} diff --git a/src/lib/orionld/troe/pgAttributePush.h b/src/lib/orionld/troe/pgAttributePush.h deleted file mode 100644 index fe05e47669..0000000000 --- a/src/lib/orionld/troe/pgAttributePush.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGATTRIBUTEPUSH_H_ -#define SRC_LIB_ORIONLD_TROE_PGATTRIBUTEPUSH_H_ - -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - - - -// ----------------------------------------------------------------------------- -// -// pgAttributePush - add an attribute to the DB -// -extern bool pgAttributePush -( - PGconn* connectionP, - KjNode* valueNodeP, - const char* attributeType, - const char* entityId, - const char* id, - const char* instanceId, - const char* datasetId, - const char* observedAt, - bool subAttrs, - const char* unitCode, - const char* opMode -); - -#endif // SRC_LIB_ORIONLD_TROE_PGATTRIBUTEPUSH_H_ diff --git a/src/lib/orionld/troe/pgAttributeTreat.cpp b/src/lib/orionld/troe/pgAttributeTreat.cpp deleted file mode 100644 index dc1526992c..0000000000 --- a/src/lib/orionld/troe/pgAttributeTreat.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -extern "C" -{ -#include "kjson/KjNode.h" // KjNode -#include "kjson/kjLookup.h" // kjLookup -#include "kjson/kjBuilder.h" // kjChildRemove -#include "kjson/kjRender.h" // kjRender -} - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/common/uuidGenerate.h" // uuidGenerate -#include "orionld/troe/troe.h" // TroeMode, troeMode -#include "orionld/troe/pgAttributePush.h" // pgAttributePush -#include "orionld/troe/pgSubAttributeTreat.h" // pgSubAttributeTreat -#include "orionld/troe/pgObservedAtExtract.h" // pgObservedAtExtract -#include "orionld/troe/pgAttributeTreat.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgAttributeTreat - treat an attribute for db insertion -// -bool pgAttributeTreat -( - PGconn* connectionP, - KjNode* attrP, - const char* entityId, - TroeMode opMode -) -{ - if (attrP->type == KjArray) - LM_RE(false, ("Attribute is an array ... datasetId? Sorry - not yet implemented")); - - char* attributeType; - KjNode* typeP = kjLookup(attrP, "type"); - - if (typeP == NULL) - LM_RE(false, ("Attribute '%s' has no type", attrP->name)); - attributeType = typeP->value.s; - - kjChildRemove(attrP, typeP); - - char instanceId[80]; - char* id = attrP->name; - char* unitCode = NULL; - char* datasetId = (char*) "None"; - char* observedAt = NULL; - KjNode* valueNodeP = NULL; - bool subAttrs = false; - - uuidGenerate(instanceId, sizeof(instanceId), true); - - // - // Strip off all special sub-attributes - // - // Get all special sub-attributes and remove them from the tree - // Only normal sub attributes left in the tree after this loop - // The sub-attributes must be added to the DB after the attribute, as the InstanceID of the attribute is - // needed (and referenced => the DB gices error if the referenced attribute doesn't exist already). - // - // I wonder if this "REFERENCED BY" slows the DB down when inserting ... If so, do we really need it? - // - KjNode* subAttrP = attrP->value.firstChildP; - KjNode* next; - - while (subAttrP != NULL) - { - next = subAttrP->next; - - if (strcmp(subAttrP->name, "observedAt") == 0) observedAt = pgObservedAtExtract(subAttrP); - else if (strcmp(subAttrP->name, "datasetId") == 0) datasetId = subAttrP->value.s; - else if (strcmp(subAttrP->name, "value") == 0) valueNodeP = subAttrP; - else if (strcmp(subAttrP->name, "object") == 0) valueNodeP = subAttrP; - else if (strcmp(subAttrP->name, "unitCode") == 0) unitCode = subAttrP->value.s; - else if (strcmp(subAttrP->name, "createdAt") == 0) {} // Skipping - else if (strcmp(subAttrP->name, "modifiedAt") == 0) {} // Skipping - else - { - subAttrs = true; - subAttrP = next; - continue; // pgSubAttributeTreat() later - after creating the attribute - } - - kjChildRemove(attrP, subAttrP); - subAttrP = next; - } - - // - // Push the attribute to DB - // - const char* opModeString = troeMode(opMode); - if (pgAttributePush(connectionP, valueNodeP, attributeType, entityId, id, instanceId, datasetId, observedAt, subAttrs, unitCode, opModeString) == false) - { - LM_E(("Internal Error (pgAttributePush failed)")); - return false; - } - - // - // Treating all sub-attrs (except those special ones that were stripped off earlier) - // - for (KjNode* subAttrP = attrP->value.firstChildP; subAttrP != NULL; subAttrP = subAttrP->next) - { - // - // Skip createdAt and modifiedAt, if present - // - // FIXME: Already expanded ... not so good - depends on the context - // However, this solution works for all uses, if I also compare and remove non-expanded. - // Let's do it this way for now, but fix it some day! - // The fix would be that the service routines removes createdAt and modifiedAt before expanding and before calling the TRoE functions - // - if ((strcmp(subAttrP->name, "https://uri.etsi.org/ngsi-ld/createdAt") == 0) || (strcmp(subAttrP->name, "https://uri.etsi.org/ngsi-ld/modifiedAt") == 0)) - {} - else if ((strcmp(subAttrP->name, "createdAt") == 0) || (strcmp(subAttrP->name, "modifiedAt") == 0)) - {} - else if (pgSubAttributeTreat(connectionP, subAttrP, entityId, instanceId, datasetId) == false) - { - LM_E(("Internal Error (pgSubAttributeTreat failed)")); - return false; - } - } - - return true; -} diff --git a/src/lib/orionld/troe/pgAttributeTreat.h b/src/lib/orionld/troe/pgAttributeTreat.h deleted file mode 100644 index c71fb5dee5..0000000000 --- a/src/lib/orionld/troe/pgAttributeTreat.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGATTRIBUTETREAT_H_ -#define SRC_LIB_ORIONLD_TROE_PGATTRIBUTETREAT_H_ - -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -extern "C" -{ -#include "kjson/KjNode.h" // KjNode -} - -#include "orionld/troe/troe.h" // TroeMode - - - -// ----------------------------------------------------------------------------- -// -// pgAttributeTreat - treat an attribute for db insertion -// -extern bool pgAttributeTreat -( - PGconn* connectionP, - KjNode* attrP, - const char* entityId, - TroeMode opMode -); - -#endif // SRC_LIB_ORIONLD_TROE_PGATTRIBUTETREAT_H_ diff --git a/src/lib/orionld/troe/pgBoolPropertyPush.cpp b/src/lib/orionld/troe/pgBoolPropertyPush.cpp deleted file mode 100644 index 6230a69f1d..0000000000 --- a/src/lib/orionld/troe/pgBoolPropertyPush.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // snprintf -#include // PGconn - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/common/orionldState.h" // orionldState -#include "orionld/troe/pgStringPropertyPush.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgBoolPropertyPush - push a String Property to its DB table -// -bool pgBoolPropertyPush -( - PGconn* connectionP, - const char* opMode, - bool value, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties -) -{ - char sql[1024]; - PGresult* res; - const char* subPropertiesString = (subProperties == false)? "false" : "true"; - const char* boolValueAsString = (value == true)? "true" : "false"; - - if (observedAt != NULL) - { - snprintf(sql, sizeof(sql), "INSERT INTO attributes(" - "opMode, instanceId, id, entityId, ts, observedAt, valueType, subProperties, datasetId, boolean) " - "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', 'Boolean', %s, '%s', %s)", - opMode, attributeInstance, attributeName, entityId, orionldState.requestTimeString, observedAt, subPropertiesString, datasetId, boolValueAsString); - } - else - { - snprintf(sql, sizeof(sql), "INSERT INTO attributes(" - "opMode, instanceId, id, entityId, ts, valueType, subProperties, datasetId, boolean) " - "VALUES ('%s', '%s', '%s', '%s', '%s', 'Boolean', %s, '%s', %s)", - opMode, attributeInstance, attributeName, entityId, orionldState.requestTimeString, subPropertiesString, datasetId, boolValueAsString); - } - - - // LM_TMP(("SQL[%p]: %s;", connectionP, sql)); - res = PQexec(connectionP, sql); - if (res == NULL) - LM_RE(false, ("Database Error (%s)", PQresStatus(PQresultStatus(res)))); - PQclear(res); - - if (PQstatus(connectionP) != CONNECTION_OK) - LM_E(("SQL[%p]: bad connection: %d", connectionP, PQstatus(connectionP))); // FIXME: string! (last error?) - - return true; -} diff --git a/src/lib/orionld/troe/pgBoolPropertyPush.h b/src/lib/orionld/troe/pgBoolPropertyPush.h deleted file mode 100644 index 03a860c9a1..0000000000 --- a/src/lib/orionld/troe/pgBoolPropertyPush.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGBOOLPROPERTYPUSH_H_ -#define SRC_LIB_ORIONLD_TROE_PGBOOLPROPERTYPUSH_H_ - -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - - - -// ----------------------------------------------------------------------------- -// -// pgBoolPropertyPush - push a bool property to its DB table -// -extern bool pgBoolPropertyPush -( - PGconn* connectionP, - const char* opMode, - bool value, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties -); - -#endif // SRC_LIB_ORIONLD_TROE_PGBOOLPROPERTYPUSH_H_ diff --git a/src/lib/orionld/troe/pgBoolSubPropertyPush.cpp b/src/lib/orionld/troe/pgBoolSubPropertyPush.cpp deleted file mode 100644 index 2e84cc3257..0000000000 --- a/src/lib/orionld/troe/pgBoolSubPropertyPush.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // snprintf -#include // PGconn - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/common/orionldState.h" // orionldState -#include "orionld/troe/pgBoolSubPropertyPush.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgBoolSubPropertyPush - push a Boolean Sub-Property to its DB table -// -bool pgBoolSubPropertyPush -( - PGconn* connectionP, - const char* subAttributeName, - const char* instanceId, - bool boolValue, - const char* entityId, - const char* attrInstanceId, - const char* attrDatasetId, - const char* observedAt -) -{ - char sql[1024]; - - // - // Two combinations for NULL/non-NULL 'observedAt' (sub-attributes have no datasetId) - // - if (observedAt != NULL) - { - snprintf(sql, sizeof(sql), "INSERT INTO subAttributes(" - "instanceId, id, entityId, attrInstanceId, attrDatasetId, ts, observedAt, valueType, boolean) " - "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', 'Boolean', %s)", - instanceId, subAttributeName, entityId, attrInstanceId, attrDatasetId, orionldState.requestTimeString, observedAt, (boolValue == true)? "true" : "false"); - } - else - { - snprintf(sql, sizeof(sql), "INSERT INTO subAttributes(" - "instanceId, id, entityId, attrInstanceId, attrDatasetId, ts, valueType, boolean) " - "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', 'Boolean', %s)", - instanceId, subAttributeName, entityId, attrInstanceId, attrDatasetId, orionldState.requestTimeString, (boolValue == true)? "true" : "false"); - } - // LM_TMP(("SQL[%p]: %s;", connectionP, sql)); - - - PGresult* res; - res = PQexec(connectionP, sql); - if (res == NULL) - LM_RE(false, ("Database Error (%s)", PQresStatus(PQresultStatus(res)))); - PQclear(res); - - if (PQstatus(connectionP) != CONNECTION_OK) - LM_E(("SQL[%p]: bad connection: %d", connectionP, PQstatus(connectionP))); // FIXME: string! (last error?) - - return true; -} diff --git a/src/lib/orionld/troe/pgBoolSubPropertyPush.h b/src/lib/orionld/troe/pgBoolSubPropertyPush.h deleted file mode 100644 index 8603a69187..0000000000 --- a/src/lib/orionld/troe/pgBoolSubPropertyPush.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGBOOLSUBPROPERTYPUSH_H_ -#define SRC_LIB_ORIONLD_TROE_PGBOOLSUBPROPERTYPUSH_H_ - -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - - - -// ----------------------------------------------------------------------------- -// -// pgBoolPropertyPush - push a Boolean Sub-Property to its DB table -// -extern bool pgBoolSubPropertyPush -( - PGconn* connectionP, - const char* subAttributeName, - const char* instanceId, - bool boolValue, - const char* entityId, - const char* attrInstanceId, - const char* attrDatasetId, - const char* observedAt -); - -#endif // SRC_LIB_ORIONLD_TROE_PGBOOLSUBPROPERTYPUSH_H_ diff --git a/src/lib/orionld/troe/pgCompoundPropertyPush.cpp b/src/lib/orionld/troe/pgCompoundPropertyPush.cpp deleted file mode 100644 index b995318ba9..0000000000 --- a/src/lib/orionld/troe/pgCompoundPropertyPush.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -extern "C" -{ -#include "kjson/KjNode.h" // KjNode -#include "kjson/kjRender.h" // kjFastRender -} - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/common/orionldState.h" // orionldState -#include "orionld/troe/pgCompoundPropertyPush.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgCompoundPropertyPush - push a Compound Property to its DB table -// -// If the value is Compound - the need for unitCode seems ... ZERO - so, not supporting it ! -// -bool pgCompoundPropertyPush -( - PGconn* connectionP, - const char* opMode, - KjNode* compoundValueNodeP, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties -) -{ - int renderedValueSize = 4 * 1024; - char* renderedValue = kaAlloc(&orionldState.kalloc, renderedValueSize); - int sqlSize = 5 * 1024; - char* sql = kaAlloc(&orionldState.kalloc, sqlSize); // FIXME - one single call to kaAlloc, por favor !!! - const char* subPropertiesString = (subProperties == false)? "false" : "true"; - PGresult* res; - - if ((renderedValue == NULL) || (sql == NULL)) - LM_RE(false, ("Internal Error (unable to allocate room for compound value")); - - kjFastRender(orionldState.kjsonP, compoundValueNodeP, renderedValue, renderedValueSize); - - if (observedAt != NULL) - { - snprintf(sql, sqlSize, "INSERT INTO attributes(" - "opMode, instanceId, id, entityId, ts, observedAt, valueType, subProperties, datasetId, compound) " - "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', 'Compound', %s, '%s', '%s')", - opMode, attributeInstance, attributeName, entityId, orionldState.requestTimeString, observedAt, subPropertiesString, datasetId, renderedValue); - } - else - { - snprintf(sql, sqlSize, "INSERT INTO attributes(" - "opMode, instanceId, id, entityId, ts, valueType, subProperties, datasetId, compound) " - "VALUES ('%s', '%s', '%s', '%s', '%s', 'Compound', %s, '%s', '%s')", - opMode, attributeInstance, attributeName, entityId, orionldState.requestTimeString, subPropertiesString, datasetId, renderedValue); - } - - // LM_TMP(("SQL[%p]: %s;", connectionP, sql)); - - res = PQexec(connectionP, sql); - if (res == NULL) - LM_RE(false, ("Database Error (%s)", PQresStatus(PQresultStatus(res)))); - PQclear(res); - - if (PQstatus(connectionP) != CONNECTION_OK) - LM_E(("SQL[%p]: bad connection: %d", connectionP, PQstatus(connectionP))); // FIXME: string! (last error?) - - return true; -} diff --git a/src/lib/orionld/troe/pgCompoundPropertyPush.h b/src/lib/orionld/troe/pgCompoundPropertyPush.h deleted file mode 100644 index f93ce8b752..0000000000 --- a/src/lib/orionld/troe/pgCompoundPropertyPush.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGCOMPOUNDPROPERTYPUSH_H_ -#define SRC_LIB_ORIONLD_TROE_PGCOMPOUNDPROPERTYPUSH_H_ - -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -extern "C" -{ -#include "kjson/KjNode.h" // KjNode -} - - - -// ----------------------------------------------------------------------------- -// -// pgCompoundPropertyPush - push a Compound Property to its DB table -// -extern bool pgCompoundPropertyPush -( - PGconn* connectionP, - const char* opMode, - KjNode* compoundValueNodeP, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties -); - -#endif // SRC_LIB_ORIONLD_TROE_PGCOMPOUNDPROPERTYPUSH_H_ diff --git a/src/lib/orionld/troe/pgCompoundSubPropertyPush.cpp b/src/lib/orionld/troe/pgCompoundSubPropertyPush.cpp deleted file mode 100644 index 2983413cb8..0000000000 --- a/src/lib/orionld/troe/pgCompoundSubPropertyPush.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -extern "C" -{ -#include "kjson/KjNode.h" // KjNode -#include "kjson/kjRender.h" // kjFastRender -} - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/common/orionldState.h" // orionldState -#include "orionld/troe/pgCompoundSubPropertyPush.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgCompoundPropertyPush - push a Compound Sub-Property to its DB table -// -bool pgCompoundSubPropertyPush -( - PGconn* connectionP, - const char* subAttributeName, - const char* instanceId, - KjNode* compoundValueNodeP, - const char* entityId, - const char* attrInstanceId, - const char* attrDatasetId, - const char* observedAt -) -{ - int renderedValueSize = 4 * 1024; - char* renderedValue = kaAlloc(&orionldState.kalloc, renderedValueSize); - int sqlSize = 5 * 1024; - char* sql = kaAlloc(&orionldState.kalloc, sqlSize); // FIXME - one single call to kaAlloc, por favor !!! - PGresult* res; - - if ((renderedValue == NULL) || (sql == NULL)) - LM_RE(false, ("Internal Error (unable to allocate room for compound value of sub-attribute")); - - kjFastRender(orionldState.kjsonP, compoundValueNodeP, renderedValue, renderedValueSize); - - // - // Two combinations for NULL/non-NULL 'observedAt' - // - if (observedAt != NULL) - { - snprintf(sql, sqlSize, "INSERT INTO subAttributes(" - "instanceId, id, entityId, attrInstanceId, attrDatasetId, ts, observedAt, valueType, compound) " - "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', 'Compound', '%s')", - instanceId, subAttributeName, entityId, attrInstanceId, attrDatasetId, orionldState.requestTimeString, observedAt, renderedValue); - } - else - { - snprintf(sql, sqlSize, "INSERT INTO subAttributes(" - "instanceId, id, entityId, attrInstanceId, attrDatasetId, ts, valueType, compound) " - "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', 'Compound', '%s')", - instanceId, subAttributeName, entityId, attrInstanceId, attrDatasetId, orionldState.requestTimeString, renderedValue); - } - - // LM_TMP(("SQL[%p]: %s;", connectionP, sql)); - - res = PQexec(connectionP, sql); - if (res == NULL) - LM_RE(false, ("Database Error (%s)", PQresStatus(PQresultStatus(res)))); - PQclear(res); - - if (PQstatus(connectionP) != CONNECTION_OK) - LM_E(("SQL[%p]: bad connection: %d", connectionP, PQstatus(connectionP))); // FIXME: string! (last error?) - - return true; -} diff --git a/src/lib/orionld/troe/pgCompoundSubPropertyPush.h b/src/lib/orionld/troe/pgCompoundSubPropertyPush.h deleted file mode 100644 index e50e46bc01..0000000000 --- a/src/lib/orionld/troe/pgCompoundSubPropertyPush.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGCOMPOUNDSUBPROPERTYPUSH_H_ -#define SRC_LIB_ORIONLD_TROE_PGCOMPOUNDSUBPROPERTYPUSH_H_ - -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -extern "C" -{ -#include "kjson/KjNode.h" // KjNode -} - - - -// ----------------------------------------------------------------------------- -// -// pgCompoundPropertyPush - push a Compoundean Sub-Property to its DB table -// -extern bool pgCompoundSubPropertyPush -( - PGconn* connectionP, - const char* subAttributeName, - const char* instanceId, - KjNode* compoundValueNodeP, - const char* entityId, - const char* attrInstanceId, - const char* attrDatasetId, - const char* observedAt -); - -#endif // SRC_LIB_ORIONLD_TROE_PGCOMPOUNDSUBPROPERTYPUSH_H_ diff --git a/src/lib/orionld/troe/pgEntityDelete.cpp b/src/lib/orionld/troe/pgEntityDelete.cpp deleted file mode 100644 index 269feb8d7c..0000000000 --- a/src/lib/orionld/troe/pgEntityDelete.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/common/orionldState.h" // orionldState -#include "orionld/troe/pgEntityDelete.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgEntityDelete - mark an entity as deleted in the database -// -bool pgEntityDelete(PGconn* connectionP, char* instanceId, char* id) -{ - char sql[512]; - PGresult* res; - - snprintf(sql, sizeof(sql), "INSERT INTO entities VALUES ('%s', '%s', 'Delete', '%s', 'NULL')", instanceId, orionldState.requestTimeString, id); - // LM_TMP(("SQL[%p]: %s", connectionP, sql)); - res = PQexec(connectionP, sql); - if (res == NULL) - LM_RE(false, ("Database Error (%s)", PQresStatus(PQresultStatus(res)))); - PQclear(res); - - return true; -} diff --git a/src/lib/orionld/troe/pgEntityDelete.h b/src/lib/orionld/troe/pgEntityDelete.h deleted file mode 100644 index 93b8fe45c4..0000000000 --- a/src/lib/orionld/troe/pgEntityDelete.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGENTITYDELETE_H_ -#define SRC_LIB_ORIONLD_TROE_PGENTITYDELETE_H_ - -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - - - -// ----------------------------------------------------------------------------- -// -// pgEntityDelete - mark an entity as deleted in the database -// -extern bool pgEntityDelete(PGconn* connectionP, char* instanceId, char* id); - -#endif // SRC_LIB_ORIONLD_TROE_PGENTITYDELETE_H_ diff --git a/src/lib/orionld/troe/pgEntityPush.cpp b/src/lib/orionld/troe/pgEntityPush.cpp deleted file mode 100644 index 283a4e131a..0000000000 --- a/src/lib/orionld/troe/pgEntityPush.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/common/orionldState.h" // orionldState -#include "orionld/troe/pgEntityPush.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgEntityPush - push an entity to the database -// -bool pgEntityPush(PGconn* connectionP, char* instanceId, char* id, char* type, const char* opMode) -{ - char sql[512]; - PGresult* res; - - snprintf(sql, sizeof(sql), "INSERT INTO entities VALUES ('%s', '%s', '%s', '%s', '%s')", instanceId, orionldState.requestTimeString, opMode, id, type); - // LM_TMP(("SQL[%p]: %s;", connectionP, sql)); - res = PQexec(connectionP, sql); - if (res == NULL) - LM_RE(false, ("Database Error (%s)", PQresStatus(PQresultStatus(res)))); - PQclear(res); - - return true; -} diff --git a/src/lib/orionld/troe/pgEntityPush.h b/src/lib/orionld/troe/pgEntityPush.h deleted file mode 100644 index f94a55bec8..0000000000 --- a/src/lib/orionld/troe/pgEntityPush.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGENTITYPUSH_H_ -#define SRC_LIB_ORIONLD_TROE_PGENTITYPUSH_H_ - -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - - - -// ----------------------------------------------------------------------------- -// -// pgEntityPush - push an entity to the database -// -extern bool pgEntityPush(PGconn* connectionP, char* instanceId, char* id, char* type, const char* opMode); - -#endif // SRC_LIB_ORIONLD_TROE_PGENTITYPUSH_H_ diff --git a/src/lib/orionld/troe/pgEntityTreat.cpp b/src/lib/orionld/troe/pgEntityTreat.cpp deleted file mode 100644 index 1e3372c3dc..0000000000 --- a/src/lib/orionld/troe/pgEntityTreat.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -extern "C" -{ -#include "kjson/KjNode.h" // KjNode -#include "kjson/kjLookup.h" // kjLookup -#include "kjson/kjBuilder.h" // kjChildRemove -#include "kjson/kjRender.h" // kjRender -} - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/common/orionldState.h" // orionldState -#include "orionld/common/uuidGenerate.h" // uuidGenerate - -#include "orionld/troe/troe.h" // TroeMode -#include "orionld/troe/pgEntityPush.h" // pgEntityPush -#include "orionld/troe/pgAttributeTreat.h" // pgAttributeTreat -#include "orionld/troe/pgEntityTreat.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgEntityTreat - -// -bool pgEntityTreat(PGconn* connectionP, KjNode* entityP, char* id, char* type, TroeMode entityOpMode, TroeMode attributeOpMode) -{ - if (id == NULL) // Find the entity id in the entity tree - { - KjNode* nodeP = kjLookup(entityP, "id"); - - if (nodeP == NULL) - LM_X(1, ("Entity without id")); - - id = nodeP->value.s; - kjChildRemove(entityP, nodeP); - } - - - if (type == NULL) // Find the entity type in the entity tree - { - KjNode* nodeP = kjLookup(entityP, "type"); - - if (nodeP == NULL) - LM_X(1, ("Entity without type")); - - type = nodeP->value.s; - kjChildRemove(entityP, nodeP); - } - - if ((entityOpMode == TROE_ENTITY_CREATE) || (entityOpMode == TROE_ENTITY_REPLACE)) - { - const char* opModeString = (entityOpMode == TROE_ENTITY_CREATE)? "Create" : "Replace"; - char entityInstance[80]; - - uuidGenerate(entityInstance, sizeof(entityInstance), true); - - if (pgEntityPush(connectionP, entityInstance, id, type, opModeString) == false) - LM_RE(false, ("pgEntityPush failed")); - } - - for (KjNode* attrP = entityP->value.firstChildP; attrP != NULL; attrP = attrP->next) - { - if (attrP->type == KjObject) - { - if (pgAttributeTreat(connectionP, attrP, id, attributeOpMode) == false) - LM_RE(false, ("pgAttributeTreat failed for attribute '%s'", attrP->name)); - } - else if (attrP->type == KjArray) - { - for (KjNode* attrInstanceP = attrP->value.firstChildP; attrInstanceP != NULL; attrInstanceP = attrInstanceP->next) - { - attrInstanceP->name = attrP->name; // For array items, the name is NULL - the attr name must be taken from the array itself - - if (pgAttributeTreat(connectionP, attrInstanceP, id, attributeOpMode) == false) - LM_RE(false, ("pgAttributeTreat(datasets) failed for attribute '%s'", attrP->name)); - } - } - else - { - if ((strcmp(attrP->name, "id") == 0) || - (strcmp(attrP->name, "@id") == 0) || - (strcmp(attrP->name, "type") == 0) || - (strcmp(attrP->name, "@type") == 0) || - (strcmp(attrP->name, "createdAt") == 0) || - (strcmp(attrP->name, "modifiedAt") == 0)) - { - // If present, all these "attributes" are ignored - } - else - LM_E(("Internal Error (The attribute '%s' is neither an Object nor an Array)", attrP->name)); - } - } - - return true; -} diff --git a/src/lib/orionld/troe/pgEntityTreat.h b/src/lib/orionld/troe/pgEntityTreat.h deleted file mode 100644 index a066bfde28..0000000000 --- a/src/lib/orionld/troe/pgEntityTreat.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGENTITYTREAT_H_ -#define SRC_LIB_ORIONLD_TROE_PGENTITYTREAT_H_ - -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -extern "C" -{ -#include "kjson/KjNode.h" // KjNode -} - -#include "orionld/troe/troe.h" // TroeMode - - - -// ----------------------------------------------------------------------------- -// -// pgEntityTreat - -// -extern bool pgEntityTreat(PGconn* connectionP, KjNode* entityP, char* id, char* type, TroeMode mode, TroeMode attributeOpMode); - -#endif // SRC_LIB_ORIONLD_TROE_PGENTITYTREAT_H_ diff --git a/src/lib/orionld/troe/pgGeoLineStringPush.cpp b/src/lib/orionld/troe/pgGeoLineStringPush.cpp deleted file mode 100644 index 401ea8cd40..0000000000 --- a/src/lib/orionld/troe/pgGeoLineStringPush.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* -* -* Copyright 2021 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // snprintf -#include // PGconn - -extern "C" -{ -#include "kalloc/kaAlloc.h" // kaAlloc -#include "kjson/KjNode.h" // KjNode -#include "kjson/kjRender.h" // kjRender - TMP -} - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/common/orionldState.h" // orionldState -#include "orionld/troe/kjGeoLineStringExtract.h" // kjGeoLineStringExtract -#include "orionld/troe/pgGeoLineStringPush.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgGeoLineStringPush - push a Geo-LineString property to its DB table -// -bool pgGeoLineStringPush -( - PGconn* connectionP, - const char* opMode, - KjNode* coordinatesP, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties -) -{ - char* lineStringCoordsString = kaAlloc(&orionldState.kalloc, 10240); - - if (lineStringCoordsString == NULL) - LM_RE(false, ("Internal Error (out of memory)")); - - if (kjGeoLineStringExtract(coordinatesP, lineStringCoordsString, 10240) == false) - LM_RE(false, ("unable to extract geo-coordinates from Kj-Tree")); - - char* sql = kaAlloc(&orionldState.kalloc, 12008); - PGresult* res; - const char* subPropertiesString = (subProperties == false)? "false" : "true"; - - if (sql == NULL) - LM_RE(false, ("Internal Error (out of memory)")); - - if (observedAt != NULL) - { - snprintf(sql, 12007, "INSERT INTO attributes(" - "opMode, ts, instanceId, id, entityId, observedAt, valueType, subProperties, datasetId, geoLineString) " - "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', 'GeoLineString', %s, '%s', ST_GeomFromText('LINESTRING(%s)', 4326))", - opMode, orionldState.requestTimeString, attributeInstance, attributeName, entityId, observedAt, subPropertiesString, datasetId, lineStringCoordsString); - } - else - { - snprintf(sql, 12007, "INSERT INTO attributes(" - "opMode, ts, instanceId, id, entityId, valueType, subProperties, datasetId, geoLineString) " - "VALUES ('%s', '%s', '%s', '%s', '%s', 'GeoLineString', %s, '%s', ST_GeomFromText('LINESTRING(%s)', 4326))", - opMode, orionldState.requestTimeString, attributeInstance, attributeName, entityId, subPropertiesString, datasetId, lineStringCoordsString); - } - - // LM_TMP(("SQL[%p]: %s;", connectionP, sql)); - res = PQexec(connectionP, sql); - if (res == NULL) - LM_RE(false, ("Database Error (%s)", PQresStatus(PQresultStatus(res)))); - PQclear(res); - - if (PQstatus(connectionP) != CONNECTION_OK) - LM_E(("SQL[%p]: bad connection: %d", connectionP, PQstatus(connectionP))); // FIXME: string! (last error?) - - return true; -} diff --git a/src/lib/orionld/troe/pgGeoLineStringPush.h b/src/lib/orionld/troe/pgGeoLineStringPush.h deleted file mode 100644 index abc0c50a40..0000000000 --- a/src/lib/orionld/troe/pgGeoLineStringPush.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGGEOLINESTRINGPUSH_H_ -#define SRC_LIB_ORIONLD_TROE_PGGEOLINESTRINGPUSH_H_ - -/* -* -* Copyright 2021 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -extern "C" -{ -#include "kjson/KjNode.h" // KjNode -} - - - -// ----------------------------------------------------------------------------- -// -// pgGeoLineStringPush - push a Geo-LineString property to its DB table -// -extern bool pgGeoLineStringPush -( - PGconn* connectionP, - const char* opMode, - KjNode* coordinatesP, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties -); - -#endif // SRC_LIB_ORIONLD_TROE_PGGEOLINESTRINGPUSH_H_ diff --git a/src/lib/orionld/troe/pgGeoMultiLineStringPush.cpp b/src/lib/orionld/troe/pgGeoMultiLineStringPush.cpp deleted file mode 100644 index b0f30f4c76..0000000000 --- a/src/lib/orionld/troe/pgGeoMultiLineStringPush.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* -* -* Copyright 2021 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // snprintf -#include // PGconn - -extern "C" -{ -#include "kalloc/kaAlloc.h" // kaAlloc -#include "kjson/KjNode.h" // KjNode -#include "kjson/kjRender.h" // kjRender - TMP -} - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/common/orionldState.h" // orionldState -#include "orionld/troe/kjGeoMultiLineStringExtract.h" // kjGeoMultiLineStringExtract -#include "orionld/troe/pgGeoLineStringPush.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgGeoMultiLineStringPush - push a Geo-MultiLineString property to its DB table -// -bool pgGeoMultiLineStringPush -( - PGconn* connectionP, - const char* opMode, - KjNode* coordinatesP, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties -) -{ - char* coordsString = kaAlloc(&orionldState.kalloc, 10240); - - if (coordsString == NULL) - LM_RE(false, ("Internal Error (out of memory)")); - - if (kjGeoMultiLineStringExtract(coordinatesP, coordsString, 10240) == false) - LM_RE(false, ("unable to extract geo-coordinates from Kj-Tree")); - - char* sql = kaAlloc(&orionldState.kalloc, 12008); - PGresult* res; - const char* subPropertiesString = (subProperties == false)? "false" : "true"; - - if (sql == NULL) - LM_RE(false, ("Internal Error (out of memory)")); - - if (observedAt != NULL) - { - snprintf(sql, 12007, "INSERT INTO attributes(" - "opMode, ts, instanceId, id, entityId, createdAt, modifiedAt, observedAt, valueType, subProperties, datasetId, geoMultiLineString) " - "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', 'GeoMultiLineString', %s, '%s', ST_GeomFromText('MULTILINESTRING(%s)', 4326))", - opMode, orionldState.requestTimeString, attributeInstance, attributeName, entityId, observedAt, subPropertiesString, datasetId, coordsString); - } - else - { - snprintf(sql, 12007, "INSERT INTO attributes(" - "opMode, ts, instanceId, id, entityId, valueType, subProperties, datasetId, geoMultiLineString) " - "VALUES ('%s', '%s', '%s', '%s', '%s', 'GeoMultiLineString', %s, '%s', ST_GeomFromText('MULTILINESTRING(%s)', 4326))", - opMode, orionldState.requestTimeString, attributeInstance, attributeName, entityId, subPropertiesString, datasetId, coordsString); - } - - // LM_TMP(("SQL[%p]: %s;", connectionP, sql)); - res = PQexec(connectionP, sql); - if (res == NULL) - LM_RE(false, ("Database Error (%s)", PQresStatus(PQresultStatus(res)))); - PQclear(res); - - if (PQstatus(connectionP) != CONNECTION_OK) - LM_E(("SQL[%p]: bad connection: %d", connectionP, PQstatus(connectionP))); // FIXME: string! (last error?) - - return true; -} diff --git a/src/lib/orionld/troe/pgGeoMultiLineStringPush.h b/src/lib/orionld/troe/pgGeoMultiLineStringPush.h deleted file mode 100644 index da03b3a70f..0000000000 --- a/src/lib/orionld/troe/pgGeoMultiLineStringPush.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGGEOMULTILINESTRINGPUSH_H_ -#define SRC_LIB_ORIONLD_TROE_PGGEOMULTILINESTRINGPUSH_H_ - -/* -* -* Copyright 2021 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -extern "C" -{ -#include "kjson/KjNode.h" // KjNode -} - - - -// ----------------------------------------------------------------------------- -// -// pgGeoMultiLineStringPush - push a Geo-LineString property to its DB table -// -extern bool pgGeoMultiLineStringPush -( - PGconn* connectionP, - const char* opMode, - KjNode* coordinatesP, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties -); - -#endif // SRC_LIB_ORIONLD_TROE_PGGEOMULTILINESTRINGPUSH_H_ diff --git a/src/lib/orionld/troe/pgGeoMultiPolygonPush.cpp b/src/lib/orionld/troe/pgGeoMultiPolygonPush.cpp deleted file mode 100644 index 2989b82ea3..0000000000 --- a/src/lib/orionld/troe/pgGeoMultiPolygonPush.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* -* -* Copyright 2021 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -extern "C" -{ -#include "kalloc/kaAlloc.h" // kaAlloc -#include "kjson/KjNode.h" // KjNode -} - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/common/orionldState.h" // orionldState -#include "orionld/troe/kjGeoMultiPolygonExtract.h" // kjGeoMultiPolygonExtract -#include "orionld/troe/pgGeoMultiPolygonPush.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgGeoMultiPolygonPush - push a Geo-MultiPolygon property to its DB table -// -bool pgGeoMultiPolygonPush -( - PGconn* connectionP, - const char* opMode, - KjNode* coordinatesP, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties -) -{ - char* coordsString = kaAlloc(&orionldState.kalloc, 8 * 1024); - - if (coordsString == NULL) - LM_RE(false, ("Internal Error (out of memory)")); - - if (kjGeoMultiPolygonExtract(coordinatesP, coordsString, 8 * 1024) == false) - LM_RE(false, ("unable to extract geo-coordinates from Kj-Tree")); - - int sqlSize = 10 * 1024; - char* sql = kaAlloc(&orionldState.kalloc, sqlSize + 1); - PGresult* res; - const char* subPropertiesString = (subProperties == false)? "false" : "true"; - - if (sql == NULL) - LM_RE(false, ("Internal Error (out of memory)")); - - if (observedAt != NULL) - { - snprintf(sql, sqlSize, "INSERT INTO attributes(" - "opMode, ts, instanceId, id, entityId, observedAt, valueType, subProperties, datasetId, geoMultiPolygon) " - "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', 'GeoMultiPolygon', %s, '%s', ST_GeomFromText('MULTIPOLYGON(%s)', 4326))", - opMode, orionldState.requestTimeString, attributeInstance, attributeName, entityId, observedAt, subPropertiesString, datasetId, coordsString); - } - else - { - snprintf(sql, sqlSize, "INSERT INTO attributes(" - "opMode, ts, instanceId, id, entityId, valueType, subProperties, datasetId, geoMultiPolygon) " - "VALUES ('%s', '%s', '%s', '%s', '%s', 'GeoMultiPolygon', %s, '%s', ST_GeomFromText('MULTIPOLYGON(%s)', 4326))", - opMode, orionldState.requestTimeString, attributeInstance, attributeName, entityId, subPropertiesString, datasetId, coordsString); - } - - - // LM_TMP(("SQL[%p]: %s;", connectionP, sql)); - res = PQexec(connectionP, sql); - if (res == NULL) - LM_RE(false, ("Database Error (%s)", PQresStatus(PQresultStatus(res)))); - PQclear(res); - - if (PQstatus(connectionP) != CONNECTION_OK) - LM_E(("SQL[%p]: bad connection: %d", connectionP, PQstatus(connectionP))); // FIXME: string! (last error?) - - return true; -} diff --git a/src/lib/orionld/troe/pgGeoMultiPolygonPush.h b/src/lib/orionld/troe/pgGeoMultiPolygonPush.h deleted file mode 100644 index 2dd2d61dd6..0000000000 --- a/src/lib/orionld/troe/pgGeoMultiPolygonPush.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGGEOMULTIPOLYGONPUSH_H_ -#define SRC_LIB_ORIONLD_TROE_PGGEOMULTIPOLYGONPUSH_H_ - -/* -* -* Copyright 2021 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -extern "C" -{ -#include "kjson/KjNode.h" // KjNode -} - - - -// ----------------------------------------------------------------------------- -// -// pgGeoMultiPolygonPush - push a Geo-MultiPolygon property to its DB table -// -extern bool pgGeoMultiPolygonPush -( - PGconn* connectionP, - const char* opMode, - KjNode* coordinatesP, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties -); - -#endif // SRC_LIB_ORIONLD_TROE_PGGEOMULTIPOLYGONPUSH_H_ diff --git a/src/lib/orionld/troe/pgGeoPointPush.cpp b/src/lib/orionld/troe/pgGeoPointPush.cpp deleted file mode 100644 index fef79baa5a..0000000000 --- a/src/lib/orionld/troe/pgGeoPointPush.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* -* -* Copyright 2021 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // snprintf -#include // PGconn - -extern "C" -{ -#include "kjson/KjNode.h" // KjNode -} - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/common/orionldState.h" // orionldState -#include "orionld/troe/kjGeoPointExtract.h" // kjGeoPointExtract -#include "orionld/troe/pgGeoPointPush.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgGeoPointPush - push a Geo-Point property to its DB table -// -bool pgGeoPointPush -( - PGconn* connectionP, - const char* opMode, - KjNode* coordinatesP, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties -) -{ - double longitude; - double latitude; - double altitude; - - if (kjGeoPointExtract(coordinatesP, &longitude, &latitude, &altitude) == false) - LM_RE(false, ("unable to extract geo-coordinates from Kj-Tree")); - - char sql[1024]; - PGresult* res; - const char* subPropertiesString = (subProperties == false)? "false" : "true"; - - if (observedAt != NULL) - { - snprintf(sql, sizeof(sql), "INSERT INTO attributes(" - "opMode, ts, instanceId, id, entityId, observedAt, valueType, subProperties, datasetId, geoPoint) " - "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', 'GeoPoint', %s, '%s', ST_GeomFromText('POINT Z(%f %f %f)'))", - opMode, orionldState.requestTimeString, attributeInstance, attributeName, entityId, observedAt, subPropertiesString, datasetId, longitude, latitude, altitude); - } - else - { - snprintf(sql, sizeof(sql), "INSERT INTO attributes(" - "opMode, ts, instanceId, id, entityId, valueType, subProperties, datasetId, geoPoint) " - "VALUES ('%s', '%s', '%s', '%s', '%s', 'GeoPoint', %s, '%s', ST_GeomFromText('POINT Z(%f %f %f)'))", - opMode, orionldState.requestTimeString, attributeInstance, attributeName, entityId, subPropertiesString, datasetId, longitude, latitude, altitude); - } - - - // LM_TMP(("SQL[%p]: %s;", connectionP, sql)); - res = PQexec(connectionP, sql); - if (res == NULL) - LM_RE(false, ("Database Error (%s)", PQresStatus(PQresultStatus(res)))); - PQclear(res); - - if (PQstatus(connectionP) != CONNECTION_OK) - LM_E(("SQL[%p]: bad connection: %d", connectionP, PQstatus(connectionP))); // FIXME: string! (last error?) - - return true; -} diff --git a/src/lib/orionld/troe/pgGeoPointPush.h b/src/lib/orionld/troe/pgGeoPointPush.h deleted file mode 100644 index b6de18c4d7..0000000000 --- a/src/lib/orionld/troe/pgGeoPointPush.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGGEOPOINTPUSH_H_ -#define SRC_LIB_ORIONLD_TROE_PGGEOPOINTPUSH_H_ - -/* -* -* Copyright 2021 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -extern "C" -{ -#include "kjson/KjNode.h" // KjNode -} - - - -// ----------------------------------------------------------------------------- -// -// pgGeoPointPush - push a Geo-Point property to its DB table -// -extern bool pgGeoPointPush -( - PGconn* connectionP, - const char* opMode, - KjNode* coordinatesP, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties -); - -#endif // SRC_LIB_ORIONLD_TROE_PGGEOPOINTPUSH_H_ diff --git a/src/lib/orionld/troe/pgGeoPolygonPush.cpp b/src/lib/orionld/troe/pgGeoPolygonPush.cpp deleted file mode 100644 index 13408d8e4e..0000000000 --- a/src/lib/orionld/troe/pgGeoPolygonPush.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* -* -* Copyright 2021 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // snprintf -#include // PGconn - -extern "C" -{ -#include "kalloc/kaAlloc.h" // kaAlloc -#include "kjson/KjNode.h" // KjNode -} - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/common/orionldState.h" // orionldState -#include "orionld/troe/kjGeoPolygonExtract.h" // kjGeoPolygonExtract -#include "orionld/troe/pgGeoPolygonPush.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgGeoPolygonPush - push a Geo-Polygon property to its DB table -// -bool pgGeoPolygonPush -( - PGconn* connectionP, - const char* opMode, - KjNode* coordinatesP, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties -) -{ - char* polygonCoordsString = kaAlloc(&orionldState.kalloc, 10240); - - if (polygonCoordsString == NULL) - LM_RE(false, ("Internal Error (out of memory)")); - - if (kjGeoPolygonExtract(coordinatesP, polygonCoordsString, 10240) == false) - LM_RE(false, ("unable to extract geo-coordinates from Kj-Tree")); - - char* sql = kaAlloc(&orionldState.kalloc, 12008); - PGresult* res; - const char* subPropertiesString = (subProperties == false)? "false" : "true"; - - if (sql == NULL) - LM_RE(false, ("Internal Error (out of memory)")); - - if (observedAt != NULL) - { - snprintf(sql, 12007, "INSERT INTO attributes(" - "opMode, ts, instanceId, id, entityId, observedAt, valueType, subProperties, datasetId, geoPolygon) " - "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', 'GeoPolygon', %s, '%s', ST_GeomFromText('POLYGON(%s)', 4326))", - opMode, orionldState.requestTimeString, attributeInstance, attributeName, entityId, observedAt, subPropertiesString, datasetId, polygonCoordsString); - } - else - { - snprintf(sql, 12007, "INSERT INTO attributes(" - "opMode, ts, instanceId, id, entityId, valueType, subProperties, datasetId, geoPolygon) " - "VALUES ('%s', '%s', '%s', '%s', '%s', 'GeoPolygon', %s, '%s', ST_GeomFromText('POLYGON(%s)', 4326))", - opMode, orionldState.requestTimeString, attributeInstance, attributeName, entityId, subPropertiesString, datasetId, polygonCoordsString); - } - - - // LM_TMP(("SQL[%p]: %s;", connectionP, sql)); - res = PQexec(connectionP, sql); - if (res == NULL) - LM_RE(false, ("Database Error (%s)", PQresStatus(PQresultStatus(res)))); - PQclear(res); - - if (PQstatus(connectionP) != CONNECTION_OK) - LM_E(("SQL[%p]: bad connection: %d", connectionP, PQstatus(connectionP))); // FIXME: string! (last error?) - - return true; -} diff --git a/src/lib/orionld/troe/pgGeoPolygonPush.h b/src/lib/orionld/troe/pgGeoPolygonPush.h deleted file mode 100644 index d0dfd8acd9..0000000000 --- a/src/lib/orionld/troe/pgGeoPolygonPush.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGGEOPOLYGONPUSH_H_ -#define SRC_LIB_ORIONLD_TROE_PGGEOPOLYGONPUSH_H_ - -/* -* -* Copyright 2021 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -extern "C" -{ -#include "kjson/KjNode.h" // KjNode -} - - - -// ----------------------------------------------------------------------------- -// -// pgGeoPolygonPush - push a Geo-Polygon property to its DB table -// -extern bool pgGeoPolygonPush -( - PGconn* connectionP, - const char* opMode, - KjNode* coordinatesP, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties -); - -#endif // SRC_LIB_ORIONLD_TROE_PGGEOPOLYGONPUSH_H_ diff --git a/src/lib/orionld/troe/pgGeoPropertyPush.cpp b/src/lib/orionld/troe/pgGeoPropertyPush.cpp deleted file mode 100644 index 3d813ee6fc..0000000000 --- a/src/lib/orionld/troe/pgGeoPropertyPush.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* -* -* Copyright 2021 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -extern "C" -{ -#include "kjson/KjNode.h" // KjNode -#include "kjson/kjLookup.h" // kjLookup -} - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/troe/pgGeoPointPush.h" // pgGeoPointPush -#include "orionld/troe/pgGeoPolygonPush.h" // pgGeoPolygonPush -#include "orionld/troe/pgGeoMultiPolygonPush.h" // pgGeoMultiPolygonPush -#include "orionld/troe/pgGeoLineStringPush.h" // pgGeoLineStringPush -#include "orionld/troe/pgGeoMultiLineStringPush.h" // pgGeoMultiLineStringPush -#include "orionld/troe/pgGeoPropertyPush.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgGeoPropertyPush - push a GeoProperty to its DB table -// -bool pgGeoPropertyPush -( - PGconn* connectionP, - const char* opMode, - KjNode* valueNodeP, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties -) -{ - KjNode* geoTypeP = kjLookup(valueNodeP, "type"); - KjNode* coordinatesP = kjLookup(valueNodeP, "coordinates"); - bool ok; - - if (geoTypeP == NULL) LM_RE(false, ("Bad Input (geometry type missing)")); - if (coordinatesP == NULL) LM_RE(false, ("Bad Input (coordinates missing)")); - if (geoTypeP->type != KjString) LM_RE(false, ("Bad Input (geometry type must be a string)")); - if (coordinatesP->type != KjArray) LM_RE(false, ("Bad Input (coordinates must be an array)")); - - - if (strcmp(geoTypeP->value.s, "Point") == 0) - ok = pgGeoPointPush(connectionP, opMode, coordinatesP, entityId, attributeName, attributeInstance, datasetId, observedAt, subProperties); - else if (strcmp(geoTypeP->value.s, "Polygon") == 0) - ok = pgGeoPolygonPush(connectionP, opMode, coordinatesP, entityId, attributeName, attributeInstance, datasetId, observedAt, subProperties); - else if (strcmp(geoTypeP->value.s, "MultiPolygon") == 0) - ok = pgGeoMultiPolygonPush(connectionP, opMode, coordinatesP, entityId, attributeName, attributeInstance, datasetId, observedAt, subProperties); - else if (strcmp(geoTypeP->value.s, "LineString") == 0) - ok = pgGeoLineStringPush(connectionP, opMode, coordinatesP, entityId, attributeName, attributeInstance, datasetId, observedAt, subProperties); - else if (strcmp(geoTypeP->value.s, "MultiLineString") == 0) - ok = pgGeoMultiLineStringPush(connectionP, opMode, coordinatesP, entityId, attributeName, attributeInstance, datasetId, observedAt, subProperties); - else - LM_RE(false, ("Bad Input (invalid geometry for GeoProperty: %s)", geoTypeP->value.s)); - - return ok; -} diff --git a/src/lib/orionld/troe/pgGeoPropertyPush.h b/src/lib/orionld/troe/pgGeoPropertyPush.h deleted file mode 100644 index 9300d216dc..0000000000 --- a/src/lib/orionld/troe/pgGeoPropertyPush.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGGEOPROPERTYPUSH_H_ -#define SRC_LIB_ORIONLD_TROE_PGGEOPROPERTYPUSH_H_ - -/* -* -* Copyright 2021 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -extern "C" -{ -#include "kjson/KjNode.h" // KjNode -} - - - -// ----------------------------------------------------------------------------- -// -// pgGeoPropertyPush - push a GeoProperty to its DB table -// -extern bool pgGeoPropertyPush -( - PGconn* connectionP, - const char* opMode, - KjNode* valueNodeP, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties -); - -#endif // SRC_LIB_ORIONLD_TROE_PGGEOPROPERTYPUSH_H_ diff --git a/src/lib/orionld/troe/pgNumberPropertyPush.cpp b/src/lib/orionld/troe/pgNumberPropertyPush.cpp deleted file mode 100644 index 57234274e3..0000000000 --- a/src/lib/orionld/troe/pgNumberPropertyPush.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // snprintf -#include // PGconn - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/common/orionldState.h" // orionldState -#include "orionld/troe/pgNumberPropertyPush.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgNumberPropertyPush - push a Number Property to its DB table -// -bool pgNumberPropertyPush -( - PGconn* connectionP, - const char* opMode, - double numberValue, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties, - const char* unitCode -) -{ - char sql[1024]; - PGresult* res; - const char* subPropertiesString = (subProperties == false)? "false" : "true"; - char unitCodeStringV[128]; - char* unitCodeString; - - if (unitCode == NULL) - unitCodeString = (char*) "NULL"; - else - { - snprintf(unitCodeStringV, sizeof(unitCodeStringV), "'%s'", unitCode); - unitCodeString = unitCodeStringV; - } - - if (observedAt != NULL) - { - snprintf(sql, sizeof(sql), "INSERT INTO attributes(" - "opMode, instanceId, id, entityId, ts, observedAt, valueType, subProperties, datasetId, number, unitCode) " - "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', 'Number', %s, '%s', %f, %s)", - opMode, attributeInstance, attributeName, entityId, orionldState.requestTimeString, observedAt, subPropertiesString, datasetId, numberValue, unitCodeString); - } - else - { - snprintf(sql, sizeof(sql), "INSERT INTO attributes(" - "opMode, instanceId, id, entityId, ts, valueType, subProperties, datasetId, number, unitCode) " - "VALUES ('%s', '%s', '%s', '%s', '%s', 'Number', %s, '%s', %f, %s)", - opMode, attributeInstance, attributeName, entityId, orionldState.requestTimeString, subPropertiesString, datasetId, numberValue, unitCodeString); - } - - - // LM_TMP(("SQL[%p]: %s;", connectionP, sql)); - res = PQexec(connectionP, sql); - if (res == NULL) - LM_RE(false, ("Database Error (%s)", PQresStatus(PQresultStatus(res)))); - PQclear(res); - - if (PQstatus(connectionP) != CONNECTION_OK) - LM_E(("SQL[%p]: bad connection: %d", connectionP, PQstatus(connectionP))); // FIXME: string! (last error?) - - return true; -} diff --git a/src/lib/orionld/troe/pgNumberPropertyPush.h b/src/lib/orionld/troe/pgNumberPropertyPush.h deleted file mode 100644 index ed9f161f21..0000000000 --- a/src/lib/orionld/troe/pgNumberPropertyPush.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGNUMBERPROPERTYPUSH_H_ -#define SRC_LIB_ORIONLD_TROE_PGNUMBERPROPERTYPUSH_H_ - -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - - - -// ----------------------------------------------------------------------------- -// -// pgNumberPropertyPush - push a Number Property to its DB table -// -extern bool pgNumberPropertyPush -( - PGconn* connectionP, - const char* opMode, - double numberValue, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties, - const char* unitCode -); - -#endif // SRC_LIB_ORIONLD_TROE_PGNUMBERPROPERTYPUSH_H_ diff --git a/src/lib/orionld/troe/pgNumberSubPropertyPush.cpp b/src/lib/orionld/troe/pgNumberSubPropertyPush.cpp deleted file mode 100644 index 600056c331..0000000000 --- a/src/lib/orionld/troe/pgNumberSubPropertyPush.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // snprintf -#include // PGconn - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/common/orionldState.h" // orionldState -#include "orionld/troe/pgNumberSubPropertyPush.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgNumberSubPropertyPush - push a Numberean Sub-Property to its DB table -// -bool pgNumberSubPropertyPush -( - PGconn* connectionP, - const char* subAttributeName, - const char* instanceId, - double numberValue, - const char* entityId, - const char* attrInstanceId, - const char* attrDatasetId, - const char* observedAt, - const char* unitCode -) -{ - char sql[1024]; - char unitCodeStringV[128]; - char* unitCodeString; - - if (unitCode == NULL) - unitCodeString = (char*) "NULL"; - else - { - snprintf(unitCodeStringV, sizeof(unitCodeStringV), "'%s'", unitCode); - unitCodeString = unitCodeStringV; - } - - // - // Two combinations for NULL/non-NULL 'observedAt' (sub-attributes have no datasetId) - // - if (observedAt != NULL) - { - snprintf(sql, sizeof(sql), "INSERT INTO subAttributes(" - "instanceId, id, entityId, attrInstanceId, attrDatasetId, ts, observedAt, valueType, number, unitCode) " - "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', 'Number', %f, %s)", - instanceId, subAttributeName, entityId, attrInstanceId, attrDatasetId, orionldState.requestTimeString, observedAt, numberValue, unitCodeString); - } - else - { - snprintf(sql, sizeof(sql), "INSERT INTO subAttributes(" - "instanceId, id, entityId, attrInstanceId, attrDatasetId, attrDatasetId, ts, valueType, number, unitCode) " - "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', 'Number', %f, %s)", - instanceId, subAttributeName, entityId, attrInstanceId, attrDatasetId, orionldState.requestTimeString, numberValue, unitCodeString); - } - // LM_TMP(("SQL[%p]: %s;", connectionP, sql)); - - - PGresult* res; - res = PQexec(connectionP, sql); - if (res == NULL) - LM_RE(false, ("Database Error (%s)", PQresStatus(PQresultStatus(res)))); - PQclear(res); - - if (PQstatus(connectionP) != CONNECTION_OK) - LM_E(("SQL[%p]: bad connection: %d", connectionP, PQstatus(connectionP))); // FIXME: string! (last error?) - - return true; -} diff --git a/src/lib/orionld/troe/pgNumberSubPropertyPush.h b/src/lib/orionld/troe/pgNumberSubPropertyPush.h deleted file mode 100644 index 9eedbe8b84..0000000000 --- a/src/lib/orionld/troe/pgNumberSubPropertyPush.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGNUMBERSUBPROPERTYPUSH_H_ -#define SRC_LIB_ORIONLD_TROE_PGNUMBERSUBPROPERTYPUSH_H_ - -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - - - -// ----------------------------------------------------------------------------- -// -// pgNumberPropertyPush - push a Number Sub-Property to its DB table -// -extern bool pgNumberSubPropertyPush -( - PGconn* connectionP, - const char* subAttributeName, - const char* instanceId, - double numberValue, - const char* entityId, - const char* attrInstanceId, - const char* attrDatasetId, - const char* observedAt, - const char* unitCode -); - -#endif // SRC_LIB_ORIONLD_TROE_PGNUMBERSUBPROPERTYPUSH_H_ diff --git a/src/lib/orionld/troe/pgRelationshipPush.cpp b/src/lib/orionld/troe/pgRelationshipPush.cpp deleted file mode 100644 index 18534e809d..0000000000 --- a/src/lib/orionld/troe/pgRelationshipPush.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // snprintf -#include // PGconn - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/common/orionldState.h" // orionldState -#include "orionld/troe/pgRelationshipPush.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgRelationshipPush - push a relationship to its DB table -// -bool pgRelationshipPush -( - PGconn* connectionP, - const char* opMode, - const char* object, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties -) -{ - char sql[1024]; - PGresult* res; - const char* subPropertiesString = (subProperties == false)? "false" : "true"; - - // - // Four combinations for NULL/non-NULL 'datasetId' and 'observedAt' - // - if ((datasetId != NULL) && (observedAt != NULL)) - { - snprintf(sql, sizeof(sql), "INSERT INTO attributes(" - "opMode, instanceId, id, entityId, ts, observedAt, valueType, subProperties, datasetId, text) " - "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', 'Relationship', %s, '%s', '%s')", - opMode, attributeInstance, attributeName, entityId, orionldState.requestTimeString, observedAt, subPropertiesString, datasetId, object); - } - else if ((datasetId == NULL) && (observedAt == NULL)) - { - snprintf(sql, sizeof(sql), "INSERT INTO attributes(" - "opMode, instanceId, id, entityId, ts, valueType, subProperties, text) " - "VALUES ('%s', '%s', '%s', '%s', '%s', 'Relationship', %s, '%s');", - opMode, attributeInstance, attributeName, entityId, orionldState.requestTimeString, subPropertiesString, object); - } - else if (datasetId != NULL) // observedAt == NULL - { - snprintf(sql, sizeof(sql), "INSERT INTO attributes(" - "opMode, instanceId, id, entityId, ts, valueType, subProperties, datasetId, text) " - "VALUES ('%s', '%s', '%s', '%s', '%s', 'Relationship', %s, '%s', '%s');", - opMode, attributeInstance, attributeName, entityId, orionldState.requestTimeString, subPropertiesString, datasetId, object); - } - else // observedAt != NULL, datasetId == NULL - { - snprintf(sql, sizeof(sql), "INSERT INTO attributes(" - "opMode, instanceId, id, entityId, ts, observedAt, valueType, subProperties, text) " - "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', 'Relationship', %s, '%s');", - opMode, attributeInstance, attributeName, entityId, orionldState.requestTimeString, observedAt, subPropertiesString, object); - } - - - // LM_TMP(("SQL[%p]: %s;", connectionP, sql)); - res = PQexec(connectionP, sql); - if (res == NULL) - LM_RE(false, ("Database Error (%s)", PQresStatus(PQresultStatus(res)))); - PQclear(res); - - if (PQstatus(connectionP) != CONNECTION_OK) - LM_E(("SQL[%p]: bad connection: %d", connectionP, PQstatus(connectionP))); // FIXME: string! (last error?) - - return true; -} diff --git a/src/lib/orionld/troe/pgRelationshipPush.h b/src/lib/orionld/troe/pgRelationshipPush.h deleted file mode 100644 index 00af730bf4..0000000000 --- a/src/lib/orionld/troe/pgRelationshipPush.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGRELATIONSHIPPUSH_H_ -#define SRC_LIB_ORIONLD_TROE_PGRELATIONSHIPPUSH_H_ - -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - - - -// ----------------------------------------------------------------------------- -// -// pgRelationshipPush - push a relationship to its DB table -// -extern bool pgRelationshipPush -( - PGconn* connectionP, - const char* opMode, - const char* object, - const char* entityId, - const char* attributeName, - const char* attributeInstance, - const char* datasetId, - const char* observedAt, - bool subProperties -); - -#endif // SRC_LIB_ORIONLD_TROE_PGRELATIONSHIPPUSH_H_ diff --git a/src/lib/orionld/troe/pgStringSubPropertyPush.cpp b/src/lib/orionld/troe/pgStringSubPropertyPush.cpp deleted file mode 100644 index fdff56ee60..0000000000 --- a/src/lib/orionld/troe/pgStringSubPropertyPush.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // snprintf -#include // PGconn - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/common/orionldState.h" // orionldState -#include "orionld/troe/pgStringSubPropertyPush.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgStringSubPropertyPush - push a String Sub-Attribute to its DB table -// -bool pgStringSubPropertyPush -( - PGconn* connectionP, - const char* instanceId, - const char* stringValue, - const char* entityId, - const char* attrInstanceId, - const char* attrDatasetId, - const char* subAttributeName, - const char* observedAt -) -{ - char sql[2048]; - PGresult* res; - - // - // Two combinations for NULL/non-NULL 'observedAt' - // - if (observedAt != NULL) - { - snprintf(sql, sizeof(sql), "INSERT INTO subAttributes(" - "instanceId, id, entityId, attrInstanceId, attrDatasetId, ts, observedAt, valueType, text) " - "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', 'String', '%s')", - instanceId, subAttributeName, entityId, attrInstanceId, attrDatasetId, orionldState.requestTimeString, observedAt, stringValue); - } - else - { - snprintf(sql, sizeof(sql), "INSERT INTO subAttributes(" - "instanceId, id, entityId, attrInstanceId, attrDatasetId, ts, valueType, text) " - "VALUES ('%s', '%s', '%s', '%s', '%s', '%s', 'String', '%s')", - instanceId, subAttributeName, entityId, attrInstanceId, attrDatasetId, orionldState.requestTimeString, stringValue); - } - - // LM_TMP(("SQL[%p]: %s;", connectionP, sql)); - res = PQexec(connectionP, sql); - if (res == NULL) - LM_RE(false, ("Database Error (%s)", PQresStatus(PQresultStatus(res)))); - PQclear(res); - - if (PQstatus(connectionP) != CONNECTION_OK) - LM_E(("SQL[%p]: bad connection: %d", connectionP, PQstatus(connectionP))); // FIXME: string! (last error?) - - return true; -} diff --git a/src/lib/orionld/troe/pgStringSubPropertyPush.h b/src/lib/orionld/troe/pgStringSubPropertyPush.h deleted file mode 100644 index f85f2c9d69..0000000000 --- a/src/lib/orionld/troe/pgStringSubPropertyPush.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGSTRINGSUBPROPERTYPUSH_H_ -#define SRC_LIB_ORIONLD_TROE_PGSTRINGSUBPROPERTYPUSH_H_ - -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - - - -// ----------------------------------------------------------------------------- -// -// pgStringSubPropertyPush - push a String Sub-Attribute to its DB table -// -extern bool pgStringSubPropertyPush -( - PGconn* connectionP, - const char* instanceId, - const char* stringValue, - const char* entityId, - const char* attrInstanceId, - const char* attrDatasetId, - const char* subAttributeName, - const char* observedAt -); - -#endif // SRC_LIB_ORIONLD_TROE_PGSTRINGSUBPROPERTYPUSH_H_ diff --git a/src/lib/orionld/troe/pgSubAttributePush.cpp b/src/lib/orionld/troe/pgSubAttributePush.cpp deleted file mode 100644 index dea45370fa..0000000000 --- a/src/lib/orionld/troe/pgSubAttributePush.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -#include "logMsg/logMsg.h" // LM_* -#include "logMsg/traceLevels.h" // Lmt* - -#include "orionld/troe/pgStringSubPropertyPush.h" // pgStringSubPropertyPush -#include "orionld/troe/pgBoolSubPropertyPush.h" // pgBoolSubPropertyPush -#include "orionld/troe/pgCompoundSubPropertyPush.h" // pgCompoundSubPropertyPush -#include "orionld/troe/pgNumberSubPropertyPush.h" // pgNumberSubPropertyPush -#include "orionld/troe/pgSubRelationshipPush.h" // pgSubRelationshipPush -#include "orionld/troe/pgGeoSubPropertyPush.h" // pgGeoSubPropertyPush -#include "orionld/troe/pgSubAttributePush.h" // Own interface - - - -// ----------------------------------------------------------------------------- -// -// pgSubAttributePush - push a sub attribute for db insertion -// -bool pgSubAttributePush -( - PGconn* connectionP, - KjNode* valueNodeP, - const char* instanceId, - const char* subAttributeType, - const char* entityId, - const char* attrInstanceId, - const char* attrDatasetId, - const char* id, - const char* observedAt, - const char* unitCode -) -{ - // - // Property - // - if (strcmp(subAttributeType, "Property") == 0) - { - if (valueNodeP->type == KjString) - { - if (pgStringSubPropertyPush(connectionP, instanceId, valueNodeP->value.s, entityId, attrInstanceId, attrDatasetId, id, observedAt) == false) - LM_RE(false, ("pgStringSubPropertyPush failed")); - } - else if (valueNodeP->type == KjBoolean) - { - if (pgBoolSubPropertyPush(connectionP, id, instanceId, valueNodeP->value.b, entityId, attrInstanceId, attrDatasetId, observedAt) == false) - LM_RE(false, ("pgStringSubPropertyPush failed")); - } - else if ((valueNodeP->type == KjObject) || (valueNodeP->type == KjArray)) - { - if (pgCompoundSubPropertyPush(connectionP, id, instanceId, valueNodeP, entityId, attrInstanceId, attrDatasetId, observedAt) == false) - LM_RE(false, ("pgStringSubPropertyPush failed")); - } - else if (valueNodeP->type == KjInt) - { - if (pgNumberSubPropertyPush(connectionP, id, instanceId, valueNodeP->value.i, entityId, attrInstanceId, attrDatasetId, observedAt, unitCode) == false) - LM_RE(false, ("pgNumberSubPropertyPush[Integer] failed")); - } - else if (valueNodeP->type == KjFloat) - { - if (pgNumberSubPropertyPush(connectionP, id, instanceId, valueNodeP->value.f, entityId, attrInstanceId, attrDatasetId, observedAt, unitCode) == false) - LM_RE(false, ("pgNumberSubPropertyPush[Float] failed")); - } - } - // - // Relationship - // - else if (strcmp(subAttributeType, "Relationship") == 0) - { - if (pgSubRelationshipPush(connectionP, instanceId, valueNodeP->value.s, entityId, attrInstanceId, attrDatasetId, id, observedAt) == false) - LM_RE(false, ("pgRelationshipPush failed")); - } - // - // GeoProperty - // - else if (strcmp(subAttributeType, "GeoProperty") == 0) - { - if (pgGeoSubPropertyPush(connectionP, valueNodeP, instanceId, entityId, attrInstanceId, attrDatasetId, id, observedAt) == false) - LM_RE(false, ("pgGeoPropertyPush failed")); - } - else - { - LM_E(("Unsupported type of sub-attribute to push to DB")); - return false; - } - - return true; -} diff --git a/src/lib/orionld/troe/pgSubAttributePush.h b/src/lib/orionld/troe/pgSubAttributePush.h deleted file mode 100644 index 5713d157fb..0000000000 --- a/src/lib/orionld/troe/pgSubAttributePush.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef SRC_LIB_ORIONLD_TROE_PGSUBATTRIBUTEPUSH_H_ -#define SRC_LIB_ORIONLD_TROE_PGSUBATTRIBUTEPUSH_H_ - -/* -* -* Copyright 2020 FIWARE Foundation e.V. -* -* This file is part of Orion-LD Context Broker. -* -* Orion-LD Context Broker is free software: you can redistribute it and/or -* modify it under the terms of the GNU Affero General Public License as -* published by the Free Software Foundation, either version 3 of the -* License, or (at your option) any later version. -* -* Orion-LD Context Broker is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero -* General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/. -* -* For those usages not covered by this license please contact with -* orionld at fiware dot org -* -* Author: Ken Zangelin -*/ -#include // PGconn - -extern "C" -{ -#include "kjson/KjNode.h" // KjNode -} - - - -// ----------------------------------------------------------------------------- -// -// pgSubAttributePush - push a sub attribute to its DB table -// -extern bool pgSubAttributePush -( - PGconn* connectionP, - KjNode* valueNodeP, - const char* instanceId, - const char* subAttributeType, - const char* entityId, - const char* attrInstanceId, - const char* attrDatasetId, - const char* id, - const char* observedAt, - const char* unitCode -); - -#endif // SRC_LIB_ORIONLD_TROE_PGSUBATTRIBUTEPUSH_H_ diff --git a/src/lib/orionld/troe/pgTransactionBegin.cpp b/src/lib/orionld/troe/pgTransactionBegin.cpp index d1a8803049..bf060a9b16 100644 --- a/src/lib/orionld/troe/pgTransactionBegin.cpp +++ b/src/lib/orionld/troe/pgTransactionBegin.cpp @@ -27,7 +27,7 @@ #include "logMsg/logMsg.h" // LM_* #include "logMsg/traceLevels.h" // Lmt* -#include "orionld/troe/pgEntityPush.h" // Own interface +#include "orionld/troe/pgTransactionBegin.h" // Own interface diff --git a/src/lib/orionld/troe/troePatchAttribute.cpp b/src/lib/orionld/troe/troePatchAttribute.cpp index 2fa20e2936..05790fc09c 100644 --- a/src/lib/orionld/troe/troePatchAttribute.cpp +++ b/src/lib/orionld/troe/troePatchAttribute.cpp @@ -41,7 +41,6 @@ extern "C" #include "orionld/troe/pgAppendInit.h" // pgAppendInit #include "orionld/troe/pgAppend.h" // pgAppend #include "orionld/troe/pgAttributeBuild.h" // pgAttributeBuild -#include "orionld/troe/pgAttributeTreat.h" // pgAttributeTreat #include "orionld/troe/pgCommands.h" // pgCommands #include "orionld/troe/troeSubAttrsExpand.h" // troeSubAttrsExpand #include "orionld/troe/troePatchAttribute.h" // Own interface @@ -66,7 +65,7 @@ bool troePatchAttribute(ConnectionInfo* ciP) char* attributeName = orionldState.wildcard[1]; // - // pgAttributeTreat assumes the name of the attribute comes as part of the tree. + // pgAttributeBuild assumes the name of the attribute comes as part of the tree. // So, let's name the tree then! :) // orionldState.requestTree->name = orionldAttributeExpand(orionldState.contextP, attributeName, true, NULL);