1 17 package org.alfresco.repo.webservice.repository; 18 19 import org.alfresco.util.GUID; 20 21 28 public abstract class AbstractQuerySession implements QuerySession 29 { 30 protected int batchSize; 31 protected int position = 0; 32 33 private String id; 34 35 40 public AbstractQuerySession(int batchSize) 41 { 42 this.id = GUID.generate(); 43 this.batchSize = batchSize; 44 } 45 46 49 public String getId() 50 { 51 return this.id; 52 } 53 54 60 protected int calculateLastRowIndex(int totalRowCount) 61 { 62 int lastRowIndex = totalRowCount; 63 64 if ((this.batchSize != -1) && ((this.position + this.batchSize) < totalRowCount)) 67 { 68 lastRowIndex = this.position + this.batchSize; 69 } 70 71 return lastRowIndex; 72 } 73 74 82 protected void updatePosition(int totalRowCount, QueryResult queryResult) 83 { 84 this.position += this.batchSize; 85 if (this.position >= totalRowCount) 86 { 87 this.position = -1; 89 queryResult.setQuerySession(null); 90 } 91 } 92 } 93 | Popular Tags |