[ 
https://jira.duraspace.org/browse/DS-749?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21096#action_21096
 ] 

Tim Donohue commented on DS-749:
--------------------------------

Hi Jose,

A few comments on this work, based on feedback from the Committers, etc.

Based on our Code Contribution Guidelines, all code in DSpace must be written 
in Java.  So, at this point in time, we unfortunately cannot accept 
contributions which require Perl, etc.  The main reason for this guideline is 
that we want to simplify the install process for DSpace (and not require Perl 
as an additional pre-requisite, etc.)    Please see our Code Contribution 
Guidelines at: 
https://wiki.duraspace.org/display/DSPACE/Code+Contribution+Guidelines  
(Especially, take a look at the "Contribution Checklist" on that page -- though 
the entire page provides some helpful information on getting patches/changes 
accepted into DSpace).   

One sidenote: in order to make JIRA tickets a little easier to read & review, 
I'd also recommend just attaching patch files directly to the JIRA ticket 
(rather than copying & pasting the text of the patch into the ticket 
Description).  It just makes it easier on the Committers to review individual 
patches (if it's in the description we have to manually apply the changes to 
each file one-by-one, which takes time). Plus, it makes it easier for you to 
update the patch later on, if necessary (by just attaching a new file to the 
JIRA ticket to replace the existing patch).

If you have other questions on this, don't hesitate to ask.  We appreciate all 
the patches/improvements you have been providing! We'd also encourage you to 
share your implementation ideas earlier on dspace-devel mailing list, at which 
point we can provide earlier suggestions or help.

Thanks!
- Tim

> allow for bitstream display order to be changed
> -----------------------------------------------
>
>                 Key: DS-749
>                 URL: https://jira.duraspace.org/browse/DS-749
>             Project: DSpace
>          Issue Type: New Feature
>          Components: JSPUI
>            Reporter: Jose Blanco
>
> This patch allows user with access priviledges to edit an item to change the 
> order in which a bitstream is displayed 
> in the item display.  This patch is for the JSPUI. 
> The first thing that needs to be done is that a new field needs to be added 
> to the bitstream table with the following SQL:
> alter table bitstream add display_order integer;
> Then that field needs to be populated with the values in the sequence_id 
> table.  I have provided a perl script 
> that I used to do this: fix-display-order.
> Once this is done, make the following code changes.
> File =>tools/edit-item-form.jsp
> +             <th id="t11" class="oddRowOddCol"><strong><fmt:message 
> key="jsp.tools.edit-item-form.elem10"/></strong></th>
>               <th id="t11" class="oddRowEvenCol"><strong><fmt:message 
> key="jsp.tools.edit-item-form.elem5"/></strong></th>
> AND
> +                <td headers="t11" class="<%= row %>RowOddCol">
> +                    <input type="text" name="bitstream_order_<%= key %>" 
> value="<%= (Integer.toString(bitstreams[j].getDisplayOrder()) == null ? "" : 
> Integer.toString(bitstreams[j].getDisplayOrder())) %>" size="4"/>
> +                </td>
>               <% if (bundles[i].getName().equals("ORIGINAL"))
>                  { %>
> File => Messages.properties
> jsp.tools.edit-item-form.elem9                                  = Description
> +jsp.tools.edit-item-form.elem10                                = 
> Display<BR>Order
> file Biststream.java
> +     public int getDisplayOrder()
> +     {
> +         return bRow.getIntColumn("display_order");
> +     }
> + 
> +     public void setDisplayOrder(int order)
> +     {
> +         bRow.setColumn("display_order", order);
> +         modifiedMetadata = true;
> +         addDetails("DisplayOrder");
> +     }
>  
> File => Item.java
>                 if (streams[k].getSequenceID() < 0)
>                 {
>                     streams[k].setSequenceID(sequence);
> +                    streams[k].setDisplayOrder(sequence);
>                     sequence++;
>                     streams[k].update();
>                 }
> File => Bundle.java
> -                        + "bundle2bitstream.bundle_id= ? ",
> +                         + "bundle2bitstream.bundle_id= ? "
> +                       + "ORDER BY bitstream.display_order",
> File =>  EditItemServlet.java
>                     int formatID = UIUtil.getIntParameter(request,
>                             "bitstream_format_id_" + key);
> +                    int display_order = UIUtil.getIntParameter(request,
> +                            "bitstream_order_" + key);
> AND
>                     bitstream.setName(name);
>                     bitstream.setSource(source);
>                     bitstream.setDescription(desc);
> +                    bitstream.setDisplayOrder(display_order);
> ==============================================
> This is the fix-display-order perl script used to iniailize display_order:
> #!/usr/bin/perl
> RE.
> BEGIN
> {
>         require "strict.pm";
>         strict::import();
> }
> # ----------------------------------------------------------------------
> #               start of MAIN
> # ----------------------------------------------------------------------
> use Encode;
> use utf8;
> use DBI;
> use File::Path;
> my $dbhP = DBI->connect("dbi:Pg:dbname=dspace-name", "dspace-user", 
> "password");
> &UpdateDisplayOrder ();
> $dbhP->disconnect;
> exit;
> sub UpdateDisplayOrder
> {
>     
>   my $statement = qq{select bitstream_id, sequence_id from bitstream};
>     my $sth = $dbhP->prepare($statement)
>       or die "Couldn't prepare statement: " . $dbhP->errstr;
>     
>     # Read the matching records and print them out
>     $sth->execute()             # Execute the query
>       or die "Couldn't execute statement: " . $sth->errstr;
>     my $count = 0;
>     my ( $url, $msg );
>     my ( $bitstream_id, $sequence_id, @data );
>     while (@data = $sth->fetchrow_array()) {
>       $bitstream_id       = $data[0];
>       $sequence_id        = $data[1];
>      
>       if ( $sequence_id )
>       {
>       my $sql = qq{update bitstream set display_order = $sequence_id where 
> bitstream_id= $bitstream_id};
>         &ProcessSQL ( $sql );
>       }
>     }
>     $sth->finish;
> }
> sub ProcessSQL 
>   {
>     my ( $statement ) = @_;
>     my $sth = $dbhP->prepare($statement)
>       or die "Couldn't prepare statement: " . $dbhP->errstr;
>   
>     # Read the matching records and print them out
>     $sth->execute()             # Execute the query
>       or die "Couldn't execute statement: " . $sth->errstr;
>     $sth->finish;
>   }
> __END__;
> ==============================================

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://jira.duraspace.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
_______________________________________________
Dspace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-devel

Reply via email to