src/it/finsiel/siged/dao/jdbc/DocumentaleDAOjdbc.java
public FileVO newFileVO(Connection connection, FileVO file)
            throws DataException {

        FileVO newFile = new FileVO();
        newFile.setReturnValue(ReturnValues.UNKNOWN);

        PreparedStatement pstmt = null;

        try {
            if (connection == null) {
                logger.warn("Connection is:" + connection);
                throw new DataException("La connessione fornita ? invalida.");
            }
            int n = 0;

            pstmt = connection.prepareStatement(INSERT_FILE,
                    ResultSet.TYPE_SCROLL_INSENSITIVE,
                    ResultSet.CONCUR_READ_ONLY);
            pstmt.setInt(++n, file.getId().intValue());
            pstmt.setInt(++n, file.getCartellaId());
            pstmt.setInt(++n, file.getRepositoryFileId());
            pstmt.setString(++n, file.getNomeFile());
            if (file.getDataDocumento() == null) {
                pstmt.setNull(++n, Types.DATE); // DATA_DOCUMENTO
            } else {
                pstmt.setDate(++n, new Date(file.getDataDocumento().getTime())); // DATA_DOCUMENTO
            }
            pstmt.setString(++n, file.getOggetto());
            pstmt.setString(++n, file.getNote());
            pstmt.setString(++n, file.getDescrizione());
            pstmt.setString(++n, file.getDescrizioneArgomento());
            pstmt.setInt(++n, file.getTipoDocumentoId());
            pstmt.setInt(++n, file.getTitolarioId());
            pstmt.setString(++n, file.getStatoDocumento());
            pstmt.setString(++n, file.getStatoArchivio());
            if (file.getUserLavId() == 0) {
                pstmt.setNull(++n, Types.INTEGER);
            } else {
                pstmt.setInt(++n, file.getUserLavId());
            }
            pstmt.setInt(++n, file.getOwnerId());
            if (file.getRowCreatedTime() == null) {
                pstmt.setNull(++n, Types.DATE); // DATA_DOCUMENTO
            } else {
                pstmt
                        .setDate(++n, new Date(file.getRowCreatedTime()
                                .getTime())); // DATA_DOCUMENTO
            }
            pstmt.setString(++n, file.getRowCreatedUser());
            pstmt.setInt(++n, file.getVersione());
            pstmt.executeUpdate();
            logger.debug("FileVO inserito - id= " + file.getId().intValue());

        } catch (Exception e) {
            logger.error("New FileVO ", e);
            throw new DataException("error.database.cannotsave");
        } finally {
            jdbcMan.close(pstmt);
        }

        // aggiornaIndice(connection);
        newFile = getFileVO(connection, file.getId().intValue());
        newFile.setReturnValue(ReturnValues.SAVED);
        return newFile;
    }
/*
     * Crea un file nella base dati,
     */
Crea un file nella base dati.
Crea un file nella base dati .
public FileVO newFileVO(Connection connection, FileVO file)
            throws DataException {
        FileVO newFile = new FileVO();
        newFile.setReturnValue(ReturnValues.UNKNOWN);
        PreparedStatement pstmt = null;
        try {
            if (connection == null) {
                logger.warn("Connection is:" + connection);
                throw new DataException("La connessione fornita ? invalida.");
            }
            int n = 0;
            pstmt = connection.prepareStatement(INSERT_FILE,
                    ResultSet.TYPE_SCROLL_INSENSITIVE,
                    ResultSet.CONCUR_READ_ONLY);
            pstmt.setInt(++n, file.getId().intValue());
            pstmt.setInt(++n, file.getCartellaId());
            pstmt.setInt(++n, file.getRepositoryFileId());
            pstmt.setString(++n, file.getNomeFile());
            if (file.getDataDocumento() == null) {
                pstmt.setNull(++n, Types.DATE); 
            } else {
                pstmt.setDate(++n, new Date(file.getDataDocumento().getTime())); 
            }
            pstmt.setString(++n, file.getOggetto());
            pstmt.setString(++n, file.getNote());
            pstmt.setString(++n, file.getDescrizione());
            pstmt.setString(++n, file.getDescrizioneArgomento());
            pstmt.setInt(++n, file.getTipoDocumentoId());
            pstmt.setInt(++n, file.getTitolarioId());
            pstmt.setString(++n, file.getStatoDocumento());
            pstmt.setString(++n, file.getStatoArchivio());
            if (file.getUserLavId() == 0) {
                pstmt.setNull(++n, Types.INTEGER);
            } else {
                pstmt.setInt(++n, file.getUserLavId());
            }
            pstmt.setInt(++n, file.getOwnerId());
            if (file.getRowCreatedTime() == null) {
                pstmt.setNull(++n, Types.DATE); 
            } else {
                pstmt
                        .setDate(++n, new Date(file.getRowCreatedTime()
                                .getTime())); 
            }
            pstmt.setString(++n, file.getRowCreatedUser());
            pstmt.setInt(++n, file.getVersione());
            pstmt.executeUpdate();
            logger.debug("FileVO inserito - id= " + file.getId().intValue());
        } catch (Exception e) {
            logger.error("New FileVO ", e);
            throw new DataException("error.database.cannotsave");
        } finally {
            jdbcMan.close(pstmt);
        }
        newFile = getFileVO(connection, file.getId().intValue());
        newFile.setReturnValue(ReturnValues.SAVED);
        return newFile;
    }
public FileVO newFileVO ( Connection connection , FileVO file ) throws DataException { FileVO newFile = new FileVO ( ) ; newFile . setReturnValue ( ReturnValues . UNKNOWN ) ; PreparedStatement pstmt = null ; try { if ( connection == null ) { logger . warn ( "Connection is:" + connection ) ; throw new DataException ( "La connessione fornita ? invalida." ) ; } int n = 0 ; pstmt = connection . prepareStatement ( INSERT_FILE , ResultSet . TYPE_SCROLL_INSENSITIVE , ResultSet . CONCUR_READ_ONLY ) ; pstmt . setInt ( ++ n , file . getId ( ) . intValue ( ) ) ; pstmt . setInt ( ++ n , file . getCartellaId ( ) ) ; pstmt . setInt ( ++ n , file . getRepositoryFileId ( ) ) ; pstmt . setString ( ++ n , file . getNomeFile ( ) ) ; if ( file . getDataDocumento ( ) == null ) { pstmt . setNull ( ++ n , Types . DATE ) ; } else { pstmt . setDate ( ++ n , new Date ( file . getDataDocumento ( ) . getTime ( ) ) ) ; } pstmt . setString ( ++ n , file . getOggetto ( ) ) ; pstmt . setString ( ++ n , file . getNote ( ) ) ; pstmt . setString ( ++ n , file . getDescrizione ( ) ) ; pstmt . setString ( ++ n , file . getDescrizioneArgomento ( ) ) ; pstmt . setInt ( ++ n , file . getTipoDocumentoId ( ) ) ; pstmt . setInt ( ++ n , file . getTitolarioId ( ) ) ; pstmt . setString ( ++ n , file . getStatoDocumento ( ) ) ; pstmt . setString ( ++ n , file . getStatoArchivio ( ) ) ; if ( file . getUserLavId ( ) == 0 ) { pstmt . setNull ( ++ n , Types . INTEGER ) ; } else { pstmt . setInt ( ++ n , file . getUserLavId ( ) ) ; } pstmt . setInt ( ++ n , file . getOwnerId ( ) ) ; if ( file . getRowCreatedTime ( ) == null ) { pstmt . setNull ( ++ n , Types . DATE ) ; } else { pstmt . setDate ( ++ n , new Date ( file . getRowCreatedTime ( ) . getTime ( ) ) ) ; } pstmt . setString ( ++ n , file . getRowCreatedUser ( ) ) ; pstmt . setInt ( ++ n , file . getVersione ( ) ) ; pstmt . executeUpdate ( ) ; logger . debug ( "FileVO inserito - id= " + file . getId ( ) . intValue ( ) ) ; } catch ( Exception e ) { logger . error ( "New FileVO " , e ) ; throw new DataException ( "error.database.cannotsave" ) ; } finally { jdbcMan . close ( pstmt ) ; } newFile = getFileVO ( connection , file . getId ( ) . intValue ( ) ) ; newFile . setReturnValue ( ReturnValues . SAVED ) ; return newFile ; }
Crea un file nella base dati,
Crea un file nella base dati
// DATA_DOCUMENTO // DATA_DOCUMENTO // DATA_DOCUMENTO // DATA_DOCUMENTO // aggiornaIndice(connection);