From 4060d444e89243afa312f930a000485a233c7c43 Mon Sep 17 00:00:00 2001 From: Kajal-NEC Date: Wed, 4 Jan 2023 15:51:50 +0530 Subject: [PATCH 1/4] fixes issue#2201 --- .../telefonica/iot/cygnus/sinks/NGSIPostgreSQLSink.java | 2 +- .../java/com/telefonica/iot/cygnus/utils/NGSIUtils.java | 6 +++++- .../flume_extensions_catalogue/ngsi_postgresql_sink.md | 9 +++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIPostgreSQLSink.java b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIPostgreSQLSink.java index c6121138a..0ff78917f 100644 --- a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIPostgreSQLSink.java +++ b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/sinks/NGSIPostgreSQLSink.java @@ -547,7 +547,7 @@ public String buildSchemaName(String service, String subService) throws CygnusBa case DMBYENTITYDATABASESCHEMA: case DMBYENTITYTYPEDATABASESCHEMA: case DMBYFIXEDENTITYTYPEDATABASESCHEMA: - name = NGSIUtils.encode(subService, false, true); + name = NGSIUtils.encode(subService, true, false); break; default: name = NGSIUtils.encode(service, false, true); diff --git a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/utils/NGSIUtils.java b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/utils/NGSIUtils.java index f6b440896..1d564f012 100644 --- a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/utils/NGSIUtils.java +++ b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/utils/NGSIUtils.java @@ -60,7 +60,11 @@ private NGSIUtils() { */ public static String encode(String in, boolean deleteSlash, boolean encodeSlash) { if (deleteSlash) { - return ENCODEPATTERN.matcher(in.substring(1)).replaceAll("_"); + if(in.startsWith("/")) { + return ENCODEPATTERN.matcher(in.substring(1)).replaceAll("_"); + }else { + return ENCODEPATTERN.matcher(in).replaceAll("_"); + } } else if (encodeSlash) { return ENCODEPATTERN.matcher(in).replaceAll("_"); } else { diff --git a/doc/cygnus-ngsi/flume_extensions_catalogue/ngsi_postgresql_sink.md b/doc/cygnus-ngsi/flume_extensions_catalogue/ngsi_postgresql_sink.md index 06adf3436..cc10c0c82 100644 --- a/doc/cygnus-ngsi/flume_extensions_catalogue/ngsi_postgresql_sink.md +++ b/doc/cygnus-ngsi/flume_extensions_catalogue/ngsi_postgresql_sink.md @@ -54,12 +54,12 @@ For a given entity, `entityname`, of type `entitytype`, inside a tenant `service | datamodel name | database name | schema name | table name | note | |-------------------------------------------|---------------|--------------|-----------------------------------|---------------------------------------------------| | by default | `agent.conf` | service | servicepath_entityname_entitytype | Automatic schema creation | -| `dm-by-fixed-entity-type-database-schema` | service | _servicepath | entitytype | Database and schema need to be created in advance | +| `dm-by-fixed-entity-type-database-schema` | service | servicepath | entitytype | Database and schema need to be created in advance | | `dm-by-fixed-entity-type-database` | service | service | entitytype | Database and schema need to be created in advance | | `dm-by-fixed-entity-type` | `agent.conf` | service | entitytype | Automatic schema creation | -| `dm-by-entity-database-schema` | service | _servicepath | servicepath_entityname_entitytype | Database and schema need to be created in advance | +| `dm-by-entity-database-schema` | service | servicepath | servicepath_entityname_entitytype | Database and schema need to be created in advance | | `dm-by-entity-database` | service | service | servicepath_entityname_entitytype | Database and schema need to be created in advance | -| `dm-by-entity-type-database-schema` | service | _servicepath | servicepath_entitytype | Database and schema need to be created in advance | +| `dm-by-entity-type-database-schema` | service | servicepath | servicepath_entitytype | Database and schema need to be created in advance | | `dm-by-entity-type-database` | service | service | servicepath_entitytype | Database and schema need to be created in advance | | `dm-by-entity-type` | `agent.conf` | service | servicepath_entitytype | Automatic schema creation | | `dm-by-service-path` | `agent.conf` | service | servicepath | Automatic schema creation | @@ -68,9 +68,6 @@ For a given entity, `entityname`, of type `entitytype`, inside a tenant `service Where [`agent.conf`](https://github.com/telefonicaid/fiware-cygnus/blob/master/doc/cygnus-ngsi/installation_and_administration_guide/ngsi_agent_conf.md) is the default database name selected in that file under the field `cygnus-ngsi.sinks.postgresql-sink.postgresql_database` or the env var `CYGNUS_POSTGRESQL_DATABASE` -**NOTE:** the leading underscore `_` in schema name column for `*-schema` cases is not a typo. However, this may change in the future, -see issue [#2201](https://github.com/telefonicaid/fiware-cygnus/issues/2201). - [Top](#top) #### PostgreSQL databases naming considerations From b5395262ee665d1c5b35ba8ca30364fdc83bb84a Mon Sep 17 00:00:00 2001 From: Kajal Katoke <94599733+Kajal-NEC@users.noreply.github.com> Date: Tue, 10 Jan 2023 19:03:52 +0530 Subject: [PATCH 2/4] Update cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/utils/NGSIUtils.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fermín Galán Márquez --- .../main/java/com/telefonica/iot/cygnus/utils/NGSIUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/utils/NGSIUtils.java b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/utils/NGSIUtils.java index 1d564f012..2050c7568 100644 --- a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/utils/NGSIUtils.java +++ b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/utils/NGSIUtils.java @@ -60,9 +60,9 @@ private NGSIUtils() { */ public static String encode(String in, boolean deleteSlash, boolean encodeSlash) { if (deleteSlash) { - if(in.startsWith("/")) { + if(in.startsWith("/")) { return ENCODEPATTERN.matcher(in.substring(1)).replaceAll("_"); - }else { + } else { return ENCODEPATTERN.matcher(in).replaceAll("_"); } } else if (encodeSlash) { From 59c4a86af420971b0c75a82677617564d2c04a3c Mon Sep 17 00:00:00 2001 From: Kajal Katoke <94599733+Kajal-NEC@users.noreply.github.com> Date: Tue, 10 Jan 2023 23:34:07 +0530 Subject: [PATCH 3/4] Update CHANGES_NEXT_RELEASE --- CHANGES_NEXT_RELEASE | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index 6df8b0573..e3c69315d 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -3,3 +3,4 @@ [cygnus-common] Upgrade postgresql from 42.4.1 to 42.4.3 [cygnus-common] OracleSQL backend (#2195) [cygnus-ngsi] OracleSQL ngsi sink added (for OracleS 11g and 12c) (#2195) +[cygnus-ngsi] Removes "_" in schema name for DM -schema family (#2201) From 2db6590ba3ad7045a45443558cdf34077a27a789 Mon Sep 17 00:00:00 2001 From: Kajal Katoke <94599733+Kajal-NEC@users.noreply.github.com> Date: Tue, 10 Jan 2023 23:40:40 +0530 Subject: [PATCH 4/4] Update cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/utils/NGSIUtils.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fermín Galán Márquez --- .../main/java/com/telefonica/iot/cygnus/utils/NGSIUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/utils/NGSIUtils.java b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/utils/NGSIUtils.java index 2050c7568..df3ee2497 100644 --- a/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/utils/NGSIUtils.java +++ b/cygnus-ngsi/src/main/java/com/telefonica/iot/cygnus/utils/NGSIUtils.java @@ -60,7 +60,7 @@ private NGSIUtils() { */ public static String encode(String in, boolean deleteSlash, boolean encodeSlash) { if (deleteSlash) { - if(in.startsWith("/")) { + if (in.startsWith("/")) { return ENCODEPATTERN.matcher(in.substring(1)).replaceAll("_"); } else { return ENCODEPATTERN.matcher(in).replaceAll("_");