/** * Get the table name. */ public String getTableNames(boolean bAddQuotes) { return (m_tableName == null) ? DatabaseInfo.DATABASE_INFO_FILE : super.getTableNames(bAddQuotes); } /**
/** * Get the autosequence field if it exists. * @return The counterfield or null. */ public FieldInfo getCounterField() { return this.getField(Constants.MAIN_FIELD); } /**
/** * Set up the key areas. */ public void setupKeys() { KeyAreaInfo keyArea = null; super.setupKeys(); }
/** * I'm done with the model, free the resources. * Note: This does not free the associated record. it just nulls the reference. * (although freeing the record will free this table). */ public void free() { if (m_record != null) // First, release the record for this table { // Do not free this.getFieldList() (may be current record) m_record.setTable(null); // Don't try to free me m_record.free(); m_record = null; } } /**
/** * Reset all the fields to their default value. * <p />NOTE: After executing, this records edit mode is set to NONE. * @param bDisplay The the new values (on work in the thick model). * @throws Exception An exception on initing a field. */ public void initRecord(boolean bDisplay) throws DBException { int iFieldCount = this.getFieldCount(); // Number of fields to read in for (int iFieldSeq = Constants.MAIN_FIELD; iFieldSeq < iFieldCount + Constants.MAIN_FIELD; iFieldSeq++) { FieldInfo field = this.getField(iFieldSeq); field.initField(bDisplay); } this.setEditMode(Constants.EDIT_NONE); } /**
if ((this.getEditMode() == Constants.EDIT_CURRENT) || (this.getEditMode() == Constants.EDIT_IN_PROGRESS)) Object bookmark = this.getCounterField().getData(); if (bookmark != null) int iOldOpenMode = this.getOpenMode(); this.setOpenMode(Constants.OPEN_REFRESH_TO_CURRENT | (iOldOpenMode/* & Constants.LOCK_TYPE_MASK*/)); // This is only trigger server listeners for changes && (this.isModified())) boolean bLockRecord = this.getEditMode() == Constants.EDIT_IN_PROGRESS; rgbModified = new boolean[this.getFieldCount()]; for (int iFieldSeq = 0; iFieldSeq < this.getFieldCount(); iFieldSeq++) rgbModified[iFieldSeq] = this.getField(iFieldSeq).isModified(); String strOldKey = this.getKeyName(); this.setKeyName(Constants.PRIMARY_KEY); this.getCounterField().setData(bookmark); boolean bSuccess = this.getTable().seek(null); this.setKeyName(strOldKey); this.getTable().addNew(); else this.getTable().edit(); // If I haven't changed any data, just refresh it. buffer.resetPosition();
/** * Convert this record to a string. * @return A string of all the fields. */ public String toString() { String string = Constants.BLANK; for (int iFieldSeq = Constants.MAIN_FIELD; iFieldSeq <= this.getFieldCount() + Constants.MAIN_FIELD - 1; iFieldSeq++) { FieldInfo field = this.getField(iFieldSeq); string += field.toString() + '\n'; } string += '\n'; return string; } /**
/** * Log this transaction. * @param strTrxType The transaction type. */ public void logTrx(FieldList record, String strTrxType) { BaseBuffer buffer = this.getBuffer(); buffer.clearBuffer(); buffer.addHeader(strTrxType); buffer.addHeader(record.getTableNames(false)); buffer.addHeader(record.getCounterField().toString()); if (ProxyConstants.REMOVE != strTrxType) buffer.fieldsToBuffer(record); Object objLogData = buffer.getPhysicalData(); this.logTrx(objLogData); } /**
if ((strKeyValue != null) && (strKeyValue.length() > 0)) if ((recBooking.getEditMode() == Constants.EDIT_CURRENT) || (recBooking.getEditMode() == Constants.EDIT_IN_PROGRESS)) if (iBookingNo == recBooking.getField(Booking.ID).getValue()) return true; // Already read if (strKeyValue.equalsIgnoreCase(recBooking.getField(Booking.CODE).toString())) return true; // Already read recBooking.getTable().addNew(); recBooking.getField(strKeyField).setString(strKeyValue); String strOldKeyArea = recBooking.getKeyName(); recBooking.setKeyArea(strKeyField); bSuccess = recBooking.getTable().seek(Constants.EQUALS); recBooking.setKeyArea(strOldKeyArea); if (bSuccess) bSuccess = this.getTourRecord().getTable().seek(Constants.SEEK_CURRENT_RECORD); if (bSuccess) bSuccess = this.getCurrencyRecord().getTable().seek(Constants.SEEK_CURRENT_RECORD); recBooking.getTable().addNew(); // Clean the booking record this.getRemoteSession().doRemoteAction(Constants.RESET, null); // Tell the remote session that I'm done with this booking this.getTourRecord().getTable().addNew(); // Clear tour record bSuccess = true;
/** * Constructor. */ public void init(FieldList record, String strStartDateTimeField, String strEndDateTimeField, String strDescriptionField, String strStatusField) { m_table = record.getTable(); m_strDescriptionField = strDescriptionField; m_strStartDateTimeField = strStartDateTimeField; m_strEndDateTimeField = strEndDateTimeField; m_strStatusField = strStatusField; } /**
/** * Free. */ public void free() { if (this.getFieldList(MealPlan.MEAL_PLAN_FILE) != null) { // Since the meal plan popup record is shared, I need to free it then disconnect it from the controls. this.getFieldList(MealPlan.MEAL_PLAN_FILE).free(); FieldList fieldList = this.getFieldList(); for (int iFieldSeq = 0; iFieldSeq < fieldList.getFieldCount(); iFieldSeq++) { FieldInfo field = fieldList.getField(iFieldSeq); Component component = null; int iIndex = 0; while ((component = (Component)field.getComponent(iIndex)) != null) { if (component instanceof JRemoteComboBox) if (((JRemoteComboBox)component).getRecord() == this.getFieldList(MealPlan.MEAL_PLAN_FILE)) ((JRemoteComboBox)component).setRecord(null); iIndex++; // Bump counter } } this.removeFieldList(this.getFieldList(MealPlan.MEAL_PLAN_FILE)); } super.free(); } /**
if (table.getRecord().getEditMode() == Constants.EDIT_ADD) for (int iKeyArea = Constants.MAIN_KEY_AREA; iKeyArea < table.getRecord().getKeyAreaCount() + Constants.MAIN_KEY_AREA; iKeyArea++) FieldInfo field = table.getRecord().getCounterField(); if (field != null) if (!field.isNull()) if (!table.getRecord().isAutoSequence()) this.getPKeyArea(iKeyArea).doWrite(table, table.getRecord().getKeyArea(iKeyArea), bufferNew); } catch (DBException ex) { if (ex.getErrorCode() == Constants.DUPLICATE_KEY) this.getPKeyArea(iKeyArea).doRemove(table, table.getRecord().getKeyArea(iKeyArea), bufferNew); iKeyArea--;
/** * */ private FieldList cloneFieldList(FieldList item) { FieldList fieldList = new FieldList(null); for (int i = 0; i < item.getFieldCount(); i++) { FieldInfo fldSource = item.getField(i); FieldInfo fldDest = new FieldInfo(fieldList, fldSource.getFieldName(), fldSource.getMaxLength(), fldSource.getFieldDesc(), fldSource.getDefault()); fldDest.setDataClass(fldSource.getDataClass()); } return fieldList; } /**
Integer intID = (Integer)recBooking.getField(strFieldName).getData(); recPricingType.getField("ID").setData(intID); try { if (recPricingType.getTable().seek(null)) int intPricingCodes = ((Integer)recPricingType.getField(PricingType.PRICING_CODES).getData()).intValue(); if ((intPricingCodes & PricingType.OPTION_PRICING) != 0) return true;
/** * Set the counter to max + 1 again. * Note: The position is undefined after this call (and the table is closed). * @param table The table to fix the counter on. */ public synchronized void fixCounter(FieldTable table) { PKeyArea vKeyArea = this.getPKeyArea(Constants.MAIN_KEY_AREA); KeyAreaInfo keyArea = table.getRecord().getKeyArea(Constants.MAIN_KEY_AREA); try { BaseBuffer buffer = vKeyArea.doMove(Constants.LAST_RECORD, table, keyArea); if (buffer == null) m_iCounter = table.getRecord().getStartingID(); else { buffer.bufferToFields(table.getRecord(), Constants.DONT_DISPLAY, Constants.READ_MOVE); Object data = table.getRecord().getCounterField().getData(); if (data instanceof Integer) m_iCounter = Math.max(m_iCounter, ((Integer)data).intValue() + 1); } // Now set the pointer back at the first record buffer = vKeyArea.doMove(Constants.FIRST_RECORD, table, keyArea); if (buffer != null) // If not at EOF (empty) back up one record vKeyArea.doMove(Constants.PREVIOUS_RECORD, table, keyArea); } catch (DBException ex) { // Ignore error } } /**
/** * Reposition to this record using this bookmark. * @param bookmark The handle to use to position the record. * @param iHandleType The type of handle (DATA_SOURCE/OBJECT_ID,OBJECT_SOURCE,BOOKMARK). * @return - true - record found/false - record not found * @exception FILE_NOT_OPEN. * @exception DBException File exception. */ public boolean doSetHandle(Object bookmark, int iHandleType) throws DBException { String strCurrentOrder = this.getRecord().getKeyName(); this.getRecord().setKeyArea(Constants.PRIMARY_KEY); this.getRecord().getCounterField().setData(bookmark); boolean bSuccess = this.seek(Constants.EQUALS); this.getRecord().setKeyArea(strCurrentOrder); return bSuccess; } /**
/** * Set the default key order. * @param String strKeyName the current index. * @return The new default key area (null if not found). */ public KeyArea getKeyArea(String strKeyName) { return (KeyArea)super.setKeyArea(strKeyName); } /**
try { FieldList recBooking = this.getFieldList(); if ((recBooking.getEditMode() == Constants.EDIT_NONE) || (recBooking.getEditMode() == Constants.EDIT_ADD)) recBooking.getTable().addNew(); return true; if (JOptionPane.showConfirmDialog(ScreenUtil.getFrame(this), strMessage, strTitle, JOptionPane.WARNING_MESSAGE) != JOptionPane.OK_OPTION) return false; recBooking.getTable().addNew(); Object objSuccess = this.getRemoteSession().doRemoteAction(Constants.DELETE, null); // Tell the remote session that I'm done with this booking if (objSuccess instanceof Boolean) bSuccess = ((Boolean)objSuccess).booleanValue(); recBooking.getTable().addNew(); // Clear the booking record this.getTourRecord().getTable().addNew(); // Clear tour record bSuccess = true; } catch (RemoteException ex) {
super.free(); // Free fields, free table.
/** * Do a remote command. * This method simplifies the task of calling a remote method. * Instead of having to override the session, all you have to do is override * doRemoteCommand in your record and handleRemoteCommand will call the remote version of the record. * @param strCommand * @param properties * @return */ public Object handleRemoteCommand(String strCommand, Map<String, Object> properties, boolean bWriteAndRefresh, boolean bDontCallIfLocal, boolean bCloneServerRecord) throws DBException, RemoteException { RemoteTarget remoteTask = this.getTable().getRemoteTableType(org.jbundle.model.Remote.class); if (remoteTask == null) { if (bDontCallIfLocal) return Boolean.FALSE; else return this.doRemoteCommand(strCommand, properties); } return remoteTask.doRemoteAction(strCommand, properties); } /**