Commit 069b5cb4 authored by Noel Alonso's avatar Noel Alonso
Browse files

Añade script de filtrado

parent 257f5496
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
def filterByConfidence = { confidence -> params.confidences.contains(confidence) }
def filterByPathTaxon = { pathTaxon -> params.taxons.contains(pathTaxon) }
def filterByMisidentification = {
	taxon -> taxon.registers.findAll { reg ->
		params.taxons.contains(reg.misidentification)
	}
}
def addRegisters = { taxon ->
	["registers": taxon.registers.findAll {
		reg -> filterByConfidence(reg.confidence)
	}]
}

_source.properties.registerCount = 0;
_source.properties.taxonCount = 0;

_source.properties.taxons.findAll { tax ->
	if (filterByPathTaxon(tax.path) || filterByPathTaxon(tax.equivalent) || filterByMisidentification(tax)) {
			tax << addRegisters(tax);

			if (tax.registers.size() > 0) {
				_source.properties.registerCount += tax.registers.size();
				_source.properties.taxonCount++;
				return true;
			}
			return false;
	}
	return false;
}

_source.properties.remove("taxons");