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


Java OObjectDatabaseTx类代码示例

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


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

示例1: beforeTest

import com.orientechnologies.orient.object.db.OObjectDatabaseTx; //导入依赖的package包/类
@Override
public void beforeTest() {
    try {
        personList = testHelper.loadData();
        testHelper.deleteDir(System.getProperty("java.io.tmpdir") + "/orientdb/");
        Files.createDirectory(Paths.get(System.getProperty("java.io.tmpdir") + "/orientdb/"));
        db = new OObjectDatabaseTx("plocal:" +
                System.getProperty("java.io.tmpdir") + "/orientdb/person");
        if (db.exists()) {
            db.open("admin", "admin");
            db.drop();
        }
        db.create();
        db.getEntityManager().registerEntityClass(Person.class);
        db.getEntityManager().registerEntityClass(Address.class);
        db.getEntityManager().registerEntityClass(PrivateData.class);
    } catch (Throwable e) {
        System.out.println("error in creating db ");
        e.printStackTrace();
    }
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:22,代码来源:BaseOrientBenchmark.java

示例2: initObjectDatabaseSchema

import com.orientechnologies.orient.object.db.OObjectDatabaseTx; //导入依赖的package包/类
private void initObjectDatabaseSchema()
{
    objectDatabaseTx = new OObjectDatabaseTx(getPartitionedDatabasePool().acquire());
    //        if (objectDatabaseTx.exists())
    //        {
    //            objectDatabaseTx.open("admin", "admin");
    //        }
    //        else
    //        {
    //            objectDatabaseTx.create();
    //        }

    objectDatabaseTx.setAutomaticSchemaGeneration(true);

    objectDatabaseTx.getEntityManager().registerEntityClasses(Transaction.class.getPackage().getName(), RepositorySource.class.getClassLoader());

    objectDatabaseTx.getMetadata().getSchema().synchronizeSchema();

    objectDatabaseTx.close();
}
 
开发者ID:geekflow,项目名称:light,代码行数:21,代码来源:RepositorySource.java

示例3: initTableClass

import com.orientechnologies.orient.object.db.OObjectDatabaseTx; //导入依赖的package包/类
private void initTableClass()
{
    OObjectDatabaseTx objectDatabaseTx = getObjectDatabaseTx();

    OClass oClass = objectDatabaseTx.getMetadata().getSchema().getClass(Transaction.class);

    if (oClass != null && !oClass.areIndexed("tid"))
    {
        oClass.createIndex("TransactionIdUnique", OClass.INDEX_TYPE.UNIQUE, "tid");
    }

    oClass = objectDatabaseTx.getMetadata().getSchema().getClass(ProfileData.class);

    if (oClass != null && !oClass.areIndexed("tid", "sequence"))
    {
        oClass.createIndex("TransactionIdSequenceUnique", OClass.INDEX_TYPE.UNIQUE, "tid", "sequence");
    }

    objectDatabaseTx.close();
}
 
开发者ID:geekflow,项目名称:light,代码行数:21,代码来源:RepositorySource.java

示例4: OrientHttpSessionRepository

import com.orientechnologies.orient.object.db.OObjectDatabaseTx; //导入依赖的package包/类
public OrientHttpSessionRepository(final OPartitionedDatabasePool pool,
                                   final int sessionTimeout) {
  this.pool = pool;
  this.sessionTimeout = sessionTimeout;

  try (final OObjectDatabaseTx db = new OObjectDatabaseTx(pool.acquire())) {
    db.setAutomaticSchemaGeneration(true);
    db.getEntityManager().registerEntityClass(OrientHttpSession.class);
    db.getMetadata().getSchema().synchronizeSchema();

    final OClass sessionClass = db.getMetadata().getSchema().getClass(OrientHttpSession.class);

    createIndex(sessionClass, SESSION_ID_PROPERTY, UNIQUE_HASH_INDEX);
    createIndex(sessionClass, LAST_ACCESSED_TIME_PROPERTY, NOTUNIQUE);
    createIndex(sessionClass, MAX_INACTIVE_INTERVAL_IN_SECONDS_PROPERTY, NOTUNIQUE);
  }
}
 
开发者ID:maseev,项目名称:spring-session-orientdb,代码行数:18,代码来源:OrientHttpSessionRepository.java

示例5: getSession

import com.orientechnologies.orient.object.db.OObjectDatabaseTx; //导入依赖的package包/类
@Override
public OrientHttpSession getSession(final String id) {
  final OrientHttpSession session;

  try (final OObjectDatabaseTx db = new OObjectDatabaseTx(pool.acquire())) {
    final List<OrientHttpSession> sessions = db.query(FIND_BY_ID_QUERY, id);
    session = sessions.isEmpty() ? null : db.detachAll(sessions.get(0), true);
  }

  if (session == null) {
    return null;
  }

  if (session.isExpired()) {
    delete(session.getId());
    return null;
  }

  session.setLastAccessedTime(System.currentTimeMillis());
  session.deserializeAttributes();

  return session;
}
 
开发者ID:maseev,项目名称:spring-session-orientdb,代码行数:24,代码来源:OrientHttpSessionRepository.java

示例6: updateTrigger

import com.orientechnologies.orient.object.db.OObjectDatabaseTx; //导入依赖的package包/类
private void updateTrigger(Identifier triggerId, Consumer<AbstractTrigger> c) {
    try (OObjectDatabaseTx db = db()) {
        try {
            db.begin();
            List<AbstractTrigger> l = db.query(new OSQLSynchQuery<>(String.format(TRIGGER_QUERY, triggerId)));
            if (l.size() != 1) {
                throw new IllegalArgumentException("Can't find trigger with id=" + triggerId);
            } else {
                AbstractTrigger trigger = l.get(0);
                c.accept(trigger);
                db.save(trigger);
            }
        } catch (Throwable t) {
            db.rollback();
            throw Exceptions.runtime(t);
        } finally {
            db.commit();
        }
    }
}
 
开发者ID:dmart28,项目名称:gcplot,代码行数:21,代码来源:TriggerOrientDbRepository.java

示例7: updateInfo

import com.orientechnologies.orient.object.db.OObjectDatabaseTx; //导入依赖的package包/类
@Override
public Account updateInfo(Account account) {
    metrics.meter(ACCOUNT_UPDATE_INFO_METRIC).mark();
    try (OObjectDatabaseTx db = db()) {
        int i;
        try {
            i = db.command(new OCommandSQL(String.format(UPDATE_INFO_COMMAND, account.id().toString(),
                    account.username(), account.email(), account.firstName(), account.lastName(),
                    account.passHash()))).execute();
        } catch (Throwable t) {
            throw Exceptions.runtime(t);
        }
        if (i != 1) {
            throw new IllegalArgumentException(String.format("Can't update account %s with data %s", account.id(), account));
        }
        return account;
    }
}
 
开发者ID:dmart28,项目名称:gcplot,代码行数:19,代码来源:AccountOrientDbRepository.java

示例8: register

import com.orientechnologies.orient.object.db.OObjectDatabaseTx; //导入依赖的package包/类
protected <T> void register(OObjectDatabaseTx db, OSchema schema, Class<T> aClass) {
    if (schema.getClass(aClass.getSimpleName()) == null) {
        db.getEntityManager().registerEntityClasses(aClass, true);
        OClass cls = db.getMetadata().getSchema().getClass(aClass);
        String indexName = aClass.getName() + ".unq";
        Table t = aClass.getAnnotation(Table.class);
        if (t != null) {
            Set<String> fields = new HashSet<>();
            for (UniqueConstraint uc : t.uniqueConstraints()) {
                fields.addAll(Lists.newArrayList(uc.columnNames()));
            }
            if (fields.size() > 0) {
                LOG.info("Registering unique constraint for fields: " + fields);
                for (String field : fields)
                    cls.createIndex(indexName + "." + field, OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, field);
            }
        }
    } else {
        db.getEntityManager().registerEntityClasses(aClass, true);
    }
}
 
开发者ID:dmart28,项目名称:gcplot,代码行数:22,代码来源:AbstractOrientDbRepository.java

示例9: executeTx

import com.orientechnologies.orient.object.db.OObjectDatabaseTx; //导入依赖的package包/类
protected void executeTx(String cmd) {
    try (OObjectDatabaseTx db = db()) {
        db.begin();
        int i;
        try {
            i = db.command(new OCommandSQL(cmd)).execute();
        } catch (Throwable t) {
            db.rollback();
            throw Exceptions.runtime(t);
        }
        if (i != 1) {
            db.rollback();
            throw new IllegalArgumentException(String.format("Command [%s] didn't affected any record!", cmd));
        }
        db.commit();
    }
}
 
开发者ID:dmart28,项目名称:gcplot,代码行数:18,代码来源:AbstractOrientDbRepository.java

示例10: processLine

import com.orientechnologies.orient.object.db.OObjectDatabaseTx; //导入依赖的package包/类
@Override
protected boolean processLine(OObjectDatabaseTx dbConnection, ODocument doc, Map<String, String> baseFields, Map<String, String> fields, int lineIndex,
    String line) {
    String[] lineParts = StringUtils.splitPreserveAllTokens(line, CrigttStringUtils.TAB, 3);

    if ((lineParts.length != 3) || (StringUtils.startsWith(line, TOPOGRAPHY_AXIS_CODE_ID_PREFIX) && !USED_TOPOGRAPHY_CODE_LEVEL_STR.equals(lineParts[1]))) {
        return false;
    }

    String code = lineParts[0];
    String displayName = lineParts[2];

    addField(dbConnection, doc, fields, code, displayName);

    if (StringUtils.contains(code, MORPHOLOGY_CODE_DELIM)) {
        addField(dbConnection, doc, fields, code.substring(0, code.indexOf(MORPHOLOGY_CODE_DELIM)), displayName);
    }

    return true;
}
 
开发者ID:esacinc,项目名称:crigtt,代码行数:21,代码来源:IcdO3Loader.java

示例11: deleteViewDefinition

import com.orientechnologies.orient.object.db.OObjectDatabaseTx; //导入依赖的package包/类
public void deleteViewDefinition(Object id, boolean notify) throws RuntimeException {
    ViewDefinition vd = null;
    String viewUrl = null;
    try (OObjectDatabaseTx database = getOObjectDatabaseTx()) {
        vd = database.load(new ORecordId(id.toString()));
        if (vd != null) {
            viewUrl = vd.getUrl();
            List<TabDefinition> tabs = database.query(new OSQLSynchQuery<TabDefinition>("SELECT * FROM TabDefinition WHERE viewId = ?"), id);
            for (TabDefinition td : tabs) {
                database.command(new OCommandSQL("DELETE VERTEX PanelDefinition WHERE tabId = " + td.getId())).execute();
            }
            database.command(new OCommandSQL("DELETE VERTEX TabDefinition WHERE viewId = " + id)).execute();
        }
        database.delete(new ORecordId(id.toString()));
        database.commit();
    }
    if (notify && vd != null && vd instanceof ViewDefinition) {
        HazelcastServer.getDashboardEventTopic().publish(DashboardEvent.createViewDeleteEvent(sessionId, viewUrl));
    }
}
 
开发者ID:hybridbpm,项目名称:hybridbpm,代码行数:21,代码来源:DashboardAPI.java

示例12: deleteTabDefinition

import com.orientechnologies.orient.object.db.OObjectDatabaseTx; //导入依赖的package包/类
public void deleteTabDefinition(Object id, boolean notify) throws RuntimeException {
    TabDefinition tab = null;
    String viewUrl = null;
    try (OObjectDatabaseTx database = getOObjectDatabaseTx()) {
        tab = database.load(new ORecordId(id.toString()));
        if (tab != null) {
            ViewDefinition view = database.load(new ORecordId(tab.getViewId().getId().toString()));
            viewUrl = view.getUrl();
            database.command(new OCommandSQL("DELETE VERTEX PanelDefinition WHERE tabId = " + id)).execute();
        }
        database.delete(new ORecordId(id.toString()));
        database.commit();
    }
    if (notify && tab != null && tab instanceof TabDefinition) {
        HazelcastServer.getDashboardEventTopic().publish(DashboardEvent.createViewChangeEvent(sessionId, viewUrl));
    }
}
 
开发者ID:hybridbpm,项目名称:hybridbpm,代码行数:18,代码来源:DashboardAPI.java

示例13: deletePanelDefinition

import com.orientechnologies.orient.object.db.OObjectDatabaseTx; //导入依赖的package包/类
public void deletePanelDefinition(Object id, boolean notify) throws RuntimeException {
    PanelDefinition panel = null;
    String viewUrl = null;
    try (OObjectDatabaseTx database = getOObjectDatabaseTx()) {
        panel = database.load(new ORecordId(id.toString()));
        if (panel != null) {
            TabDefinition tab = detach(database.load(new ORecordId(panel.getTabId().getId().toString())));
            ViewDefinition view = database.load(new ORecordId(tab.getViewId().getId().toString()));
            viewUrl = view.getUrl();
            if (Objects.equals(tab.getLayout(), TabDefinition.LAYOUT_TYPE.VERTICAL) || Objects.equals(tab.getLayout(), TabDefinition.LAYOUT_TYPE.HORIZONTAL)){
                database.command(new OCommandSQL("UPDATE PanelDefinition INCREMENT order = -1 WHERE tabId = " + tab.getId() + " AND order > " + panel.getOrder())).execute();
            }
        }
        database.delete(new ORecordId(id.toString()));
        database.commit();
    }
    if (notify && viewUrl != null) {
        HazelcastServer.getDashboardEventTopic().publish(DashboardEvent.createViewChangeEvent(sessionId, viewUrl));
    }
}
 
开发者ID:hybridbpm,项目名称:hybridbpm,代码行数:21,代码来源:DashboardAPI.java

示例14: finishTask

import com.orientechnologies.orient.object.db.OObjectDatabaseTx; //导入依赖的package包/类
public void finishTask(Task task, Map<String, Object> variables, Map<String, List<File>> files, List<String> fileIdsToDelete) {
    Object caseId = getOrientGraph().getVertex(task.getId()).getEdges(Direction.IN, "ProcessTaskList").iterator().next().getVertex(Direction.OUT).getId();
    try (OObjectDatabaseTx database = getOObjectDatabaseTx()) {
        task.setStatus(TaskModel.STATUS.FINISHED);
        task.setUpdateDate(new Date());
        task.setFinishDate(new Date());
        task = database.save(task);
        task = detach(task);
        if (variables != null) {
            saveVariables(caseId.toString(), variables);
        }
        if (files != null) {
            saveFiles(caseId.toString(), files);
        }
        if (fileIdsToDelete != null) {
            deleteFiles(fileIdsToDelete);
        }
        database.commit();
    }
    publishNextExecutor(caseId.toString(), task, null);
}
 
开发者ID:hybridbpm,项目名称:hybridbpm,代码行数:22,代码来源:InternalAPI.java

示例15: saveTask

import com.orientechnologies.orient.object.db.OObjectDatabaseTx; //导入依赖的package包/类
public void saveTask(Task task, Map<String, Object> variables, Map<String, List<File>> files, List<String> fileIdsToDelete) {
    Object caseId = getOrientGraph().getVertex(task.getId()).getEdges(Direction.IN, "ProcessTaskList").iterator().next().getVertex(Direction.OUT).getId();
    try (OObjectDatabaseTx database = getOObjectDatabaseTx()) {
        task.setUpdateDate(new Date());
        task = database.save(task);
        task = detach(task);
        if (variables != null) {
            saveVariables(caseId.toString(), variables);
        }
        if (files != null) {
            saveFiles(caseId.toString(), files);
        }
        if (fileIdsToDelete != null) {
            deleteFiles(fileIdsToDelete);
        }
    }
}
 
开发者ID:hybridbpm,项目名称:hybridbpm,代码行数:18,代码来源:InternalAPI.java


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