Add/Update this record (Always called from the record class).
@exception DBException File exception.
507386
public void doAdd(Record record) throws DBException
    {
        m_LastModifiedBookmark = null;
        try   {
            m_pTable.add(this);
            m_LastModifiedBookmark = this.getHandle(DBConstants.BOOKMARK_HANDLE);
        } catch (DBException ex)    {
            throw DatabaseException.toDatabaseException(ex);
        }
    }
710592
public void doOpen() throws DBException
    {
        super.doOpen();
        try   {
            m_pTable.open(this);
        } catch (DBException ex)    {
            throw DatabaseException.toDatabaseException(ex);
        }
    }
144062
public void doAdd(Record record) throws DBException
    {
        record = this.moveRecordToBase(record);

        int iOpenMode = record.getOpenMode();
        RecordChangedHandler recordChangeListener = (RecordChangedHandler)record.getListener(RecordChangedHandler.class);
        Object[] rgobjEnabledFields = record.setEnableFieldListeners(false);
        boolean[] rgbEnabled = record.setEnableListeners(false);
        if (recordChangeListener != null)
        	recordChangeListener.setEnabledListener(true);	// I may need this listener (for an update) to do the update =ID AND =LastChangeDate
        
        try {
            record.setOpenMode(0);  // Normal add
            this.getNextTable().add(record);
        } catch (DBException ex) {
            throw ex;
        } finally {
            record.setOpenMode(iOpenMode);
            record.setEnableListeners(rgbEnabled);
            record.setEnableFieldListeners(rgobjEnabledFields);
        }
    }
114838
public void doAdd(Record record) throws DBException
    {
        if (this.lockOnDBTrxType(null, DBConstants.AFTER_ADD_TYPE, false))  // Should I do the unlock in my code?
            this.unlockIfLocked(this.getRecord(), null);    // Release any locks
        m_LastModifiedBookmark = null;
        CounterField fldID = (CounterField)record.getCounterField();
        if (fldID != null)
            if (!fldID.isNull())
                if (DBConstants.FALSE.equalsIgnoreCase(this.getProperty(SQLParams.AUTO_SEQUENCE_ENABLED)))
                    fldID = null;   // Special case - autosequence is disabled, so write the field.
        if (fldID != null)
            fldID.setModified(false); // Never set a counter field
        if (fldID != null)
            if (!this.getDatabase().isAutosequenceSupport())
        { // If the db does not support identity, you must get the next larger key by doing a select desc on the primary key
            this.doAddAutosequence(record);     // Special code to get next sequence
            return;
        }
        String strRecordset = record.getSQLInsert(SQLParams.USE_INSERT_UPDATE_LITERALS);
        int iType = DBConstants.SQL_INSERT_TABLE_TYPE;
        this.executeUpdate(strRecordset, iType);
    }
1222377
public void addListeners()
    {
        super.addListeners();
        this.addMainKeyBehavior();
        if (!this.getHeaderRecord().getField(ClassInfo.CLASS_NAME).isNull())
        {
            if (this.getMainRecord().getEditMode() != DBConstants.EDIT_CURRENT)
                if (this.getMainRecord().getEditMode() != DBConstants.EDIT_IN_PROGRESS)
                    this.getMainRecord().getField(FileHdr.FILE_NAME).moveFieldToThis(this.getHeaderRecord().getField(ClassInfo.CLASS_NAME));    // Current filename
        }
    }
1227415
public int update() throws SQLException {
		checkForDao();
		@SuppressWarnings("unchecked")
		T t = (T) this;
		return dao.update(t);
	}
764669
public void set(Rec record) throws DBException
    {
        if ((this.getRecord().getEditMode() != Constants.EDIT_CURRENT)
            && ((this.getRecord().getEditMode() != Constants.EDIT_IN_PROGRESS)))
                throw new DBException(Constants.INVALID_RECORD);
        m_record = (FieldList)record;
        this.fieldsToData(record);
        this.doSet(record);
        this.setDataSource(null);
        this.getRecord().setEditMode(Constants.EDIT_NONE);
    }
253848
public void addNew() throws DBException
    {
        if (((this.getRecord().getOpenMode() & DBConstants.OPEN_REFRESH_AND_LOCK_ON_CHANGE_STRATEGY) == 0)
            && ((this.getRecord().getOpenMode() & DBConstants.OPEN_READ_ONLY) != DBConstants.OPEN_READ_ONLY)
            && (this.getRecord().getCounterField() != null))
                this.getRecord().setOpenMode(this.getRecord().getOpenMode() | DBConstants.OPEN_REFRESH_AND_LOCK_ON_CHANGE_STRATEGY); // Must have for MirrorTable to sync new records
        super.addNew();
        Iterator<BaseTable> iterator = this.getTables();
        while (iterator.hasNext())
        {
            BaseTable table = iterator.next();
            if ((table != null) && (table != this.getNextTable()))
            {
                table.addNew();
            }
        }
    }
1123074
public void addListener(Record record, FileListener listener)
    {
        record.doAddListener(listener);
        boolean bOldState = listener.setEnabledListener(false);      // To disable recursive forever loop!
        BaseListener nextListener = listener.setNextListener(null);     // Make sure this is the ONLY listener in the chain to get this call
        if (record.getEditMode() == Constants.EDIT_ADD)
        {
            boolean[] rgbModified = this.getRecord().getModified();
            listener.doNewRecord(DBConstants.DISPLAY);
            this.getRecord().setModified(rgbModified);   // Restore since doNew should not change modified fields.
        }
        else if ((record.getEditMode() == Constants.EDIT_IN_PROGRESS) || (record.getEditMode() == Constants.EDIT_CURRENT))
            listener.doValidRecord(DBConstants.DISPLAY);
        listener.setNextListener(nextListener);
        listener.setEnabledListener(bOldState);   // Renable the listener to eliminate echos
    }
1180066
public void set(Rec fieldList) throws DBException
    {
        super.set(fieldList);
        Record record = (Record)fieldList;
        Iterator<BaseTable> iterator = this.getTables();
        while (iterator.hasNext())
        {
            BaseTable table = iterator.next();
            if ((table != null) && (table != this.getNextTable()))
            {
                if ((table.getRecord().getEditMode() == Constants.EDIT_IN_PROGRESS) || (table.getRecord().getEditMode() == Constants.EDIT_CURRENT))
                {
                    Record record2 = table.getRecord();
                    this.copyRecord(record2, record);
                    table.set(record2);
                }
                else if (table.getRecord().getEditMode() == Constants.EDIT_ADD)
                {   // Should have been in sync, but it is now!
                    Record record2 = table.getRecord();
                    boolean bIsAutoSequence = record2.setAutoSequence(false);
                    this.copyRecord(record2, record);
                    try {
                        table.add(record2);
                    } catch (DBException ex) {
                        throw ex;
                    } finally {
                        record2.setAutoSequence(bIsAutoSequence);
                    }
                }
            }
        }
    }
498685
public void open() throws DBException
    {
        m_bIsOpen = true;
        this.getRecord().setEditMode(Constants.EDIT_NONE);
        this.setDataSource(null);
    }
1134581
public void open() throws DBException
    {
        if (this.isOpen())
            return;         // Ignore if already open
        m_bIsOpen = false;
        this.getRecord().handleInitialKey();        // Set up the smaller key
        this.getRecord().handleEndKey();            // Set up the larger key
        this.doOpen();      // Now do the physical open in sub class.
        m_bIsOpen = true;
        m_iRecordStatus = DBConstants.RECORD_INVALID | DBConstants.RECORD_AT_BOF;
        if ((this.getRecord().getOpenMode() & DBConstants.OPEN_SUPPRESS_MESSAGES) == 0)
            this.getRecord().handleRecordChange(DBConstants.AFTER_REQUERY_TYPE);    // Notify listeners that a new table will be built
    }
415092
public synchronized void add(FieldTable table) throws DBException
    {
        if (m_VKeyList == null)
            this.initKeyAreas(table);

        BaseBuffer bufferNew = (BaseBuffer)table.getDataSource(); // same as .getHandle(Constants.DATA_SOURCE_HANDLE);
        if (table.getRecord().getEditMode() == Constants.EDIT_ADD)
        {
            for (int iKeyArea = Constants.MAIN_KEY_AREA; iKeyArea < table.getRecord().getKeyAreaCount() + Constants.MAIN_KEY_AREA; iKeyArea++)
            {
                try   {
                    if (iKeyArea == Constants.MAIN_KEY_AREA)
                    {   // Special logic to set auto-counter field
                        FieldInfo field = table.getRecord().getCounterField();
                        if (field != null)
                            if (!field.isNull())
                                if (!table.getRecord().isAutoSequence())
                        {   // Autosequence disabled
                            int iValue = (int)field.getValue();
                            if (iValue >= m_iCounter)
                                m_iCounter = iValue + 1;    // New next counter value
                            field = null;   // Special case - autosequence is disabled, so write the field as is.
                        }
                        if (field != null)
                        {
                            field.setValue(m_iCounter++, Constants.DONT_DISPLAY, Constants.READ_MOVE);  // ReadMove keeps this method from being called again
                            table.fieldsToData(table.getRecord()); // Update buffer
                            bufferNew = (BaseBuffer)table.getDataSource();  // same as .getHandle(Constants.DATA_SOURCE_HANDLE);
                        }
                    }
                    bufferNew.bufferToFields(table.getRecord(), Constants.DONT_DISPLAY, Constants.READ_MOVE);
                    this.getPKeyArea(iKeyArea).doWrite(table, table.getRecord().getKeyArea(iKeyArea), bufferNew);
                } catch (DBException ex)    {
                    if (ex.getErrorCode() == Constants.DUPLICATE_KEY)
                    {
                        iKeyArea--;     // Duplicate key, delete all keys added so far!!!
                        while (iKeyArea >= Constants.MAIN_KEY_AREA)
                        {
                            bufferNew.bufferToFields(table.getRecord(), Constants.DONT_DISPLAY, Constants.READ_MOVE);
                            this.getPKeyArea(iKeyArea).doRemove(table, table.getRecord().getKeyArea(iKeyArea), bufferNew);
                            iKeyArea--;
                        }
                    }
                    throw ex;
                }
            }
            // Restore the record before returing (key.doWrite probably changed it).
            bufferNew.bufferToFields(table.getRecord(), Constants.DONT_DISPLAY, Constants.READ_MOVE);
        }
        else
            throw new DBException(Constants.INVALID_RECORD);
    }
1347248
public int update(Entity record, Entity where) throws SQLException {
		Connection conn = null;
		try {
			conn = this.getConnection();
			return runner.update(conn, record, where);
		} catch (SQLException e) {
			throw e;
		} finally {
			this.closeConnection(conn);
		}
	}
372386
public void doRemove() throws DBException
    {
        super.doRemove();
        if (m_arrayCache != null)
            if (m_iLogicalIndex != -1)
                m_arrayCache.set(m_iLogicalIndex, null);    // Show the current record as deleted.
    }
470112
private void updateTable(Connection connection) throws DatabaseException {
        try {
			// Add the SOURCEHISTORYID column to the db if necessary
			if (!DbUtils.hasColumn(connection, TABLE_NAME, SOURCEHISTORYID)) {
			    DbUtils.execute(connection, "ALTER TABLE "+TABLE_NAME+" ADD COLUMN "+SOURCEHISTORYID+" INT DEFAULT 0");
			}
			
			// Add the ATTACK column to the db if necessary
			if (!DbUtils.hasColumn(connection, TABLE_NAME, ATTACK)) {
			    DbUtils.execute(connection, "ALTER TABLE "+TABLE_NAME+" ADD COLUMN "+ATTACK+" VARCHAR(32768) DEFAULT ''");
			}
			
			if (!DbUtils.hasColumn(connection, TABLE_NAME, EVIDENCE)) {
				// Evidence, cweId and wascId all added at the same time
			    DbUtils.execute(connection, "ALTER TABLE "+TABLE_NAME+" ADD COLUMN "+EVIDENCE+" VARCHAR(16777216) DEFAULT ''");
			    DbUtils.execute(connection, "ALTER TABLE "+TABLE_NAME+" ADD COLUMN "+CWEID+" INT DEFAULT -1");
			    DbUtils.execute(connection, "ALTER TABLE "+TABLE_NAME+" ADD COLUMN "+WASCID+" INT DEFAULT -1");
			}
			
			if (!DbUtils.hasIndex(connection, TABLE_NAME, ALERT_INDEX)) {
				// this speads up session loading
				DbUtils.execute(connection, "CREATE INDEX "+ALERT_INDEX+" ON "+TABLE_NAME+" ("+SOURCEHISTORYID+")");
			}

			if (!DbUtils.hasColumn(connection, TABLE_NAME, SOURCEID)) {
				DbUtils.execute(connection, "ALTER TABLE "+TABLE_NAME+" ADD COLUMN "+SOURCEID+" INT DEFAULT 0");
				DbUtils.execute(connection, "CREATE INDEX INDEX_ALERT_SOURCEID ON "+TABLE_NAME+" ("+SOURCEID+")");
			}
		} catch (SQLException e) {
			throw new DatabaseException(e);
		}
        
    }
361406
public void addRecord(String key,
                          boolean b)
                          throws TarMalformatException, IOException {
        addRecord(key, Boolean.toString(b));
    }