use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.
the class OEmbeddedRidBag method convertRecords2Links.
@Override
public boolean convertRecords2Links() {
for (int i = 0; i < entriesLength; i++) {
final Object entry = entries[i];
if (entry instanceof OIdentifiable) {
final OIdentifiable identifiable = (OIdentifiable) entry;
if (identifiable instanceof ORecord) {
final ORecord record = (ORecord) identifiable;
entries[i] = record.getIdentity();
}
}
}
return true;
}
use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.
the class OEmbeddedRidBag method toString.
@Override
public String toString() {
if (size < 10) {
final StringBuilder sb = new StringBuilder(256);
sb.append('[');
for (final Iterator<OIdentifiable> it = this.iterator(); it.hasNext(); ) {
try {
OIdentifiable e = it.next();
if (e != null) {
if (sb.length() > 1)
sb.append(", ");
sb.append(e.getIdentity());
}
} catch (NoSuchElementException ex) {
// IGNORE THIS
}
}
return sb.append(']').toString();
} else
return "[size=" + size + "]";
}
use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.
the class OEmbeddedRidBag method returnOriginalState.
@Override
public Object returnOriginalState(List<OMultiValueChangeEvent<OIdentifiable, OIdentifiable>> multiValueChangeEvents) {
final OEmbeddedRidBag reverted = new OEmbeddedRidBag();
for (OIdentifiable identifiable : this) reverted.add(identifiable);
final ListIterator<OMultiValueChangeEvent<OIdentifiable, OIdentifiable>> listIterator = multiValueChangeEvents.listIterator(multiValueChangeEvents.size());
while (listIterator.hasPrevious()) {
final OMultiValueChangeEvent<OIdentifiable, OIdentifiable> event = listIterator.previous();
switch(event.getChangeType()) {
case ADD:
reverted.remove(event.getKey());
break;
case REMOVE:
reverted.add(event.getOldValue());
break;
default:
throw new IllegalArgumentException("Invalid change type : " + event.getChangeType());
}
}
return reverted;
}
use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.
the class OEmbeddedRidBag method convertLinks2Records.
@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;
}
}
}
}
use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.
the class OTraverse method next.
public OIdentifiable next() {
if (Thread.interrupted())
throw new OCommandExecutionException("The traverse execution has been interrupted");
if (lastTraversed != null) {
// RETURN LATEST AND RESET IT
final OIdentifiable result = lastTraversed;
lastTraversed = null;
return result;
}
if (limit > 0 && resultCount >= limit)
return null;
OIdentifiable result;
OTraverseAbstractProcess<?> toProcess;
// RESUME THE LAST PROCESS
while ((toProcess = nextProcess()) != null) {
result = toProcess.process();
if (result != null) {
resultCount++;
return result;
}
}
return null;
}
Aggregations