Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify registrations database model #4611

Open
fgalan opened this issue Aug 28, 2024 · 4 comments
Open

Simplify registrations database model #4611

fgalan opened this issue Aug 28, 2024 · 4 comments

Comments

@fgalan
Copy link
Member

fgalan commented Aug 28, 2024

Registration documents are this way:

 {
   "_id": ObjectId("5149f60cf0075f2fabca43da"),
   "format": "JSON",
   "fwdMode": "all",
   "expiration": 1360232760,
   "contextRegistration": [
       {
           "entities": [
               {
                   "id": "E1",
                   "type": "T1",
                   "isPattern": "false"
               },
               {
                   "id": "E2",
                   "type": "T2",
                   "isPattern": "false"
               }
           ],
           "attrs": [
               {
                   "name": "A1",
                   "type": "TA1"
               },
               {
                   "name": "A2",
                   "type": "TA2"
               }
           ],
           "providingApplication": "http://foo.bar/notif"
      },
      "status": "active"
    }
  ]
 }

The contextRegistration is always mono-item. It is a vector due to NGSIv1 legacy.

It would be better to simplify to:

 {
   "_id": ObjectId("5149f60cf0075f2fabca43da"),
   "format": "JSON",
   "fwdMode": "all",
   "expiration": 1360232760,
   "entities": [
       {
           "id": "E1",
           "type": "T1",
           "isPattern": "false"
       },
       {
           "id": "E2",
           "type": "T2",
           "isPattern": "false"
       }
   ],
   "attrs": [
       {
           "name": "A1",
           "type": "TA1"
       },
       {
          "name": "A2",
          "type": "TA2"
       }
   ],
   "providingApplication": "http://foo.bar/notif",
   "status": "active"
}

In addition, isPattern should be also removed.

This issue should be addressed after #4610 (the format field will be removed as part of that issue).

A DB migration script would be probably needed.

@fgalan
Copy link
Member Author

fgalan commented Aug 28, 2024

Look for FIXME #4611 marks in the code.

@fgalan
Copy link
Member Author

fgalan commented Aug 28, 2024

registrationsQuery() logic should be changed

@fgalan
Copy link
Member Author

fgalan commented Aug 28, 2024

A DB migration script would be probably needed.

In this sense a new Rule Rxx should be added to https://github.com/telefonicaid/fiware-orion/tree/master/scripts/oriondb_consistency to detect situations in which contextRegistration vector has more than one element. The migration could be the autofix action for that rule.

@fgalan
Copy link
Member Author

fgalan commented Sep 4, 2024

In addition, in the structure:

       {
           "id": "E1",
           "type": "T1",
           "isPattern": "false"
       },

isPattern (with a string value) is ugly.

Maybe more natural to use "pattern": true|false:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant