public void writeProperties(CmsDbContext dbc, CmsResource resource, List<CmsProperty> properties, int publishTag)
    throws CmsDataAccessException {

        Connection conn = null;
        PreparedStatement stmt = null;

        Map<CmsProperty, CmsPropertyDefinition> propDefs = new HashMap<CmsProperty, CmsPropertyDefinition>();

        try {
            for (CmsProperty property : properties) {
                CmsPropertyDefinition propDef = null;
                try {
                    propDef = readPropertyDefinition(dbc, property.getName());
                } catch (CmsDbEntryNotFoundException e) {
                    // create if missing
                    propDef = createPropertyDefinition(dbc, property.getName(), CmsPropertyDefinition.TYPE_NORMAL);
                }
                propDefs.put(property, propDef);
            }
        } catch (CmsDataAccessException e) {
            throw new CmsDbSqlException(
                Messages.get().container(Messages.ERR_GENERIC_SQL_1, CmsDbSqlException.getErrorQuery(stmt)),
                e);
        } finally {
            m_sqlManager.closeAll(dbc, conn, stmt, null);
        }

        try {
            conn = m_sqlManager.getConnection(dbc);
            for (Map.Entry<CmsProperty, CmsPropertyDefinition> entry : propDefs.entrySet()) {

                for (int i = 0; i < 2; i++) {
                    int mappingType;
                    String value;
                    CmsUUID id;
                    if (i == 0) {
                        // write the structure value on the first cycle
                        value = entry.getKey().getStructureValue();
                        mappingType = CmsProperty.STRUCTURE_RECORD_MAPPING;
                        id = resource.getStructureId();
                        if (CmsStringUtil.isEmpty(value)) {
                            continue;
                        }
                    } else {
                        // write the resource value on the second cycle
                        value = entry.getKey().getResourceValue();
                        mappingType = CmsProperty.RESOURCE_RECORD_MAPPING;
                        id = resource.getResourceId();
                        if (CmsStringUtil.isEmpty(value)) {
                            break;
                        }
                    }

                    stmt = m_sqlManager.getPreparedStatement(conn, "C_PROPERTIES_HISTORY_CREATE");

                    stmt.setString(1, resource.getStructureId().toString());
                    stmt.setString(2, entry.getValue().getId().toString());
                    stmt.setString(3, id.toString());
                    stmt.setInt(4, mappingType);
                    stmt.setString(5, m_sqlManager.validateEmpty(value));
                    stmt.setInt(6, publishTag);

                    stmt.executeUpdate();
                    m_sqlManager.closeAll(dbc, null, stmt, null);
                }
            }
        } catch (SQLException e) {
            throw new CmsDbSqlException(
                Messages.get().container(Messages.ERR_GENERIC_SQL_1, CmsDbSqlException.getErrorQuery(stmt)),
                e);
        } finally {
            m_sqlManager.closeAll(dbc, conn, stmt, null);
        }
    }
public void writeProperties ( CmsDbContext dbc , CmsResource resource , List < CmsProperty > properties , int publishTag ) throws CmsDataAccessException { Connection conn = null ; PreparedStatement stmt = null ; Map < CmsProperty , CmsPropertyDefinition > propDefs = new HashMap < CmsProperty , CmsPropertyDefinition > ( ) ; try { for ( CmsProperty property : properties ) { CmsPropertyDefinition propDef = null ; try { propDef = readPropertyDefinition ( dbc , property . getName ( ) ) ; } catch ( CmsDbEntryNotFoundException e ) { propDef = createPropertyDefinition ( dbc , property . getName ( ) , CmsPropertyDefinition . TYPE_NORMAL ) ; } propDefs . put ( property , propDef ) ; } } catch ( CmsDataAccessException e ) { throw new CmsDbSqlException ( Messages . get ( ) . container ( Messages . ERR_GENERIC_SQL_1 , CmsDbSqlException . getErrorQuery ( stmt ) ) , e ) ; } finally { m_sqlManager . closeAll ( dbc , conn , stmt , null ) ; } try { conn = m_sqlManager . getConnection ( dbc ) ; for ( Map . Entry < CmsProperty , CmsPropertyDefinition > entry : propDefs . entrySet ( ) ) { for ( int i = 0 ; i < 2 ; i ++ ) { int mappingType ; String value ; CmsUUID id ; if ( i == 0 ) { value = entry . getKey ( ) . getStructureValue ( ) ; mappingType = CmsProperty . STRUCTURE_RECORD_MAPPING ; id = resource . getStructureId ( ) ; if ( CmsStringUtil . isEmpty ( value ) ) { continue ; } } else { value = entry . getKey ( ) . getResourceValue ( ) ; mappingType = CmsProperty . RESOURCE_RECORD_MAPPING ; id = resource . getResourceId ( ) ; if ( CmsStringUtil . isEmpty ( value ) ) { break ; } } stmt = m_sqlManager . getPreparedStatement ( conn , "C_PROPERTIES_HISTORY_CREATE" ) ; stmt . setString ( 1 , resource . getStructureId ( ) . toString ( ) ) ; stmt . setString ( 2 , entry . getValue ( ) . getId ( ) . toString ( ) ) ; stmt . setString ( 3 , id . toString ( ) ) ; stmt . setInt ( 4 , mappingType ) ; stmt . setString ( 5 , m_sqlManager . validateEmpty ( value ) ) ; stmt . setInt ( 6 , publishTag ) ; stmt . executeUpdate ( ) ; m_sqlManager . closeAll ( dbc , null , stmt , null ) ; } } } catch ( SQLException e ) { throw new CmsDbSqlException ( Messages . get ( ) . container ( Messages . ERR_GENERIC_SQL_1 , CmsDbSqlException . getErrorQuery ( stmt ) ) , e ) ; } finally { m_sqlManager . closeAll ( dbc , conn , stmt , null ) ; } }
@see org.opencms.db.I_CmsHistoryDriver#writeProperties(org.opencms.db.CmsDbContext, org.opencms.file.CmsResource, java.util.List, int)