Project

General

Profile

« Previous | Next » 

Revision 1956

Added by Matt Jones about 21 years ago

Enabled stylesheet parameters to be passed through metacat even when the
'query' function is called. Previously, query would interpret all
parameters except a few hardcoded ones to be pathexpressions that should be
built into a squery. Now, metacat.properties contains a new configuration
parameter called "query.ignored.params" which is a comma separated list of
paramters that should be passed through DBQuery.createSQuery without being
interpreted as a path expression. This allows these additional paramters to
be used in stylesheets and other places (html files) to customize the L&F
of particular skins.

The feature was implemented in order to allow the 'enableediting' parameter
for resultset.xsl to be passed through metacat without altering the query.
This parameter, when set to true, causes an 'edit' and 'delete' button to be
included for each record in the resultset. These buttons call the registry
edit and delete functions for the OBFS and (later) NRS and other registries.

View differences:

lib/style/skins/obfs/index.html
76 76
<p><b>Registry Tools</b></p>
77 77
<p>
78 78
<menu>
79
  <li><a href="@servlet-path@?action=query&amp;operator=INTERSECT&amp;anyfield=%25&amp;organizationName=Organization%20of%20Biological%20Field%20Stations&amp;qformat=obfs&amp;returndoctype=eml://ecoinformatics.org/eml-2.0.0&amp;returndoctype=-//ecoinformatics.org//eml-dataset-2.0.0beta6//EN&amp;returndoctype=-//ecoinformatics.org//eml-dataset-2.0.0beta4//EN&amp;returnfield=dataset/title&amp;returnfield=keyword&amp;returnfield=originator/individualName/surName&amp;returnfield=creator/individualName/surName&amp;returnfield=originator/organizationName&amp;returnfield=creator/organizationName">Browse existing OBFS data sets</a><br />
79
  <li><a href="@servlet-path@?action=query&amp;operator=INTERSECT&amp;anyfield=%25&amp;organizationName=Organization%20of%20Biological%20Field%20Stations&amp;qformat=obfs&amp;enableediting=true&amp;returndoctype=eml://ecoinformatics.org/eml-2.0.0&amp;returndoctype=-//ecoinformatics.org//eml-dataset-2.0.0beta6//EN&amp;returndoctype=-//ecoinformatics.org//eml-dataset-2.0.0beta4//EN&amp;returnfield=dataset/title&amp;returnfield=keyword&amp;returnfield=originator/individualName/surName&amp;returnfield=creator/individualName/surName&amp;returnfield=originator/organizationName&amp;returnfield=creator/organizationName">Browse existing OBFS data sets</a><br />
80 80
    <menu>
81 81
      The registry search system is used to locate data sets of interest
82 82
      by searching through existing registered data sets.  
lib/style/skins/obfs/header.html
67 67
  <input name="organizationName" value="Organization of Biological Field Stations" type="hidden">
68 68
  <input name="action" value="query" type="hidden">
69 69
  <input name="qformat" value="obfs" type="hidden">
70
  <input name="enableediting" value="true" type="hidden">
70 71
  <input name="operator" value="UNION" type="hidden">
71 72
  <input name="returnfield" value="originator/individualName/surName" type="hidden">
72 73
  <input name="returnfield" value="originator/individualName/givenName" type="hidden">
lib/style/skins/obfs/searchform.html
5 5
  <input name="organizationName" value="Organization of Biological Field Stations" type="hidden">
6 6
  <input name="action" value="query" type="hidden">
7 7
  <input name="qformat" value="obfs" type="hidden">
8
  <input name="enableediting" value="true" type="hidden">
8 9
  <input name="operator" value="UNION" type="hidden">
9 10
  <input name="returnfield" value="originator/individualName/surName" type="hidden">
10 11
  <input name="returnfield" value="originator/individualName/givenName" type="hidden">
lib/style/common/resultset.xsl
116 116
                 <input type="hidden" name="abstractpath" />
117 117
                 <!-- specified down IN javascript:submitform2('read','zip',docid) -->
118 118

  
119
                <input type="hidden" name="qformat" />
119
                 <input type="hidden" name="qformat" />
120
                 <xsl:if test="$enableediting = 'true'">
121
	 	           <input type="hidden" name="enableediting" value="{$enableediting}"/>
122
                 </xsl:if>
120 123
                 <input type="hidden" name="action" value="read"/>
121 124
                 <input type="hidden" name="docid">
122 125
                   <xsl:attribute name="value">
lib/metacat.properties
59 59
datafileflag=datafile
60 60
datafilesizelimit=1000
61 61
defaultcontenttype=@defaultcontenttype@
62
query.ignored.params=enableediting,foo
src/edu/ucsb/nceas/metacat/DBQuery.java
33 33

  
34 34
import edu.ucsb.nceas.morpho.datapackage.*;
35 35
import java.io.*;
36
import java.util.StringTokenizer;
36 37
import java.util.Vector;
37 38
import java.util.zip.*;
38 39
import java.net.URL;
......
954 955
      //make sure we aren't querying for any of these
955 956
      //parameters since the are already in the query
956 957
      //in one form or another.
957
      if (!nextkey.toString().equals("returndoctype") && 
958
         !nextkey.toString().equals("filterdoctype")  &&
959
         !nextkey.toString().equals("action")  &&
960
         !nextkey.toString().equals("qformat") && 
961
         !nextkey.toString().equals("anyfield") &&
962
         !nextkey.toString().equals("returnfield") &&
963
         !nextkey.toString().equals("owner") &&
964
         !nextkey.toString().equals("site") &&
965
         !nextkey.toString().equals("operator") )
966
      {
958
      Vector ignoredParams = new Vector();
959
      ignoredParams.add("returndoctype");
960
      ignoredParams.add("filterdoctype");
961
      ignoredParams.add("action");
962
      ignoredParams.add("qformat");
963
      ignoredParams.add("anyfield");
964
      ignoredParams.add("returnfield");
965
      ignoredParams.add("owner");
966
      ignoredParams.add("site");
967
      ignoredParams.add("operator");
968

  
969
      // Also ignore parameters listed in the properties file
970
      // so that they can be passed through to stylesheets
971
      String paramsToIgnore = MetaCatUtil.getOption("query.ignored.params");
972
      StringTokenizer st = new StringTokenizer(paramsToIgnore, ",");
973
      while (st.hasMoreTokens()) {
974
          ignoredParams.add(st.nextToken());
975
      }
976
      if (!ignoredParams.contains(nextkey.toString())) {
967 977
        //allow for more than value per field name
968
        for(int i=0; i<((String[])nextelement).length; i++)
969
        {
970
          if (!((String[])nextelement)[i].equals(""))
971
          {
978
        for(int i=0; i<((String[])nextelement).length; i++) {
979
          if (!((String[])nextelement)[i].equals("")) {
972 980
            query.append("<queryterm casesensitive=\"" + casesensitive +"\" " + 
973 981
                         "searchmode=\"" + searchmode + "\">" +
974 982
                         "<value>" +
src/edu/ucsb/nceas/metacat/MetaCatServlet.java
610 610
      outPutTime = System.currentTimeMillis()/1000;
611 611
      MetaCatUtil.debugMessage("Output time: "+(outPutTime-toStringTime), 30);
612 612
    } else {
613
      transformResultset(resultdoc, response, out, qformat, sessionid);
613
      transformResultset(resultdoc, response, out, qformat, sessionid, params);
614 614
      outPutTime = System.currentTimeMillis()/1000;
615 615
      MetaCatUtil.debugMessage("Output time: "+(outPutTime-toStringTime), 30);
616 616
    }
......
641 641
      response.setContentType("text/xml");
642 642
      out.println(resultdoc);
643 643
    } else {
644
      transformResultset(resultdoc, response, out, qformat, sessionid);
644
      transformResultset(resultdoc, response, out, qformat, sessionid, params);
645 645
    }
646 646
  }
647 647

  
......
733 733
  protected void transformResultset(String resultdoc,
734 734
                                    HttpServletResponse response,
735 735
                                    PrintWriter out, String qformat,
736
                                    String sessionid)
736
                                    String sessionid, Hashtable params)
737 737
  {
738 738

  
739 739
    try {
......
741 741
      DBTransform trans = new DBTransform();
742 742
      response.setContentType("text/html");
743 743
      trans.transformXMLDocument(resultdoc, "-//NCEAS//resultset//EN",
744
                                 "-//W3C//HTML//EN", qformat, out, null,
744
                                 "-//W3C//HTML//EN", qformat, out, params,
745 745
                                 sessionid);
746 746

  
747 747
    }

Also available in: Unified diff