当前位置: 首页>>代码示例>>Java>>正文


Java ORecord类代码示例

本文整理汇总了Java中com.orientechnologies.orient.core.record.ORecord的典型用法代码示例。如果您正苦于以下问题:Java ORecord类的具体用法?Java ORecord怎么用?Java ORecord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ORecord类属于com.orientechnologies.orient.core.record包,在下文中一共展示了ORecord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: set

import com.orientechnologies.orient.core.record.ORecord; //导入依赖的package包/类
/**
 * Set singleton entity.  Returns {@code true} if entity was replaced.
 */
public boolean set(final ODatabaseDocumentTx db, final T entity) {
  checkNotNull(db);
  checkNotNull(entity);

  ODictionary<ORecord> dictionary = db.getDictionary();
  ODocument document = dictionary.get(key);
  if (document == null) {
    document = adapter.addEntity(db, entity);
    dictionary.put(key, document);
    return false;
  }
  else {
    adapter.writeEntity(document, entity);
    return true;
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:20,代码来源:SingletonActions.java

示例2: getIndexedElements

import com.orientechnologies.orient.core.record.ORecord; //导入依赖的package包/类
private <ElementType extends OrientElement> Stream<ElementType> getIndexedElements(
        OIndex<Object> index,
        Iterator<Object> valuesIter,
        BiFunction<OrientGraph, OIdentifiable, ElementType> newElement) {
    return executeWithConnectionCheck(() -> {
        makeActive();

        if (index == null) {
            return Collections.<ElementType> emptyList().stream();
        } else {
            if (!valuesIter.hasNext()) {
                return index.cursor().toValues().stream().map(id -> newElement.apply(this, id));
            } else {
                Stream<Object> convertedValues = StreamUtils.asStream(valuesIter).map(value -> convertValue(index, value));
                Stream<OIdentifiable> ids = convertedValues.flatMap(v -> lookupInIndex(index, v)).filter(r -> r != null);
                Stream<ORecord> records = ids.map(id -> id.getRecord());
                return records.map(r -> newElement.apply(this, getRawDocument(r)));
            }
        }
    });
}
 
开发者ID:orientechnologies,项目名称:orientdb-gremlin,代码行数:22,代码来源:OrientGraph.java

示例3: load

import com.orientechnologies.orient.core.record.ORecord; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected T load() {
	ODocument doc = docModel.getObject();
	OProperty prop = propertyModel!=null?propertyModel.getObject():null;
	if(doc==null) return null;
	if(prop==null) return (T) doc;
	if(valueType==null) {
		return (T) doc.field(prop.getName());
	} else
	{
		Object ret = doc.field(prop.getName(), valueType);
		if(ORecord.class.isAssignableFrom(valueType) && ret instanceof ORID) {
			ret = ((ORID)ret).getRecord();
		}
		return (T) ret;
	}
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:19,代码来源:DynamicPropertyValueModel.java

示例4: result

import com.orientechnologies.orient.core.record.ORecord; //导入依赖的package包/类
@Override
@SuppressWarnings({"unchecked", "PMD.ConsecutiveLiteralAppends"})
public boolean result(final Object rec) {
    // in all cases rec will be ORecord, but any other type would also be handled properly (just in case)
    try {
        final Object converted = converter.convert(rec, targetType);
        final boolean res = listener.onResult(converted);
        if (res) {
            results.add(converted);
        }
        return res;
    } catch (Exception th) {
        final StringBuilder id = new StringBuilder(
                rec instanceof ODocument
                        // ODocument may not have class if its a wrapper around simple value (select t from Model)
                        ? MoreObjects.firstNonNull(((ODocument) rec).getClassName(), "ODocument")
                        : rec.getClass().getSimpleName()
        ).append("(").append(rec instanceof ORecord ? ((ORecord) rec).getIdentity() : rec.toString()).append(")");
        throw new AsyncResultMappingException(
                "Error calling query result listener for record " + id, th);
    }
}
 
开发者ID:xvik,项目名称:guice-persist-orient,代码行数:23,代码来源:AsyncResultMapper.java

示例5: convert

import com.orientechnologies.orient.core.record.ORecord; //导入依赖的package包/类
/**
 * @param result     orient record
 * @param targetType target conversion type
 * @param converter  converter object
 * @param <T>        target conversion type
 * @return converted object
 * @throws ResultConversionException if conversion is impossible
 */
@SuppressWarnings("unchecked")
public <T> T convert(final Object result, final Class<T> targetType, final ResultConverter converter) {
    // wrap primitive, because result will always be object
    final Class<T> target = Primitives.wrap(targetType);
    // do manual conversion to other types if required (usually this will be done automatically by connection
    // object, but async and live callbacks will always return documents)
    T res = tryConversion(result, target);
    if (res != null) {
        return res;
    }

    // use converter
    final ResultDescriptor desc = new ResultDescriptor();
    // support void case for more universal usage
    desc.returnType = target.equals(Void.class) ? ResultType.VOID : ResultType.PLAIN;
    desc.entityType = target;
    desc.expectType = target;
    desc.entityDbType = ORecord.class.isAssignableFrom(target) ? DbType.DOCUMENT : DbType.UNKNOWN;
    res = (T) converter.convert(desc, result);
    ResultUtils.check(res, target);
    return res;
}
 
开发者ID:xvik,项目名称:guice-persist-orient,代码行数:31,代码来源:RecordConverter.java

示例6: convertPlainImpl

import com.orientechnologies.orient.core.record.ORecord; //导入依赖的package包/类
private static Object convertPlainImpl(final Object result, final Class returnClass, final boolean projection) {
    Object converted = null;
    // only update query returns simple number
    if (returnClass.equals(Long.class) && result instanceof Number) {
        converted = ((Number) result).longValue();
    } else if (returnClass.equals(Integer.class) && result instanceof Number) {
        converted = ((Number) result).intValue();
    } else {
        if (result instanceof ORecord) {
            // most likely ResultConverter call (because queries always return collections)
            converted = projection ? applyProjection(result, returnClass) : result;
        } else {
            // if single type required convert from collection
            // simple single type case will be handled on checking assignment (at the top).
            // No projection to apply it to one element only
            final Iterator it = toIterator(result, returnClass, false);
            if (it.hasNext()) {
                converted = projection ? applyProjection(it.next(), returnClass) : it.next();
            }
        }
    }
    return converted;
}
 
开发者ID:xvik,项目名称:guice-persist-orient,代码行数:24,代码来源:ResultUtils.java

示例7: getMap

import com.orientechnologies.orient.core.record.ORecord; //导入依赖的package包/类
protected Map<String, Object> getMap(final ORecord record) {
  Map<String, Object> map = null;

  if (record instanceof ODocument) {
    final ODocument doc = (ODocument) record;

    final Set<String> syncFields = esClient.getSyncFields(doc);
    if (syncFields == null)
      return null;

    map = new HashMap<String, Object>();

    map.put("@rid", doc.getIdentity());
    map.put("@class", doc.getClassName());

    for (String f : doc.fieldNames()) {
      if (!syncFields.isEmpty() && !syncFields.contains(f))
        // SKIP FIELD
        continue;

      final Object value = doc.field(f);

      if (value instanceof ORidBag) {
        final List<OIdentifiable> list = new ArrayList<OIdentifiable>();
        for (Iterator<OIdentifiable> it = ((ORidBag) value).rawIterator(); it.hasNext(); ) {
          list.add(it.next());
        }
        map.put(f, list);

      } else if (value instanceof ORecord && ((ORecord) value).getIdentity().isPersistent()) {
        map.put(f, ((ORecord) value).getIdentity());
      } else
        map.put(f, value);
    }
  }

  return map;
}
 
开发者ID:orientechnologies,项目名称:orientdb-elasticsearch,代码行数:39,代码来源:OElasticSearchDatabaseSync.java

示例8: onTrigger

import com.orientechnologies.orient.core.record.ORecord; //导入依赖的package包/类
@Override
public RESULT onTrigger(final TYPE type, final ORecord record) {
  final EventKind eventKind = getEventKind(type);
  if (eventKind != null && record instanceof ODocument && recordEvent((ODocument) record, eventKind)) {
    log.trace("Recorded {} {}", type, record);
  }
  else {
    log.trace("Ignored {} {}", type, record);
  }
  return RESULT.RECORD_NOT_CHANGED;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:12,代码来源:EntityHook.java

示例9: get

import com.orientechnologies.orient.core.record.ORecord; //导入依赖的package包/类
/**
 * Get singleton entity or {@code null} if entity was not found.
 */
@Nullable
public T get(final ODatabaseDocumentTx db) {
  checkNotNull(db);

  ODictionary<ORecord> dictionary = db.getDictionary();
  ODocument document = dictionary.get(key);
  if (document != null) {
    return adapter.readEntity(document);
  }
  return null;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:15,代码来源:SingletonActions.java

示例10: delete

import com.orientechnologies.orient.core.record.ORecord; //导入依赖的package包/类
/**
 * Delete singleton entity.  Returns {@code true} if entity was deleted.
 */
public boolean delete(final ODatabaseDocumentTx db) {
  checkNotNull(db);

  ODictionary<ORecord> dictionary = db.getDictionary();
  ODocument document = dictionary.get(key);
  if (document != null) {
    db.delete(document);
    dictionary.remove(key);
    return true;
  }
  return false;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:16,代码来源:SingletonActions.java

示例11: replicate

import com.orientechnologies.orient.core.record.ORecord; //导入依赖的package包/类
/**
 * TEMP: workaround OrientDB 2.1 issue where in-TX dictionary updates are not replicated.
 *
 * @since 3.1
 */
public void replicate(final ODocument document, final EventKind eventKind) {
  ODictionary<ORecord> dictionary = document.getDatabase().getDictionary();
  switch (eventKind) {
    case CREATE:
    case UPDATE:
      dictionary.put(key, document);
      break;
    case DELETE:
      dictionary.remove(key);
      break;
    default:
      break;
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:20,代码来源:SingletonActions.java

示例12: elements

import com.orientechnologies.orient.core.record.ORecord; //导入依赖的package包/类
protected <A extends Element> Iterator<A> elements(String elementClass, Function<ORecord, A> toA, Object... elementIds) {
    boolean polymorphic = true;
    if (elementIds.length == 0) {
        // return all vertices as stream
        Iterator<ORecord> itty = new ORecordIteratorClass<>(database, database, elementClass, polymorphic);
        return asStream(itty).map(toA).iterator();
    } else {
        Stream<ORID> ids = Stream.of(elementIds).map(OrientGraph::createRecordId).peek(id -> checkId(id));
        Stream<ORecord> records = ids.filter(ORID::isValid).map(id -> getRecord(id)).filter(r -> r != null);
        return records.map(toA).iterator();
    }
}
 
开发者ID:orientechnologies,项目名称:orientdb-gremlin,代码行数:13,代码来源:OrientGraph.java

示例13: getRecord

import com.orientechnologies.orient.core.record.ORecord; //导入依赖的package包/类
protected ORecord getRecord(ORID id) {
    try {
        return id.getRecord();
    } catch (ORecordNotFoundException e) {
        throw new NoSuchElementException(
                "The " + getClass().getSimpleName().toLowerCase() + " with id " + id + " of type " + id.getClass().getSimpleName()
                        + " does not exist in the graph");
    }
}
 
开发者ID:orientechnologies,项目名称:orientdb-gremlin,代码行数:10,代码来源:OrientGraph.java

示例14: getRawDocument

import com.orientechnologies.orient.core.record.ORecord; //导入依赖的package包/类
protected ODocument getRawDocument(ORecord record) {
    if (record == null) throw new NoSuchElementException();
    if (record instanceof OIdentifiable)
        record = record.getRecord();
    ODocument currentDocument = (ODocument) record;
    if (currentDocument.getInternalStatus() == ODocument.STATUS.NOT_LOADED)
        currentDocument.load();
    if (ODocumentInternal.getImmutableSchemaClass(currentDocument) == null)
        throw new IllegalArgumentException(
                "Cannot determine the graph element type because the document class is null. Probably this is a projection, use the EXPAND() function");
    return currentDocument;
}
 
开发者ID:orientechnologies,项目名称:orientdb-gremlin,代码行数:13,代码来源:OrientGraph.java

示例15: execute

import com.orientechnologies.orient.core.record.ORecord; //导入依赖的package包/类
public LinkedList<OrientVertex> execute(Object iThis, OIdentifiable iCurrentRecord, Object iCurrentResult,
    final Object[] iParams, OCommandContext iContext) {
  
final OModifiableBoolean shutdownFlag = new OModifiableBoolean();
final OrientBaseGraph graph = OGraphCommandExecutorSQLFactory.getGraph(false, shutdownFlag);

  final ORecord record = (ORecord) (iCurrentRecord != null ? iCurrentRecord.getRecord() : null);

  Object source = iParams[0];
  if (OMultiValue.isMultiValue(source)) {
    if (OMultiValue.getSize(source) > 1)
      throw new IllegalArgumentException("Only one sourceVertex is allowed");
    source = OMultiValue.getFirstValue(source);
  }
  paramSourceVertex = graph.getVertex(OSQLHelper.getValue(source, record, iContext));

  Object dest = iParams[1];
  if (OMultiValue.isMultiValue(dest)) {
    if (OMultiValue.getSize(dest) > 1)
      throw new IllegalArgumentException("Only one destinationVertex is allowed");
    dest = OMultiValue.getFirstValue(dest);
  }
  paramDestinationVertex = graph.getVertex(OSQLHelper.getValue(dest, record, iContext));

  paramWeightFieldName = OStringSerializerHelper.getStringContent(iParams[2]);
  
  paramWeightLimit = Double.parseDouble(iParams[3].toString());
  
  if (iParams.length > 4)
    paramDirection = Direction.valueOf(iParams[4].toString().toUpperCase());

  return super.execute(iContext);
}
 
开发者ID:jrosocha,项目名称:jarvisCli,代码行数:34,代码来源:OSQLFunctionDijkstraWithWeightMax.java


注:本文中的com.orientechnologies.orient.core.record.ORecord类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。