本文整理汇总了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();
}
}
示例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();
}
示例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();
}
示例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);
}
}
示例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;
}
示例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();
}
}
}
示例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;
}
}
示例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);
}
}
示例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();
}
}
示例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;
}
示例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));
}
}
示例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));
}
}
示例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));
}
}
示例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);
}
示例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);
}
}
}