From 17b13e75a8d39e02763b95c1cf8aa7736ba52aa2 Mon Sep 17 00:00:00 2001 From: Gaetan Craig-Riou Date: Wed, 14 Feb 2024 15:47:05 +1100 Subject: [PATCH] Add DfcProvider::Address Add our own address to include `region`, currently not supported by the DFC connector. `region` is already included in the next branch of data-model-uml: https://github.com/datafoodconsortium/data-model-uml/commit/729eba31a5e551736a18d263531291a5811919c5 To me removed once the DFC connector is updated --- engines/dfc_provider/lib/dfc_provider.rb | 1 + .../dfc_provider/lib/dfc_provider/address.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 engines/dfc_provider/lib/dfc_provider/address.rb diff --git a/engines/dfc_provider/lib/dfc_provider.rb b/engines/dfc_provider/lib/dfc_provider.rb index 9e917a5701..526cceb9c3 100644 --- a/engines/dfc_provider/lib/dfc_provider.rb +++ b/engines/dfc_provider/lib/dfc_provider.rb @@ -8,6 +8,7 @@ require "dfc_provider/engine" # Custom data types require "dfc_provider/supplied_product" +require "dfc_provider/address" module DfcProvider DataFoodConsortium::Connector::Importer.register_type(SuppliedProduct) diff --git a/engines/dfc_provider/lib/dfc_provider/address.rb b/engines/dfc_provider/lib/dfc_provider/address.rb new file mode 100644 index 0000000000..02ecc5ca3b --- /dev/null +++ b/engines/dfc_provider/lib/dfc_provider/address.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +# Temporary solution to add `region` to Address, to be removed once the DFC connector supports it + +module DfcProvider + class Address < DataFoodConsortium::Connector::Address + # @return [String] + attr_accessor :region + + def initialize(semantic_id, region: "", **properties) + super(semantic_id, **properties) + @region = region + + registerSemanticProperty("dfc-b:region", &method("region")).valueSetter = method("region=") + end + end +end