|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.sql.JDBCRowStore<T>
com.antelmann.sql.RelationshipStore<T>
public class RelationshipStore<T extends DefaultEntryRelationship>
provides an SQL-based store for relationships.
The class T must have a constructor that corresponds to
DefaultEntryRelationship.DefaultEntryRelationship(Object, com.antelmann.db.EntryRelationship),
so that the instantiation of the mapper works based on reflection.
When using a TopicMapFilter on this store, make sure that you are using
an object derivable from the EntryClassMapper in use; see setEntryClassMapper(EntryClassMapper).
By default, a EntryClassMapper.STRING_MAPPER is used.
To allow more efficient storage, an implementation may be restricted to only allow relations
of already specified types, so that the from-/to-class may not be stored.
If that is the case, do not put these topics into the configuration map used in the constructor,
but use setFromClass(Class) and setToClass(Class) respectively.
If, on the other hand, the classes are mapped, then these two methods should be left with a null value.
The fastDelete option is generally set to true here.
JDBCRowStore.setFastDelete(boolean)| Nested Class Summary | |
|---|---|
static class |
RelationshipStore.Mapper<T extends DefaultEntryRelationship>
|
| Nested classes/interfaces inherited from interface com.antelmann.sql.RelationshipManager |
|---|
RelationshipManager.Column |
| Nested classes/interfaces inherited from interface com.antelmann.db.DBClassStore |
|---|
DBClassStore.DBMethod |
| Field Summary |
|---|
| Fields inherited from class com.antelmann.sql.JDBCRowStore |
|---|
database, ensureTransactionsOnFetch, helper, mapper |
| Constructor Summary | |
|---|---|
RelationshipStore(Database<Connection> db,
RelationshipStore.Mapper<T> mapper,
Class<T> type)
|
|
RelationshipStore(Database<Connection> db,
String tableName,
String idColumn,
Class<T> type,
boolean useNextIntAsID)
|
|
RelationshipStore(Database<Connection> db,
String tableName,
String idColumn,
IDFactory factory,
Class<T> type)
|
|
RelationshipStore(Database<Connection> db,
String tableName,
String idColumn,
Map<RelationshipManager.Column,String> config,
Class<T> type,
boolean useNextIntAsID)
|
|
RelationshipStore(Database<Connection> db,
String tableName,
String idColumn,
Map<RelationshipManager.Column,String> config,
IDFactory factory,
Class<T> type)
|
|
RelationshipStore(Database<Connection> db,
String tableName,
String idColumn,
Map<RelationshipManager.Column,String> config,
IDFactory factory,
Class<T> type,
String query)
|
|
| Method Summary | ||
|---|---|---|
int |
countRelations(Map<RelationshipManager.Column,Object> restrictions)
the mapped values for the class columns RelationshipManager.Column.TO_CLASS and RelationshipManager.Column.FROM_CLASS
may be represented as Class |
|
static
|
findBrokenRelationships(DBClassStore<T> store,
boolean breakOnFirstEncounter)
|
|
static
|
findBrokenRelationships(DBClassStore<T> store,
Collection<T> set,
Monitor monitor,
boolean breakOnFirstEncounter)
looks for broken relationships in the database and puts them into the given collection. |
|
static
|
findBrokenRelationships(DBClassStore<T> store,
Monitor monitor,
boolean breakOnFirstEncounter)
|
|
static HashMap<RelationshipManager.Column,String> |
getDefaultColumns()
|
|
EntryClassMapper |
getEntryClassMapper()
returns the EntryClassMapper used by the store to map the class of the references |
|
RelationshipStore.Mapper<T> |
getMapper()
|
|
boolean |
hasRelationships(DBReference ref)
determines if there are any relationsips present for a given reference (both: active and passive) |
|
Set<DefaultEntryRelationship> |
listAllRelations(DBReference ref,
Object relationType)
contains passive and active relationships for the given reference - restricted to the given type if non-null |
|
List<DefaultEntryRelationship> |
listRelations(Map<RelationshipManager.Column,Object> restrictions)
the mapped values for the class columns RelationshipManager.Column.TO_CLASS and RelationshipManager.Column.FROM_CLASS
may be represented as Class |
|
void |
setDefaultRelationType(Object relationType)
must be set if the topic RelationshipManager.Column.TYPE is not set |
|
void |
setEntryClassMapper(EntryClassMapper ecm)
use this method to set the EntryClassMapper of the embedded mapper to something other than EntryClassMapper.STRING_MAPPER |
|
void |
setFromClass(Class<? extends DBEntry> c)
must be set if the topic RelationshipManager.Column.FROM_CLASS is not set |
|
void |
setPreventSameRelation(boolean flag)
|
|
void |
setTableQuery(String query)
|
|
void |
setToClass(Class<? extends DBEntry> c)
must be set if the topic RelationshipManager.Column.TO_CLASS is not set |
|
void |
setVerifyRelationsOnStore(boolean flag)
|
|
protected Object |
translateForColumn(Object value,
RelationshipManager.Column column)
|
|
protected Object |
translateForColumn(Object value,
String column)
|
|
protected Map<Object,Object> |
translateMap(Map<RelationshipManager.Column,Object> restrictions)
responsible for converting the restrictions map to a map that can be used as a TopicMapFilter |
|
protected Map<String,Object> |
translateQueryMap(Map<String,Object> restrictions)
|
|
| Methods inherited from class com.antelmann.sql.JDBCRowStore |
|---|
add, checkTransaction, containsID, deleteEntries, deleteEntry, fetch, fetchStubs, generateNewID, getColumnNames, getColumnsForTopic, getColumnSize, getDatabase, getDisplayColumn, getDisplayNameForColumn, getEntry, getEntryClass, getIDColumn, getMappingForTopic, getSQLTypeforColumn, getStub, getTableName, getTableQuery, insert, insertAsNew, isFastDelete, isIgnoreInvalidProperties, remove, setFastDelete, setIgnoreInvalidProperties, size, trimIdString, update |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RelationshipStore(Database<Connection> db,
String tableName,
String idColumn,
Class<T> type,
boolean useNextIntAsID)
throws DatabaseException
DatabaseException
public RelationshipStore(Database<Connection> db,
String tableName,
String idColumn,
Map<RelationshipManager.Column,String> config,
Class<T> type,
boolean useNextIntAsID)
throws DatabaseException
DatabaseException
public RelationshipStore(Database<Connection> db,
String tableName,
String idColumn,
IDFactory factory,
Class<T> type)
throws DatabaseException
DatabaseException
public RelationshipStore(Database<Connection> db,
String tableName,
String idColumn,
Map<RelationshipManager.Column,String> config,
IDFactory factory,
Class<T> type)
throws DatabaseException
DatabaseException
public RelationshipStore(Database<Connection> db,
String tableName,
String idColumn,
Map<RelationshipManager.Column,String> config,
IDFactory factory,
Class<T> type,
String query)
throws DatabaseException
DatabaseException
public RelationshipStore(Database<Connection> db,
RelationshipStore.Mapper<T> mapper,
Class<T> type)
| Method Detail |
|---|
public static HashMap<RelationshipManager.Column,String> getDefaultColumns()
public void setTableQuery(String query)
throws DatabaseException
DatabaseExceptionpublic RelationshipStore.Mapper<T> getMapper()
getMapper in class JDBCRowStore<T extends DefaultEntryRelationship>public void setEntryClassMapper(EntryClassMapper ecm)
EntryClassMapper.STRING_MAPPER
public void setFromClass(Class<? extends DBEntry> c)
RelationshipManager.Column.FROM_CLASS is not set
public void setToClass(Class<? extends DBEntry> c)
RelationshipManager.Column.TO_CLASS is not set
public void setDefaultRelationType(Object relationType)
RelationshipManager.Column.TYPE is not set
public void setPreventSameRelation(boolean flag)
public void setVerifyRelationsOnStore(boolean flag)
protected Object translateForColumn(Object value,
String column)
protected Object translateForColumn(Object value,
RelationshipManager.Column column)
protected Map<Object,Object> translateMap(Map<RelationshipManager.Column,Object> restrictions)
TopicMapFilter
public List<DefaultEntryRelationship> listRelations(Map<RelationshipManager.Column,Object> restrictions)
throws DatabaseException
RelationshipManagerRelationshipManager.Column.TO_CLASS and RelationshipManager.Column.FROM_CLASS
may be represented as Class> objects as an alternative to the class name base on
EntryClassMapper.STRING_MAPPER.
listRelations in interface RelationshipManagerDatabaseException
public int countRelations(Map<RelationshipManager.Column,Object> restrictions)
throws DatabaseException
RelationshipManagerRelationshipManager.Column.TO_CLASS and RelationshipManager.Column.FROM_CLASS
may be represented as Class> objects as an alternative to the class name base on
EntryClassMapper.STRING_MAPPER.
countRelations in interface RelationshipManagerDatabaseException
public boolean hasRelationships(DBReference ref)
throws DatabaseException
RelationshipManager
hasRelationships in interface RelationshipManagerDatabaseException
public Set<DefaultEntryRelationship> listAllRelations(DBReference ref,
Object relationType)
throws DatabaseException
RelationshipManager
listAllRelations in interface RelationshipManagerDatabaseException
public static <T extends DefaultEntryRelationship> ArrayList<T> findBrokenRelationships(DBClassStore<T> store,
boolean breakOnFirstEncounter)
throws DatabaseException
DatabaseException
public static <T extends DefaultEntryRelationship> ArrayList<T> findBrokenRelationships(DBClassStore<T> store,
Monitor monitor,
boolean breakOnFirstEncounter)
throws DatabaseException
DatabaseException
public static <T extends DefaultEntryRelationship> void findBrokenRelationships(DBClassStore<T> store,
Collection<T> set,
Monitor monitor,
boolean breakOnFirstEncounter)
throws DatabaseException
DBUtils.runInTransaction(Task, com.antelmann.db.DBTransaction, boolean)
T - denotes the relationship classstore - the store that holds the relationships in questionset - used to store the broken relations foundmonitor - allows to monitor the (potentially long-running) operation;
the Monitor.runTask()-method is called whenever a broken
relationship is foundbreakOnFirstEncounter - if true, the method will return when the first broken relationship is found
DatabaseExceptionDefaultEntryRelationship.isBroken(Database)public EntryClassMapper getEntryClassMapper()
RelationshipManager
getEntryClassMapper in interface RelationshipManagerprotected Map<String,Object> translateQueryMap(Map<String,Object> restrictions)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||