It’s my first post here. Please also excus my bad english.
I’ve been working on this problem in Java for several days now.
I have a “JsonOrder” class with 2 attributes :
-order which is a Double
-uuid_d which is a UUID
To simplify things, I have a JsonOrder[] that I retrieve from my database. There can’t be 2 JsonOrders in this array that share the same “order”, and the same goes for “uuid_d”.
If we have a JsonOrder with say 4.0 in order, we can have another one with 4.1, 4.2 etc… they would be children of this JsonOrder, they must be dependent on it.
The algorithm I’m trying to implement must take a parameter of type JsonOrder. It must then check whether the uuid_d of this JsonOrder exists in my JsonOrder[]. If it doesn’t, it must insert this JsonOrder into it, at the associated “order”, while shifting the others. If it’s a child JsonOrder of another (“order”%1 != 0) then it will only offset the other children of the parent JsonOrder. If, on the other hand, the JsonOrder corresponds (via uuid_d) to an element in my JsonOrder[], then we need to reassign the order of the existing JsonOrder and its possible children so that it follows.
I think you get the idea: it reminds me of a drag&drop system you sometimes see visually, which dynamically shifts the whole thing according to the location of what you’re dragging.
I have a lot of trouble with this, and particularly with parent-child dependencies via the Double order. But it has to stay in that format.
My current W.I.P. takes 200+ lines, is incomplete an does not fully work.
The more I dive into it, the more it appears to require complex procssing. At first I thought it would be simple as I saw a lot of these “drag and drop” systems. Note that that’s not at all for a drag & drop feature. It will be used to order things from a database.
I would love to share it but it contains sensitive data that i’m not allowed to share.
Do you have any ideas? Thanks a lot
I’ve succeeded in the part where the JsonOrder I’m integrating is not yet present in the base (based on its uuid_d) but when it comes to modifying an order, I can’t find a good approach…