LP#1857150: various schema and IDL changes
authorGalen Charlton <gmc@equinoxinitiative.org>
Wed, 2 Sep 2020 16:32:25 +0000 (12:32 -0400)
committerJason Etheridge <jason@EquinoxInitiative.org>
Thu, 10 Sep 2020 20:36:12 +0000 (16:36 -0400)
* Add a primary_contact column to acq.provider. The primary contact,
  when set, signifies the primary point of contact in case a provider
  has multiple contacts. This is displayed on the summary pane in
  the Angular interface.

* Mark various non-NULL fields as required so that the record editor,
  can require them in turn:

  - acqpro.name
  - acqpro.owner
  - acqpro.currency_type
  - acqpro.code
  - acqpa.city
  - acqpa.country
  - acqpa.post_code
  - acqpa.state
  - acqpa.street1
  - acqpc.provider
  - acqpc.name
  - acqpca.city
  - acqpca.country
  - acqpca.post_code
  - acqpca.state
  - acqpca.street
  - acqlipad.code
  - acqlipad.description
  - acqlipad.xpath
  - acqlipad.provider
  - acqphsm.provider
  - acqphsm.name
  - acqphsm.subfield
  - acqedi.label
  - acqedi.host
  - acqedi.owner
  - acqedi.provider
  - acqedi.use_attrs

* Make acqpro.name not be translatable. This appears to have just
  been a case of copy-and-pastitis, as providers don't seem to
  vary their names by locale.

* Add various virtual fields to support more fleshing:

  - acqpro.contacts
  - acqpro.holdings_subfields
  - acqpro.attributes
  - acqpro.edi_accounts
  - acqpc.addresses

This patch includes contributions by Mike Rylander.

Sponsored-by: Evergreen Community Development Initiative
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Ruth Frasur <rfrasur@library.in.gov>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jason Etheridge <jason@EquinoxInitiative.org>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/200.schema.acq.sql
Open-ILS/src/sql/Pg/800.fkeys.sql
Open-ILS/src/sql/Pg/upgrade/AAAA.schema.provider-primary-contact.sql [new file with mode: 0644]

index 44455db..520f6e6 100644 (file)
@@ -8785,10 +8785,10 @@ SELECT  usr,
        <class id="acqpro" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::provider" oils_persist:tablename="acq.provider" reporter:label="Provider">
                <fields oils_persist:primary="id" oils_persist:sequence="acq.provider_id_seq">
                        <field reporter:label="Provider ID" name="id" reporter:datatype="id" reporter:selector='code'/>
-                       <field reporter:label="Provider Name" name="name" reporter:datatype="text" oils_persist:i18n="true" />
-                       <field reporter:label="Owner" name="owner" reporter:datatype="org_unit" />
-                       <field reporter:label="Currency" name="currency_type" oils_persist:primitive="string" reporter:datatype="link" />
-                       <field reporter:label="Code" name="code" reporter:datatype="text" />
+                       <field reporter:label="Provider Name" name="name" reporter:datatype="text" oils_obj:required="true"/>
+                       <field reporter:label="Owner" name="owner" reporter:datatype="org_unit" oils_obj:required="true"/>
+                       <field reporter:label="Currency" name="currency_type" oils_persist:primitive="string" reporter:datatype="link" oils_obj:required="true"/>
+                       <field reporter:label="Code" name="code" reporter:datatype="text" oils_obj:required="true"/>
                        <field reporter:label="Holdings Tag" name="holding_tag" reporter:datatype="text" />
                        <field reporter:label="Addresses" name="addresses" oils_persist:virtual="true" reporter:datatype="link" />
                        <field reporter:label="SAN" name="san" reporter:datatype="text" />
@@ -8801,15 +8801,25 @@ SELECT  usr,
                        <field reporter:label="Fax Phone" name="fax_phone" reporter:datatype="text" />
                        <field reporter:label="Default Claim Policy" name="default_claim_policy" reporter:datatype="link" />
                        <field reporter:label="Default # Copies" name="default_copy_count" reporter:datatype="int" />
+                       <field reporter:label="Primary Contact" name="primary_contact" reporter:datatype="link" />
+                       <field reporter:label="Contacts" name="contacts" oils_persist:virtual="true" reporter:datatype="link" />
                        <field reporter:label="Notes" name="provider_notes" oils_persist:virtual="true" reporter:datatype="link" />
+                       <field reporter:label="Holdings Subfields" name="holdings_subfields" oils_persist:virtual="true" reporter:datatype="link" />
+                       <field reporter:label="Attribute Definitions" name="attributes" oils_persist:virtual="true" reporter:datatype="link" />
+                       <field reporter:label="EDI Accounts" name="edi_accounts" oils_persist:virtual="true" reporter:datatype="link" />
                </fields>
                <links>
                        <link field="currency_type" reltype="has_a" key="code" map="" class="acqct"/>
                        <link field="owner" reltype="has_a" key="id" map="" class="aou"/>
-            <link field="addresses" reltype="has_many" map="" key="provider" class="acqpa"/>
-            <link field="edi_default" reltype="has_a" map="" key="id" class="acqedi"/>
+                       <link field="addresses" reltype="has_many" map="" key="provider" class="acqpa"/>
+                       <link field="contacts" reltype="has_many" map="" key="provider" class="acqpc"/>
+                       <link field="edi_default" reltype="has_a" map="" key="id" class="acqedi"/>
+                       <link field="primary_contact" reltype="has_a" map="" key="id" class="acqpc"/>
                        <link field="default_claim_policy" reltype="has_a" map="" key="id" class="acqclp"/>
                        <link field="provider_notes" reltype="has_many" map="" key="provider" class="acqpron"/>
+                       <link field="holdings_subfields" reltype="has_many" map="" key="provider" class="acqphsm"/>
+                       <link field="attributes" reltype="has_many" map="" key="provider" class="acqlipad"/>
+                       <link field="edi_accounts" reltype="has_many" map="" key="provider" class="acqedi"/>
                </links>
         <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
             <actions>
@@ -8974,14 +8984,14 @@ SELECT  usr,
        <class id="acqpa" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::provider_address" oils_persist:tablename="acq.provider_address" reporter:label="Provider Address">
                <fields oils_persist:primary="id" oils_persist:sequence="acq.provider_address_id_seq">
                        <field reporter:label="Address Type" name="address_type"  reporter:datatype="text"/>
-                       <field reporter:label="City" name="city"  reporter:datatype="text"/>
-                       <field reporter:label="Country" name="country"  reporter:datatype="text"/>
+                       <field reporter:label="City" name="city"  reporter:datatype="text" oils_obj:required="true"/>
+                       <field reporter:label="Country" name="country"  reporter:datatype="text" oils_obj:required="true"/>
                        <field reporter:label="County" name="county"  reporter:datatype="text"/>
                        <field reporter:label="ID" name="id" reporter:datatype="id"/>
                        <field reporter:label="Provider" name="provider" reporter:datatype="link"/>
-                       <field reporter:label="Post Code" name="post_code"  reporter:datatype="text"/>
-                       <field reporter:label="State" name="state"  reporter:datatype="text"/>
-                       <field reporter:label="Street 1" name="street1"  reporter:datatype="text"/>
+                       <field reporter:label="Post Code" name="post_code"  reporter:datatype="text" oils_obj:required="true"/>
+                       <field reporter:label="State" name="state"  reporter:datatype="text" oils_obj:required="true"/>
+                       <field reporter:label="Street 1" name="street1"  reporter:datatype="text" oils_obj:required="true"/>
                        <field reporter:label="Street 2" name="street2"  reporter:datatype="text"/>
                        <field reporter:label="Is Valid?" name="valid" reporter:datatype="bool"/>
                        <field reporter:label="Fax Phone" name="fax_phone" reporter:datatype="text"/>
@@ -9010,13 +9020,15 @@ SELECT  usr,
        <class id="acqpc" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::provider_contact" oils_persist:tablename="acq.provider_contact" reporter:label="Provider Contact">
                <fields oils_persist:primary="id" oils_persist:sequence="acq.provider_contact_id_seq">
                        <field reporter:label="ID" name="id" reporter:datatype="id"/>
-                       <field reporter:label="Provider" name="provider" reporter:datatype="link"/>
-                       <field reporter:label="Name" name="name" reporter:datatype="text"/>
+                       <field reporter:label="Provider" name="provider" reporter:datatype="link" oils_obj:required="true"/>
+                       <field reporter:label="Name" name="name" reporter:datatype="text" oils_obj:required="true"/>
                        <field reporter:label="Role" name="role" reporter:datatype="text"/>
                        <field reporter:label="Email" name="email" reporter:datatype="text"/>
                        <field reporter:label="Phone" name="phone" reporter:datatype="text"/>
+                       <field reporter:label="Addresses" name="addresses" oils_persist:virtual="true" reporter:datatype="link"/>
         </fields>
                <links>
+                       <link field="addresses" reltype="has_many" key="contact" map="" class="acqpca"/>
                        <link field="provider" reltype="has_a" key="id" map="" class="acqpro"/>
                </links>
         <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
@@ -9039,15 +9051,15 @@ SELECT  usr,
        <class id="acqpca" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::provider_contact_address" oils_persist:tablename="acq.provider_contact_address" reporter:label="Provider Contact Address">
                <fields oils_persist:primary="id" oils_persist:sequence="acq.provider_contact_address_id_seq">
                        <field reporter:label="Type" name="address_type"  reporter:datatype="text"/>
-                       <field reporter:label="City" name="city"  reporter:datatype="text"/>
-                       <field reporter:label="Country" name="country"  reporter:datatype="text"/>
+                       <field reporter:label="City" name="city"  reporter:datatype="text" oils_obj:required="true"/>
+                       <field reporter:label="Country" name="country"  reporter:datatype="text" oils_obj:required="true"/>
                        <field reporter:label="County" name="county"  reporter:datatype="text"/>
                        <field reporter:label="Address ID" name="id" reporter:datatype="id" />
-                       <field reporter:label="Postal Code" name="post_code" reporter:datatype="text"/>
-                       <field reporter:label="State" name="state"  reporter:datatype="text"/>
-                       <field reporter:label="Street (1)" name="street1"  reporter:datatype="text"/>
+                       <field reporter:label="Postal Code" name="post_code" reporter:datatype="text" oils_obj:required="true"/>
+                       <field reporter:label="State" name="state"  reporter:datatype="text" oils_obj:required="true"/>
+                       <field reporter:label="Street (1)" name="street1"  reporter:datatype="text" oils_obj:required="true"/>
                        <field reporter:label="Street (2)" name="street2"  reporter:datatype="text"/>
-                       <field reporter:label="Contact" name="contact" reporter:datatype="link"/>
+                       <field reporter:label="Contact" name="contact" reporter:datatype="link" oils_obj:required="true"/>
                        <field reporter:label="Valid Address?" name="valid" reporter:datatype="bool"/>
                        <field reporter:label="Fax Phone" name="fax_phone" reporter:datatype="text"/>
                </fields>
@@ -10026,10 +10038,10 @@ SELECT  usr,
        <class id="acqlipad" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::lineitem_provider_attr_definition" oils_persist:tablename="acq.lineitem_provider_attr_definition" reporter:label="Line Item Provider Attribute Definition">
            <fields oils_persist:primary="id" oils_persist:sequence="acq.lineitem_attr_definition_id_seq">
                <field reporter:label="Definition ID" name="id" reporter:datatype="id" />
-               <field reporter:label="Code" name="code" reporter:datatype="text" />
-               <field reporter:label="Description" name="description" reporter:datatype="text" oils_persist:i18n="true" />
-               <field reporter:label="XPath" name="xpath" reporter:datatype="text" />
-               <field reporter:label="Provider" name="provider" reporter:datatype="link" />
+               <field reporter:label="Code" name="code" reporter:datatype="text"  oils_obj:required="true" />
+               <field reporter:label="Description" name="description" reporter:datatype="text" oils_persist:i18n="true" oils_obj:required="true" />
+               <field reporter:label="XPath" name="xpath" reporter:datatype="text" oils_obj:required="true" />
+               <field reporter:label="Provider" name="provider" reporter:datatype="link" oils_obj:required="true" />
                <field reporter:label="Is Identifier?" name="ident" reporter:datatype="bool"/>
         <field reporter:label="Remove" name="remove" reporter:datatype="text" />
 
@@ -10058,9 +10070,9 @@ SELECT  usr,
        <class id="acqphsm" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::provider_holding_subfield_map" oils_persist:tablename="acq.provider_holding_subfield_map" reporter:label="Provider Holding Subfield Map">
            <fields oils_persist:primary="id" oils_persist:sequence="acq.provider_holding_subfield_map_id_seq">
                <field reporter:label="ID" name="id" reporter:datatype="id" />
-               <field reporter:label="Provider" name="provider" reporter:datatype="link" />
-               <field reporter:label="Name" name="name" reporter:datatype="text" />
-               <field reporter:label="Subfield" name="subfield" reporter:datatype="text" />
+               <field reporter:label="Provider" name="provider" reporter:datatype="link" oils_obj:required="true" />
+               <field reporter:label="Name" name="name" reporter:datatype="text" oils_obj:required="true" />
+               <field reporter:label="Subfield" name="subfield" reporter:datatype="text" oils_obj:required="true" />
            </fields>
            <links>
                <link field="provider" reltype="has_a" key="id" map="" class="acqpro"/>
@@ -10096,20 +10108,20 @@ SELECT  usr,
        <class id="acqedi" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::edi_account" oils_persist:tablename="acq.edi_account" reporter:label="EDI Account">
                <fields oils_persist:primary="id" oils_persist:sequence="config.remote_account_id_seq"><!-- edi_account inherits from config.remote_account, hence the seq -->
                        <field name="id"            reporter:datatype="id"        reporter:label="EDI Account ID" reporter:selector="label"/>
-                       <field name="label"         reporter:datatype="text"      reporter:label="Label"/>
-                       <field name="host"          reporter:datatype="text"      reporter:label="Host"/>
+                       <field name="label"         reporter:datatype="text"      reporter:label="Label" oils_obj:required="true"/>
+                       <field name="host"          reporter:datatype="text"      reporter:label="Host" oils_obj:required="true"/>
                        <field name="username"      reporter:datatype="text"      reporter:label="Username"/>
                        <field name="password"      reporter:datatype="text"      reporter:label="Password"/>
                        <field name="account"       reporter:datatype="text"      reporter:label="Account"/>
                        <field name="path"          reporter:datatype="text"      reporter:label="Path"/>
-                       <field name="owner"         reporter:datatype="link"      reporter:label="Owner"/>
+                       <field name="owner"         reporter:datatype="link"      reporter:label="Owner" oils_obj:required="true"/>
                        <field name="last_activity" reporter:datatype="timestamp" reporter:label="Last Activity"/>
-                       <field name="provider"      reporter:datatype="link"      reporter:label="Provider"/>
+                       <field name="provider"      reporter:datatype="link"      reporter:label="Provider" oils_obj:required="true"/>
                        <field name="in_dir"        reporter:datatype="text"      reporter:label="Incoming Directory"/>
                        <field name="vendacct"      reporter:datatype="text"      reporter:label="Vendor Account Number"/>
                        <field name="vendcode"      reporter:datatype="text"      reporter:label="Vendor Assigned Code"/>
                        <field name="attr_set"      reporter:datatype="link"      reporter:label="EDI Attribute Set"/>
-                       <field name="use_attrs"     reporter:datatype="bool"      reporter:label="Use EDI Attributes"/>
+                       <field name="use_attrs"     reporter:datatype="bool"      reporter:label="Use EDI Attributes" oils_obj:required="true"/>
                </fields>
                <links>
                        <link field="provider" reltype="has_a" key="id" map="" class="acqpro"/>
index ce23237..2ddf74e 100644 (file)
@@ -84,6 +84,7 @@ CREATE TABLE acq.provider (
     default_copy_count  INT     NOT NULL DEFAULT 0,
        default_claim_policy INT    REFERENCES acq.claim_policy
                                    DEFERRABLE INITIALLY DEFERRED,
+    primary_contact     INT,    -- REFERENCE acq.provider_contact(id) ON DELETE SET NULL ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED
     CONSTRAINT provider_name_once_per_owner UNIQUE (name,owner),
        CONSTRAINT code_once_per_owner UNIQUE (code, owner)
 );
index 58181cb..9ec6446 100644 (file)
@@ -66,6 +66,7 @@ ALTER TABLE actor.org_unit_proximity_adjustment ADD CONSTRAINT actor_org_unit_pr
 ALTER TABLE actor.org_unit_proximity_adjustment ADD CONSTRAINT actor_org_unit_proximity_copy_location_fkey FOREIGN KEY (copy_location) REFERENCES asset.copy_location (id) DEFERRABLE INITIALLY DEFERRED;
 
 ALTER TABLE acq.provider ADD CONSTRAINT acq_provider_edi_default_fkey FOREIGN KEY (edi_default) REFERENCES acq.edi_account (id) DEFERRABLE INITIALLY DEFERRED;
+ALTER TABLE acq.provider ADD CONSTRAINT acq_provider_primary_contact_fkey FOREIGN KEY (primary_contact) REFERENCES acq.provider_contact (id) ON DELETE SET NULL ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED;
 
 ALTER TABLE biblio.record_note ADD CONSTRAINT biblio_record_note_record_fkey FOREIGN KEY (record) REFERENCES biblio.record_entry (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED;
 ALTER TABLE biblio.record_note ADD CONSTRAINT biblio_record_note_creator_fkey FOREIGN KEY (creator) REFERENCES actor.usr (id) DEFERRABLE INITIALLY DEFERRED;
diff --git a/Open-ILS/src/sql/Pg/upgrade/AAAA.schema.provider-primary-contact.sql b/Open-ILS/src/sql/Pg/upgrade/AAAA.schema.provider-primary-contact.sql
new file mode 100644 (file)
index 0000000..b95f456
--- /dev/null
@@ -0,0 +1,8 @@
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+ALTER TABLE acq.provider ADD COLUMN primary_contact INT;
+ALTER TABLE acq.provider ADD CONSTRAINT acq_provider_primary_contact_fkey FOREIGN KEY (primary_contact) REFERENCES acq.provider_contact (id) ON DELETE SET NULL ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED;
+
+COMMIT;