Java Code Examples for com.orientechnologies.orient.core.metadata.schema.OClass#getIndexes()

The following examples show how to use com.orientechnologies.orient.core.metadata.schema.OClass#getIndexes() . 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: ListOIndexesModel.java    From wicket-orientdb with Apache License 2.0 6 votes vote down vote up
@Override
public Collection<OIndex<?>> getData() {
	OClass oClass = oClassModel.getObject();
	if(oClass==null)
	{
		return null;
	}
	else if(allIndexesModel==null||Boolean.TRUE.equals(allIndexesModel.getObject()))
	{
		return oClass.getIndexes();
	}
	else
	{
		return oClass.getClassIndexes();
	}
}
 
Example 2
Source File: TestModels.java    From wicket-orientdb with Apache License 2.0 6 votes vote down vote up
@Test
public void testOIndexDataProvider()
{
	OSchema schema = wicket.getTester().getSchema();
	OClass oClass = schema.getClass("OUser");
	OIndexesDataProvider provider = new OIndexesDataProvider(oClass, true);
	provider.setSort("name", SortOrder.ASCENDING);
	Iterator<? extends OIndex<?>> it = provider.iterator(0, -1);
	List<OIndex<?>> allIndexes = new ArrayList<OIndex<?>>(oClass.getIndexes());
	while(it.hasNext())
	{
		OIndex<?> oIndex = it.next();
		assertTrue(allIndexes.remove(provider.model(oIndex).getObject()));
	}
	assertTrue(allIndexes.size()==0);
	provider.detach();
}
 
Example 3
Source File: OLuceneClassIndexManager.java    From orientdb-lucene with Apache License 2.0 6 votes vote down vote up
private void addIndexesEntries(ODocument document) {
  document = checkForLoading(document);

  // STORE THE RECORD IF NEW, OTHERWISE ITS RID
  final OIdentifiable rid = document.getIdentity().isPersistent() ? document.placeholder() : document;

  final OClass cls = document.getSchemaClass();
  if (cls != null) {
    final Collection<OIndex<?>> indexes = cls.getIndexes();
    for (final OIndex<?> index : indexes) {
      final Object key = index.getDefinition().getDocumentValueToIndex(document);
      // SAVE A COPY TO AVOID PROBLEM ON RECYCLING OF THE RECORD
      if (key instanceof Collection) {
        for (final Object keyItem : (Collection<?>) key)
          if (keyItem != null)
            index.put(keyItem, rid);
      } else if (key != null)
        index.put(key, rid);
    }

  }
}
 
Example 4
Source File: OLuceneClassIndexManager.java    From orientdb-lucene with Apache License 2.0 6 votes vote down vote up
private void checkIndexes(ODocument document, TYPE hookType) {
  document = checkForLoading(document);

  final OClass cls = document.getSchemaClass();
  if (cls != null) {
    final Collection<OIndex<?>> indexes = cls.getIndexes();
    switch (hookType) {
    case BEFORE_CREATE:
      checkIndexedPropertiesOnCreation(document, indexes);
      break;
    case BEFORE_UPDATE:
      checkIndexedPropertiesOnUpdate(document, indexes);
      break;
    default:
      throw new IllegalArgumentException("Invalid hook type: " + hookType);
    }
  }
}