teksi / district_heating

Future TEKSI distance heating module
GNU General Public License v3.0
0 stars 0 forks source link

name_number - set MANDATORY? #3

Open sjib opened 1 month ago

sjib commented 1 month ago

Name_Nummer (name_number) – in INTERLIS not MANDATORY – how to handle in TEKSI Distance heating? I would suggest to set it MANDATORY

sjib commented 1 month ago

@sjib to do write concept for this as discussed

sjib commented 1 month ago
sjib commented 1 month ago
  • Add MANDATORY constraint to datamodel @sjib

I saw that we also do not have MANDATORY constraints in the postgres data model of tww - discuss with Technical group

sjib commented 1 month ago
  • Implement trigger in forms, that fill in Name_Number = obj_id if no Name_Number is added - see TWW implementation (to do add link @sjib)

@urskaufmann How and where did we add this in tww? In the project file or as trigger in the database?

urskaufmann commented 1 month ago

Name_Nummer (=Identifier) is in tww normally not defined in the project. There must be somewhere a trigger, that sets identifier = obj_id as default value. With one exception: all identifier (reach, channel, reachpoint) in vw_tww_reach do not work like this, there has to be the obj_id defined as default value. The vw_tww_reach is somewhere specially, it's to only view, where the QGIS-standard-"reuse last value" does not work...

sjib commented 1 month ago

These triggers seem to be created here in tww: https://github.com/teksi/wastewater/blob/d8a3e3a8f92be62848dfc465c6cba45b824467ca/datamodel/app/view/vw_tww_wastewater_structure.py#L277

In the final database it then looks like this: NEW.identifier = COALESCE(NEW.identifier, NEW.obj_id);

20240527_vw_tww_wws_insert_trigger

And for cover: 20240527_vw_cover_on_insert

, CASE WHEN NEW.identifier IS NOT NULL AND NEW.identifier::text <> '' THEN NEW.identifier ELSE COALESCE( NEW.obj_id, tww_sys.generate_oid('tww_od'::text, 'structure_part'::text) ) END

sjib commented 1 month ago

@urskaufmann In vw_tww_reach there is nothing defined for NEW wwn.identifier - may be that is the reason: 20240507_vw_tww_reach_insert_identifier_wwn