specify / specify7

Specify 7
https://www.specifysoftware.org/products/specify-7/
GNU General Public License v2.0
66 stars 36 forks source link

Enable creating Collection Object Relationships in Specify 7 #3120

Open grantfitzsimmons opened 1 year ago

grantfitzsimmons commented 1 year ago

Currently there is this quite difficult and incomplete workaround:

https://discourse.specifysoftware.org/t/create-a-collection-relationship-in-specify-7/581

Collection relationships in Specify allow specimens to be associated with either specimens in another collection or with a taxonomic name in another collection. Some examples of these types of relationships are tissue and voucher, plant and pollinator and host parasite, etc. Specify allows collection objects in two different collections to be related to one another for the purpose of documenting these types of relationships. The collections may be in different disciplines.

Collection relationships require that one collection be the ‘Source’ and the other the ‘Destination’. In a single relationship, a source may have many destinations, but a destination may only have one source. This is important to remember when choosing which collection will be the source and which will be the destination. For instance, if a bee pollinates several flowers the bee collection would be the source and the flowers would be the destination.

At the database level:

Left Side: Source collection Right Side: Destination collection

Collection relationships can either associate two collection objects (cataloged specimens) or a collection object from a source collection with a taxonomic name in a destination collection. A relationship that associates two collection objects is called an Object Relationship and a relationship that associates a collection object with a taxonomic name is called a Host Taxon ID.

Forms must be edited to include controls which allow the source collection object to be associated with the destination collection object or taxonomic name. Members may contact Specify at support@specifysoftware.org to request forms that include either of these relationships.


Important Note: Currently, you must define a CollectionRelType view in your form definition to establish this in 7. You can expand the form definitions section to copy and paste the views used in this tutorial into your user's form definition.

[details="Form definitions:"] Views:

        <view name="CollectionRelType"
            class="edu.ku.brc.specify.datamodel.CollectionRelType"
            resourcelabels="false">
            <desc><![CDATA[The CollectionRelType Form.]]></desc>
            <altviews>
                <altview name="CollectionRelType View" viewdef="CollectionRelType" mode="view" validated="false" default="true"/>                
                <altview name="CollectionRelType Edit" viewdef="CollectionRelType" mode="edit" validated="true"/>                
            </altviews>
        </view>

Viewdef:

        <viewdef
            type="form"
            name="CollectionRelType"
            class="edu.ku.brc.specify.datamodel.CollectionRelType"
            gettable="edu.ku.brc.af.ui.forms.DataGetterForObj"
            settable="edu.ku.brc.af.ui.forms.DataSetterForObj">
            <desc><![CDATA[The Journal form - unknown use in schema]]></desc>

            <columnDef>100px,2px,195px,5px,86px,2px,210px,5px,74px,2px,146px,15px,p:g</columnDef>
            <columnDef os="lnx">115px,2px,195px,5px,125px,2px,210px,5px,125px,2px,131px,15px,p:g</columnDef>
            <columnDef os="mac">130px,2px,215px,5px,138px,2px,260px,5px,138px,2px,155px,15px,p:g</columnDef>
            <columnDef os="exp">p,2px,min(p;220px),5px:g,p,2px,p,5px:g,p,2px,200px,p,p:g</columnDef>
            <rowDef auto="true" cell="p" sep="2dlu"/>

            <rows>
                <row>
                    <cell type="label" labelfor="1"/>
                    <cell type="field" id="1" name="name" uitype="text"/>
                    <cell type="label" labelfor="2"/>
                    <cell type="field" id="2" name="remarks" uitype="text"/>
                </row>
                <row>
                    <cell type="label" labelfor="4"/>
                    <cell type="field" id="4" name="leftSideCollection" uitype="querycbx" initialize="name=Collection" isrequired="true" colspan="6"/>
                </row>
                <row>
                    <cell type="label" labelfor="5"/>
                    <cell type="field" id="5" name="rightSideCollection" uitype="querycbx" initialize="name=Collection" isrequired="true" colspan="6"/>
                </row>
            </rows>
        </viewdef>

[/details]

Step 1: Create a new Collection Relationship Type

You can do this by appending the following to your database's URL:

/specify/view/collectionreltype/new/

You need to give your new relationship a name (which will be used later) and select both the "left side" (source) collection and "right side" (destination) collection.

Collection Relationship Type form|690x253, 75%

Step 2: Add the relationship to your CO form.

In this instance, you can see that the relname= attribute is followed by the name we established in Step 1. In this case, relname="VoucherToTissue".

<cell type="field" id="colrel" uitype="plugin" name="this" initialize="name=CollectionRelOneToManyPlugin;relname=VoucherToTissue;" colspan="9"/>

Step 3: View the updated form and create a connection! You just need to press the "+" button on the new Collection Relationship view. You can then search for the catalog number of the related CO record.

image|642x500

maxpatiiuk commented 1 year ago

Looks like the main task here is for us to modify the default view definition in sp6 (or better yet - add a mechanism for providing default forms in sp7 - we do have such capability front-end right now, but it's defined as XML right now - need to convert them back to XML using the syncer library)

grantfitzsimmons commented 1 year ago

This should have a custom UI in my opinion. The 6 implementation does and it is much more user-friendly than using the standard form system for it.

The query combo boxes for the collections don't work, so you have to use the search function and only sometimes does it work correctly. (No typesearch definition, no unscoped queries)

The UI would need to describe what's happening, where it can be used, and how the linkage works. None of that is clear now. It should let you just pick a collection as a source and pick a collection as a destination, then give it a name.

emenslin commented 3 months ago

Can recreate in edge (7.9.6)

grantfitzsimmons commented 3 weeks ago

This can be done when we finish #5312