claeis / ili2db

interlis import/export to relational databases
30 stars 29 forks source link

Implement BAG OF REFRENCE TO as array with `!!@ili2db.mapping=ARRAY` #491

Open signedav opened 2 years ago

signedav commented 2 years ago

The metaattribute !!@ili2db.mapping=ARRAY allows us to store BAG OF values of a STRUCTURE with enumeration-attribute as an array. But when this does not contain an enumeration-attribute but a REFERENCE TO object instead, this is not possible.

The second is the use case of having a catalogue. Since this use case is often the same like using enumerations, the possibility of being able to use this metaattribute on such situations would be appreciated.

Example with enumeration

Like this (cropped model):

[...]
DOMAIN

Kalendermonat = (
  Januar,
  Februar,
  Maerz,
);

TOPIC Pflegeplanung =

  STRUCTURE Kalendermonat_Typ =
    Monat : Kalendermonat;
  END Kalendermonat_Typ;

  CLASS Vegetation =
    !!@ili2db.mapping=ARRAY
    Zeitpunkt : BAG {1..*} OF Kalendermonat_Typ;
  END Vegetation;

END Pflegeplanung;
[...]

Will lead to this (in PostgreSQL):

[...]   
zeitpunkt bigint[] NOT NULL,
[...]

Example with REFERENCE TO

[...]
TOPIC Pflegeplanung =

  CLASS Kalendermonat =
    Name : TEXT*25; 
  END Kalendermonat;

  STRUCTURE Kalendermonat_Typ =
    Reference : MANDATORY REFERENCE TO Kalendermonat;
  END Kalendermonat_Typ;

  CLASS Vegetation =
    !!@ili2db.mapping=ARRAY
    Zeitpunkt : BAG {1..*} OF Kalendermonat_Typ;
  END Vegetation;
END Pflegeplanung;
[...]

Will lead to an error:

mapping of ili-classes to sql-tables failed
  mapping of Pflegeplanung_Fliessgewaesser_SH_V1_0.Pflegeplanung.Vegetation failed
    Pflegeplanung_Fliessgewaesser_SH_V1_0.Pflegeplanung.Vegetation.Zeitpunkt
      unexpected attr type Pflegeplanung_Fliessgewaesser_SH_V1_0.Pflegeplanung.Kalendermonat_Typ.Reference

The initial input on the Model Baker Issues: https://github.com/opengisch/QgisModelBaker/issues/664

claeis commented 1 year ago

see also #438