Project

General

Profile

« Previous | Next » 

Revision 3262

Added by berkley over 17 years ago

paging now works in a more normal manner. also fixed a bug where the last page would display too many results.

View differences:

lib/style/skins/kepler/resultset.xsl
135 135
            </p>
136 136
          </xsl:if>
137 137
          
138
          <!-- paging code here -->
138 139
          <xsl:if test="/resultset/pagesize &gt; 0">
139
          <table cellspacing="0" cellpadding="0" style="width: 100%;">
140
          <table cellspacing="0" cellpadding="0" style="width: 50%;">
140 141
          <tr>
141 142
          <td>
142
          <xsl:if test="/resultset/previouspage != -1">
143
            <div class="emphasis">
144
              <a style="font-size: smaller;">
145
                        <xsl:attribute name="href">
146
                          <xsl:text>metacat?action=query&amp;operator=INTERSECT&amp;enableediting=false</xsl:text>
147
                          
148
                          <xsl:if test="count(/resultset/query/pathquery/querygroup/queryterm/value) &gt; 0">
149
                            <xsl:text>&amp;anyfield=</xsl:text>
150
                            <xsl:value-of select="/resultset/query/pathquery/querygroup/queryterm/value"/>
151
                          </xsl:if>
152
                          
153
                          <xsl:if test="count(/resultset/query/pathquery/querygroup/queryterm/value) &lt;= 0">
154
                            <xsl:text>&amp;anyfield=%25</xsl:text>
155
                          </xsl:if>
156
                          
157
                          <xsl:text>&amp;qformat=</xsl:text>
158
                          <xsl:value-of select="$qformat"/>
159
                          
160
                          <xsl:text>&amp;sessionid=</xsl:text>
161
                          <xsl:value-of select="$sessid"/>
162
                          
163
                          <xsl:for-each select="/resultset/query/pathquery/returndoctype">
164
                            <xsl:text>&amp;returndoctype=</xsl:text>
165
                            <xsl:value-of select="."/>
166
                          </xsl:for-each>
167
                          
168
                          <xsl:for-each select="/resultset/query/pathquery/returnfield">
169
                            <xsl:text>&amp;returnfield=</xsl:text>
170
                            <xsl:value-of select="."/>
171
                          </xsl:for-each>
172
                          
173
                          <xsl:text>&amp;pagestart=</xsl:text>
174
                          <xsl:value-of select="/resultset/previouspage"/>
175
                          
176
                          <xsl:text>&amp;pagesize=</xsl:text>
177
                          <xsl:value-of select="/resultset/pagesize"/>
178
                        </xsl:attribute>
179
  
180
                        <xsl:text>Previous Page</xsl:text>
181
                      </a>
182
            </div>
183
          </xsl:if>
143
          <xsl:choose>
144
            <xsl:when test="/resultset/previouspage != -1">
145
              <div class="emphasis">
146
                <a style="font-size: smaller;">
147
                          <xsl:attribute name="href">
148
                            <xsl:text>metacat?action=query&amp;operator=INTERSECT&amp;enableediting=false</xsl:text>
149
                            
150
                            <xsl:if test="count(/resultset/query/pathquery/querygroup/queryterm/value) &gt; 0">
151
                              <xsl:text>&amp;anyfield=</xsl:text>
152
                              <xsl:value-of select="/resultset/query/pathquery/querygroup/queryterm/value"/>
153
                            </xsl:if>
154
                            
155
                            <xsl:if test="count(/resultset/query/pathquery/querygroup/queryterm/value) &lt;= 0">
156
                              <xsl:text>&amp;anyfield=%25</xsl:text>
157
                            </xsl:if>
158
                            
159
                            <xsl:text>&amp;qformat=</xsl:text>
160
                            <xsl:value-of select="$qformat"/>
161
                            
162
                            <xsl:text>&amp;sessionid=</xsl:text>
163
                            <xsl:value-of select="$sessid"/>
164
                            
165
                            <xsl:for-each select="/resultset/query/pathquery/returndoctype">
166
                              <xsl:text>&amp;returndoctype=</xsl:text>
167
                              <xsl:value-of select="."/>
168
                            </xsl:for-each>
169
                            
170
                            <xsl:for-each select="/resultset/query/pathquery/returnfield">
171
                              <xsl:text>&amp;returnfield=</xsl:text>
172
                              <xsl:value-of select="."/>
173
                            </xsl:for-each>
174
                            
175
                            <xsl:text>&amp;pagestart=</xsl:text>
176
                            <xsl:value-of select="/resultset/previouspage"/>
177
                            
178
                            <xsl:text>&amp;pagesize=</xsl:text>
179
                            <xsl:value-of select="/resultset/pagesize"/>
180
                          </xsl:attribute>
181
    
182
                          <xsl:text>Previous Page</xsl:text>
183
                        </a>
184
              </div>
185
            </xsl:when>
186
            <xsl:otherwise>
187
              <div class="emphasis-grey">
188
                Previous Page
189
              </div>
190
            </xsl:otherwise>
191
          </xsl:choose>
184 192
          </td>
185 193

  
186 194
          <td>
187
          <div class="emphasis">
188
            <a style="font-size: smaller;">
189
                      <xsl:attribute name="href">
190
                        <xsl:text>metacat?action=query&amp;operator=INTERSECT&amp;enableediting=false</xsl:text>
191
                        
192
                        <xsl:if test="count(/resultset/query/pathquery/querygroup/queryterm/value) &gt; 0">
193
                          <xsl:text>&amp;anyfield=</xsl:text>
194
                          <xsl:value-of select="/resultset/query/pathquery/querygroup/queryterm/value"/>
195
                        </xsl:if>
196
                        
197
                        <xsl:if test="count(/resultset/query/pathquery/querygroup/queryterm/value) &lt;= 0">
198
                          <xsl:text>&amp;anyfield=%25</xsl:text>
199
                        </xsl:if>
200
                        
201
                        <xsl:text>&amp;qformat=</xsl:text>
202
                        <xsl:value-of select="$qformat"/>
203
                        
204
                        <xsl:text>&amp;sessionid=</xsl:text>
205
                        <xsl:value-of select="$sessid"/>
206
                        
207
                        <xsl:for-each select="/resultset/query/pathquery/returndoctype">
208
                          <xsl:text>&amp;returndoctype=</xsl:text>
209
                          <xsl:value-of select="."/>
210
                        </xsl:for-each>
211
                        
212
                        <xsl:for-each select="/resultset/query/pathquery/returnfield">
213
                          <xsl:text>&amp;returnfield=</xsl:text>
214
                          <xsl:value-of select="."/>
215
                        </xsl:for-each>
216
                        
217
                        <xsl:text>&amp;pagestart=</xsl:text>
218
                        <xsl:value-of select="/resultset/nextpage"/>
219
                        
220
                        <xsl:text>&amp;pagesize=</xsl:text>
221
                        <xsl:value-of select="/resultset/pagesize"/>
222
                      </xsl:attribute>
223

  
224
                      <xsl:text>Next Page</xsl:text>
225
                    </a>
226
          </div>
195
          <xsl:choose>
196
            <xsl:when test="/resultset/lastpage = 'false'">
197
              <div class="emphasis">
198
                <a style="font-size: smaller;">
199
                          <xsl:attribute name="href">
200
                            <xsl:text>metacat?action=query&amp;operator=INTERSECT&amp;enableediting=false</xsl:text>
201
                            
202
                            <xsl:if test="count(/resultset/query/pathquery/querygroup/queryterm/value) &gt; 0">
203
                              <xsl:text>&amp;anyfield=</xsl:text>
204
                              <xsl:value-of select="/resultset/query/pathquery/querygroup/queryterm/value"/>
205
                            </xsl:if>
206
                            
207
                            <xsl:if test="count(/resultset/query/pathquery/querygroup/queryterm/value) &lt;= 0">
208
                              <xsl:text>&amp;anyfield=%25</xsl:text>
209
                            </xsl:if>
210
                            
211
                            <xsl:text>&amp;qformat=</xsl:text>
212
                            <xsl:value-of select="$qformat"/>
213
                            
214
                            <xsl:text>&amp;sessionid=</xsl:text>
215
                            <xsl:value-of select="$sessid"/>
216
                            
217
                            <xsl:for-each select="/resultset/query/pathquery/returndoctype">
218
                              <xsl:text>&amp;returndoctype=</xsl:text>
219
                              <xsl:value-of select="."/>
220
                            </xsl:for-each>
221
                            
222
                            <xsl:for-each select="/resultset/query/pathquery/returnfield">
223
                              <xsl:text>&amp;returnfield=</xsl:text>
224
                              <xsl:value-of select="."/>
225
                            </xsl:for-each>
226
                            
227
                            <xsl:text>&amp;pagestart=</xsl:text>
228
                            <xsl:value-of select="/resultset/nextpage"/>
229
                            
230
                            <xsl:text>&amp;pagesize=</xsl:text>
231
                            <xsl:value-of select="/resultset/pagesize"/>
232
                          </xsl:attribute>
233
    
234
                          <xsl:text>Next Page</xsl:text>
235
                        </a>
236
              </div>
237
            </xsl:when>
238
            <xsl:otherwise>
239
              <div class="emphasis-grey">
240
                Next Page
241
              </div>
242
            </xsl:otherwise>
243
          </xsl:choose>
227 244
          </td>
228 245
          </tr>
229 246
          </table>
230 247
          </xsl:if>
248
          <!-- end paging code -->
231 249
          
232 250
          <!-- This tests to see if there are returned documents,
233 251
              if there are not then don't show the query results -->
......
277 295
                      <xsl:text>Download</xsl:text>
278 296
                    </a>
279 297
                  </td>
280

  
281
                  <!--xsl:if test="$enableediting = 'true'">
282
                    <td class="text_plain">
283
                      <form action="@servlet-path@" method="get">
284
                        <input type="hidden" name="action" value="read"/>
285
                        <input type="hidden" name="qformat" value="{$qformat}"/>
286
                        <input type="hidden" name="sessionid"  value="{$sessid}"/>
287

  
288
                        <input type="hidden" name="docid">
289
                          <xsl:attribute name="value">
290
                            <xsl:value-of select="./docid"/>
291
                          </xsl:attribute>
292
                        </input>
293

  
294
                        <center>
295
                          <input type="SUBMIT"  value=" View " name="View"></input>
296
                        </center>
297
                      </form>
298

  
299
                      <form action="@cgi-prefix@/register-dataset.cgi" method="get">
300
                        <input type="hidden" name="stage" value="modify"/>
301
                        <input type="hidden" name="cfg" value="{$qformat}"/>
302
                        <input type="hidden" name="sessionid"  value="{$sessid}"/>
303

  
304
                        <input type="hidden" name="docid">
305
                          <xsl:attribute name="value">
306
                            <xsl:value-of select="./docid"/>
307
                          </xsl:attribute>
308
                        </input>
309

  
310
                        <center>
311
                          <input type="SUBMIT"  value=" Edit " name="Edit"></input>
312
                        </center>
313
                      </form>
314

  
315
                      <form action="@cgi-prefix@/register-dataset.cgi" method="get">
316
                        <input type="hidden" name="stage" value="delete"/>
317
                        <input type="hidden" name="cfg" value="{$qformat}"/>
318
                        <input type="hidden" name="sessionid"  value="{$sessid}"/>
319

  
320
                        <input type="hidden" name="docid">
321
                          <xsl:attribute name="value">
322
                            <xsl:value-of select="./docid"/>
323
                          </xsl:attribute>
324
                        </input>
325

  
326
                        <center>
327
                          <input type="SUBMIT"  value="Delete" name="Delete"></input>
328
                        </center>
329
                      </form>
330
                    </td>
331
                  </xsl:if-->
332 298
                </tr>
333 299

  
334 300
                <tr>
lib/style/skins/kepler/kepler.xml
16 16
  <doctype publicid="entity">
17 17
    <target publicid="-//W3C//HTML//EN">@systemidserver@/kepler/style/skins/kepler/entity.xsl</target>
18 18
  </doctype>
19
  <doctype publicid="kepler://kepler-project.org/kepler-moml-1.0.0">
20
    <target publicid="-//W3C//HTML//EN">@systemidserver@/kepler/style/skins/kepler/entity.xsl</target>
21
  </doctype>
22 19
</style-set>
lib/style/skins/kepler/kepler.css
305 305
.emphasis {
306 306
    font-weight: bold;
307 307
    font-size: 18px;
308
    color: #000000;
308
    color: #dd7744; 
309 309
}
310 310

  
311
.emphasis-grey {
312
    font-weight: bold;
313
    font-size: 18px;
314
    color: #dddddd; 
315
}
316

  
311 317
.colorbold {
312 318
	font-weight: bold;
313 319
	color: #096B79;
lib/style/skins/kepler/index.html
72 72
  <input name="returnfield" value="entity/property[@name='documentation']/property[@name='description']/configure" type="hidden">
73 73
  <input name="returnfield" value="entity/property[@name='documentation']/property[@name='userLevelDocumentation']/configure" type="hidden">
74 74
  <input name="returndoctype" value="entity" type="hidden">
75
  <input name="returndoctype" value="kepler://kepler-project.org/kepler-moml-1.0.0" type="hidden">
76 75
  <input value="Search" type="submit">
77 76
</form>
78 77
      The repository search system is used to locate analytical components of interest
......
83 82
      </menu>
84 83
  <p>&nbsp;</p>
85 84
  <li>
86
  <a href="@servlet-path@?action=query&qformat=kepler&enableediting=false&operator=UNION&returnfield=entity%2F%40name&returnfield=entity%2Fproperty%5B%40name%3D%27karId%27%5D%2F%40value&returnfield=entity%2Fproperty%5B%40name%3D%27documentation%27%5D%2Fproperty%5B%40name%3D%27author%27%5D%2Fconfigure&returnfield=entity%2Fproperty%5B%40name%3D%27documentation%27%5D%2Fproperty%5B%40name%3D%27version%27%5D%2Fconfigure&returnfield=entity%2Fproperty%5B%40name%3D%27documentation%27%5D%2Fproperty%5B%40name%3D%27description%27%5D%2Fconfigure&returnfield=entity%2Fproperty%5B%40name%3D%27documentation%27%5D%2Fproperty%5B%40name%3D%27userLevelDocumentation%27%5D%2Fconfigure&returndoctype=entity&returndoctype=kepler%3A%2F%2Fkepler-project.org%2Fkepler-moml-1.0.0&pagestart=0&pagesize=10">Browse existing Kepler analytical components</a>
85
  <a href="@servlet-path@?action=query&qformat=kepler&enableediting=false&operator=UNION&returnfield=entity%2F%40name&returnfield=entity%2Fproperty%5B%40name%3D%27karId%27%5D%2F%40value&returnfield=entity%2Fproperty%5B%40name%3D%27documentation%27%5D%2Fproperty%5B%40name%3D%27author%27%5D%2Fconfigure&returnfield=entity%2Fproperty%5B%40name%3D%27documentation%27%5D%2Fproperty%5B%40name%3D%27version%27%5D%2Fconfigure&returnfield=entity%2Fproperty%5B%40name%3D%27documentation%27%5D%2Fproperty%5B%40name%3D%27description%27%5D%2Fconfigure&returnfield=entity%2Fproperty%5B%40name%3D%27documentation%27%5D%2Fproperty%5B%40name%3D%27userLevelDocumentation%27%5D%2Fconfigure&returndoctype=entity&pagestart=0&pagesize=10">Browse existing Kepler analytical components</a>
87 86
  <br />
88 87
    <menu>
89 88
    Browse all existing data sets by title.  This operation can slow as the
lib/style/skins/kepler/header.html
57 57
<p class="searchbox">
58 58
Search for Data<br />
59 59
<form method="POST" action="@servlet-path@" target="_top">
60
  <input value="INTERSECT" name="operator" type="hidden">   
61 60
  <input size="14" name="anyfield" type="text" value="">
62
  <!--<input name="organizationName" value="Kruger National Park" type="hidden">-->
63 61
  <input name="action" value="query" type="hidden">
64 62
  <input name="qformat" value="kepler" type="hidden">
65 63
  <input name="enableediting" value="false" type="hidden">
66 64
  <input name="operator" value="UNION" type="hidden">
67 65
  <input name="returnfield" value="entity/@name" type="hidden">
66
  <input name="returnfield" value="entity/property[@name='documentation']/property[@name='author']/configure" type="hidden">
67
  <input name="returnfield" value="entity/property[@name='karId']/@value" type="hidden">
68
  <input name="returnfield" value="entity/property[@name='documentation']/property[@name='version']/configure" type="hidden">
69
  <input name="returnfield" value="entity/property[@name='documentation']/property[@name='description']/configure" type="hidden">
70
  <input name="returnfield" value="entity/property[@name='documentation']/property[@name='userLevelDocumentation']/configure" type="hidden">
68 71
  <input name="returndoctype" value="entity" type="hidden">
69
  <input name="returndoctype" value="kepler://kepler-project.org/kepler-moml-1.0.0" type="hidden">
72
  <input name="pagestart" value="0" type="hidden">
73
  <input name="pagesize" value="10" type="hidden">
70 74
  <!-- <input value="Start Search" type="submit"> -->
71 75
</form>
72 76
</p>
lib/style/skins/kepler/searchform.html
7 7
  <input name="enableediting" value="false" type="hidden">
8 8
  <input name="operator" value="UNION" type="hidden">
9 9
  <input name="returnfield" value="entity/@name" type="hidden">
10
  <input name="returnfield" value="entity/property[@name='documentation']/property[@name='author']/configure" type="hidden">
11
  <input name="returnfield" value="entity/property[@name='karId']/@value" type="hidden">
12
  <input name="returnfield" value="entity/property[@name='documentation']/property[@name='version']/configure" type="hidden">
13
  <input name="returnfield" value="entity/property[@name='documentation']/property[@name='description']/configure" type="hidden">
14
  <input name="returnfield" value="entity/property[@name='documentation']/property[@name='userLevelDocumentation']/configure" type="hidden">
10 15
  <input name="returndoctype" value="entity" type="hidden">
11
  <input name="returndoctype" value="kepler://kepler-project.org/kepler-moml-1.0.0" type="hidden">
16
  <input name="pagestart" value="0" type="hidden">
17
  <input name="pagesize" value="10" type="hidden">
12 18
  <input value="Start Search" type="submit">
13 19
</form>
src/edu/ucsb/nceas/metacat/DBQuery.java
471 471
      String createDate = null;
472 472
      String updateDate = null;
473 473
      StringBuffer document = null;
474
      boolean lastpage = false;
474 475
      int rev = 0;
475 476
      double startTime = 0;
476 477
      int offset = 1;
......
551 552
      int currentIndex = 0;
552 553
      while (tableHasRows)
553 554
      {
554
        logMetacat.warn("############getting result: " + currentIndex);
555
        //logMetacat.warn("############getting result: " + currentIndex);
555 556
        docid = rs.getString(1).trim();
556
        logMetacat.warn("############processing: " + docid);
557
        //logMetacat.warn("############processing: " + docid);
557 558
        docname = rs.getString(2);
558 559
        doctype = rs.getString(3);
559
        logMetacat.warn("############processing: " + doctype);
560
        //logMetacat.warn("############processing: " + doctype);
560 561
        createDate = rs.getString(4);
561 562
        updateDate = rs.getString(5);
562 563
        rev = rs.getInt(6);
......
672 673
                  new ResultDocument(docid, (String) document.toString()));
673 674
                currentIndex++;
674 675
                list.put(docid, docid);
675
                logMetacat.warn("$$$$$$$real result: " + docid);
676
                //logMetacat.warn("$$$$$$$real result: " + docid);
676 677
                count++;
677 678

  
678 679
                // Get the next package document linked to our hit
......
720 721
        if (count == offset && pagesize == 0)
721 722
        { //if pagesize is not 0, do this later.
722 723
          //reset count
723
          logMetacat.warn("############doing subset cache");
724
          //logMetacat.warn("############doing subset cache");
724 725
          count = 0;
725 726
          handleSubsetResult(qspec, resultsetBuffer, out, docListResult,
726 727
                              user, groups,dbconn, useXMLIndex);
......
728 729
          docListResult = new ResultDocumentSet();
729 730
        }
730 731
       
731
        logMetacat.warn("currentIndex: " + currentIndex);
732
       logMetacat.warn("currentIndex: " + currentIndex);
733
       logMetacat.warn("page comparator: " + (pagesize * pagestart) + pagesize);
732 734
       if(currentIndex >= ((pagesize * pagestart) + pagesize))
733 735
       {
734 736
         ResultDocumentSet pagedResultsHash = new ResultDocumentSet();
......
744 746
       tableHasRows = rs.next();
745 747
       if(!tableHasRows)
746 748
       {
749
         ResultDocumentSet pagedResultsHash = new ResultDocumentSet();
750
         //get the last page of information then break
751
         if(pagesize != 99999)
752
         {
753
           for(int i=pagesize*pagestart; i<docListResult.size(); i++)
754
           {
755
             pagedResultsHash.put(docListResult.get(i));
756
           }
757
           docListResult = pagedResultsHash;
758
         }
759
         
760
         lastpage = true;
747 761
         break;
748 762
       }
749 763
     }//while
......
760 774
                              user, groups,dbconn, useXMLIndex);
761 775
     }
762 776

  
777
     resultsetBuffer.append("\n<lastpage>" + lastpage + "</lastpage>\n");
778
     if (out != null)
779
     {
780
         out.println("\n<lastpage>" + lastpage + "</lastpage>\n");
781
     }
782
          
763 783
     return resultsetBuffer;
764 784
    }//findReturnDoclist
765 785

  

Also available in: Unified diff