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


Java ODocument类代码示例

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


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

示例1: executeQuery

import com.orientechnologies.orient.core.record.impl.ODocument; //导入依赖的package包/类
public IResultSet executeQuery() throws OdaException
{
	String currentQueryText = queryText;
	if(getMaxRows()!=0){
		currentQueryText = currentQueryText+ " LIMIT "+getMaxRows(); 
	}
	try {
		OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>(currentQueryText);
		List<ODocument> dbResult = getOrMakeDBResult(db.command(query).execute(parameters));
		/*
		ArrayList<ODocument> unCachedResult = new ArrayList<ODocument>(dbResult.size());
		for (ODocument oDocument : dbResult) {
			ODocument newDoc = new ODocument();
			for (Entry<String, Object> entry : oDocument) {
				newDoc.field(entry.getKey(),entry.getValue());
			}
			unCachedResult.add(newDoc);
		}*/
		return new ResultSet(dbResult,curMetaData);
	} catch (OCommandSQLParsingException e) {
		throw new OdaException(e);
	}
}
 
开发者ID:OrienteerBAP,项目名称:orientdb-oda-birt,代码行数:24,代码来源:Query.java

示例2: getOrMakeDBResult

import com.orientechnologies.orient.core.record.impl.ODocument; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private List<ODocument> getOrMakeDBResult(Object result) throws OdaException{
	if (!(result instanceof List)){
		throw new OdaException("OrientDB query result is not a list!");
	}
	List<ODocument> dbResult = (List<ODocument>) result;
	if (dbResult.size()>0){
		return dbResult;
	}else{
		List<ODocument> fakeDBResult = new ArrayList<ODocument>(1); 
		ODocument fakeDBResultdoc = new ODocument(); 
		fakeDBResultdoc.field("emptyResult", "");
		fakeDBResult.add(fakeDBResultdoc);
		return fakeDBResult;
	}
}
 
开发者ID:OrienteerBAP,项目名称:orientdb-oda-birt,代码行数:17,代码来源:Query.java

示例3: ResultSet

import com.orientechnologies.orient.core.record.impl.ODocument; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public ResultSet(Object sqlResult, ResultSetMetaData metadata) {
   	if (sqlResult instanceof List && !((List)sqlResult).isEmpty() ){
       	this.sqlResult = (List<ODocument>)sqlResult;
   	}else{
   		this.sqlResult = new ArrayList<ODocument>(1);
   		if (sqlResult instanceof ODocument){
       		this.sqlResult.add((ODocument)sqlResult);
   		}else{
   			ODocument newDoc = new ODocument();
   			newDoc.field("result",sqlResult);
       		this.sqlResult.add(newDoc);
   		}
   	}
   	m_currentRowId=0;
   	currentRow = this.sqlResult.get(m_currentRowId);
   	this.metadata = metadata;
}
 
开发者ID:OrienteerBAP,项目名称:orientdb-oda-birt,代码行数:19,代码来源:ResultSet.java

示例4: convertToCatalogLinkIfAble

import com.orientechnologies.orient.core.record.impl.ODocument; //导入依赖的package包/类
private Object convertToCatalogLinkIfAble(Object value,OProperty fieldProperty,ODocument mainDoc){
	String catalogsLinkNameAttribute = getOrientDBEndpoint().getCatalogsLinkAttr();//
	String catalogsLinkName = getOrientDBEndpoint().getCatalogsLinkName();//
	String catalogNameField = fieldProperty.getLinkedClass().getCustom(catalogsLinkNameAttribute); 
	if (catalogNameField==null){
		catalogNameField = catalogsLinkName;
	}
	List<OIdentifiable> catalogLinks = curDb.query(new OSQLSynchQuery<OIdentifiable>(
			"select from "+fieldProperty.getLinkedClass().getName()+" where "+catalogNameField+"=?"), value);
	if (catalogLinks.size()>0){
		value = catalogLinks.get(0).getIdentity();
	}else{
		boolean updateCatalogs = getOrientDBEndpoint().isCatalogsUpdate();//
		if (updateCatalogs){
			ODocument catalogRecord = new ODocument(fieldProperty.getLinkedClass());
			catalogRecord.field(catalogNameField,value);
			catalogRecord.save(true);
			value = catalogRecord.getIdentity();
		}
	}
	return value;
}
 
开发者ID:OrienteerBAP,项目名称:camel-orientdb,代码行数:23,代码来源:OrientDBProducer.java

示例5: toList

import com.orientechnologies.orient.core.record.impl.ODocument; //导入依赖的package包/类
private Object toList(Object obj){
	if (obj instanceof ODocument){
		ODocument objDoc =(ODocument)obj;
		List<Object> result = new ArrayList<Object>();

		for (Object value : objDoc.fieldValues()){
	    	if (value instanceof ODocument){
		    	result.add(((ODocument) value).toJSON());
	    	}else{
		    	result.add(value.toString());
	    	}
	    }
   		return result;
	}else{
		return obj;
	}	
}
 
开发者ID:OrienteerBAP,项目名称:camel-orientdb,代码行数:18,代码来源:OrientDBEndpoint.java

示例6: createItem

import com.orientechnologies.orient.core.record.impl.ODocument; //导入依赖的package包/类
private ODocument createItem(int id, ODocument doc)
{
    String itemKey = Integer.valueOf(id).toString();

    doc.setClassName("Item");
    doc.field("stringKey", itemKey);
    doc.field("intKey", id);
    String contents = "OrientDB is a deeply scalable Document-Graph DBMS with the flexibility of the Document databases and the power to manage links of the Graph databases. " + "It can work in schema-less mode, schema-full or a mix of both. Supports advanced features such as ACID Transactions, Fast Indexes, Native and SQL queries." + " It imports and exports documents in JSON." + " Graphs of hundreads of linked documents can be retrieved all in memory in few milliseconds without executing costly JOIN such as the Relational DBMSs do. " + "OrientDB uses a new indexing algorithm called MVRB-Tree, derived from the Red-Black Tree and from the B+Tree with benefits of both: fast insertion and ultra fast lookup. " + "The transactional engine can run in distributed systems supporting up to 9.223.372.036 Billions of records for the maximum capacity of 19.807.040.628.566.084 Terabytes of data distributed on multiple disks in multiple nodes. " + "OrientDB is FREE for any use. Open Source License Apache 2.0. ";
    doc.field("text", contents);
    doc.field("title", "orientDB");
    doc.field("length", contents.length());
    doc.field("published", (id % 2 > 0));
    doc.field("author", "anAuthor" + id);
    // doc.field("tags", asList("java", "orient", "nosql"), OType.EMBEDDEDLIST);
    Calendar instance = Calendar.getInstance(TimeZone.getTimeZone("UTC"));

    instance.add(Calendar.HOUR_OF_DAY, -id);
    Date time = instance.getTime();
    doc.field("date", time, OType.DATE);
    doc.field("time", time, OType.DATETIME);

    return doc;
}
 
开发者ID:geekflow,项目名称:light,代码行数:24,代码来源:OrientJdbcTest.java

示例7: start

import com.orientechnologies.orient.core.record.impl.ODocument; //导入依赖的package包/类
@Override
public void start(final Future<Void> startFuture) throws Exception {
  consumer = vertx.eventBus().consumer("read",
      (Message<JsonObject> m) -> {
        documentDatabase.exec(adb -> {
          if (adb.failed()) {
            log.warn("DB failure", adb.cause());
          }
          else {
            ODatabaseDocumentTx db = adb.result();
            List<ODocument> res = db.query(new OSQLSynchQuery<ODocument>("select count(*) as count from test"));
            log.info("List size=" + res.get(0).field("count"));
          }
        });
      }
  );
  super.start(startFuture);
}
 
开发者ID:cstamas,项目名称:vertx-orientdb,代码行数:19,代码来源:ReaderVerticle.java

示例8: start

import com.orientechnologies.orient.core.record.impl.ODocument; //导入依赖的package包/类
@Override
public void start(final Future<Void> startFuture) throws Exception {
  consumer = vertx.eventBus().consumer("write",
      (Message<JsonObject> m) -> {
        documentDatabase.exec(adb -> {
              if (adb.succeeded()) {
                ODatabaseDocumentTx db = adb.result();
                JsonObject message = m.body();
                db.begin();
                ODocument doc = new ODocument("test");
                doc.field("name", message.getValue("name"));
                doc.field("value", message.getValue("value"));
                db.save(doc);
                db.commit();
                log.info("Written " + message);
              }
              else {
                log.error("Error", adb.cause());
              }
            }
        );
      }
  );
  super.start(startFuture);
}
 
开发者ID:cstamas,项目名称:vertx-orientdb,代码行数:26,代码来源:WriterVerticle.java

示例9: insert

import com.orientechnologies.orient.core.record.impl.ODocument; //导入依赖的package包/类
@Override
public DocumentDatabaseService insert(final String clazz,
                                      final JsonObject document,
                                      final Handler<AsyncResult<String>> handler)
{
  documentDatabase.exec(
      ah -> {
        if (ah.succeeded()) {
          ODatabaseDocumentTx db = ah.result();
          db.begin();
          ODocument doc = db.newInstance(clazz);
          doc.fromJSON(document.toString());
          db.save(doc);
          db.commit();
          handler.handle(Future.succeededFuture(doc.getIdentity().toString()));
        }
        else {
          handler.handle(Future.failedFuture(ah.cause()));
        }
      }
  );
  return this;
}
 
开发者ID:cstamas,项目名称:vertx-orientdb,代码行数:24,代码来源:DocumentDatabaseServiceImpl.java

示例10: initializeData

import com.orientechnologies.orient.core.record.impl.ODocument; //导入依赖的package包/类
@Override
public void initializeData() {
    // Important! method is called without transaction to let implementation control transaction scope and type
    // (initializer may even use many (different?) transactions).
    // Unit of work must be defined before calling orient api:  the simplest way is to use @Transactional
    // on class or method

    final ODatabaseDocumentTx db = context.getConnection();
    if (db.countClass(ManualSchemeInitializer.CLASS_NAME) > 0) {
        // perform initialization only in case of empty table
        return;
    }

    // low level api used to insert records, but the same could be done with sql insert commands
    for (int i = 0; i < 10; i++) {
        final ODocument rec = db.newInstance(ManualSchemeInitializer.CLASS_NAME)
                .field("name", "Sample" + i)
                .field("amount", (int) (Math.random() * 200));
        rec.save();
    }
}
 
开发者ID:xvik,项目名称:guice-persist-orient-examples,代码行数:22,代码来源:SampleDataInitializer.java

示例11: main

import com.orientechnologies.orient.core.record.impl.ODocument; //导入依赖的package包/类
public static void main(String[] args) {
    // admin/admin is default user, created for each new db
    final Injector injector = Guice.createInjector(new DbModule("memory:sample", "admin", "admin"));

    // to initialize db context we must manually call start
    final PersistService persistService = injector.getInstance(PersistService.class);
    persistService.start();

    try {
        final SampleService service = injector.getInstance(SampleService.class);

        System.out.println("Overall records: " + service.count());

        final ODocument rec = service.selectLast();
        System.out.println("Last record: " + rec.toJSON());

        service.replaceName(rec.<String>field("name"), "test");
        // pay attention to record @version property in console
        System.out.println("Renamed record: " + service.findByName("test").toJSON());
        System.out.println("Records count is the same: " + service.count());
    } finally {
        // at the end service must be stopped
        persistService.stop();
    }
}
 
开发者ID:xvik,项目名称:guice-persist-orient-examples,代码行数:26,代码来源:InMemoryDbApp.java

示例12: newEvent

import com.orientechnologies.orient.core.record.impl.ODocument; //导入依赖的package包/类
@Nullable
@Override
public EntityEvent newEvent(final ODocument document, final EventKind eventKind) {
  final EntityMetadata metadata = new AttachedEntityMetadata(this, document);
  final String repositoryName = document.field(P_REPOSITORY_NAME);

  log.debug("newEvent: eventKind: {}, repositoryName: {}, metadata: {}", eventKind, repositoryName, metadata);
  switch (eventKind) {
    case CREATE:
      return new BucketCreatedEvent(metadata, repositoryName);
    case UPDATE:
      return new BucketUpdatedEvent(metadata, repositoryName);
    case DELETE:
      return new BucketDeletedEvent(metadata, repositoryName);
    default:
      return null;
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:19,代码来源:BucketEntityAdapter.java

示例13: createNode

import com.orientechnologies.orient.core.record.impl.ODocument; //导入依赖的package包/类
@Override
public OrientNode createNode(Map<String, Object> properties, String label) {
	final String vertexTypeName = getVertexTypeName(label);

	ensureClassExists(vertexTypeName);
	ODocument newDoc = new ODocument(vertexTypeName);
	if (properties != null) {
		OrientNode.setProperties(newDoc, properties);
	}
	newDoc.save(vertexTypeName);

	if (newDoc.getIdentity().isPersistent()) {
		return new OrientNode(newDoc.getIdentity(), this);
	} else {
		return new OrientNode(newDoc, this);
	}
}
 
开发者ID:mondo-project,项目名称:mondo-hawk,代码行数:18,代码来源:OrientDatabase.java

示例14: queryMultiPolygon

import com.orientechnologies.orient.core.record.impl.ODocument; //导入依赖的package包/类
protected void queryMultiPolygon() {

    String query = "select * from Place where location && 'POLYGON((-162.5537109375 62.11416112594049,-161.87255859375 61.80428390136847,-161.455078125 61.92861247439052,-160.7958984375 62.03183469254472,-160.24658203125 62.196264616146884,-160.64208984375 62.63376960786813,-160.2685546875 63.00513377927512,-159.9609375 63.450509218001095,-159.4775390625 63.860035895395306,-158.97216796875 64.28275952823394,-158.79638671875 64.54844014422517,-158.4228515625 64.77412531292873,-157.43408203125 64.95146502589559,-156.77490234375 64.87693823228864,-155.85205078125 64.79284777557432,-155.41259765625 64.94216049820734,-154.18212890625 64.92354174306496,-154.8193359375 64.76475920891367,-155.56640625 64.65211223878966,-156.51123046875 64.58618480339979,-157.17041015625 64.5578812115091,-157.763671875 64.69910544204765,-158.04931640625 64.33039136366138,-158.26904296875 64.05297838071347,-158.62060546875 63.68524808030714,-159.06005859375 63.361982464431236,-159.45556640625 62.96521201337507,-159.5654296875 62.63376960786813,-159.521484375 62.27814559876582,-160.77392578125 61.53316997618228,-162.53173828125 61.4597705702975,-162.861328125 61.762728830472696,-163.14697265625 62.12443624549497,-162.5537109375 62.11416112594049))' ";
    List<ODocument> docs = databaseDocumentTx.query(new OSQLSynchQuery<ODocument>(query));

    Assert.assertEquals(docs.size(), 1);

    query = "select * from Place where location && 'MULTIPOLYGON("
        + "((-159.78515625 22.126354759919685,-159.510498046875 22.238259929564308,-159.27978515625 22.16705785788614,-159.290771484375 21.9328547363353,-159.466552734375 21.841104749065046,-159.796142578125 21.94304553343818,-159.78515625 22.126354759919685)),"
        + "((-157.269287109375 21.233062254412808,-157.10174560546875 21.20233749272323,-157.005615234375 21.189533621502626,-156.95343017578125 21.217700673132317,-156.8902587890625 21.194655303138642,-156.8133544921875 21.192094484509035,-156.697998046875 21.174167511794955,-156.7364501953125 21.081937360616084,-156.86004638671875 21.025546284581797,-157.07977294921875 21.066560095381984,-157.247314453125 21.06912308335471,-157.335205078125 21.112687117676757,-157.269287109375 21.18185076626612,-157.269287109375 21.233062254412808)),"
        + "((-157.06878662109375 20.92296241226858,-157.060546875 20.861378341878538,-157.01934814453125 20.825442642791966,-157.005615234375 20.745840238902257,-156.95068359375 20.72529087399421,-156.84906005859375 20.73556590521865,-156.79962158203125 20.79463378941528,-156.796875 20.84597837877989,-156.86553955078125 20.91013448169267,-156.9671630859375 20.93578924489374,-157.03033447265625 20.93578924489374,-157.06878662109375 20.92296241226858)),"
        + "((-156.7034912109375 20.925527866647226,-156.67327880859375 21.002471054356725,-156.5936279296875 21.040927787394494,-156.5277099609375 20.981956742832327,-156.5057373046875 20.943484817224167,-156.456298828125 20.92296241226858,-156.37115478515625 20.948614979019347,-156.28326416015625 20.96400440917832,-156.16241455078125 20.89217353537473,-156.04705810546875 20.835710860933656,-155.95367431640625 20.77409105752739,-155.994873046875 20.658486188041294,-156.0992431640625 20.599365240955553,-156.302490234375 20.56336734348637,-156.43707275390625 20.571081893508193,-156.4727783203125 20.658486188041294,-156.47552490234375 20.761250430919663,-156.49749755859375 20.781794909576234,-156.55242919921875 20.756113874762082,-156.66229248046875 20.80747157680652,-156.7034912109375 20.86907773201848,-156.7034912109375 20.925527866647226)),"
        + "((-156.60736083984375 20.499064283413055,-156.7034912109375 20.4964915991075,-156.71722412109375 20.532505247689578,-156.67327880859375 20.57879605371868,-156.59637451171875 20.609648794045206,-156.5386962890625 20.607077970830282,-156.52496337890625 20.560795740208448,-156.54144287109375 20.514499482150526,-156.5716552734375 20.50678207718623,-156.60736083984375 20.499064283413055)),"
        + "((-155.928955078125 20.25704380463238,-155.7476806640625 20.2725032501349,-155.58837890625 20.17456745043183,-155.3741455078125 20.12299755620777,-155.2093505859375 19.99916046737026,-154.9786376953125 19.808054128088585,-154.786376953125 19.580493479202527,-154.7259521484375 19.49248592618279,-154.9346923828125 19.331878440818787,-155.3851318359375 19.129599439736833,-155.5224609375 18.932268511298087,-155.7806396484375 18.916679786648565,-155.93994140625 19.062117883514667,-156.0003662109375 19.25929414046391,-156.0113525390625 19.54943746814108,-156.192626953125 19.766703551716972,-155.950927734375 19.921712747556207,-155.9344482421875 20.13847031245115,-155.928955078125 20.25704380463238))"
        + ")' ";
    docs = databaseDocumentTx.query(new OSQLSynchQuery<ODocument>(query));

    Assert.assertEquals(docs.size(), 1);
  }
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:20,代码来源:LuceneSpatialMultiPolygonTest.java

示例15: listDomains

import com.orientechnologies.orient.core.record.impl.ODocument; //导入依赖的package包/类
public List<String> listDomains( String username ) {
	
	Set<? extends OSecurityRole> roles = graph.getRawGraph().getUser().getRoles();
	for( OSecurityRole role : roles ) {
		if( role.hasRule( ResourceGeneric.BYPASS_RESTRICTED, null ) ) {
			return new GenericNodeCollection<String>( 
					query( "select from " + GDomConfig.global().getRootClass() ), new NameAttributeProvider() );
		}
	}
	
	String q = "select from ( select expand(domain) from (select from orole where @this in (select expand(roles) from ouser where name = '" + username + "')))";
	
	List<ODocument> list = query( q );
	
	return new GenericNodeCollection<String>( list, new NameAttributeProvider() );
}
 
开发者ID:RISCOSS,项目名称:riscoss-corporate,代码行数:17,代码来源:GDomContainer.java


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