Java Code Examples for com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx#getDictionary()

The following examples show how to use com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx#getDictionary() . 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: SingletonActions.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Set singleton entity.  Returns {@code true} if entity was replaced.
 */
public boolean set(final ODatabaseDocumentTx db, final T entity) {
  checkNotNull(db);
  checkNotNull(entity);

  ODictionary<ORecord> dictionary = db.getDictionary();
  ODocument document = dictionary.get(key);
  if (document == null) {
    document = adapter.addEntity(db, entity);
    dictionary.put(key, document);
    return false;
  }
  else {
    adapter.writeEntity(document, entity);
    return true;
  }
}
 
Example 2
Source File: SingletonActions.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Get singleton entity or {@code null} if entity was not found.
 */
@Nullable
public T get(final ODatabaseDocumentTx db) {
  checkNotNull(db);

  ODictionary<ORecord> dictionary = db.getDictionary();
  ODocument document = dictionary.get(key);
  if (document != null) {
    return adapter.readEntity(document);
  }
  return null;
}
 
Example 3
Source File: SingletonActions.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Delete singleton entity.  Returns {@code true} if entity was deleted.
 */
public boolean delete(final ODatabaseDocumentTx db) {
  checkNotNull(db);

  ODictionary<ORecord> dictionary = db.getDictionary();
  ODocument document = dictionary.get(key);
  if (document != null) {
    db.delete(document);
    dictionary.remove(key);
    return true;
  }
  return false;
}