/** * Deletes a Certificate and saves the association. * * @return the struts forward */ @Action("deleteCertificate") public String deleteCertificateAction() { getLab().removeCertificate(certificate.getType()); associationService.save(laboratory); certificate = null; return INPUT; }
@Override public void prepare() { super.prepare(); if (getAssociationId() != null) { laboratory = associationService.getById(getAssociationId()); } else { laboratory = null; } resolveContentType(certificateFile); }
/** * Saves the Updated Clinical Lab Certificate data. * * @return the struts forward * @throws ParseException the dates were improperly formatted */ @Validations( requiredFields = { @RequiredFieldValidator( fieldName = "certificate.type", key = "clinical.laboratory.certificates.error.required.type"), @RequiredFieldValidator( fieldName = EXPIRATION_DATE_FIELD, key = "error.expiration.date.required"), @RequiredFieldValidator(fieldName = "certificateFile.data", key = "error.file.required") }, regexFields = { @RegexFieldValidator( fieldName = "effectiveDate", key = "error.date.month.year.format", regexExpression = "[01]?\\d/\\d{4}"), @RegexFieldValidator( fieldName = EXPIRATION_DATE_FIELD, key = "error.date.month.year.format", regexExpression = "[01]?\\d/\\d{4}") }) @Action("saveCertificate") public String saveCertificateAction() throws ParseException { if (getLab().getCertificate(certificate.getType()) != null) { certificate = getLab().getCertificate(certificate.getType()); } certificate.setEffectiveDate(FirebirdDateUtils.parseMonthAndYearStringOrNull(effectiveDate)); certificate.setExpirationDate(FirebirdDateUtils.parseMonthAndYearStringOrNull(expirationDate)); try { validateExpirationAndEffectiveDates(); File file = getCertificateFile().getData(); FileMetadata metadata = getCertificateFile().getMetadata(); associationService.handleCertificate(getLaboratory(), getCertificate(), file, metadata); } catch (IOException e) { LOG.error("An Error occurred saving a certificate to a lab", e); addActionError("A Problem has occurred while trying to save this certificate."); return INPUT; } catch (ValidationException e) { addFieldError(EXPIRATION_DATE_FIELD, getText("error.expiration.date.before.effective")); return INPUT; } certificate = null; effectiveDate = null; expirationDate = null; return INPUT; }