Synchronize this refernce field with this record.
Adds the behaviors to sync this field and the record.
Used for popup screenfields where the referencerecord has a detail to display on change.
@param record The reference record to synchronize.
505669
public void syncReference(Record record)
    {
        this.setReferenceRecord(record);
        BaseField recordKeyField = (BaseField)record.getCounterField();
        if ((recordKeyField.isNull()) && (!this.isNull())
            && (!record.isModified())
                && (record.getEditMode() != DBConstants.EDIT_CURRENT)
                    && (record.getEditMode() != DBConstants.EDIT_IN_PROGRESS)
                     && ((record.getOpenMode() & DBConstants.OPEN_REFRESH_AND_LOCK_ON_CHANGE_STRATEGY) == 0))
        {
            recordKeyField.moveFieldToThis(this, DBConstants.DISPLAY, DBConstants.SCREEN_MOVE);   // Start with this field's value if you arn't going to mess up the record
            recordKeyField.setModified(false);
        } 
        else
            this.setReference(record, DBConstants.DISPLAY, DBConstants.SCREEN_MOVE);
            // If the screen field is changed, make sure the passed in header record's key field is changed to match.
        MoveOnChangeHandler listener = (MoveOnChangeHandler)this.getListener(MoveOnChangeHandler.class.getName());
        if ((listener == null)
            || (listener.getDestField() != recordKeyField))
                this.addListener(new MoveOnChangeHandler(recordKeyField, null));
            // If the record is externally selected, sync the record's key with the screenfield
        MoveOnValidHandler listener2 = (MoveOnValidHandler)record.getListener(MoveOnValidHandler.class.getName());
        if ((listener2 == null)
            || (listener2.getSourceField() != recordKeyField))
                record.addListener(new MoveOnValidHandler(this, recordKeyField));
        MainReadOnlyHandler listener3 = (MainReadOnlyHandler)recordKeyField.getListener(MainReadOnlyHandler.class.getName());
        if (listener3 == null)
            recordKeyField.addListener(new MainReadOnlyHandler(null));
    }
1301023
public boolean isChangeToNewID(Record record)
    {
        Record recClassInfo = this.getRecord(ClassInfo.CLASS_INFO_FILE);
        recClassInfo.setKeyArea(ClassInfo.CLASS_NAME_KEY);
        recClassInfo.getField(ClassInfo.CLASS_NAME).moveFieldToThis(record.getField(ScreenIn.SCREEN_IN_PROG_NAME));
        try {
            if (!recClassInfo.seek(DBConstants.EQUALS))
                return false;
        } catch (DBException e) {
            e.printStackTrace();
        }
        return (recClassInfo.getField(ClassInfo.CLASS_PROJECT_ID).getValue() == 1);
    }
275069
public void moveFieldToThin(FieldInfo fieldInfo, BaseField field, Record record)
    {
        if ((field == null) || (!field.getFieldName().equals(fieldInfo.getFieldName())))
        {
            field = null;
            if (record != null)
                field = record.getField(fieldInfo.getFieldName());
        }
        if (field != null)
        {
            if (field.getDataClass() == fieldInfo.getDataClass())
                fieldInfo.setData(field.getData());
            else
                fieldInfo.setString(field.toString());
        }
    }
940181
public void doSet(Record record) throws DBException
    {
        if (this.lockOnDBTrxType(null, DBConstants.UPDATE_TYPE, true))
        {
            int iErrorCode = this.lockCurrentRecord();
            if ((iErrorCode == DBConstants.NORMAL_RETURN) || (iErrorCode == DBConstants.RECORD_CHANGED))
            {
                iErrorCode = record.refreshToCurrent(DBConstants.UPDATE_TYPE, true);
            }
        }
//        int iRowsUpdated = 0;
        Object bookmark = record.getHandle(DBConstants.BOOKMARK_HANDLE);
        CounterField fldID = (CounterField)record.getCounterField();
        if (fldID != null)
            if (record.isAutoSequence())
                fldID.setModified(false); // Never set a counter field
        String strRecordset = record.getSQLUpdate(SQLParams.USE_INSERT_UPDATE_LITERALS);
        int iType = DBConstants.SQL_UPDATE_TYPE;
            if (strRecordset != null)
                /*iRowsUpdated =*/ this.executeUpdate(strRecordset, iType);
//            else
//                iRowsUpdated = 1; // No changes
        if (this.lockOnDBTrxType(null, DBConstants.AFTER_UPDATE_TYPE, false))  // ADD_TYPE = Add new; Should I do the unlock in my code?
            this.unlockIfLocked(record, bookmark);
    }
917266
public void index(Record record) {
    for (Property p : config.getIdentityProperties()) {
      Collection<String> values = record.getValues(p.getName());
      if (values == null)
        continue;
      
      for (String id : values)
        idindex.put(id, record);
    }
    records.add(record);
  }

  /**
   * Look up record by identity.
   */
  public Record findRecordById(String id) {
    return idindex.get(id);
  }

  /**
   * Look up potentially matching records.
   */
  public Collection<Record> findCandidateMatches(Record record) {
    return records;
  }

  /**
   * Flushes all changes to disk. For in-memory databases this is a
   * no-op.
   */
  public void commit() {
  }
  
  /**
   * Stores state to disk and closes all open resources.
   */
  public void close() {
  }

  public String toString() {
    return "InMemoryDatabase";
  }
}
714508
public int moveFieldToThis(BaseField field, boolean bDisplayOption, int iMoveMode)
    {   // Save the record and datarecord.
        if (field == null)
            return DBConstants.NORMAL_RETURN;
        if (field instanceof CounterField)
        {
            if (this.getReferenceRecord(null, false) == null)
                if (field.getRecord().getListener(ClearFieldReferenceOnCloseHandler.class) == null) // While it is okay to have two fields reference on record, don't default it.
                    this.setReferenceRecord(field.getRecord());
        }
        else if (field instanceof ReferenceField)
        {
//x no           this.setReferenceRecord(((ReferenceField)field).getReferenceRecord());
        }
        else
            this.setReferenceRecord(null);
        return super.moveFieldToThis(field, bDisplayOption, iMoveMode);
    }
641128
@Override
	public void setReference(Record reference) {
		for (int i = 0; i < this.keyFields1.length; i++) {
			if (!reference.getFieldInto(this.keyFields1[i], this.keyHolders1[i])) {
				throw new NullKeyFieldException(this.keyFields1[i]);
			}
		}
	}
687569
public void addListeners()
    {
        super.addListeners();
        
            // Link the screen field to the passed in record
        ((ReferenceField)this.getScreenRecord().getField(ClassInfoScreenRecord.CLASS_PROJECT_ID)).syncReference(this.getHeaderRecord());
        this.getScreenRecord().getField(ClassInfoScreenRecord.CLASS_PROJECT_ID).addListener(new FieldReSelectHandler(this));
        
        this.getMainRecord().addListener(new ExtractRangeFilter(ClassInfo.CLASS_NAME, this.getScreenRecord().getField(ClassInfoScreenRecord.NAME)));
        this.getScreenRecord().getField(ClassInfoScreenRecord.NAME).addListener(new FieldReSelectHandler(this));
        
        this.getMainRecord().addListener(new ExtractRangeFilter(ClassInfo.CLASS_PACKAGE, this.getScreenRecord().getField(ClassInfoScreenRecord.PACKAGE)));
        this.getScreenRecord().getField(ClassInfoScreenRecord.PACKAGE).addListener(new FieldReSelectHandler(this));
    }
964481
public void markRecord(BufferedRecord<D> record, int bytesWritten) {
    synchronized (this) {
      thunks.add(new Thunk<>(record, bytesWritten));
      byteSize += bytesWritten;
    }
  }
765600
public void fieldChanged(Field field)
    {
        Record record = this.getMainRecord();
        if (field != null)
            if (record != null)
            if (field.getRecord() == record)
        {
            int iErrorCode= record.handleRecordChange((BaseField)field, DBConstants.FIELD_CHANGED_TYPE, DBConstants.DONT_DISPLAY);   // Tell table that I'm getting changed (if not locked)
            if (iErrorCode != DBConstants.NORMAL_RETURN)
                this.displayError(iErrorCode);
        }
    }
694345
public void setReference(final Reference reference) {

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, "setReference", reference);
        }

        // Make sure no-one can pull the rug from beneath us.
        synchronized (_properties) {
            _properties = JmsJcaReferenceUtils.getInstance()
                            .getMapFromReference(reference, defaultJNDIProperties);
        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, "setReference");
        }

    }
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);
        }
    }
821103
public void init(Object parent, Object record)
    {
        super.init(parent, record);
        record = this.getFieldList();   // Created/set in JBaseScreen.init
        this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
        FieldTable table = ((FieldList)record).getTable();
        CalendarModel model = this.getCalendarModel(table);
        ImageIcon backgroundImage = null;
        if (this.getBaseApplet() != null)
        	backgroundImage = this.getBaseApplet().getBackgroundImage();	// Calendar panel is transparent, but this helps with rendering see-thru components 
        CalendarPanel panel = new CalendarPanel(model, true, backgroundImage);
        this.add(panel);
    }
207511
public void initSharedRecord(Record record)
    {
        FieldListener listener = null;
        try {
            BaseField field = record.getSharedRecordTypeKey();
            field.addListener(listener = new InitOnceFieldHandler(null));
            field.setData(new Integer(0), true, DBConstants.INIT_MOVE);
            field.setData(new Integer(0), true, DBConstants.INIT_MOVE);
            if (field != null)
                if (field.getDataClass() == Integer.class)
            {
                for (int i = 1; ; i++)
                {
                    Integer intData = new Integer(i);
                    field.setData(intData);
                    record.addNew();
                    Record recShared = record.getTable().getCurrentTable().getRecord();
                    if (recShared == null)
                        break;
                    if (recShared == record)
                        break;
                    if (recShared.getField(field.getFieldName()).getValue() != i)
                        break;
                    this.disableAllListeners(recShared);
                }
            }
        } catch (DBException ex) {
            ex.printStackTrace();
        } finally {
            if (listener != null)
                record.removeListener(listener, true);
        }
    }
866454
@Override
	public void index(Record record) {
		if (this.client == null) {
			this.init();
		}

		String id = null;
		Map<String, Object> json = new HashMap<String, Object>();
		for (String propname : record.getProperties()) {
			Property prop = config.getPropertyByName(propname);

			if (prop == null) {
				throw new DukeConfigException("Record has property " + propname
						+ " for which there is no configuration");
			}

			if (prop.isIdProperty()) {
				id = record.getValue(propname);
			} else {

				Collection<String> values = record.getValues(propname);
				if (values != null && !values.isEmpty()) {
					if (values.size() == 1) {
						json.put(propname, Iterables.get(values, 0));
					} else {
						json.put(propname, values);
					}
				}
			}

		}

		this.addToIndex(id, json);
	}
836732
public void addListeners()
    {
        super.addListeners();
            // Link the screen field to the passed in record
        ((ReferenceField)this.getScreenRecord().getField(MessageInfoScreenRecord.MESSAGE_INFO_ID)).syncReference(this.getHeaderRecord());
        
        String strManualTransportID = Integer.toString(((ReferenceField)this.getMainRecord().getField(MessageProcessInfo.DEFAULT_MESSAGE_TRANSPORT_ID)).getIDFromCode(MessageTransport.MANUAL));
        this.getMainRecord().getField(MessageProcessInfo.DEFAULT_MESSAGE_TRANSPORT_ID).addListener(new DisableOnFieldHandler(this.getMainRecord().getField(MessageProcessInfo.INITIAL_MESSAGE_STATUS_ID), strManualTransportID, false));
        Converter convCheckMark = new RadioConverter(this.getMainRecord().getField(MessageProcessInfo.DEFAULT_MESSAGE_TRANSPORT_ID), strManualTransportID, false);
        this.getMainRecord().getField(MessageProcessInfo.DEFAULT_MESSAGE_TRANSPORT_ID).addListener(new RemoveConverterOnFreeHandler(convCheckMark));
        this.getMainRecord().getField(MessageProcessInfo.DEFAULT_MESSAGE_TRANSPORT_ID).addListener(new CopyDataHandler(this.getMainRecord().getField(MessageProcessInfo.INITIAL_MESSAGE_STATUS_ID), null, convCheckMark));
    }
1373458
public void publish(LogRecord record)
  {
    if (! isLoggable(record))
      return;
    
    int level = getLevel().intValue();

    for (int i = 0; i < _handlers.length; i++) {
      Handler handler = _handlers[i];

      if (level <= handler.getLevel().intValue())
        handler.publish(record);
    }
  }