use of org.akaza.openclinica.service.crfdata.ErrorObj in project OpenClinica by OpenClinica.
the class CreateXformCRFVersionServlet method processRequest.
// public final String FM_BASEURL = "http://oc.local:8090/api/protocol/";
@Override
protected void processRequest() throws Exception {
CrfDao crfDao = (CrfDao) SpringServletAccess.getApplicationContext(context).getBean("crfDao");
XformMetaDataService xformService = (XformMetaDataService) SpringServletAccess.getApplicationContext(context).getBean("xformService");
Locale locale = LocaleResolver.getLocale(request);
ResourceBundleProvider.updateLocale(locale);
resword = ResourceBundleProvider.getWordsBundle(locale);
// Retrieve submission data from multipart request
DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List<FileItem> items = upload.parseRequest(request);
String crfName = retrieveFormFieldValue(items, "crfName");
DataBinder dataBinder = new DataBinder(new FormVersion());
Errors errors = dataBinder.getBindingResult();
int crfId = Integer.valueOf(retrieveFormFieldValue(items, "crfId"));
if (crfId != 0) {
CrfBean crfBean = crfDao.findByCrfId(crfId);
crfName = crfBean.getName();
}
FormArtifactTransferObj transferObj = getFormArtifactsFromFM(items, currentStudy.getOid(), crfName);
if (transferObj.getErr().size() != 0) {
for (ErrorObj er : transferObj.getErr()) {
errors.rejectValue("name", er.getCode(), er.getMessage());
}
} else {
List<OCodmComplexTypeDefinitionFormLayoutDef> formLayoutDefs = new ArrayList<>();
OCodmComplexTypeDefinitionFormLayoutDef formLayoutDef;
for (FormVersion version : transferObj.getForm().getVersions()) {
formLayoutDef = new OCodmComplexTypeDefinitionFormLayoutDef();
formLayoutDef.setOID(version.getName());
formLayoutDef.setURL(version.getArtifactURL());
formLayoutDefs.add(formLayoutDef);
}
ExecuteIndividualCrfObject eicObj = new ExecuteIndividualCrfObject(transferObj.getForm(), formLayoutDefs, errors, currentStudy, ub, false, null);
xformService.executeIndividualCrf(eicObj);
}
if (errors.hasErrors()) {
request.setAttribute("errorList", errors.getAllErrors());
}
forwardPage(Page.CREATE_XFORM_CRF_VERSION_SERVLET);
}
Aggregations