geosolutions-it / geonode-rndt

Geonode-RNDT is a Django App to let GeoNode be able to expose the metadata compliant to the RNDT standard
BSD 2-Clause "Simplified" License
1 stars 1 forks source link

UUID: logic #5

Closed etj closed 3 years ago

etj commented 3 years ago

We want to update a Layer UUID according to the associated GroupProfile.

When a Layer has an associated GroupProfile, we need to read the related IPA code from Layer --> GroupProfile --> GroupProfileRNDT --> PubblicaAmministrazione.ipa

The UUID will be trasformed as: IPA + ":" + UUID

The UUID should always reflect the associated IPA.

The main actions to check for are (not limited to)

We do not want to customize GeoNode logic; we need instead to create hooks wherever needed in order for GeoNode to be extensible. For instance, we may want to create an UUIDHandler class that should be used at UUID initialization and whenever the Layer is updated. For instance, in geonode/layers/models.py, function pre_save_layer() we have:

if instance.uuid == '':
    instance.uuid = str(uuid.uuid1())

We may want to check the configuration if a constant LAYER_UUID_HANDLER exists. If it's there, we may call its methods, for instance handler.create_uuid(instance).

mattiagiupponi commented 3 years ago

IPA association is found by layer -> group -> groupprofile -> groupprofilerndt -> pa (fk) -> ipa

legenda: x -> available ' ' -> not available

Layer creation:

The library takes the IPA from the instance object and checks if is available. if is present, will update the UUID otherwise will take the already assigned UUID.

Cases managed

UUID IPA output
uuid1
x ipa:uuid1
x uuid1
x x ipa:uuid1

Layer update:

Cases managed

The library takes the IPA from the instance object and checks if is the same that is present in the uuid. If is the same will keep the old UUID, otherwise will update the UUID by replacing the old IPA with the new one found.

UUID IPA is not changed IPA changed output
x x ipa:uuid1
x x newipa:uuid1

All the use-case could be found in the tests.py

mattiagiupponi commented 3 years ago

PubblicaAmministrazione

If the IPA value changes, in the post_save method, all the UUID of the ResouceBase with the related code, will be updated by replacing the code in the UUID Example: IPA UUID
123abc 123abc:0ae99018-af2c-400b-b60e-34

After the update:

IPA UUID
678gft 678gft:0ae99018-af2c-400b-b60e-34

NOTE:

GroupProfileRNDT

If the IPA fk changes, in the post_save method, all the UUID of the ResouceBase with the related code, will be updated by replacing the code in the UUID Example: IPA UUID
123abc 123abc:0ae99018-af2c-400b-b60e-34

After the update:

IPA UUID
678gft 678gft:0ae99018-af2c-400b-b60e-34

NOTE: