@Override public void setOwner(ORecord owner) { if (owner != null && this.owner != null && !this.owner.equals(owner)) { throw new IllegalStateException("This data structure is owned by document " + owner + " if you want to use it in other document create new rid bag instance and copy content of current one."); } if (this.owner != null) { for (int i = 0; i < entriesLength; i++) { final Object entry = entries[i]; if (entry instanceof OIdentifiable) { ORecordInternal.unTrack(this.owner, (OIdentifiable) entry); } } } this.owner = owner; if (this.owner != null) { for (int i = 0; i < entriesLength; i++) { final Object entry = entries[i]; if (entry instanceof OIdentifiable) { ORecordInternal.track(this.owner, (OIdentifiable) entry); } } } }
public void convertLinks2Records() { final Iterator<Entry<OIdentifiable, Object>> all = map.entrySet().iterator(); while (all.hasNext()) { Entry<OIdentifiable, Object> entry = all.next(); if (entry.getValue() == ENTRY_REMOVAL) { try { ORecord record = entry.getKey().getRecord(); if (record != null) { ORecordInternal.unTrack(sourceRecord, entry.getKey()); ORecordInternal.track(sourceRecord, record); } entry.setValue(record); } catch (ORecordNotFoundException ignore) { // IGNORE THIS } } } }
@Override public void convertLinks2Records() { TreeMap<OIdentifiable, Change> newChanges = new TreeMap<>(); for (Map.Entry<OIdentifiable, Change> entry : changes.entrySet()) { final OIdentifiable key = entry.getKey().getRecord(); if (key != null && this.owner != null) { ORecordInternal.unTrack(this.owner, entry.getKey()); ORecordInternal.track(this.owner, key); } newChanges.put((key == null) ? entry.getKey() : key, entry.getValue()); } changes.clear(); changes.putAll(newChanges); }
@Override public void remove() { if (currentRemoved) throw new IllegalStateException("Current element has already been removed"); if (currentIndex == -1) throw new IllegalStateException("Next method was not called for given iterator"); currentRemoved = true; final OIdentifiable nextValue = (OIdentifiable) entries[currentIndex]; entries[currentIndex] = Tombstone.TOMBSTONE; size--; contentWasChanged = true; if (OEmbeddedRidBag.this.owner != null) ORecordInternal.unTrack(OEmbeddedRidBag.this.owner, nextValue); fireCollectionChangedEvent( new OMultiValueChangeEvent<OIdentifiable, OIdentifiable>(OMultiValueChangeEvent.OChangeType.REMOVE, nextValue, null, nextValue)); }
@Override public void convertLinks2Records() { for (int i = 0; i < entriesLength; i++) { final Object entry = entries[i]; if (entry instanceof OIdentifiable) { final OIdentifiable identifiable = (OIdentifiable) entry; ORecord record = identifiable.getRecord(); if (record != null) { if (this.owner != null) { ORecordInternal.unTrack(this.owner, identifiable); ORecordInternal.track(this.owner, record); } entries[i] = record; } } } }
@Override public void remove(OIdentifiable identifiable) { if (removeEntry(identifiable)) { size--; contentWasChanged = true; if (this.owner != null) ORecordInternal.unTrack(this.owner, identifiable); fireCollectionChangedEvent( new OMultiValueChangeEvent<OIdentifiable, OIdentifiable>(OMultiValueChangeEvent.OChangeType.REMOVE, identifiable, null, identifiable)); } }
@Override public void setOwner(ORecord owner) { if (owner != null && this.owner != null && !this.owner.equals(owner)) { throw new IllegalStateException("This data structure is owned by document " + owner + " if you want to use it in other document create new rid bag instance and copy content of current one."); } if (this.owner != null) { for (OIdentifiable entry : newEntries.keySet()) { ORecordInternal.unTrack(this.owner, entry); } for (OIdentifiable entry : changes.keySet()) { ORecordInternal.unTrack(this.owner, entry); } } this.owner = owner; if (this.owner != null) { for (OIdentifiable entry : newEntries.keySet()) { ORecordInternal.track(this.owner, entry); } for (OIdentifiable entry : changes.keySet()) { ORecordInternal.track(this.owner, entry); } } }
ORecordInternal.unTrack(OSBTreeRidBag.this.owner, currentValue);
ORecordInternal.unTrack(sourceRecord, rid); ORecordInternal.track(sourceRecord, record);
ORecordInternal.unTrack(this.owner, identifiable);
/** * Convert the item requested from link to record. * * @param iIndex Position of the item to convert */ private void convertLink2Record(final int iIndex) { if (ridOnly || !autoConvertToRecord) // PRECONDITIONS return; final OIdentifiable o = super.get(iIndex); if (contentType == MULTIVALUE_CONTENT_TYPE.ALL_RECORDS && !o.getIdentity().isNew()) // ALL RECORDS AND THE OBJECT IS NOT NEW, DO NOTHING return; if (o != null && o instanceof ORecordId) { final ORecordId rid = (ORecordId) o; marshalling = true; try { ORecord record = rid.getRecord(); if (record != null) { ORecordInternal.unTrack(sourceRecord, rid); ORecordInternal.track(sourceRecord, record); } super.set(iIndex, record); } catch (ORecordNotFoundException ignore) { // IGNORE THIS } finally { marshalling = false; } } }