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


Java ODocument.save方法代码示例

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


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

示例1: 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

示例2: 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

示例3: importKeyStoreFiles

import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
public void importKeyStoreFiles() throws Exception {
  log.debug("Importing legacy trust store from {}", keyStoreBasedir);
  try (ODatabaseDocumentTx db = databaseInstance.get().connect()) {
    for (String filename : Arrays.asList(TRUSTED_KEYS_FILENAME, PRIVATE_KEYS_FILENAME)) {
      String keyStoreName = "ssl/" + filename;
      String query = "SELECT FROM " + DB_CLASS + " WHERE " + P_NAME + " = ?";
      List<ODocument> results = db.command(new OSQLSynchQuery<>(query)).execute(keyStoreName);
      if (!results.isEmpty()) {
        log.debug("Skipped import of existing legacy key store {}", results.get(0));
        // NOTE: Upgrade steps run on each node but within a cluster, another node might already have upgraded the db
        continue;
      }
      Path keyStorePath = keyStoreBasedir.resolve(filename);
      if (!Files.isRegularFile(keyStorePath)) {
        continue;
      }
      ODocument doc = db.newInstance(DB_CLASS);
      doc.field(P_NAME, keyStoreName);
      doc.field(P_BYTES, Files.readAllBytes(keyStorePath));
      doc.save();
      log.debug("Imported legacy key store {}", doc);
    }
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:25,代码来源:LegacyKeyStoreUpgradeService.java

示例4: writeEntity

import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
/**
 * Write document from entity.
 */
public ODocument writeEntity(final ODocument document, final T entity) {
  checkNotNull(document);
  checkNotNull(entity);

  // TODO: MVCC

  try {
    writeFields(document, entity);
  }
  catch (Exception e) {
    Throwables.throwIfUnchecked(e);
    throw new RuntimeException(e);
  }
  attachMetadata(entity, document);

  return document.save();
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:21,代码来源:EntityAdapter.java

示例5: 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

示例6: verifyWriteFails

import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
/**
 * Utility method to check the status of the databases by attempting writes.
 * Note: this method only works in non-HA simulations in this test class.
 *
 * @param errorExpected if true, this method will still pass the test when a write fails, and fail if no error is
 *                      encountered. If false, it will fail a test if the write fails.
 */
void verifyWriteFails(boolean errorExpected) {
  for (Provider<DatabaseInstance> provider : providerSet) {
    try (ODatabaseDocumentTx db = provider.get().connect()) {
      db.begin();

      ODocument document = db.newInstance(DB_CLASS);
      document.field(P_NAME, "test");
      document.save();

      try {
        db.commit();
        if (errorExpected) {
          fail("Expected OModificationOperationProhibitedException");
        }
      }
      catch (OModificationOperationProhibitedException e) {
        if (!errorExpected) {
          throw e;
        }
      }
    }
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:31,代码来源:DatabaseFreezeServiceImplTest.java

示例7: deleteAssetNode

import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
/**
 * Removes the {@link BrowseNode} associated with the given asset id.
 */
public void deleteAssetNode(final ODatabaseDocumentTx db, final EntityId assetId) {
  // a given asset will only appear once in the tree
  ODocument document = getFirst(
      db.command(new OCommandSQL(FIND_BY_ASSET)).execute(
          ImmutableMap.of(P_ASSET_ID, recordIdentity(assetId))), null);

  if (document != null) {
    if (document.containsField(P_COMPONENT_ID)) {
      // component still exists, just remove asset details
      document.removeField(P_ASSET_ID);
      document.removeField(P_ASSET_NAME_LOWERCASE);
      document.save();
    }
    else {
      document.delete();
    }
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:22,代码来源:BrowseNodeEntityAdapter.java

示例8: property

import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
private <V> Property<V> property(final String key, final V value, boolean saveDocument) {
    if (key == null)
        throw Property.Exceptions.propertyKeyCanNotBeNull();
    if (value == null)
        throw Property.Exceptions.propertyValueCanNotBeNull();
    if (Graph.Hidden.isHidden(key))
        throw Property.Exceptions.propertyKeyCanNotBeAHiddenKey(key);

    ODocument doc = getRawDocument();
    doc.field(key, value);

    // when setting multiple properties at once, it makes sense to only save
    // them in the end
    // for performance reasons and so that the schema checker only kicks in
    // at the end
    if (saveDocument) doc.save();
    return new OrientProperty<>(key, value, this);
}
 
开发者ID:orientechnologies,项目名称:orientdb-gremlin,代码行数:19,代码来源:OrientElement.java

示例9: removeLink

import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void removeLink(Direction direction) {
    final String fieldName = OrientVertex.getConnectionFieldName(direction, this.label());
    ODocument doc = this.getVertex(direction).getRawDocument();
    Object found = doc.field(fieldName);
    if (found == null)
        //already removed
        return;

    if (found instanceof ORidBag) {
        ORidBag bag = (ORidBag) found;
        bag.remove(this.getRawElement());
        if (bag.size() == 0) doc.removeField(fieldName);
    } else if (found instanceof Collection<?>) {
        ((Collection<Object>) found).remove(this.getRawElement());
        if (((Collection<Object>) found).size() == 0) doc.removeField(fieldName);
    } else
        throw new IllegalStateException("Relationship content is invalid on field " + fieldName + ". Found: " + found);
    doc.save();
}
 
开发者ID:orientechnologies,项目名称:orientdb-gremlin,代码行数:21,代码来源:OrientEdge.java

示例10: crawlSourceFile

import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
private void crawlSourceFile(final File sourceFile, final String sha1, final String uri) {
    Map<String, Object> fileContents = parser.processFile(sourceFile);
    if (fileContents != null) {
    	fileContents.put(Attributes.ROOTPATH, getPathToRoot(sourceFile));
        fileContents.put(String.valueOf(DocumentAttributes.SHA1), sha1);
        fileContents.put(String.valueOf(DocumentAttributes.RENDERED), false);
        if (fileContents.get(Attributes.TAGS) != null) {
            // store them as a String[]
            String[] tags = (String[]) fileContents.get(Attributes.TAGS);
            fileContents.put(Attributes.TAGS, tags);
        }
        fileContents.put(Attributes.FILE, sourceFile.getPath());
        fileContents.put(String.valueOf(DocumentAttributes.SOURCE_URI), uri);
        fileContents.put(Attributes.URI, uri);

        String documentType = (String) fileContents.get(Attributes.TYPE);
        if (fileContents.get(Attributes.STATUS).equals(Status.PUBLISHED_DATE)) {
            if (fileContents.get(Attributes.DATE) != null && (fileContents.get(Attributes.DATE) instanceof Date)) {
                if (new Date().after((Date) fileContents.get(Attributes.DATE))) {
                    fileContents.put(Attributes.STATUS, Status.PUBLISHED);
                }
            }
        }

        if (config.getBoolean(Keys.URI_NO_EXTENSION)) {
        	fileContents.put(Attributes.NO_EXTENSION_URI, uri.replace("/index.html", "/"));
        }

        ODocument doc = new ODocument(documentType);
        doc.fields(fileContents);
        boolean cached = fileContents.get(DocumentAttributes.CACHED) != null ? Boolean.valueOf((String)fileContents.get(DocumentAttributes.CACHED)):true;
        doc.field(String.valueOf(DocumentAttributes.CACHED), cached);
        doc.save();
    } else {
        LOGGER.warn("{} has an invalid header, it has been ignored!", sourceFile);
    }
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:38,代码来源:Crawler.java

示例11: testPagination

import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
@Test
public void testPagination() {
    Map<String, Object> fileContents = new HashMap<String, Object>();
    final int TOTAL_POSTS = 5;
    final int PER_PAGE = 2;

    for (int i = 1; i <= TOTAL_POSTS; i++) {
        fileContents.put("name", "dummyfile" + i);

        ODocument doc = new ODocument("post");
        doc.fields(fileContents);
        boolean cached = fileContents.get("cached") != null ? Boolean.valueOf((String) fileContents.get("cached")) : true;
        doc.field("cached", cached);
        doc.save();
    }

    int pageCount = 1;
    int start = 0;
    db.setLimit(PER_PAGE);

    while (start < TOTAL_POSTS) {
        db.setStart(start);
        DocumentList posts = db.getAllContent("post");

        int expectedNumber = (pageCount==1)?pageCount:((pageCount%2==0)?pageCount+1:pageCount+PER_PAGE);

        Assert.assertEquals("pagcount " +pageCount,"dummyfile" + expectedNumber, posts.get(0).get("name"));
        pageCount++;
        start += PER_PAGE;
    }
    Assert.assertEquals(4, pageCount);
}
 
开发者ID:ghaseminya,项目名称:jbake-rtl-jalaali,代码行数:33,代码来源:PaginationTest.java

示例12: addPerson

import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
public ODocument addPerson(String name) {
    try (ODatabaseDocumentTx database = databasePool.acquire()) {
        ODocument document = new ODocument("Person");
        document.field("name", name);
        database.commit();
        return document.save();
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:9,代码来源:TestPeopleDao.java

示例13: filter

import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
@Override
public void filter(String type, String value) {
    try (ODatabaseDocumentTx db = docDb()) {
        ODocument newFilter = db.newInstance("Filter");
        newFilter.field("type", type);
        newFilter.field("value", value);
        newFilter.save();
    }
}
 
开发者ID:dmart28,项目名称:gcplot,代码行数:10,代码来源:FiltersOrientDbRepository.java

示例14: createSampleDb

import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
private void createSampleDb() {
  try (ODatabaseDocumentTx db = database.getInstance().connect()) {
    ODocument doc = db.newInstance("Person");
    doc.field("name", "Luke")
        .field("surname", "Skywalker")
        .field("city", new ODocument("City")
            .field("name", "Rome")
            .field("country", "Italy"));
    doc.save();
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:12,代码来源:DatabaseExternalizerTest.java

示例15: createPerson

import com.orientechnologies.orient.core.record.impl.ODocument; //导入方法依赖的package包/类
private ODocument createPerson(final ODatabaseDocumentTx db) {
  ODocument doc = db.newInstance("Person");
  doc.field("name", "Luke");
  doc.field("surname", "Skywalker");
  doc.field("city", new ODocument("City")
      .field("name", "Rome")
      .field("country", "Italy"));
  doc.save();
  return doc;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:11,代码来源:BackupRestoreTrial.java


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