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


Java OClass类代码示例

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


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

示例1: setupTypesAndIndices

import com.orientechnologies.orient.core.metadata.schema.OClass; //导入依赖的package包/类
/**
 * Setup some indices. This is highly orientdb specific and may not be easy so setup using blueprint API.
 */
private void setupTypesAndIndices() {
	try (Tx tx = graph.tx()) {
		OrientGraph g = ((OrientGraph) ((DelegatingFramedOrientGraph) tx.getGraph()).getBaseGraph());
		ODatabaseDocument rawDb = g.getRawDatabase();
		OClass e = rawDb.createEdgeClass("HAS_MEMBER");
		e.createProperty("in", OType.LINK);
		e.createProperty("out", OType.LINK);
		e.createIndex("e.has_member", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, "out", "in");

		OClass v = rawDb.createVertexClass(Group.class.getSimpleName());
		v.createProperty("name", OType.STRING);

		v = rawDb.createVertexClass(Person.class.getSimpleName());
		v.createProperty("name", OType.STRING);
		v.createIndex(Person.class.getSimpleName() + ".name", OClass.INDEX_TYPE.UNIQUE_HASH_INDEX, "name");
		tx.success();
	}

}
 
开发者ID:Syncleus,项目名称:Ferma-OrientDB,代码行数:23,代码来源:IndexTest.java

示例2: initTableClass

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

示例3: createSchemaDB

import com.orientechnologies.orient.core.metadata.schema.OClass; //导入依赖的package包/类
private void createSchemaDB(ODatabaseDocumentTx db)
{
    OSchema schema = db.getMetadata().getSchema();

    // item
    OClass item = schema.createClass("Item");

    item.createProperty("stringKey", OType.STRING).createIndex(OClass.INDEX_TYPE.UNIQUE);
    item.createProperty("intKey", OType.INTEGER).createIndex(OClass.INDEX_TYPE.UNIQUE);
    item.createProperty("date", OType.DATE).createIndex(OClass.INDEX_TYPE.NOTUNIQUE);
    item.createProperty("time", OType.DATETIME).createIndex(OClass.INDEX_TYPE.NOTUNIQUE);
    item.createProperty("text", OType.STRING);
    item.createProperty("length", OType.LONG).createIndex(OClass.INDEX_TYPE.NOTUNIQUE);
    item.createProperty("published", OType.BOOLEAN).createIndex(OClass.INDEX_TYPE.NOTUNIQUE);
    item.createProperty("title", OType.STRING).createIndex(OClass.INDEX_TYPE.NOTUNIQUE);
    item.createProperty("author", OType.STRING).createIndex(OClass.INDEX_TYPE.NOTUNIQUE);
    item.createProperty("tags", OType.EMBEDDEDLIST);

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

示例4: initialize

import com.orientechnologies.orient.core.metadata.schema.OClass; //导入依赖的package包/类
@Override
public void initialize() {
    // method is called under unit of work (with NOTX transaction mode,
    // because orient "DDL" must be executed in this mode).

    final ODatabaseDocumentTx db = context.getConnection();
    final OSchema schema = db.getMetadata().getSchema();

    // creating class only if it isn't already exists
    // this is very naive approach: normally existing class structure must also be
    // verified and updated if necessary
    if (schema.existsClass(CLASS_NAME)) {
        return;
    }

    final OClass sampleClass = schema.createClass(CLASS_NAME);
    sampleClass.createProperty("name", OType.STRING);
    sampleClass.createProperty("amount", OType.INTEGER);
}
 
开发者ID:xvik,项目名称:guice-persist-orient-examples,代码行数:20,代码来源:ManualSchemeInitializer.java

示例5: OrientHttpSessionRepository

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

示例6: fix

import com.orientechnologies.orient.core.metadata.schema.OClass; //导入依赖的package包/类
public static void fix(MeshOptions options) {
	File graphDir = new File(options.getStorageOptions().getDirectory(), "storage");
	if (graphDir.exists()) {
		log.info("Checking database {" + graphDir + "}");
		OrientGraphFactory factory = new OrientGraphFactory("plocal:" + graphDir.getAbsolutePath()).setupPool(5, 100);
		try {
			// Enable the patched security class
			factory.setProperty(ODatabase.OPTIONS.SECURITY.toString(), OSecuritySharedPatched.class);
			ODatabaseDocumentTx tx = factory.getDatabase();
			try {
				OClass userClass = tx.getMetadata().getSchema().getClass("OUser");
				if (userClass == null) {
					log.info("OrientDB user credentials not found. Recreating needed roles and users.");
					tx.getMetadata().getSecurity().create();
					tx.commit();
				} else {
					log.info("OrientDB user credentials found. Skipping fix.");
				}
			} finally {
				tx.close();
			}
		} finally {
			factory.close();
		}
	}
}
 
开发者ID:gentics,项目名称:mesh,代码行数:27,代码来源:MissingOrientCredentialFixer.java

示例7: register

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

示例8: upgradeSchema

import com.orientechnologies.orient.core.metadata.schema.OClass; //导入依赖的package包/类
public void upgradeSchema() throws Exception {
  log.debug("Updgrading schema for trust store");
  try (ODatabaseDocumentTx db = databaseInstance.get().connect()) {
    OSchema schema = db.getMetadata().getSchema();
    OClass type = schema.getClass(DB_CLASS);
    if (type == null) {
      type = schema.createClass(DB_CLASS);
      type.createProperty(P_NAME, OType.STRING).setMandatory(true).setNotNull(true);
      type.createProperty(P_BYTES, OType.BINARY).setMandatory(true).setNotNull(true);
      type.createIndex(I_NAME, INDEX_TYPE.UNIQUE, P_NAME);
      log.debug("Created schema type {}: properties={}, indexes={}", type, type.properties(), type.getIndexes());
    }
    else {
      // NOTE: Upgrade steps run on each node but within a cluster, another node might already have upgraded the db
      log.debug("Skipped creating existing schema type {}: properties={}, indexes={}", type, type.properties(),
          type.getIndexes());
    }
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:20,代码来源:LegacyKeyStoreUpgradeService.java

示例9: testUpgradeSchema_TypeDoesNotYetExist

import com.orientechnologies.orient.core.metadata.schema.OClass; //导入依赖的package包/类
@Test
public void testUpgradeSchema_TypeDoesNotYetExist() throws Exception {
  service.upgradeSchema();
  try (ODatabaseDocumentTx db = database.getInstance().connect()) {
    OSchema schema = db.getMetadata().getSchema();
    OClass type = schema.getClass("key_store");
    assertThat(type, is(notNullValue()));
    OProperty prop = type.getProperty("name");
    assertThat(prop, is(notNullValue()));
    assertThat(prop.isMandatory(), is(true));
    assertThat(prop.isNotNull(), is(true));
    assertThat(prop.getType(), is(OType.STRING));
    prop = type.getProperty("bytes");
    assertThat(prop, is(notNullValue()));
    assertThat(prop.isMandatory(), is(true));
    assertThat(prop.isNotNull(), is(true));
    assertThat(prop.getType(), is(OType.BINARY));
    assertThat(type.getInvolvedIndexes("name"), hasSize(1));
    assertThat(type.getInvolvedIndexes("name").iterator().next().getType(), is("UNIQUE"));
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:22,代码来源:LegacyKeyStoreUpgradeServiceTest.java

示例10: defineType

import com.orientechnologies.orient.core.metadata.schema.OClass; //导入依赖的package包/类
@Override
protected void defineType(final OClass type) {
  type.createProperty(P_DOMAIN, OType.STRING)
      .setNotNull(true);
  type.createProperty(P_TYPE, OType.STRING)
      .setNotNull(true);
  type.createProperty(P_CONTEXT, OType.STRING)
      .setNotNull(true);
  type.createProperty(P_TIMESTAMP, OType.LONG)
      .setNotNull(true);
  type.createProperty(P_NODE_ID, OType.STRING)
      .setNotNull(true);
  type.createProperty(P_INITIATOR, OType.STRING)
      .setNotNull(true);
  type.createProperty(P_ATTRIBUTES, OType.EMBEDDEDMAP);
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:17,代码来源:AuditDataEntityAdapter.java

示例11: encode

import com.orientechnologies.orient.core.metadata.schema.OClass; //导入依赖的package包/类
/**
 * @see #doEncode(OClass, ORID)
 */
@Override
public String encode(final OClass type, final ORID rid) {
  checkNotNull(type);
  checkNotNull(rid);

  log.trace("Encoding: {}->{}", type, rid);
  try {
    return doEncode(type, rid);
  }
  catch (Exception e) {
    log.error("Failed to encode: {}->{}", type, rid);
    Throwables.throwIfUnchecked(e);
    throw new RuntimeException(e);
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:19,代码来源:RecordIdObfuscatorSupport.java

示例12: decode

import com.orientechnologies.orient.core.metadata.schema.OClass; //导入依赖的package包/类
/**
 * @see #doDecode(OClass, String)
 */
@Override
public ORID decode(final OClass type, final String encoded) {
  checkNotNull(type);
  checkNotNull(encoded);

  log.trace("Decoding: {}->{}", type, encoded);
  ORID rid;
  try {
    rid = doDecode(type, encoded);
  }
  catch (Exception e) {
    log.error("Failed to decode: {}->{}", type, encoded);
    Throwables.throwIfUnchecked(e);
    throw new RuntimeException(e);
  }

  // ensure rid points to the right type
  checkArgument(Ints.contains(type.getClusterIds(), rid.getClusterId()),
      "Invalid RID '%s' for class: %s", rid, type);

  return rid;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:26,代码来源:RecordIdObfuscatorSupport.java

示例13: verifyIdTypeMismatchFails

import com.orientechnologies.orient.core.metadata.schema.OClass; //导入依赖的package包/类
@Test
public void verifyIdTypeMismatchFails() {
  ORID rid = new ORecordId("#9:1");
  OClass type = mock(OClass.class);
  when(type.getClusterIds()).thenReturn(new int[] { 1 });
  String encoded = underTest.encode(type, rid);

  // this should fail since the cluster-id of the RID is not a member of the given type
  try {
    underTest.decode(type, encoded);
    fail();
  }
  catch (IllegalArgumentException e) {
    // expected
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:17,代码来源:RecordIdObfuscatorTestSupport.java

示例14: setupDocumentClass

import com.orientechnologies.orient.core.metadata.schema.OClass; //导入依赖的package包/类
protected static void setupDocumentClass(OClass oClass) {
	// Oversize leaves some extra space in the record, to reduce the
	// frequency in which we need to defragment. Orient sets the oversize
	// of class V at 2 by default, so we do the same.
	oClass.setOverSize(2);

	// TODO: should use constants from .graph, or there should be a way for
	// graph to tell the DB certain things so it can optimize for them.
	switch (oClass.getName()) {
	case "V_eclass":
		oClass.setOverSize(4);
		oClass.createProperty(PREFIX_INCOMING + "ofType", OType.LINKBAG);
		oClass.createProperty(PREFIX_INCOMING + "ofKind", OType.LINKBAG);
		break;
	case "V_eobject":
		oClass.createProperty(PREFIX_OUTGOING + "file", OType.LINKBAG);
		oClass.createProperty(PREFIX_OUTGOING + "ofType", OType.LINKLIST);
		oClass.createProperty(PREFIX_OUTGOING + "ofKind", OType.LINKLIST);
		break;
	case "V_file":
		oClass.createProperty(PREFIX_INCOMING + "file", OType.LINKBAG);
		break;
	}

	System.out.println("set up properties for " + oClass.getName() + ": "+ oClass.declaredProperties());
}
 
开发者ID:mondo-project,项目名称:mondo-hawk,代码行数:27,代码来源:OrientNode.java

示例15: setUp

import com.orientechnologies.orient.core.metadata.schema.OClass; //导入依赖的package包/类
@Before
public void setUp() {
  try (ODatabaseDocumentTx db = componentDatabase.getInstance().connect()) {
    OSchema schema = db.getMetadata().getSchema();

    OClass bucketType = schema.createClass(BUCKET_CLASS);

    OClass componentType = schema.createClass(COMPONENT_CLASS);

    componentType.createProperty(P_GROUP, OType.STRING);
    componentType.createProperty(P_NAME, OType.STRING)
        .setMandatory(true)
        .setNotNull(true);
    componentType.createProperty(P_VERSION, OType.STRING);
    componentType.createProperty(P_BUCKET, OType.LINK, bucketType).setMandatory(true).setNotNull(true);
  }

  underTest = new ComponentDatabaseUpgrade_1_2(componentDatabase.getInstanceProvider());
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:20,代码来源:ComponentDatabaseUpgrade_1_2_Test.java


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