Changeset 2507
- Timestamp:
- 06/17/08 15:37:52 (6 months ago)
- Location:
- trunk
- Files:
-
- 5 modified
-
components/server/resources/ome/services/service-ome.api.Search.xml (modified) (1 diff)
-
components/server/src/ome/services/fulltext/EventLogLoader.java (modified) (4 diffs)
-
components/server/src/ome/tools/hibernate/QueryBuilder.java (modified) (1 diff)
-
components/server/test/ome/server/itests/search/PersistentEventLogLoaderTest.java (modified) (2 diffs)
-
etc/omero.properties (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/components/server/resources/ome/services/service-ome.api.Search.xml
r2495 r2507 81 81 <property name="types" ref="internal:ome.api.ITypes"/> 82 82 <property name="batchSize" value="${omero.search.batch}"/> 83 <property name="excludes" value="${omero.search.excludes}"/> 83 84 </bean> 84 85 -
trunk/components/server/src/ome/services/fulltext/EventLogLoader.java
r2495 r2507 9 9 10 10 import java.util.ArrayList; 11 import java.util.Arrays; 11 12 import java.util.Collections; 12 13 import java.util.Iterator; … … 18 19 import ome.parameters.Filter; 19 20 import ome.parameters.Parameters; 21 import ome.tools.hibernate.QueryBuilder; 20 22 21 23 /** … … 67 69 private EventLog log; 68 70 71 /** 72 * Array of class types which will get excluded from indexing. 73 */ 74 protected List<String> excludes = Collections.emptyList(); 75 76 /** 77 * Spring injector 78 */ 79 public void setExcludes(String[] excludes) { 80 this.excludes = Collections.unmodifiableList(Arrays.asList(excludes)); 81 } 82 69 83 protected IQuery queryService; 70 84 85 /** 86 * Spring injector 87 */ 71 88 public void setQueryService(IQuery queryService) { 72 89 this.queryService = queryService; … … 150 167 * Returns the {@link EventLog} with the next id after the given argument or 151 168 * null if none exists. This method will only return "true" {@link EventLog} 152 * instances, with a valid id. 169 * instances, with a valid id. The {@link #excludes} list is used to filter 170 * out unwanted {@link EventLog} isntances. 153 171 */ 154 172 public final EventLog nextEventLog(long id) { 155 return queryService.findByQuery("select el from EventLog el " 156 + "where el.id > :id order by id", new Parameters(new Filter() 157 .page(0, 1)).addId(id)); 173 List<String> copy = excludes; // Instead of synchronizing 174 QueryBuilder qb = new QueryBuilder(); 175 qb.select("el"); 176 qb.from("EventLog", "el"); 177 qb.where(); 178 qb.and("el.id > " + id); 179 if (copy != null) { 180 for (String exclude : copy) { 181 qb.and("el.entityType != '" + exclude + "'"); 182 } 183 } 184 qb.order("id", true); 185 String query = qb.queryString(); 186 187 return queryService.findByQuery(query, new Parameters(new Filter() 188 .page(0, 1))); 158 189 } 159 190 -
trunk/components/server/src/ome/tools/hibernate/QueryBuilder.java
r2109 r2507 257 257 } 258 258 259 /** 260 * Returns the current query as a String. As opposed to {@link #toString()}, 261 * this method should return parseable HQL. 262 */ 263 public String queryString() { 264 return sb.toString(); 265 } 266 259 267 @Override 260 268 public String toString() { -
trunk/components/server/test/ome/server/itests/search/PersistentEventLogLoaderTest.java
r2141 r2507 38 38 ome.model.meta.Session s = sm.create(new Principal("root", "system", 39 39 "FullText")); 40 final boolean[] result = new boolean[1]; 40 41 ex.execute(new Principal(s.getUuid(), "system", "FullText"), 41 42 new Executor.Work() { … … 51 52 } 52 53 } 53 assertTrue(ll.getCurrentId() > 0); 54 result[0] = ll.getCurrentId() > 0; 55 return null; 56 } 57 }); 58 assertTrue(result[0]); 59 } 60 61 public void testTestExcludes() throws Exception { 62 ome.model.meta.Session s = sm.create(new Principal("root", "system", 63 "FullText")); 64 ex.execute(new Principal(s.getUuid(), "system", "FullText"), 65 new Executor.Work() { 66 public Object doWork(TransactionStatus status, 67 Session session, ServiceFactory sf) { 68 ll.nextEventLog(0); 54 69 return null; 55 70 } -
trunk/etc/omero.properties
r2505 r2507 62 62 # Maximum number of OR-clauses to which a single search can expand 63 63 omero.search.maxclause=4096 64 65 # Indexing takes place on all EventLogs as the occur in the database. 66 # The types listed here will be skipped if they appear in the "entityType" 67 # field of the EventLog table. 68 omero.search.excludes=ome.model.core.PlaneInfo,ome.model.meta.Session 64 69 65 70 # Extra bridge classes, comma-separated, to be invoked on each indexing.
