Revision 2134 tmp/org.txm.analec.rcp/src/org/txm/macro/urs/AnalecUtils.groovy

AnalecUtils.groovy (revision 2134)
54 54
static def selectSchemas(def debug, Corpus analecCorpus, String schema_ursql, Integer minimum_schema_size, Integer maximum_schema_size) {
55 55
	if (maximum_schema_size <= 0) maximum_schema_size = Integer.MAX_VALUE;
56 56
	def allSchemas = []
57
	if (schema_ursql != null && schema_ursql.length() > 0 || minimum_schema_size > 1) {
57
	if (schema_ursql != null && schema_ursql.length() > 0 || minimum_schema_size > 1 || maximum_schema_size >= 1) {
58 58

  
59 59
		if (schema_ursql != null && schema_ursql.length() > 0) allSchemas = AnalecUtils.findAllInCorpus(debug, analecCorpus, Schema.class, schema_ursql)
60 60
		else allSchemas = analecCorpus.getTousSchemas()
61 61

  
62 62
		if (debug >= 2) println "allSchemas=${allSchemas.size()}"
63
		if (minimum_schema_size > 1) allSchemas = AnalecUtils.filterBySize(allSchemas, minimum_schema_size, maximum_schema_size);
63
		if (minimum_schema_size > 1 || maximum_schema_size >= 1) allSchemas = AnalecUtils.filterBySize(allSchemas, minimum_schema_size, maximum_schema_size);
64 64
	} else {
65 65
		allSchemas = analecCorpus.getTousSchemas()
66 66
	}
......
235 235
}
236 236

  
237 237
static def filterBySize(def elements, Integer minSize, Integer maximum_schema_size) {
238
	if (maximum_schema_size == null || maximum_schema_size < 0) maximum_schema_size = Integer.MAX_VALUE;
238
	if (maximum_schema_size == null || maximum_schema_size <= 0) maximum_schema_size = Integer.MAX_VALUE;
239 239
	if (minSize == null || minSize < 0) minSize = 0;
240 240

  
241 241
	def filteredElements = []

Also available in: Unified diff