Java Code Examples for com.orientechnologies.orient.core.metadata.schema.OSchema#getClass()
The following examples show how to use
com.orientechnologies.orient.core.metadata.schema.OSchema#getClass() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LuceneVsLuceneTest.java From orientdb-lucene with Apache License 2.0 | 6 votes |
@BeforeClass public void init() { initDB(); OSchema schema = databaseDocumentTx.getMetadata().getSchema(); OClass v = schema.getClass("V"); OClass song = schema.createClass("Song"); song.setSuperClass(v); song.createProperty("title", OType.STRING); song.createProperty("author", OType.STRING); try { Directory dir = getDirectory(); Analyzer analyzer = new StandardAnalyzer(OLuceneIndexManagerAbstract.LUCENE_VERSION); IndexWriterConfig iwc = new IndexWriterConfig(OLuceneIndexManagerAbstract.LUCENE_VERSION, analyzer); iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND); indexWriter = new IndexWriter(dir, iwc); } catch (IOException e) { e.printStackTrace(); } databaseDocumentTx.command(new OCommandSQL("create index Song.title on Song (title) FULLTEXT ENGINE LUCENE")).execute(); }
Example 2
Source File: ODocumentTextChoiceProvider.java From Orienteer with Apache License 2.0 | 6 votes |
@Override public void query(String term, int page, Response<ODocument> response) { OSchema schema = OrienteerWebApplication.lookupApplication().getDatabase().getMetadata().getSchema(); if (classNamesModel.getObject() != null && !classNamesModel.getObject().isEmpty()) { for (String className : classNamesModel.getObject()) { OClass oClass = schema.getClass(className); if (oClass != null) { OQueryModel<ODocument> queryModel = new OQueryModel<>("SELECT FROM " + className); String nameProperty = getOClassIntrospector().getNameProperty(oClass).getName(); IFilterCriteriaManager manager = new FilterCriteriaManager( new OPropertyModel(getOClassIntrospector().getNameProperty(oClass))); manager.addFilterCriteria(manager.createContainsStringFilterCriteria(Model.of(term), Model.of(true))); queryModel.addFilterCriteriaManager(nameProperty, manager); response.addAll(queryModel.getObject()); } } } }
Example 3
Source File: TestModels.java From wicket-orientdb with Apache License 2.0 | 6 votes |
@Test public void testOPropertiesDataProvider() { OSchema schema = wicket.getTester().getSchema(); OClass oClass = schema.getClass("ClassA"); OPropertiesDataProvider provider = new OPropertiesDataProvider(oClass, true); provider.setSort("name", SortOrder.ASCENDING); Iterator<? extends OProperty> it = provider.iterator(0, -1); List<OProperty> allProperties = new ArrayList<OProperty>(oClass.properties()); while(it.hasNext()) { OProperty oProperty = it.next(); assertTrue(allProperties.remove(provider.model(oProperty).getObject())); } assertTrue(allProperties.size()==0); provider.detach(); }
Example 4
Source File: LuceneSingleFieldEmbeddedTest.java From orientdb-lucene with Apache License 2.0 | 5 votes |
@BeforeClass public void init() { initDB(); OSchema schema = databaseDocumentTx.getMetadata().getSchema(); OClass v = schema.getClass("V"); OClass song = schema.createClass("Song"); song.setSuperClass(v); song.createProperty("title", OType.STRING); song.createProperty("author", OType.STRING); databaseDocumentTx.command(new OCommandSQL("create index Song.title on Song (title) FULLTEXT ENGINE LUCENE")).execute(); databaseDocumentTx.command(new OCommandSQL("create index Song.author on Song (author) FULLTEXT ENGINE LUCENE")).execute(); }
Example 5
Source File: LuceneInsertUpdateSingleDocumentNoTxTest.java From orientdb-lucene with Apache License 2.0 | 5 votes |
@BeforeClass public void init() { initDB(); OSchema schema = databaseDocumentTx.getMetadata().getSchema(); if (schema.getClass("City") == null) { OClass oClass = schema.createClass("City"); oClass.createProperty("name", OType.STRING); } databaseDocumentTx.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute(); }
Example 6
Source File: TestInAppOrientDBCompatibility.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Test public void testPropertyRenaming() { ODatabaseDocument db = wicket.getTester().getDatabase(); OSchema schema = db.getMetadata().getSchema(); OClass classA = schema.createClass("TestPropertyRenaming"); OProperty property = classA.createProperty("propertyOld", OType.STRING); assertEquals(property, classA.getProperty("propertyOld")); assertNull(classA.getProperty("propertyNew")); property.setName("propertyNew"); schema.reload(); classA = schema.getClass("TestPropertyRenaming"); assertNull(classA.getProperty("propertyOld")); assertEquals(property, classA.getProperty("propertyNew")); }
Example 7
Source File: CreateCityDb.java From orientdb-lucene with Apache License 2.0 | 5 votes |
@Override @Test(enabled = false) public void init() throws Exception { String buildDirectory = System.getProperty("buildDirectory", "."); if (buildDirectory == null) buildDirectory = "."; String uri = "plocal:" + buildDirectory + "/databases/city"; databaseDocumentTx = new ODatabaseDocumentTx(uri); if (databaseDocumentTx.exists()) { databaseDocumentTx.open("admin", "admin"); databaseDocumentTx.drop(); } databaseDocumentTx.create(); OSchema schema = databaseDocumentTx.getMetadata().getSchema(); if (schema.getClass("City") == null) { OClass oClass = schema.createClass("City"); oClass.createProperty("latitude", OType.DOUBLE); oClass.createProperty("longitude", OType.DOUBLE); oClass.createProperty("name", OType.STRING); oClass.createIndex("City.name", "FULLTEXT", null, null, "LUCENE", new String[] { "name" }); oClass.createIndex("City.lat_lng", "SPATIAL", null, null, "LUCENE", new String[] { "latitude", "longitude" }); } ZipFile zipFile = new ZipFile("files/allCountries.zip"); Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); if (entry.getName().equals("allCountries.txt")) { InputStream stream = zipFile.getInputStream(entry); lineReader = new LineNumberReader(new InputStreamReader(stream)); } } databaseDocumentTx.declareIntent(new OIntentMassiveInsert()); }
Example 8
Source File: ApplyEditorChangesBehavior.java From Orienteer with Apache License 2.0 | 5 votes |
private void addSuperClassesToOClass(OSchema schema, OClass oClass, List<String> superClassNames) { if (superClassNames != null && !superClassNames.isEmpty()) { List<OClass> superClasses = Lists.newArrayList(); for (String architectSuperClass : superClassNames) { if (schema.existsClass(architectSuperClass)) { OClass superClass = schema.getClass(architectSuperClass); superClasses.add(superClass); } } oClass.setSuperClasses(superClasses); } }
Example 9
Source File: OPropertyPrototyper.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Override protected Object handleGet(String propName, Class<?> returnType) { if("ownerClass".equals(propName)) { OSchema schema = OrientDbWebSession.get().getDatabase().getMetadata().getSchema(); return schema.getClass(className); } else if("fullName".equals(propName)) { return className + "." + values.get(NAME); } else return super.handleGet(propName, returnType); }
Example 10
Source File: OrientDbLoader.java From nextreports-server with Apache License 2.0 | 5 votes |
protected OClass getOrCreateClass(String className) { OClass clazz; OSchema schema = documentDatabase.getMetadata().getSchema(); if (schema.existsClass(className)) { clazz = schema.getClass(className); } else { clazz = schema.createClass(className); log.debug("Created class '{}'", className); } return clazz; }
Example 11
Source File: OPropertyFullNameConverter.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Override protected OProperty doBackward(String b) { ODatabaseDocument db = OrientDbWebSession.get().getDatabase(); OSchema schema = db.getMetadata().getSchema(); String className = Strings.beforeFirst(b, '.'); String propertyName = Strings.afterFirst(b, '.'); OClass oClass = schema.getClass(className); return oClass.getProperty(propertyName); }
Example 12
Source File: LuceneInsertUpdateSingleDocumentTransactionTest.java From orientdb-lucene with Apache License 2.0 | 5 votes |
@BeforeClass public void init() { initDB(); OSchema schema = databaseDocumentTx.getMetadata().getSchema(); if (schema.getClass("City") == null) { OClass oClass = schema.createClass("City"); oClass.createProperty("name", OType.STRING); } databaseDocumentTx.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute(); }
Example 13
Source File: LuceneContextTest.java From orientdb-lucene with Apache License 2.0 | 5 votes |
@BeforeClass public void init() { initDB(); OSchema schema = databaseDocumentTx.getMetadata().getSchema(); OClass v = schema.getClass("V"); OClass song = schema.createClass("Song"); song.setSuperClass(v); song.createProperty("title", OType.STRING); song.createProperty("author", OType.STRING); databaseDocumentTx.command(new OCommandSQL("create index Song.title on Song (title) FULLTEXT ENGINE LUCENE")).execute(); databaseDocumentTx.command(new OCommandSQL("create index Song.author on Song (author) FULLTEXT ENGINE LUCENE")).execute(); }
Example 14
Source File: LuceneInsertUpdateTransactionTest.java From orientdb-lucene with Apache License 2.0 | 5 votes |
@BeforeClass public void init() { initDB(); OSchema schema = databaseDocumentTx.getMetadata().getSchema(); if (schema.getClass("City") == null) { OClass oClass = schema.createClass("City"); oClass.createProperty("name", OType.STRING); } databaseDocumentTx.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute(); }
Example 15
Source File: LuceneBooleanIndex.java From orientdb-lucene with Apache License 2.0 | 5 votes |
@BeforeClass public void init() { initDB(); OSchema schema = databaseDocumentTx.getMetadata().getSchema(); OClass v = schema.getClass("V"); OClass song = schema.createClass("Person"); song.setSuperClass(v); song.createProperty("isDeleted", OType.BOOLEAN); databaseDocumentTx.command(new OCommandSQL("create index Person.isDeleted on Person (isDeleted) FULLTEXT ENGINE LUCENE")) .execute(); }
Example 16
Source File: OPropertyPrototyper.java From wicket-orientdb with Apache License 2.0 | 4 votes |
@Override protected OProperty createInstance(OProperty proxy) { OSchema schema = OrientDbWebSession.get().getDatabase().getMetadata().getSchema(); OClass oClass = schema.getClass(className); return oClass.createProperty(proxy.getName(), proxy.getType()); }
Example 17
Source File: DAOTest.java From Orienteer with Apache License 2.0 | 4 votes |
@Test @Sudo public void testDescribeAllTypes() { OSchema schema = tester.getMetadata().getSchema(); try { DAO.describe(OSchemaHelper.bind(tester.getDatabase()), IDAOAllTypesTestClass.class); assertTrue(schema.existsClass("DAOAllTypesTestClass")); assertTrue(schema.existsClass("IDAODummyClass")); OClass oClass = schema.getClass("DAOAllTypesTestClass"); OClass dummyClass = schema.getClass("IDAODummyClass"); assertTrue(!oClass.isAbstract()); assertProperty(oClass, "boolean", OType.BOOLEAN, false); assertProperty(oClass, "booleanPrimitive", OType.BOOLEAN, true); assertProperty(oClass, "booleanDeclared", OType.BOOLEAN, true); assertProperty(oClass, "integer", OType.INTEGER); assertProperty(oClass, "short", OType.SHORT); assertProperty(oClass, "long", OType.LONG); assertProperty(oClass, "float", OType.FLOAT); assertProperty(oClass, "double", OType.DOUBLE); assertProperty(oClass, "dateTime", OType.DATETIME); assertProperty(oClass, "date", OType.DATE); assertProperty(oClass, "string", OType.STRING); assertProperty(oClass, "binary", OType.BINARY); assertProperty(oClass, "decimal", OType.DECIMAL); assertProperty(oClass, "byte", OType.BYTE); assertProperty(oClass, "custom", OType.CUSTOM); assertProperty(oClass, "transient", OType.TRANSIENT); assertProperty(oClass, "any", OType.ANY); assertProperty(oClass, "link", OType.LINK, dummyClass, null); assertProperty(oClass, "linkList", OType.LINKLIST, dummyClass, null); assertProperty(oClass, "linkSet", OType.LINKSET, dummyClass, null); assertProperty(oClass, "linkMap", OType.LINKMAP, dummyClass, null); assertProperty(oClass, "linkBag", OType.LINKBAG, dummyClass, null); assertProperty(oClass, "embedded", OType.EMBEDDED, dummyClass, null); assertProperty(oClass, "embeddedList", OType.EMBEDDEDLIST, dummyClass, null); assertProperty(oClass, "embeddedSet", OType.EMBEDDEDSET, dummyClass, null); assertProperty(oClass, "embeddedMap", OType.EMBEDDEDMAP, dummyClass, null); assertProperty(oClass, "embeddedStringSet", OType.EMBEDDEDSET, OType.STRING); assertProperty(oClass, "embeddedStringList", OType.EMBEDDEDLIST, OType.STRING); assertProperty(oClass, "embeddedStringMap", OType.EMBEDDEDMAP, OType.STRING); assertProperty(oClass, "docs", OType.LINKLIST, dummyClass, null); } finally { if(schema.existsClass("DAOAllTypesTestClass")) schema.dropClass("DAOAllTypesTestClass"); if(schema.existsClass("IDAODummyClass")) schema.dropClass("IDAODummyClass"); } }
Example 18
Source File: TestDataInstallator.java From wicket-orientdb with Apache License 2.0 | 4 votes |
@Override protected void installData(OrientDbWebApplication app, ODatabaseDocument db) { OSchema schema = db.getMetadata().getSchema(); OClass classA = schema.createClass("ClassA"); classA.createProperty("name", OType.STRING); classA.createProperty("description", OType.STRING); classA.createProperty("other", OType.LINKLIST).setLinkedClass(classA); classA.createProperty("empty", OType.LINKLIST).setLinkedClass(classA); OClass classB = schema.createClass("ClassB"); classB.createProperty("name", OType.STRING); classB.createProperty("description", OType.STRING); ODocument doc1 = new ODocument("ClassA").field("name", "doc1"); ODocument doc2 = new ODocument("ClassA").field("name", "doc2"); ODocument doc3 = new ODocument("ClassA").field("name", "doc3"); doc1.field("other", Arrays.asList(doc2, doc3)); doc2.field("other", Arrays.asList(doc1, doc3)); doc3.field("other", Arrays.asList(doc1, doc2)); doc1.save(); doc2.save(); doc3.save(); OClass testRest = schema.createClass(TestRestApi.TEST_REST_CLASS); testRest.createProperty("a", OType.STRING); testRest.createProperty("b", OType.INTEGER); testRest.createProperty("c", OType.BOOLEAN); ODocument restDoc = new ODocument(testRest); restDoc.field("a", "test"); restDoc.field("b", 10); restDoc.field("c", true); restDoc.save(); OClass function = schema.getClass("OFunction"); ODocument fun1 = new ODocument(function); fun1.field("name", "fun1"); fun1.field("language", "javascript"); fun1.field("idempotent", true); fun1.field("code", "return \"fun1\";"); fun1.save(); ODocument fun2 = new ODocument(function); fun2.field("name", "fun2"); fun2.field("language", "javascript"); fun2.field("idempotent", false); fun2.field("code", "return \"fun2\";"); fun2.save(); OClass classTestHooks = schema.createClass("TestHooks"); classTestHooks.createProperty("name", OType.STRING); ODocument testHook = new ODocument(classTestHooks); testHook.field("name", "SAVED"); testHook.save(); }
Example 19
Source File: ComponentDatabaseUpgrade_1_3.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
private OClass getAssetDbClass(final ODatabaseDocumentTx db) { OSchema schema = db.getMetadata().getSchema(); return schema.getClass(ASSET_CLASS); }
Example 20
Source File: LuceneCreateJavaApi.java From orientdb-lucene with Apache License 2.0 | 3 votes |
public void testCreateIndex() { OSchema schema = databaseDocumentTx.getMetadata().getSchema(); OClass song = schema.getClass("Song"); OIndex<?> lucene = song.createIndex("Song.title", OClass.INDEX_TYPE.FULLTEXT.toString(), null, null, "LUCENE", new String[] { "title" }); Assert.assertNotNull(lucene); }