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


Java ODatabaseDocument类代码示例

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


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

示例1: setupTypesAndIndices

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入依赖的package包/类
/**
 * Setup some indices. This is highly orientdb specific and may not be easy so setup using blueprint API.
 */
private void setupTypesAndIndices() {
	try (Tx tx = graph.tx()) {
		OrientGraph g = ((OrientGraph) ((DelegatingFramedOrientGraph) tx.getGraph()).getBaseGraph());
		ODatabaseDocument rawDb = g.getRawDatabase();
		OClass e = rawDb.createEdgeClass("HAS_MEMBER");
		e.createProperty("in", OType.LINK);
		e.createProperty("out", OType.LINK);
		e.createIndex("e.has_member", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, "out", "in");

		OClass v = rawDb.createVertexClass(Group.class.getSimpleName());
		v.createProperty("name", OType.STRING);

		v = rawDb.createVertexClass(Person.class.getSimpleName());
		v.createProperty("name", OType.STRING);
		v.createIndex(Person.class.getSimpleName() + ".name", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, "name");
		tx.success();
	}

}
 
开发者ID:Syncleus,项目名称:Ferma-OrientDB,代码行数:23,代码来源:IndexTest.java

示例2: execute

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入依赖的package包/类
/**
 * @return result of execution
 */
public final V execute()
{
	ODatabaseDocument db = null;
	ODatabaseDocument oldDb = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined();
	if(oldDb!=null) ODatabaseRecordThreadLocal.INSTANCE.remove(); //Required to avoid stack of transactions
	try
	{
		db = getSettings().getDatabasePoolFactory().get(getDBUrl(), getUsername(), getPassword()).acquire();
		db.activateOnCurrentThread();
		return execute(db);
	} 
	finally
	{
		if(db!=null) db.close();
		if(oldDb!=null) ODatabaseRecordThreadLocal.INSTANCE.set((ODatabaseDocumentInternal)oldDb);
		else ODatabaseRecordThreadLocal.INSTANCE.remove();
	}
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:22,代码来源:DBClosure.java

示例3: sudoSave

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入依赖的package包/类
/**
 * Allow to save set of document under admin
 * @param docs set of document to be saved
 */
public static void sudoSave(final ODocument... docs) {
	if(docs==null || docs.length==0) return;
	new DBClosure<Boolean>() {

		@Override
		protected Boolean execute(ODatabaseDocument db) {
			db.begin();
			for (ODocument doc : docs) {
				db.save(doc);
			}
			db.commit();
			return true;
		}
	}.execute();
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:20,代码来源:DBClosure.java

示例4: load

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入依赖的package包/类
@Override
protected ODocument load() {
	if(orid!=null && orid.isValid())
	{
		try {
			ODatabaseDocument db = OrientDbWebSession.get().getDatabase();
			return db.load(orid);
		} catch (ORecordNotFoundException e) {
			return null;
		}
	}
	else
	{
		return savedDocument;
	}
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:17,代码来源:ODocumentModel.java

示例5: size

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入依赖的package包/类
/**
 * Get the size of the data
 * @return results size
 */
public long size()
{
	if(size==null)
	{
 	ODatabaseDocument db = OrientDbWebSession.get().getDatabase();
 	OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(queryManager.getCountSql());
 	List<ODocument> ret = db.query(enhanceContextByVariables(query), prepareParams());
 	if(ret!=null && ret.size()>0)
 	{
 		Number sizeNumber = ret.get(0).field("count");
 		size = sizeNumber!=null?sizeNumber.longValue():0;
 	}
 	else
 	{
 		size = 0L;
 	}
	}
	return size;
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:24,代码来源:OQueryModel.java

示例6: onAfterInitialized

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入依赖的package包/类
@Override
public void onAfterInitialized(Application application) {
	OrientDbWebApplication app = (OrientDbWebApplication)application;
	ODatabaseDocument db = getDatabase(app);
	try
	{
		installData(app, db);
	}
	catch(Exception ex)
	{
		LOG.error("Data can't be installed", ex);
	}
	finally
	{
		db.close();
	}
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:18,代码来源:AbstractDataInstallator.java

示例7: testRemovingReadonlyField

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入依赖的package包/类
@Test
public void testRemovingReadonlyField()
{
	ODatabaseDocument db = wicket.getTester().getDatabase();
	OSchema schema = db.getMetadata().getSchema();
	OClass classA = schema.createClass("TestRemovingField");
	classA.createProperty("name", OType.STRING);
	OProperty property = classA.createProperty("property", OType.STRING);
	property.setReadonly(true);
	
	ODocument doc = new ODocument(classA);
	doc.field("name", "My Name");
	doc.field("property", "value1");
	doc.save();
	
	doc.field("name", "My Name 2");
	doc.field("property", "value2");
	doc.undo("property");
	doc.save();
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:21,代码来源:TestInAppOrientDBCompatibility.java

示例8: testRemovingReadonlyField2

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入依赖的package包/类
@Test
public void testRemovingReadonlyField2()
{
	ODatabaseDocument db = wicket.getTester().getDatabase();
	OSchema schema = db.getMetadata().getSchema();
	OClass classA = schema.createClass("TestRemovingField2");
	classA.createProperty("name", OType.STRING);
	OProperty property = classA.createProperty("property", OType.STRING);
	property.setReadonly(true);
	
	ODocument doc = new ODocument(classA);
	doc.field("name", "My Name");
	doc.field("property", "value1");
	doc.save();
	
	doc.field("name", "My Name 2");
	doc.field("property", "value2");
	doc.undo();
	doc.field("name", "My Name 3");
	doc.save();
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:22,代码来源:TestInAppOrientDBCompatibility.java

示例9: testClassChange

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入依赖的package包/类
@Test
@Ignore
public void testClassChange()
{
	ODatabaseDocument db = wicket.getTester().getDatabase();
	OSchema schema = db.getMetadata().getSchema();
	OClass classA = schema.createClass("TestClassChangeA");
	OClass classB = schema.createClass("TestClassChangeB");
	ODocument doc = new ODocument(classA);
	doc.save();
	doc = doc.getIdentity().getRecord();
	doc.setClassName(classB.getName());
	assertEquals(classB.getName(), doc.getClassName());
	doc = doc.getIdentity().getRecord();
	assertEquals(classB.getName(), doc.getClassName());
	ORID id = doc.getIdentity();
	db.commit(true);
	db.close();
	db = wicket.getTester().getDatabase();
	doc = id.getRecord();
	assertEquals(classB.getName(), doc.getClassName());
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:23,代码来源:TestInAppOrientDBCompatibility.java

示例10: testDeletionOfDependentClass2

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入依赖的package包/类
@Test
public void testDeletionOfDependentClass2()
{
	ODatabaseDocument db = wicket.getTester().getDatabase();
	OSchema schema = db.getMetadata().getSchema();
	OClass classAbs = schema.createAbstractClass("TestDeletionAbst");
	OClass classA = schema.createClass("TestDeletionA", classAbs);
	ODocument doc = new ODocument(classA);
	doc.save();
	assertEquals(1, classA.count());
	OClass classB = schema.createClass("TestDeletionB", classA);
	doc = new ODocument(classB);
	doc.save();
	assertEquals(1, classB.count());
	assertEquals(2, classA.count());
	schema.dropClass(classB.getName());
	assertEquals(1, classA.count());
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:19,代码来源:TestInAppOrientDBCompatibility.java

示例11: createOClass

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入依赖的package包/类
private OClass createOClass(ODatabaseDocument db, String className, boolean complexTypes) {
    OClass oClass = db.getMetadata().getSchema().createClass(className);
    oClass.createProperty(STRING_FIELD, OType.STRING);
    oClass.createProperty(NUMBER_FIELD, OType.INTEGER);
    oClass.createProperty(DATE_FIELD, OType.DATE);
    oClass.createProperty(DATETIME_FIELD, OType.DATETIME);
    if (complexTypes) {
        oClass.createProperty(LINK_FIELD, OType.LINK);
        oClass.createProperty(LINK_LIST_FIELD, OType.LINKLIST);
        oClass.createProperty(LINK_SET_FIELD, OType.LINKSET);
        oClass.createProperty(LINK_MAP_FIELD, OType.LINKMAP);
        oClass.createProperty(EMBEDDED_FIELD, OType.EMBEDDED);
        oClass.createProperty(EMBEDDED_LIST_FIELD, OType.EMBEDDEDLIST);
        oClass.createProperty(EMBEDDED_SET_FIELD, OType.EMBEDDEDSET);
        oClass.createProperty(EMBEDDED_MAP_FIELD, OType.EMBEDDEDMAP);
        oClass.createProperty(EMBEDDED_LIST_STRING_FIELD, OType.EMBEDDEDLIST);
        oClass.createProperty(EMBEDDED_SET_STRING_FIELD, OType.EMBEDDEDSET);
    }
    initPropertiesMap(oClass.propertiesMap());
    db.commit();
    return oClass;
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:23,代码来源:WicketOrientDbFilterTesterScope.java

示例12: connectInTransaction

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入依赖的package包/类
protected <R> Observable<R> connectInTransaction(Function<ODatabaseDocument, R> function) {
  return Observable.create(subscriber -> {
    try (ODatabaseDocument conn = getConnection()) {
      try {
        subscriber.onStart();
        conn.begin();
        R result = function.apply(conn);
        conn.commit();
        subscriber.onNext(result);
        subscriber.onCompleted();
      } catch (Exception e) {
        conn.rollback();
        subscriber.onError(e);
      }
    }
  });
}
 
开发者ID:lfridael,项目名称:resourceful-java-prototype,代码行数:18,代码来源:OrientDbDao.java

示例13: execute

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入依赖的package包/类
public Observable<Integer> execute() {
  return Observable.create(subscriber -> {
    try (ODatabaseDocument conn = dao.getConnection()) {
      subscriber.onStart();
      logger.debug("Executing command '{}'. Params: {}", sql, asList(params));
      OCommandSQL command = new OCommandSQL(sql);
      int count = command.execute(params);
      logger.debug("Result of executing command '{}': {} ", sql, count);
      subscriber.onNext(count);
      subscriber.onCompleted();
    } catch (Throwable e) {
      logger.error("Error excuting command: {}", e.getMessage());
      subscriber.onError(e);
    }
  });
}
 
开发者ID:lfridael,项目名称:resourceful-java-prototype,代码行数:17,代码来源:OrientDbCommand.java

示例14: execute

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入依赖的package包/类
@Override
public Object execute(Object iThis, OIdentifiable iCurrentRecord, Object iCurrentResult, Object[] iParams,
    OCommandContext iContext) {

  String clazz = (String) iParams[0];
  String latField = (String) iParams[1];
  String lngField = (String) iParams[2];
  ODatabaseDocument databaseRecord = ODatabaseRecordThreadLocal.INSTANCE.get();
  Set<OIndex<?>> indexes = databaseRecord.getMetadata().getSchema().getClass(clazz).getInvolvedIndexes(latField, lngField);
  for (OIndex i : indexes) {
    if (OClass.INDEX_TYPE.SPATIAL.toString().equals(i.getInternal().getType())) {
      List<Object> params = new ArrayList<Object>();
      params.add(iParams[3]);
      params.add(iParams[4]);
      double distance = iParams.length > 5 ? ((Number) iParams[5]).doubleValue() : 0;
      Object ret = i.get(new OSpatialCompositeKey(params).setMaxDistance(distance));
      if (ret instanceof Collection) {
        if (context == null)
          context = new HashSet<Object>();
        context.addAll((Collection<?>) ret);
      }
      return ret;
    }
  }
  return null;
}
 
开发者ID:orientechnologies,项目名称:orientdb-lucene,代码行数:27,代码来源:OLuceneNearFunction.java

示例15: setUp

import com.orientechnologies.orient.core.db.document.ODatabaseDocument; //导入依赖的package包/类
public static TestWrapper setUp(){
    TestWrapper container = new TestWrapper();
    container.time = System.nanoTime();
    container.db = new ODatabaseDocumentTx(OrientDBDao.DEFAULT_CONFIG);
    if(container.db.exists()){
        container.db.open("admin","admin");
    } else {
        container.db.create();
    }
    container.serverDao = new OrientDBDao((ODatabaseDocument) container.db);
    try {
        container.serverDao.query(new QueryBuilder().delete().from(Credentials.class).build());
    } catch (ServerDAO.DAOException e) {
        e.printStackTrace();
    }
    container.app = new TestApplication(container.serverDao);

    return container;
}
 
开发者ID:williamwebb,项目名称:divide,代码行数:20,代码来源:TestUtils.java


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