• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ODatabase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: fix

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
public static void fix(MeshOptions options) {
	File graphDir = new File(options.getStorageOptions().getDirectory(), "storage");
	if (graphDir.exists()) {
		log.info("Checking database {" + graphDir + "}");
		OrientGraphFactory factory = new OrientGraphFactory("plocal:" + graphDir.getAbsolutePath()).setupPool(5, 100);
		try {
			// Enable the patched security class
			factory.setProperty(ODatabase.OPTIONS.SECURITY.toString(), OSecuritySharedPatched.class);
			ODatabaseDocumentTx tx = factory.getDatabase();
			try {
				OClass userClass = tx.getMetadata().getSchema().getClass("OUser");
				if (userClass == null) {
					log.info("OrientDB user credentials not found. Recreating needed roles and users.");
					tx.getMetadata().getSecurity().create();
					tx.commit();
				} else {
					log.info("OrientDB user credentials found. Skipping fix.");
				}
			} finally {
				tx.close();
			}
		} finally {
			factory.close();
		}
	}
}
 
开发者ID:gentics,项目名称:mesh,代码行数:27,代码来源:MissingOrientCredentialFixer.java


示例2: withActiveDb

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
private static <T> T withActiveDb(final ODatabase db, final Supplier<T> supplier) {
  @SuppressWarnings("resource")
  final ODatabaseDocumentInternal currentDb = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined();
  if (db.equals(currentDb) || !(db instanceof ODatabaseDocumentInternal)) {
    return supplier.get();
  }
  try {
    ODatabaseRecordThreadLocal.INSTANCE.set((ODatabaseDocumentInternal) db);
    return supplier.get();
  }
  finally {
    if (currentDb != null) {
      ODatabaseRecordThreadLocal.INSTANCE.set(currentDb);
    }
    else {
      ODatabaseRecordThreadLocal.INSTANCE.remove();
    }
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:20,代码来源:EntityHook.java


示例3: flushEvents

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
private void flushEvents(final ODatabase db) {
  final Map<ODocument, EventKind> events = dbEvents.remove(db);
  if (events != null) {
    final UnitOfWork work = UnitOfWork.pause();
    final String remoteNodeId = isRemote.get();
    try {
      if (remoteNodeId == null) {
        postEvents(db, events, null);
      }
      else {
        // posting events from remote node, mark current thread as replicating
        EventHelper.asReplicating(() -> postEvents(db, events, remoteNodeId));
      }
    }
    catch (Throwable e) { // NOSONAR
      // exceptions as a result of posting events should not affect the commit,
      // so log and swallow them rather than let them propagate back to Orient
      log.error("Failed to post entity events", e);
    }
    finally {
      UnitOfWork.resume(work);
    }
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:25,代码来源:EntityHook.java


示例4: postEvents

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
private void postEvents(final ODatabase db, final Map<ODocument, EventKind> events, final String remoteNodeId) {
  final List<EntityEvent> batchedEvents = new ArrayList<>();
  for (final Entry<ODocument, EventKind> entry : events.entrySet()) {
    final EntityEvent event = newEntityEvent(entry.getKey(), entry.getValue());
    if (event != null) {
      event.setRemoteNodeId(remoteNodeId);
      eventManager.post(event);
      db.activateOnCurrentThread();
      if (event instanceof Batchable) {
        batchedEvents.add(event);
      }
    }
  }

  if (!batchedEvents.isEmpty()) {
    eventManager.post(new EntityBatchEvent(batchedEvents));
    db.activateOnCurrentThread();
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:20,代码来源:EntityHook.java


示例5: initDatabase

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
public static void initDatabase(@NonNull final ODatabase db) {
    final JsonLog info = JsonLog.newInfoLog(Logger.getLogger(EventLogRepository.class.getName()), EventLogRepository.class.getName());
    try {
        OClass timestampedClass = db.getMetadata().getSchema().getClass(Timestamped.class.getSimpleName());
        if (timestampedClass == null) {
            timestampedClass = db.getMetadata().getSchema().createAbstractClass(Timestamped.class.getSimpleName());
            timestampedClass.createProperty(Timestamped.Field.created_on.name(), OType.DATETIME);
            timestampedClass.createProperty(Timestamped.Field.updated_on.name(), OType.DATETIME);
            info.log("startUp", () -> Json.createObjectBuilder().add("class", Timestamped.class.getSimpleName()).add("created", true).build());
        } else {
            info.log("startUp", () -> Json.createObjectBuilder().add("class", Timestamped.class.getSimpleName()).build());
        }

        OClass logRecordClass = db.getMetadata().getSchema().getClass(EventLogRecord.class.getSimpleName());
        if (logRecordClass == null) {
            logRecordClass = db.getMetadata().getSchema().createClass(EventLogRecord.class.getSimpleName()).setSuperClasses(ImmutableList.of(timestampedClass));
            logRecordClass.createProperty(EventLogRecord.Field.event.name(), OType.STRING);
            info.log("startUp", () -> Json.createObjectBuilder().add("class", EventLogRecord.class.getSimpleName()).add("created", true).build());
        } else {
            info.log("startUp", () -> Json.createObjectBuilder().add("class", EventLogRecord.class.getSimpleName()).build());
        }

    } finally {
        db.close();
    }
}
 
开发者ID:runrightfast,项目名称:runrightfast-vertx,代码行数:27,代码来源:EventLogRepository.java


示例6: testSavingEventLogRecord

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
private void testSavingEventLogRecord(final ODatabase db, final String testName) throws Exception {
    db.registerHook(new SetCreatedOnAndUpdatedOn());

    final EventLogRecord eventLogRecord = new EventLogRecord();
    try {
        db.begin();
        eventLogRecord.setEvent("app.started");
        eventLogRecord.save();
        db.commit();
    } catch (final Exception e) {
        db.rollback();
        throw e;
    }

    log.logp(INFO, CLASS_NAME, testName, String.format("doc = %s", eventLogRecord.toJSON()));
    assertThat(eventLogRecord.getCreatedOn(), is(notNullValue()));
    assertThat(eventLogRecord.getUpdatedOn(), is(notNullValue()));
}
 
开发者ID:runrightfast,项目名称:runrightfast-vertx,代码行数:19,代码来源:RunRightFastOrientDBLifeCycleListenerTest.java


示例7: initDatabase

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
private static void initDatabase() {
    final OServerAdmin admin = service.getServerAdmin();
    try {
        OrientDBUtils.createDatabase(admin, CLASS_NAME);
    } finally {
        admin.close();
    }

    final Optional<ODatabaseDocumentTxSupplier> dbSupplier = service.getODatabaseDocumentTxSupplier(CLASS_NAME);
    assertThat(dbSupplier.isPresent(), is(true));

    try (final ODatabase db = dbSupplier.get().get()) {
        final OClass timestampedClass = db.getMetadata().getSchema().createAbstractClass(Timestamped.class.getSimpleName());
        timestampedClass.createProperty(Timestamped.Field.created_on.name(), OType.DATETIME);
        timestampedClass.createProperty(Timestamped.Field.updated_on.name(), OType.DATETIME);

        final OClass logRecordClass = db.getMetadata().getSchema().createClass(EventLogRecord.class.getSimpleName()).setSuperClasses(ImmutableList.of(timestampedClass));
        logRecordClass.createProperty(EventLogRecord.Field.event.name(), OType.STRING);
    }
}
 
开发者ID:runrightfast,项目名称:runrightfast-vertx,代码行数:21,代码来源:EmbeddedOrientDBServiceWithSSLTest.java


示例8: initDatabase

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
private static void initDatabase() {
    final OServerAdmin admin = service.getServerAdmin();
    try {
        OrientDBUtils.createDatabase(admin, CLASS_NAME);
    } finally {
        admin.close();
    }
    try (final ODatabase db = service.getODatabaseDocumentTxSupplier(CLASS_NAME).get().get()) {
        final OClass timestampedClass = db.getMetadata().getSchema().createAbstractClass(Timestamped.class.getSimpleName());
        timestampedClass.createProperty(Timestamped.Field.created_on.name(), OType.DATETIME);
        timestampedClass.createProperty(Timestamped.Field.updated_on.name(), OType.DATETIME);

        final OClass logRecordClass = db.getMetadata().getSchema().createClass(EventLogRecord.class.getSimpleName()).setSuperClasses(ImmutableList.of(timestampedClass));
        logRecordClass.createProperty(EventLogRecord.Field.event.name(), OType.STRING);
    }
}
 
开发者ID:runrightfast,项目名称:runrightfast-vertx,代码行数:17,代码来源:OrientDBHazelcastPluginTest.java


示例9: initDatabase

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
public void initDatabase() {
    try (final ODatabase db = dbSupplier.get()) {
        OClass timestampedClass = db.getMetadata().getSchema().getClass(Timestamped.class.getSimpleName());
        if (timestampedClass == null) {
            timestampedClass = db.getMetadata().getSchema().createAbstractClass(Timestamped.class.getSimpleName());
            timestampedClass.createProperty(Timestamped.Field.created_on.name(), OType.DATETIME);
            timestampedClass.createProperty(Timestamped.Field.updated_on.name(), OType.DATETIME);
            info.log("startUp", () -> Json.createObjectBuilder().add("class", Timestamped.class.getSimpleName()).add("created", true).build());
        } else {
            info.log("startUp", () -> Json.createObjectBuilder().add("class", Timestamped.class.getSimpleName()).build());
        }

        OClass logRecordClass = db.getMetadata().getSchema().getClass(EventLogRecord.class.getSimpleName());
        if (logRecordClass == null) {
            logRecordClass = db.getMetadata().getSchema().createClass(EventLogRecord.class.getSimpleName()).setSuperClasses(ImmutableList.of(timestampedClass));
            logRecordClass.createProperty(EventLogRecord.Field.event.name(), OType.STRING);
            info.log("startUp", () -> Json.createObjectBuilder().add("class", EventLogRecord.class.getSimpleName()).add("created", true).build());
        } else {
            info.log("startUp", () -> Json.createObjectBuilder().add("class", EventLogRecord.class.getSimpleName()).build());
        }
    }
}
 
开发者ID:runrightfast,项目名称:runrightfast-vertx,代码行数:23,代码来源:EventLogRepository.java


示例10: fixOrientDBRights

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
/**
 * Required for explicit update of rights due to changes in OrientDB 2.2.23
 * Related issue: https://github.com/orientechnologies/orientdb/issues/7549
 * @param db - database to apply fix on
 */
public void fixOrientDBRights(ODatabase<?> db) {
	OSecurity security = db.getMetadata().getSecurity();
	ORole readerRole = security.getRole("reader");
	readerRole.grant(ResourceGeneric.CLUSTER, "orole", ORole.PERMISSION_READ);
	readerRole.grant(ResourceGeneric.CLUSTER, "ouser", ORole.PERMISSION_READ);
	readerRole.grant(ResourceGeneric.CLASS, "orole", ORole.PERMISSION_READ);
	readerRole.grant(ResourceGeneric.CLASS, "ouser", ORole.PERMISSION_READ);
	readerRole.grant(ResourceGeneric.SYSTEM_CLUSTERS, null, ORole.PERMISSION_READ);
	readerRole.save();
	ORole writerRole = security.getRole("writer");
	writerRole.grant(ResourceGeneric.CLUSTER, "orole", ORole.PERMISSION_READ);
	writerRole.grant(ResourceGeneric.CLUSTER, "ouser", ORole.PERMISSION_READ);
	writerRole.grant(ResourceGeneric.CLASS, "orole", ORole.PERMISSION_READ);
	writerRole.grant(ResourceGeneric.CLASS, "ouser", ORole.PERMISSION_READ);
	writerRole.grant(ResourceGeneric.SYSTEM_CLUSTERS, null, ORole.PERMISSION_READ);
	writerRole.save();
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:23,代码来源:OrientDbWebApplication.java


示例11: doStart

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
@Override
protected void doStart() throws Exception {
	OrientDBEndpoint endpoint = (OrientDBEndpoint)getEndpoint();
	ODatabase<?> db = endpoint.databaseOpen();
	Object dbResult = db.command(new OCommandSQL(endpoint.getSQLQuery())).execute();
	
	Object out = endpoint.makeOutObject(dbResult);
	endpoint.databaseClose(db);
	
	Exchange exchange = getEndpoint().createExchange();
	exchange.getIn().setBody(out);
	getProcessor().process(exchange);
	
	super.doStart();
}
 
开发者ID:OrienteerBAP,项目名称:camel-orientdb,代码行数:16,代码来源:OrientDBConsumer.java


示例12: processList

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
private List<Object> processList(List<?> inputList,OrientDBEndpoint endpoint,ODatabase<?> db) throws Exception{
	List<Object> outputList = new ArrayList<Object>();
	for (Object inputElement : inputList) {
		Object dbResult = processSingleObject(inputElement,endpoint,db);
		if (dbResult instanceof List){
			outputList.addAll((List<?>)dbResult);
		}else{
			outputList.add(dbResult);
		}
	}
	return outputList;
}
 
开发者ID:OrienteerBAP,项目名称:camel-orientdb,代码行数:13,代码来源:OrientDBProducer.java


示例13: databaseOpen

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
public ODatabase<?> databaseOpen() throws Exception{
	String url = getCamelContext().getProperty(OrientDBComponent.DB_URL);
	String username = getCamelContext().getProperty(OrientDBComponent.DB_USERNAME);
	String password = getCamelContext().getProperty(OrientDBComponent.DB_PASSWORD);
	
	if(url!=null && username!=null) {
		return dbPool.get(url, username, password).acquire();
	}else{
		throw new Exception("Cannot connect to OrientDB server without properties "+OrientDBComponent.DB_URL+" and "+OrientDBComponent.DB_USERNAME);
	}
}
 
开发者ID:OrienteerBAP,项目名称:camel-orientdb,代码行数:12,代码来源:OrientDBEndpoint.java


示例14: onOpen

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
@Override
public void onOpen(final ODatabaseInternal db) {
  if (OSecurityNull.class.equals(db.getProperty(ODatabase.OPTIONS.SECURITY.toString()))) {
    return; // ignore maintenance operations which run without security, such as index repair
  }
  if (!startRecording(db)) {
    pendingDbs.add(db);
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:10,代码来源:EntityHook.java


示例15: startRecording

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
private boolean startRecording(final ODatabase db) {
  if (recordingDatabases.contains(db.getName())) {
    db.registerListener(this);
    // this call must be made with the given db active on this thread
    withActiveDb(db, () -> db.registerHook(this, HOOK_POSITION.LAST));
    return true;
  }
  return false;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:10,代码来源:EntityHook.java


示例16: getDatabaseInfo

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
private JsonObject getDatabaseInfo(final ODatabase db) {
    return Json.createObjectBuilder()
            .add("name", db.getName())
            .add("type", db.getType())
            .add("url", db.getURL())
            .build();

}
 
开发者ID:runrightfast,项目名称:runrightfast-vertx,代码行数:9,代码来源:ODatabaseDocumentTxHealthCheck.java


示例17: setUpClass

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
@BeforeClass
public static void setUpClass() throws Exception {
    orientdbHome.mkdirs();
    FileUtils.cleanDirectory(orientdbHome);
    FileUtils.deleteDirectory(orientdbHome);
    log.logp(INFO, CLASS_NAME, "setUpClass", String.format("orientdbHome.exists() = %s", orientdbHome.exists()));

    final File configDirSrc = new File("src/test/resources/orientdb/config");
    final File configDirTarget = new File(orientdbHome, "config");
    FileUtils.copyFileToDirectory(new File(configDirSrc, "default-distributed-db-config.json"), configDirTarget);
    FileUtils.copyFileToDirectory(new File(configDirSrc, "hazelcast.xml"), configDirTarget);

    server = createOServer();
    server.activate();

    final File dbDir = new File(orientdbHome, String.format("databases/%s", RunRightFastOrientDBLifeCycleListenerTest.class.getSimpleName()));
    final String dbUrl = "plocal:" + dbDir.getAbsolutePath();
    try (final ODatabase db = new ODatabaseFactory().createDatabase("document", dbUrl).create()) {
        log.logp(INFO, CLASS_NAME, "setUpClass", String.format("created db = %s", db.getName()));

        final OClass timestampedClass = db.getMetadata().getSchema().createAbstractClass(Timestamped.class.getSimpleName());
        timestampedClass.createProperty(Timestamped.Field.created_on.name(), OType.DATETIME);
        timestampedClass.createProperty(Timestamped.Field.updated_on.name(), OType.DATETIME);

        final OClass logRecordClass = db.getMetadata().getSchema().createClass(EventLogRecord.class.getSimpleName()).setSuperClasses(ImmutableList.of(timestampedClass));
        logRecordClass.createProperty(EventLogRecord.Field.event.name(), OType.STRING);
    }
}
 
开发者ID:runrightfast,项目名称:runrightfast-vertx,代码行数:29,代码来源:RunRightFastOrientDBLifeCycleListenerTest.java


示例18: testLifeCycleListener

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
@Test
public void testLifeCycleListener() throws Exception {
    try (final ODatabase db = server.openDatabase("document", getClass().getSimpleName(), ROOT_USER, "root")
            .registerHook(new SetCreatedOnAndUpdatedOn())
            .activateOnCurrentThread()) {
        testSavingEventLogRecord(db, "testLifeCycleListener");
    }

}
 
开发者ID:runrightfast,项目名称:runrightfast-vertx,代码行数:10,代码来源:RunRightFastOrientDBLifeCycleListenerTest.java


示例19: init

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
@BeforeClass
public void init() {
  initDB();

  databaseDocumentTx.set(ODatabase.ATTRIBUTES.CUSTOM, "strictSql=false");
  OSchema schema = databaseDocumentTx.getMetadata().getSchema();
  OClass v = schema.getClass("V");
  OClass oClass = schema.createClass("Place");
  oClass.setSuperClass(v);
  oClass.createProperty("location", OType.EMBEDDED, schema.getClass("OLineString"));
  oClass.createProperty("name", OType.STRING);

  databaseDocumentTx.command(new OCommandSQL("CREATE INDEX Place.location ON Place(location) SPATIAL ENGINE LUCENE")).execute();

}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:16,代码来源:LuceneSpatialLineStringTest.java


示例20: init

import com.orientechnologies.orient.core.db.ODatabase; //导入依赖的package包/类
@BeforeClass
public void init() {
  initDB();

  databaseDocumentTx.set(ODatabase.ATTRIBUTES.CUSTOM, "strictSql=false");
  OSchema schema = databaseDocumentTx.getMetadata().getSchema();
  OClass v = schema.getClass("V");
  OClass oClass = schema.createClass("Place");
  oClass.setSuperClass(v);
  oClass.createProperty("location", OType.EMBEDDED, schema.getClass("OPolygon"));
  oClass.createProperty("name", OType.STRING);

  databaseDocumentTx.command(new OCommandSQL("CREATE INDEX Place.location ON Place(location) SPATIAL ENGINE LUCENE")).execute();

}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:16,代码来源:LuceneSpatialPolygonTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ProgressSplitsBlock类代码示例发布时间:2022-05-22
下一篇:
Java ORBDefaultInitRefResolverImpl类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap