opentripmodel / otm5-change-requests

Tracking and reporting bugs and change requests of the OTM5 specification.
5 stars 1 forks source link

Move action sequenceNr to support multiple sequences #79

Closed SytseOegema closed 11 months ago

SytseOegema commented 1 year ago

Is your feature request related to a problem? We want to track the sequence of actions inside different entities. Currently an action contains a sequenceNr which can be used to defined the sequence number of the action with the parent entity. This is a great feature we are already using to determine the sequence of stops and substops within a trip. We also want to use the sequence number for ordering load and unload actions within a consignment. But that is not possible because we store an action in the database which is associated with both a Trip and a Consignment.

So we want to define multiple sequences for the same action.

Describe the solution you'd like For us the problem would be solved if the sequence number of an action is stored in the association of the action instead of in the action itself. That makes it possible to define a sequence for actions within each parent entity. Consider the example JSON below. This would also make it possible to define other sequences of actions in other parent entities.

{ // trip
  "actions": [
    {
      "associationType": "inline",
      "sequenceNr": 1
      "entity": {
        "id": "action1"
      }
    },
    {
      "associationType": "inline",
      "sequenceNr": 2
      "entity": {
        "id": "action3"
      }
    }
  ]
}

{ // consignment 1
  "actions": [
    {
      "associationType": "inline",
      "sequenceNr": 2
      "entity": {
        "id": "action1"
      }
    },
    {
      "associationType": "inline",
      "sequenceNr": 1
      "entity": {
        "id": "action2"
      }
    }
  ]
}

{ // consignment 2
  "actions": [
    {
      "associationType": "inline",
      "sequenceNr": 1
      "entity": {
        "id": "action3"
      }
    }
  ]
}

Describe alternatives you've considered At this moment in time we are not aware of any solution that supports this within OTM. It could of course always be communicated within the externalAttributes, but we deemed this important enough to submit.

thomaskolmans commented 1 year ago

I'm against this change for the following reasons:

  1. It introduces ambiguity in my opinion
  2. OTM is a data-communication model, not a database model in and of itself. Thus the issue that you flagged is a database-design problem, not necessarily a data-communication one

Also I've tried to imagine why this can cause an issue. Let's say a that the sequenceNr changes, why is it bad that it changes on both levels? Isn't that a good thing?

SytseOegema commented 1 year ago

I'll try to clearify the issue a bit better. In our use case an Action can be part of multiple sequences. An action is part of the sequence within a Consignment and the sequence within a Stop Action. While I agree that this can be regarded as a database-design issue, the single sequence number introduces ambiguity in the communication with our partners.

Depending on the wishes of the shipper we sometimes share updates on both the Consignment and the Trip. This means that for example the unload action of a Consignment is also included in the Stop actions of a Trip. And it is not necessary that the action has the same sequenceNr inside the Consignment as in the Stop Action. For example consider a consignment with 4 actions where the fourth action is the final delivery at the receiver's address. That unload action might be in a stop action with a load action at the same address. In that situation you always want to do the unload action before the load action. So the same action gets sequenceNr 4 in the Consignment and sequenceNr 1 in the Stop Action.

There are numerous ways to solve this problem in the database but this still means that an action with the same UUID has two different sequence numbers in a different context. Therefore I suggested moving the sequence to the association such that you can have multiple sequences in accordance with other multi-purpose relations between other OTM entities. For example an actor can have different roles in other entities because the role is defined on the association. I am proposing to use a similar solution for defining multiple sequences.

To specifically answer your final question, no you don't want the sequence number of the action to change in other relations when you change it in one. You might remove a substop in the Stop Action for numerous reasons but that does not change the sequence in the Consignment. Similarly something might change in the Consignment but that does not necessarily influence the Trip.

bmeesters commented 1 year ago

Hello @SytseOegema, thanks for your contribution. I understand the concern and that it is not possible with the current specification. However, I also think that having the same field in two places can be very confusing.

Personally I believe the sequenceNr is a bit redundant because you can use both

  1. The order of the actions in the list of actions itself.
  2. Use the chronological order based on the start/end time of the actions.

So, IMO, I don't think it would be wise to add it since it is confusing and order can still be determined. We will need to discuss it with the group though. @woutvandenheuvel could you pick this up once the group is complete again?

bmeesters commented 11 months ago

Since it can be confusing and there are alternative methods, this will not be added to OTM