specify6 icon indicating copy to clipboard operation
specify6 copied to clipboard

ExchangeOutAttachment not working correctly (default forms should include EO and EI attachments)

Open grantfitzsimmons opened this issue 4 years ago • 4 comments

@chanulee1 and I each wrote different view definitions for the exchangeOutAttachments relationship and are experiencing this error:

image

on Ubuntu 20.04

image

on Windows 10 per @chanulee1

We could totally be writing this definition incorrectly.


In my global.views.xml:

		<view name="ExchangeOutAttachment"
			class="edu.ku.brc.specify.datamodel.ExchangeOutAttachment"
			busrules="edu.ku.brc.specify.datamodel.busrules.AttachmentBusRules"
			resourcelabels="false">
			<desc><![CDATA[The Exchange Out - Attachment View.]]></desc>
            <altviews>
                <altview name="ExchangeOutAttachment Icon View"  viewdef="CollectionObjectAttachment IconView" mode="view"/>
                <altview name="ExchangeOutAttachment Icon Edit"  viewdef="CollectionObjectAttachment IconView" mode="edit"/>
                <altview name="ExchangeOutAttachment Table View" viewdef="CollectionObjectAttachment Table"    mode="view" />
                <altview name="ExchangeOutAttachment Table Edit" viewdef="CollectionObjectAttachment Table"    mode="edit"/>
                <altview name="ExchangeOutAttachment Form View"  viewdef="CollectionObjectAttachment Form"     label="Form" mode="view" default="true"/>
                <altview name="ExchangeOutAttachment Form Edit"  viewdef="CollectionObjectAttachment Form" 	label="Form" mode="edit"/>
            </altviews>
        </view>
       <viewdef
            type="iconview"
            name="ExchangeOutAttachment IconView"
            class="edu.ku.brc.specify.datamodel.ExchangeOutAttachment"
            gettable="edu.ku.brc.af.ui.forms.DataGetterForObj"
            settable="edu.ku.brc.af.ui.forms.DataSetterForObj">
            <desc><![CDATA[The ExchangeOutAttachment Icon Viewer]]></desc>
        </viewdef>

        <viewdef
            type="form"
            name="ExchangeOutAttachment Form"
            class="edu.ku.brc.specify.datamodel.ExchangeOutAttachment"
            gettable="edu.ku.brc.af.ui.forms.DataGetterForObj"
            settable="edu.ku.brc.af.ui.forms.DataSetterForObj"
            useresourcelabels="true">
            <desc><![CDATA[The ExchangeOutAttachment form.]]></desc>
            
            <!--<columnDef>110px,2dlu,p:g,5dlu,100px,2dlu,85px</columnDef> -->
            <columnDef>p,5dlu,p:g</columnDef>
            <rowDef auto="true" cell="p" sep="2px"/>

              <rows>
                <row>
                    <cell type="label" labelfor="origFilename" label="FILENAME"/>
                    <cell type="field" id="origFilename" name="attachment.origFilename" initialize="editoncreate=true" uitype="browse" isrequired="true"/>
                </row>
                <row>
                      <cell type="label" labelfor="title"  label="TITLE"/>
                    <cell type="field" id="title" name="attachment.title" isrequired="true"/>
                </row>
                <!--<row>
                    <cell type="subview" id="metadata" name="attachment.metadata" viewname="AttachmentMetadata" colspan="3"/>
                </row> -->
                <row>
                    <cell type="label" labelfor="dateImaged" label="DATE_IMAGED"/>
                    <cell type="field" id="dateImaged" name="attachment.dateImaged" uitype="text"/>
                </row>
                <row>
                    <cell type="label" labelfor="fileCreatedDate" label="FILE_CREATED_DATE"/>
                    <cell type="field" id="fileCreatedDate" name="attachment.fileCreatedDate" uitype= "formattedtext" uifieldformatter="Date" default="today"/>
                </row>
                <row>
                    <cell type="label" labelfor="copyrightHolder" label="COPYRIGHT_HOLDER"/>
                    <cell type="field" id="copyrightHolder" name="attachment.copyrightHolder" uitype="text"/>
                </row>
                <row>
                    <cell type="label" labelfor="copyrightDate" label="COPYRIGHT_DATE"/>
                    <cell type="field" id="copyrightDate" name="attachment.copyrightDate" uitype="text"/>
                </row>
                <row>
                    <cell type="label" labelfor="attachmentLocation" label="ATTACHMENT_LOCATION"/>
                    <cell type="field" id="attachmentLocation" name="attachment.attachmentLocation" uitype="text"/>
                </row>
                <row>
                    <cell type="label" labelfor="isPublic" label="is public"/>
                    <cell type="field" id="isPublic" name="attachment.isPublic" isrequired="true" uitype="checkbox"/>
                </row>
                <row>
                    <cell type="label" labelfor="license" label="LICENSE"/>
                    <cell type="field" id="license" name="attachment.license" uitype="text"/>
                </row>
                <row>
                    <cell type="label" labelfor="credit" label="CREDIT"/>
                    <cell type="field" id="credit" name="attachment.credit" uitype="text"/>
                </row>
                <row>
                    <cell type="label" labelfor="mimeType" label="MIME_TYPE"/>
                    <cell type="field" id="mimeType" name="attachment.mimeType" uitype="text"/>
                </row>
                <row>
                    <cell type="label" labelfor="remarks" label="REMARKS"/>
                    <cell type="field" id="remarks" name="attachment.remarks" uitype="textareabrief" rows="2"/>
                </row>
                <!--<row>
                    <cell type="subview" id="imageatt" viewname="AttachmentImageAttribute" name="attachment.attachmentImageAttribute" colspan="3" />
                </row>-->
            </rows>
        </viewdef>

@chanulee1's view definition: fish.views.210.xml.zip

grantfitzsimmons avatar Oct 28 '22 17:10 grantfitzsimmons

The above should fix the exception that stops attachments being added for these tables. For the views, you don't need to add an Exchange*Attachment viewdef. Just adding it to the ExchangeIn or Out view like I described to Chanu seems to work for me.

benanhalt avatar Oct 28 '22 20:10 benanhalt

While creating a view/viewdef for each exchangeAttachment (in/out) would work, this can be shortened down to a single field in the Exchange In/Out, using the ObjectAttachment view (as defined in global.views.xml). (Event though i'm pretty sure explicitly defining the Views/Viewdefs would allow for greater customizability)

For example, adding the ExchangeInAttachments to the form can be accomplished by the following:

<cell type="subview" id="exchangeInAttachments" name="exchangeInAttachments" viewname="ObjectAttachment" colspan="10"/>

Making it a button can be accomplished by:

<cell type="subview" id="exchangeInAttachments" name="exchangeInAttachments" viewname="ObjectAttachment" initialize="btn=true;icon=CollectionObjectAttachment"/>

However, there database error still occurs when you try and save an exchange with an attachment. @benanhalt , does ExchangeIn and ExchangeOut need to be added to the createTblScopeMapping() method in the Attachment class? By default, it seems like it would scope them to GLOBAL

https://github.com/specify/specify6/blob/366b209eb36215c2564a560fbadcbedbee5eace7/src/edu/ku/brc/specify/datamodel/Attachment.java#L626-L660

melton-jason avatar Oct 28 '22 20:10 melton-jason

The above should fix the exception that stops attachments being added for these tables. For the views, you don't need to add an Exchange*Attachment viewdef. Just adding it to the ExchangeIn or Out view like I described to Chanu seems to work for me.

Looks like you beat me to it! Glad it should be fixed though

melton-jason avatar Oct 28 '22 20:10 melton-jason

I was able to save both ExchangeIn/Out with attachments, query on the exchanges, and delete the exchanges. They seem to be working as intended as of the fix!

melton-jason avatar Oct 28 '22 21:10 melton-jason