return new Element("NoUpdate");
}
private Element renameGroup(Element params, ServiceContext context) {
final SchematronCriteriaGroupRepository repository = context.getBean(SchematronCriteriaGroupRepository.class);
String groupName = Util.getParam(params, PARAM_GROUP_NAME);
int schematronId = Integer.parseInt(Util.getParam(params, PARAM_SCHEMATRON_ID));
String newRequirement = Util.getParam(params, PARAM_REQUIREMENT, null);
final SchematronCriteriaGroup group = repository.findOne(new SchematronCriteriaGroupId(groupName, schematronId));
SchematronRequirement finalRequirement = group.getRequirement();
if (newRequirement != null) {
finalRequirement = SchematronRequirement.valueOf(newRequirement.toUpperCase());
}
String newGroupName = Util.getParam(params, PARAM_NEW_GROUP_NAME, groupName);
int newSchematronId = Util.getParam(params, PARAM_NEW_SCHEMATRON_ID, schematronId);
SchematronCriteriaGroup newGroup = new SchematronCriteriaGroup().
setId(new SchematronCriteriaGroupId(newGroupName, newSchematronId)).
setRequirement(finalRequirement);
for (SchematronCriteria schematronCriteria : group.getCriteria()) {
newGroup.addCriteria(schematronCriteria.copy());
}
if (group.getId().equals(newGroup.getId())) {
throw new BadInputEx(PARAM_NEW_GROUP_NAME + " and " + PARAM_NEW_SCHEMATRON_ID +
" have the same value as the old values", newGroupName+":"+newSchematronId){};
}
repository.delete(group.getId());
repository.saveAndFlush(newGroup);
return new Element("ok");
}