use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.
the class OTraverseRecordProcess method processFields.
private void processFields(Iterator<Object> target) {
final ODocument doc = this.target.getRecord();
while (target.hasNext()) {
Object field = target.next();
final Object fieldValue;
if (field instanceof OSQLFilterItem)
fieldValue = ((OSQLFilterItem) field).getValue(doc, null, null);
else
fieldValue = doc.rawField(field.toString());
if (fieldValue != null) {
final OTraverseAbstractProcess<?> subProcess;
if (fieldValue instanceof Iterator<?> || OMultiValue.isMultiValue(fieldValue)) {
final Iterator<?> coll;
if (fieldValue instanceof ORecordLazyMultiValue)
coll = ((ORecordLazyMultiValue) fieldValue).rawIterator();
else
coll = OMultiValue.getMultiValueIterator(fieldValue, false);
subProcess = new OTraverseMultiValueProcess(command, (Iterator<Object>) coll, getPath().appendField(field.toString()));
} else if (fieldValue instanceof OIdentifiable && ((OIdentifiable) fieldValue).getRecord() instanceof ODocument) {
subProcess = new OTraverseRecordProcess(command, (ODocument) ((OIdentifiable) fieldValue).getRecord(), getPath().appendField(field.toString()));
} else
continue;
command.getContext().push(subProcess);
}
}
}
use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.
the class OClassImpl method firePropertyNameMigration.
public void firePropertyNameMigration(final ODatabaseDocument database, final String propertyName, final String newPropertyName, final OType type) {
final boolean strictSQL = ((ODatabaseInternal) database).getStorage().getConfiguration().isStrictSql();
database.query(new OSQLAsynchQuery<Object>("select from " + getEscapedName(name, strictSQL) + " where " + getEscapedName(propertyName, strictSQL) + " is not null ", new OCommandResultListener() {
@Override
public boolean result(Object iRecord) {
final ODocument record = ((OIdentifiable) iRecord).getRecord();
record.setFieldType(propertyName, type);
record.field(newPropertyName, record.field(propertyName), type);
database.save(record);
return true;
}
@Override
public void end() {
}
@Override
public Object getResult() {
return null;
}
}));
}
use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.
the class OIndexMultiValues method remove.
@Override
public boolean remove(Object key, final OIdentifiable value) {
key = getCollatingValue(key);
final ODatabase database = getDatabase();
final boolean txIsActive = database.getTransaction().isActive();
if (!txIsActive)
keyLockManager.acquireExclusiveLock(key);
try {
acquireSharedLock();
try {
Set<OIdentifiable> values = null;
while (true) {
try {
values = (Set<OIdentifiable>) storage.getIndexValue(indexId, key);
break;
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
}
if (values == null) {
return false;
}
final OModifiableBoolean removed = new OModifiableBoolean(false);
final Callable<Object> creator = new EntityRemover(value, removed, values);
while (true) try {
storage.updateIndexEntry(indexId, key, creator);
break;
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
return removed.getValue();
} finally {
releaseSharedLock();
}
} finally {
if (!txIsActive)
keyLockManager.releaseExclusiveLock(key);
}
}
use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.
the class OIndexMultiValues method get.
public Set<OIdentifiable> get(Object key) {
key = getCollatingValue(key);
final ODatabase database = getDatabase();
final boolean txIsActive = database.getTransaction().isActive();
if (!txIsActive)
keyLockManager.acquireSharedLock(key);
try {
acquireSharedLock();
try {
Set<OIdentifiable> values;
while (true) {
try {
values = (Set<OIdentifiable>) storage.getIndexValue(indexId, key);
break;
} catch (OInvalidIndexEngineIdException e) {
doReloadIndexEngine();
}
}
if (values == null)
return Collections.emptySet();
return Collections.unmodifiableSet(values);
} finally {
releaseSharedLock();
}
} finally {
if (!txIsActive)
keyLockManager.releaseSharedLock(key);
}
}
use of com.orientechnologies.orient.core.db.record.OIdentifiable in project orientdb by orientechnologies.
the class OFetchHelper method fetchCollectionRidMap.
@SuppressWarnings("unchecked")
private static void fetchCollectionRidMap(final OFetchPlan iFetchPlan, final Object fieldValue, final String fieldName, final int iCurrentLevel, final int iLevelFromRoot, final int iFieldDepthLevel, final Map<ORID, Integer> parsedRecords, final String iFieldPathFromRoot, final OFetchContext iContext) throws IOException {
final Iterable<OIdentifiable> linked = (Iterable<OIdentifiable>) fieldValue;
for (OIdentifiable d : linked) {
if (d != null) {
// GO RECURSIVELY
d = d.getRecord();
updateRidMap(iFetchPlan, (ODocument) d, iCurrentLevel, iLevelFromRoot, iFieldDepthLevel, parsedRecords, iFieldPathFromRoot, iContext);
}
}
}
Aggregations