use of com.autentia.tnt.businessobject.CommissioningFile in project TNTConcept by autentia.
the class CommissioningBean method doBeforeSave.
@Override
public String doBeforeSave() {
String result = super.doBeforeSave();
// performs file upload
try {
if (uploadFile != null) {
String fileName = FileUtil.getFileName(uploadFile.getName());
if (uploader.exists(Integer.toString(commissioning.getId()), fileName)) {
// el fichero ya existe y lo versionamos
fileName = uploader.version(Integer.toString(commissioning.getId()), fileName, uploadFile);
} else {
uploader.store(Integer.toString(commissioning.getId()), uploadFile);
}
final CommissioningFile file = new CommissioningFile();
file.setInsertDate(new Date());
file.setUser(authManager.getCurrentPrincipal().getUser());
file.setCommissioning(commissioning);
file.setFile(fileName);
file.setFileMime(uploadFile.getContentType());
commissioning.getFiles().add(file);
}
} catch (IOException e) {
log.error("save - exception uploading field file", e);
FacesUtils.addErrorMessage("commissioning:file", "error.fileTransfer", uploadFile.getName());
return NavigationResults.EDIT;
}
return result;
}
use of com.autentia.tnt.businessobject.CommissioningFile in project TNTConcept by autentia.
the class CommissioningBean method deleteFile.
public String deleteFile() {
UIData table = (UIData) FacesUtils.getComponent("commissioning:list");
CommissioningFile toDelete = (CommissioningFile) table.getRowData();
commissioning.getFiles().remove(toDelete);
return null;
}
Aggregations