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


Java ODatabaseDocumentInternal类代码示例

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


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

示例1: doFilter

import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; //导入依赖的package包/类
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException
{
    try
    {
        chain.doFilter(request, response);
    }
    catch (IOException e)
    {
        throw new ServletException(e);
    }
    finally
    {
        ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined();
        if (database != null)
        {
            database.close();
            ODatabaseRecordThreadLocal.INSTANCE.remove();
        }
    }
}
 
开发者ID:geekflow,项目名称:light,代码行数:22,代码来源:OrientDBFilter.java

示例2: withActiveDb

import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; //导入依赖的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: createIndex

import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; //导入依赖的package包/类
@Override
public OIndexInternal<?> createIndex(String name, ODatabaseDocumentInternal database, String indexType, String algorithm,
                                     String valueContainerAlgorithm, ODocument metadata, int version)
    throws OConfigurationException {

  OAbstractPaginatedStorage storage = (OAbstractPaginatedStorage) database.getStorage()
                                                                          .getUnderlying();

  OBinarySerializer<?> objectSerializer = storage.getComponentsFactory().binarySerializerFactory
      .getObjectSerializer(OLuceneMockSpatialSerializer.INSTANCE.getId());

  if (objectSerializer == null) {
    storage.getComponentsFactory().binarySerializerFactory
        .registerSerializer(OLuceneMockSpatialSerializer.INSTANCE, OType.EMBEDDED);
  }

  if (metadata == null)
    metadata = new ODocument().field("analyzer", StandardAnalyzer.class.getName());

  if (OClass.INDEX_TYPE.SPATIAL.toString()
                               .equals(indexType)) {

    return new OLuceneSpatialIndex(name, indexType, LUCENE_ALGORITHM, version, storage, valueContainerAlgorithm, metadata);
  }
  throw new OConfigurationException("Unsupported type : " + algorithm);
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:27,代码来源:OLuceneSpatialIndexFactory.java

示例4: execute

import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; //导入依赖的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

示例5: getThreadDatabase

import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; //导入依赖的package包/类
@Override
public ODatabaseDocumentInternal getThreadDatabase() {
	IOrientDbSettings settings = app.getOrientDbSettings();
	OrientDbWebSession session = OrientDbWebSession.exists()?OrientDbWebSession.get():null;
	ODatabaseDocumentInternal db;
	String username;
	String password;
	if(session!=null && session.isSignedIn())
	{
		username = session.getUsername();
		password = session.getPassword();
	}
	else
	{
		username = settings.getGuestUserName();
		password = settings.getGuestPassword();
	}
	db = settings.getDatabasePoolFactory().get(settings.getDBUrl(), username, password).acquire();
	return db;
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:21,代码来源:DefaultODatabaseThreadLocalFactory.java

示例6: buildFacetIndexIfNeeded

import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; //导入依赖的package包/类
protected void buildFacetIndexIfNeeded() throws IOException {

    if (metadata != null && metadata.containsField(FACET_FIELDS)) {
      ODatabaseDocumentInternal database = owner.getDatabase();
      Iterable<String> iterable = metadata.field(FACET_FIELDS);
      if (iterable != null) {
        Directory dir = getTaxDirectory(database);
        taxonomyWriter = new DirectoryTaxonomyWriter(dir, IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
        for (String s : iterable) {
          facetField = s;
          // facetField = "facet_" + s;
          // facetDim = s;
          // config.setIndexFieldName(s, "facet_" + s);
          config.setHierarchical(s, true);
        }
      }

    }
  }
 
开发者ID:orientechnologies,项目名称:orientdb-lucene,代码行数:20,代码来源:OLuceneFacetManager.java

示例7: internalDelete

import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; //导入依赖的package包/类
protected void internalDelete(String indexName) {
  try {
    if (mgrWriter != null && mgrWriter.getIndexWriter() != null) {
      closeIndex();
    }
    ODatabaseDocumentInternal database = getDatabase();
    final OAbstractPaginatedStorage storageLocalAbstract = (OAbstractPaginatedStorage) database.getStorage().getUnderlying();
    if (storageLocalAbstract instanceof OLocalPaginatedStorage) {

      OLocalPaginatedStorage localAbstract = (OLocalPaginatedStorage) storageLocalAbstract;

      File f = new File(getIndexPath(localAbstract, indexName));
      OLuceneIndexUtils.deleteFolder(f);
      f = new File(getIndexBasePath(localAbstract));
      OLuceneIndexUtils.deleteFolderIfEmpty(f);
    }
  } catch (IOException e) {
    OLogManager.instance().error(this, "Error on deleting Lucene index", e);
  }
}
 
开发者ID:orientechnologies,项目名称:orientdb-lucene,代码行数:21,代码来源:OLuceneIndexManagerAbstract.java

示例8: delete

import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; //导入依赖的package包/类
public void delete() {
  if (mgrWriter == null)
    // INDEX NOT COMPLETELY INITIALIZED, SKIP IT
    return;

  try {
    if (mgrWriter.getIndexWriter() != null) {
      closeIndex();
    }
    ODatabaseDocumentInternal database = getDatabase();
    final OAbstractPaginatedStorage storageLocalAbstract = (OAbstractPaginatedStorage) database.getStorage().getUnderlying();
    if (storageLocalAbstract instanceof OLocalPaginatedStorage) {

      File f = new File(getIndexPath((OLocalPaginatedStorage) storageLocalAbstract));
      OLuceneIndexUtils.deleteFolder(f);
      f = new File(getIndexBasePath((OLocalPaginatedStorage) storageLocalAbstract));
      OLuceneIndexUtils.deleteFolderIfEmpty(f);
    }
  } catch (IOException e) {
    OLogManager.instance().error(this, "Error on deleting Lucene index", e);
  }
}
 
开发者ID:orientechnologies,项目名称:orientdb-lucene,代码行数:23,代码来源:OLuceneIndexManagerAbstract.java

示例9: getSyncFields

import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; //导入依赖的package包/类
/**
 * Returns null if the record must be not synchronized, other wise the set of fields to synchronize. An empty set means all the
 * fields.
 */
public Set<String> getSyncFields(final ODocument record) {
  final String className = record.getClassName();
  if (className == null)
    return null;

  if (excludeClasses.contains(className))
    return null;

  final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.get();

  final String clusterName = db.getClusterNameById(record.getIdentity().getClusterId());
  if (excludeClasses.contains(clusterName))
    return null;

  if (!includeClasses.isEmpty()) {
    if (includeClasses.containsKey(className))
      return includeClasses.get(className);
  }

  if (!includeClusters.isEmpty()) {
    if (includeClusters.containsKey(clusterName))
      return includeClusters.get(clusterName);
  }

  // SYNCHRONIZE ALL FIELDS
  return Collections.EMPTY_SET;
}
 
开发者ID:orientechnologies,项目名称:orientdb-elasticsearch,代码行数:32,代码来源:OElasticSearchDatabaseConfiguration.java

示例10: storage

import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; //导入依赖的package包/类
private OLocalPaginatedStorage storage() {
  if (storage == null || storage.isClosed()) {
    // use temp TX to get local storage; note we don't need a TX when reading write-ahead-log
    ODatabaseDocumentInternal currentDb = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined();
    try (ODatabaseDocumentInternal db = databaseProvider.get().acquire()) {
      storage = (OLocalPaginatedStorage) db.getStorage().getUnderlying();
    }
    finally {
      ODatabaseRecordThreadLocal.INSTANCE.set(currentDb);
    }
  }
  return storage;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:14,代码来源:EntityLog.java

示例11: browseComponentAssets

import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; //导入依赖的package包/类
private Iterable<ODocument> browseComponentAssets(final ODocument component) {
  checkNotNull(component);
  OIdentifiable bucket = component.field(ComponentEntityAdapter.P_BUCKET, OIdentifiable.class);
  ODatabaseDocumentInternal db = component.getDatabase();
  Iterable<ODocument> results = db
      .command(new OCommandSQL("select from asset where bucket = :bucket and component = :component")).execute(
          new ImmutableMap.Builder<String, Object>()
              .put("bucket", bucket.getIdentity())
              .put("component", component.getIdentity())
              .build()
      );
  return results;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:14,代码来源:ContentAuth.java

示例12: withOtherDatabase

import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; //导入依赖的package包/类
/**
 * Utility function for working around "ODatabaseException: Database instance is not set in current thread" issues.
 * The current database ThreadLocal is preserved and restored after calling the lambda.
 */
public static <T> T withOtherDatabase(Callable<T> function) {
  final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.INSTANCE.getIfDefined();
  try {
    return function.call();
  }
  catch (Exception e) {
    Throwables.throwIfUnchecked(e);
    throw new RuntimeException(e);
  }
  finally {
    ODatabaseRecordThreadLocal.INSTANCE.set(db);
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:18,代码来源:DatabaseThreadUtils.java

示例13: authenticate

import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; //导入依赖的package包/类
@Override
	public boolean authenticate(String username, String password) {
		ODatabaseDocumentInternal currentDB = getDatabase();
		try
		{
			boolean inTransaction = currentDB.getTransaction().isActive();
			IOrientDbSettings settings = OrientDbWebApplication.get().getOrientDbSettings();
			ODatabaseDocumentInternal newDB = settings.getDatabasePoolFactory().get(settings.getDBUrl(), username, password).acquire();
			if(newDB!=currentDB)
			{
				currentDB.activateOnCurrentThread();
				currentDB.commit();
				currentDB.close();
				newDB.activateOnCurrentThread();
			}
			setUser(username, password);
			userModel.setObject(newDB.getUser().getDocument());
//			user = newDB.getMetadata().getSecurity().getUser(username);
//			newDB.setUser(user);
			if(inTransaction && !newDB.getTransaction().isActive()) newDB.begin();
			return true;
		} catch (OSecurityAccessException e)
		{
			currentDB.activateOnCurrentThread();
			return false;
		}
	}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:28,代码来源:OrientDbWebSession.java

示例14: start

import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; //导入依赖的package包/类
@Override
public void start(RequestCycle cycle) {
	OrientDbWebSession session = OrientDbWebSession.get();
	ODatabaseDocumentInternal db = session.getDatabase();
	//It's required to have ability to check security rights locally
	OSecurityUser oUser = session.getUser();
	OSecurityUser dbUser = db.getUser();
	if(oUser!=null && oUser.getDocument()!=null 
			&& oUser.getDocument().getIdentity()!=null 
			&& (!oUser.getDocument().getIdentity().isValid() || dbUser==null || !Objects.equal(dbUser.getName(), oUser.getName())))
	{
		db.setUser(db.getMetadata().getSecurity().getUser(oUser.getName()));
	}
	db.begin();
}
 
开发者ID:OrienteerBAP,项目名称:wicket-orientdb,代码行数:16,代码来源:TransactionRequestCycleListener.java

示例15: getTaxDirectory

import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal; //导入依赖的package包/类
private Directory getTaxDirectory(ODatabaseDocumentInternal database) throws IOException {
  Directory dir = null;
  final OAbstractPaginatedStorage storageLocalAbstract = (OAbstractPaginatedStorage) database.getStorage().getUnderlying();
  if (storageLocalAbstract instanceof OLocalPaginatedStorage) {
    String pathname = getIndexFacetPath((OLocalPaginatedStorage) storageLocalAbstract);
    dir = NIOFSDirectory.open(new File(pathname));
  } else {
    dir = new RAMDirectory();
  }
  return dir;
}
 
开发者ID:orientechnologies,项目名称:orientdb-lucene,代码行数:12,代码来源:OLuceneFacetManager.java


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