Unlock this record if it is locked.
@param record The record to unlock.
@param The bookmark to unlock (all if null).
@return true if successful (it is usually okay to ignore this return).
190982
public boolean unlockIfLocked(Record record, Object bookmark) throws DBException
    {
        if (record != null)
        {   // unlock record
            BaseApplication app = null;
            org.jbundle.model.Task task = null;
            if (record.getRecordOwner() != null)
                task = record.getRecordOwner().getTask();
            if (task != null)
                app = (BaseApplication)record.getRecordOwner().getTask().getApplication();
            Environment env = null;
            if (app != null)
                env = app.getEnvironment();
            else
                env = Environment.getEnvironment(null);
            return env.getLockManager().unlockThisRecord(task, record.getDatabaseName(), record.getTableNames(false), bookmark);
        }
        return true;
    }
717768
public void fixRecord(Record record)
    {
        super.fixRecord(record);
        if (this.getProperty("field") != null)
        {
            BaseField field = this.getMainRecord().getField(this.getProperty("field").toString());
            if (field != null)
                this.fixCapitalization(field);
        }
    }
1244754
public Record moveRecordToBase(Record record)
    {
        SharedBaseRecordTable sharedTable = this.getSharedTable();
        sharedTable.setCurrentRecord(record);
        boolean bCopyEditMode = false;
        boolean bOnlyModifiedFields = false;
        Record recBase = sharedTable.getBaseRecord();
        sharedTable.copyRecordInfo(recBase, record, bCopyEditMode, bOnlyModifiedFields);
        return recBase;
    }
942941
public Record setRecordCurrent()
    {
        Record recordMain = this.getMainRecord();
        try   {
            if (recordMain != null)
            {
                if (m_objectID != null)
                { // Read the request
                    if (recordMain.setHandle(m_objectID, DBConstants.BOOKMARK_HANDLE) != null)
                        recordMain.edit();
                    else
                        m_objectID = null;
                }
                if (m_objectID == null)
                    if ((recordMain.getEditMode() != DBConstants.EDIT_CURRENT) && (recordMain.getEditMode() != DBConstants.EDIT_IN_PROGRESS))   // If the record is current, don't touch it.
                {
                    recordMain.addNew();
                }
            }
        } catch (DBException ex)    {
            Debug.print(ex);
            ex.printStackTrace();
            m_objectID = null;
        }
        if (m_objectID == null)
            return null;
        else
            return recordMain;
    }
787871
public void publish(LogRecord record)
  {
    if (! isLoggable(record))
      return;

    if (_handler != null)
      _handler.publish(record);
  }
1118575
public BaseTable doMakeTable(Record record)
    {
        BaseTable table = null;
        boolean bIsQueryRecord = record.isQueryRecord();
        if (m_pDatabase == null)
        {
            try   {
                this.open();
            } catch (DBException ex)    {
                return null;        // No database
            }
        }
        if (bIsQueryRecord)
        { // Physical Tables cannot process SQL queries, so use QueryTable!
            PassThruTable passThruTable = new QueryTable(this, record);
            passThruTable.addTable(record.getRecordlistAt(0).getTable());
            return passThruTable;
        }
        table = this.makePhysicalTable(record);
        return table;
    }
360365
public FieldList setHandle(Object bookmark, int iHandleType) throws DBException
    {
        Record recMain = this.getRecord();
        this.setCurrentTable(this.getNextTable());
        FieldList record = super.setHandle(bookmark, iHandleType);
        
        if (record == null)
        {   // Not found in the main table, try the other tables
            Iterator<BaseTable> iterator = this.getTables();
            while (iterator.hasNext())
            {
                BaseTable table = iterator.next();
                if ((table != null) && (table != this.getNextTable()))
                {
                    Record recAlt = table.getRecord();
                    record = recAlt.setHandle(bookmark, iHandleType);
                    if (record != null)
                    {
                        this.syncRecordToBase(recMain, recAlt, false);
                        this.setCurrentTable(table);
                        break;
                    }
                }
            }
        }
        return record;
    }
564926
public void addRecord(Rec record, boolean bMainQuery)
    {
        if (record == null)
            return;
        if (this.contains(record))
        {     // Don't add this twice.
            if (!bMainQuery)
                return;
            this.removeRecord(record);  // Change order
        }
        if (bMainQuery)
            this.insertElementAt(record, 0);
        else
            this.addElement(record);
    }
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));
    }
489348
public int lockCurrentRecord() throws DBException
    {
        int iErrorCode = DBConstants.NORMAL_RETURN;
        Record record = this.getRecord();
        Object bookmark = record.getHandle(DBConstants.BOOKMARK_HANDLE);
        if (bookmark != null)
        {   // Always
            String strUserName = null;
            BaseApplication app = null;
            org.jbundle.model.Task task = null;
            if (record.getRecordOwner() != null)
                task = record.getRecordOwner().getTask();
            if (task != null)
                app = (BaseApplication)record.getRecordOwner().getTask().getApplication();
            if (app != null)
                strUserName = app.getProperty(DBParams.USER_NAME);
            Environment env = null;
            if (app != null)
                env = app.getEnvironment();
            else
                env = Environment.getEnvironment(null);
            iErrorCode = env.getLockManager().lockThisRecord(task, record.getDatabaseName(), record.getTableNames(false), bookmark, strUserName, record.getOpenMode());
        }
        return iErrorCode;
    }
154833
public synchronized boolean removeLock(Object bookmark, SessionInfo sessionInfo)
    {
        Utility.getLogger().info("Unlock: " + bookmark + ", Session: " + sessionInfo.m_iSessionID + " success: " + sessionInfo.equals(this.get(bookmark)));
        if (!sessionInfo.equals(this.get(bookmark)))
            return false;   // Not my session - error.
        if (this.getWaitlist(bookmark, false) != null)
        	if (this.getWaitlist(bookmark, false).size() > 0)
        {   // Notify this person that the wait is over
    		SessionInfo sessionInfoToUnlock = this.getWaitlist(bookmark, true).get(0);
            if (sessionInfoToUnlock == null)
            	return false;	// Never
            synchronized (sessionInfoToUnlock)
            {
        		if (sessionInfoToUnlock != this.popWaitlistSession(bookmark))
                	return false;	// Never since the only remove is this (synchronized line)
                boolean bSuccess = sessionInfo.equals(this.remove(bookmark));
                if (bSuccess)	// Always
                	sessionInfoToUnlock.notify();	// Tell locked session to continue
            	return bSuccess;
            }
        }
        return sessionInfo.equals(this.remove(bookmark));
    }
738623
public void setRecord(Rec record)
    {
        if (m_tableNext != null)
            m_tableNext.setRecord(record);  // Must be synchronized
        super.setRecord(record);
    }
1137415
protected function getIsGarbageRecord($table, $record):bool
    {
        return $this->tcaService->isHidden($table, $record) ||
                $this->isInvisibleByStartOrEndtime($table, $record) ||
                $this->hasFrontendGroupsRemoved($table, $record) ||
                ($table === 'pages' && $this->isPageExcludedFromSearch($record)) ||
                ($table === 'pages' && !$this->isIndexablePageType($record));
    }
923207
public void updateRecord(final ORecordInternal<?> record) {
    if (isEnabled() && record.getIdentity().getClusterId() != excludedCluster && record.getIdentity().isValid()) {
      underlying.lock(record.getIdentity());
      try {
        if (underlying.get(record.getIdentity()) != record)
          underlying.put(record);
      } finally {
        underlying.unlock(record.getIdentity());
      }
    }

    secondary.updateRecord(record);
  }
340288
public Collection<Record> findCandidateMatches(Record record) {
    if (DEBUG)
      System.out.println("---------------------------------------------------------------------------");
    
    // do lookup on all tokens from all lookup properties
    // (we only identify the buckets for now. later we decide how to process
    // them)
    List<Bucket> buckets = lookup(record);
    
    // preprocess the list of buckets
    Collections.sort(buckets);
    double score_sum = 0.0;
    for (Bucket b : buckets)
      score_sum += b.getScore();
      
    double score_so_far = 0.0;
    int threshold = buckets.size() - 1;
    for (; (score_so_far / score_sum) < min_relevance; threshold--) {
      score_so_far += buckets.get(threshold).getScore();
      if (DEBUG)
        System.out.println("score_so_far: " + (score_so_far/score_sum) + " (" +
                           threshold + ")");
    }
    // bucket.get(threshold) made us go over the limit, so we need to step
    // one back
    threshold++;
    if (DEBUG)
      System.out.println("Threshold: " + threshold);
    
    // the collection of candidates
    Map<Long, Score> candidates = new HashMap();

    // go through the buckets that we're going to collect candidates from
    int next_bucket = collectCandidates(candidates, buckets, threshold);

    // there might still be some buckets left below the threshold. for
    // these we go through the existing candidates and check if we can
    // find them in the buckets.
    bumpScores(candidates, buckets, next_bucket);

    if (DEBUG)
      System.out.println("candidates: " + candidates.size());
    
    // if the cutoff properties are not set we can stop right here
    // FIXME: it's possible to make this a lot cleaner
    if (max_search_hits > candidates.size() && min_relevance == 0.0) {
      Collection<Record> cands = new ArrayList(candidates.size());
      for (Long id : candidates.keySet())
        cands.add(store.findRecordById(id));
      if (DEBUG)
        System.out.println("final: " + cands.size());
      return cands;
    }
    
    // flatten candidates into an array, prior to sorting etc
    int ix = 0;
    Score[] scores = new Score[candidates.size()];
    double max_score = 0.0;
    for (Score s : candidates.values()) {
      scores[ix++] = s;
      if (s.score > max_score)
        max_score = s.score;
      if (DEBUG && false)
        System.out.println("" + s.id + ": " + s.score);
    }

    // allow map to be GC-ed
    candidates = null;

    // filter candidates with min_relevance and max_search_hits. do
    // this by turning the scores[] array into a priority queue (on
    // .score), then retrieving the best candidates. (gives a big
    // performance improvement over sorting the array.)
    PriorityQueue pq = new PriorityQueue(scores);
    int count = Math.min(scores.length, max_search_hits);
    Collection<Record> records = new ArrayList(count);
    for (ix = 0; ix < count; ix++) {
      Score s = pq.next();
      if (s.score >= min_relevance)
        records.add(store.findRecordById(s.id));
    }

    if (DEBUG)
      System.out.println("final: " + records.size());
    return records;
  }
220527
public Object doSetHandle(Object bookmark, int iOpenMode, String strFields, int iHandleType) throws DBException, RemoteException
    {
        m_objCurrentCacheRecord = NONE;
        m_objCurrentLockedRecord = NONE;
        try {   // This caching logic is exactly the same as seek caching.
            Object objData = null;
            if ((m_mapCache == null) && (m_htCache == null))
                m_htCache = new Hashtable<Object,Object>();    // Okay, start caching keys and records
            if (m_htCache != null)
            {
                if (bookmark instanceof Integer)
                    objData = m_htCache.get(bookmark);    // Try to find this in the cache
            }
            m_mapCache = null;  // If seek is used, the grid cache is no good anymore.
            if (objData != null)
                m_objCurrentCacheRecord = bookmark;   // Current data is Cached
            if (objData == null)
            {
                m_objCurrentPhysicalRecord = NONE;
                objData = m_tableRemote.doSetHandle(bookmark, iOpenMode, strFields, iHandleType);
                if (objData instanceof Vector)
                    if (m_htCache != null)
                {
                    m_objCurrentPhysicalRecord = bookmark;    // Current data is current
                    m_objCurrentCacheRecord = bookmark;
                    m_htCache.put(bookmark, objData);
                }
            }
            return objData;
        } catch (RemoteException ex) {
            throw ex;
        }
    }
877194
public boolean isSingleDetail(Rec record)
    {
        boolean bSingleDetail = true;
        
        if (Boolean.toString(false).equals(this.getMessage().getMessageHeader().get(BaseMessageHeader.SINGLE_DETAIL_PARAM)))
            return false;
        
        return bSingleDetail;
    }