Search in sources :

Example 1 with CommissioningFile

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;
}
Also used : CommissioningFile(com.autentia.tnt.businessobject.CommissioningFile) IOException(java.io.IOException) Date(java.util.Date)

Example 2 with CommissioningFile

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;
}
Also used : CommissioningFile(com.autentia.tnt.businessobject.CommissioningFile) UIData(javax.faces.component.UIData)

Aggregations

CommissioningFile (com.autentia.tnt.businessobject.CommissioningFile)2 IOException (java.io.IOException)1 Date (java.util.Date)1 UIData (javax.faces.component.UIData)1