final SchematronCriteriaRepository criteriaRepository = context.getBean(SchematronCriteriaRepository.class);
final Element element;
if (id == null) {
Specifications spec = null;
if (schematronId != null) {
spec = Specifications.where(SchematronCriteriaSpecs.hasSchematronId(Integer.parseInt(schematronId)));
}
if (groupName != null) {
final Specification<SchematronCriteria> hasGroupSpec = SchematronCriteriaSpecs.hasGroupName(groupName);
if (spec == null) {
spec = Specifications.where(hasGroupSpec);
} else {
spec = spec.and(hasGroupSpec);
}
}
element = criteriaRepository.findAllAsXml(spec);
} else {
final SchematronCriteria criteria = criteriaRepository.findOne(Integer.parseInt(id));