if (id != null && schematronId != null && groupName != null) {
throw new IllegalArgumentException("Either one of " + Params.ID + " cannot be present if either "+ PARAM_GROUP_NAME + " or " + PARAM_SCHEMATRON_ID + " are also present.");
}
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));
if (criteria == null) {
throw new BadParameterEx(Params.ID, id);
}
element = new Element(Jeeves.Elem.RESPONSE).addContent(criteria.asXml());