XBRLAPI

A Java API for XBRL


org.xbrlapi.data.xindice
Class StoreImpl

java.lang.Object
  extended by org.xbrlapi.data.BaseStoreImpl
      extended by org.xbrlapi.data.XBRLStoreImpl
          extended by org.xbrlapi.data.xindice.StoreImpl
All Implemented Interfaces:
Serializable, Store, XBRLStore

public class StoreImpl
extends XBRLStoreImpl
implements XBRLStore

Implementation of the Xindice based data store for the XBRLAPI.

Author:
Geoffrey Shuetrim (geoff@galexy.net)
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.xbrlapi.data.BaseStoreImpl
logger, matcher, namespaceBindings, storeDOM
 
Constructor Summary
StoreImpl(DBConnectionImpl connection, String storeParentPath, String dataCollectionName)
          Initialise the database connection.
 
Method Summary
 void addIndex(String name, String type, String pattern)
          Adds an index to the collection containing the DTS.
 void close()
          Close the data store by closing the data and metadata collections.
 void delete()
          Delete and close the data store.
 void deleteIndex(String name)
          Deletes an index to the collection containing the DTS.
 Fragment getFragment(String index)
          Retrieves a fragment from an XBRL API data store.
 boolean hasFragment(String index)
          Test if a store contains a specific fragment, as identified by its index.
<F extends Fragment>
FragmentList<F>
query(String query)
          Run a query against the collection of all fragments in the DTS.
 Map<String,String> queryForIndices(String query)
          Run a query against the collection of all fragments in the store.
 void removeFragment(String index)
          Remove a fragment from the DTS.
 void storeFragment(Fragment fragment)
          Add a fragment to the data store.
 
Methods inherited from class org.xbrlapi.data.XBRLStoreImpl
getArcRoles, getArcroleTypes, getArcroleTypes, getConcept, getExtendedLinksWithRole, getFacts, getFacts, getItems, getItems, getLinkRoles, getLinkRoles, getMinimalNetworksWithArcrole, getMinimalNetworksWithArcrole, getMinimumDocumentSet, getMinimumDocumentSet, getNetworkRoots, getNetworkRoots, getResourceRoles, getRoleTypes, getRoleTypes, getTuples, getTuples
 
Methods inherited from class org.xbrlapi.data.BaseStoreImpl
clearFilteringURIs, deleteDocument, deleteRelatedDocuments, DOM2String, formCompositeDocument, getChildFragments, getDocumentAsDOM, getDocumentId, getDocumentsToDiscover, getFilteringURIs, getFollowingSibling, getFragments, getFragmentsFromDocument, getLanguage, getLanguages, getMatcher, getNetworks, getNetworks, getNextFragmentId, getReferencedDocuments, getReferencingDocuments, getRootFragmentForDocument, getRootFragments, getStoreAsDOM, getStoredNetworks, getStoredURIs, getStub, getStubs, getSubtree, getURIFilteringQueryClause, hasDocument, hasStoredNetworks, isFilteringByURIs, removeStub, saveDocuments, saveDocuments, saveStoreAsSingleDocument, serialize, serialize, serialize, serialize, serialize, serializeToString, setFilteringURIs, setMatcher, setNamespaceBinding, setStoredNetworks, storeLoaderState, storeStub
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xbrlapi.data.XBRLStore
getArcRoles, getArcroleTypes, getArcroleTypes, getConcept, getExtendedLinksWithRole, getFacts, getFacts, getItems, getItems, getLinkRoles, getLinkRoles, getMinimalNetworksWithArcrole, getMinimalNetworksWithArcrole, getMinimumDocumentSet, getMinimumDocumentSet, getNetworkRoots, getNetworkRoots, getResourceRoles, getRoleTypes, getRoleTypes, getTuples, getTuples
 
Methods inherited from interface org.xbrlapi.data.Store
clearFilteringURIs, deleteDocument, deleteRelatedDocuments, formCompositeDocument, getChildFragments, getDocumentAsDOM, getDocumentId, getDocumentsToDiscover, getFilteringURIs, getFragments, getFragmentsFromDocument, getLanguage, getLanguages, getMatcher, getNetworks, getNetworks, getNextFragmentId, getReferencedDocuments, getReferencingDocuments, getRootFragmentForDocument, getRootFragments, getStoreAsDOM, getStoredNetworks, getStoredURIs, getStub, getStubs, getSubtree, hasDocument, hasStoredNetworks, isFilteringByURIs, removeStub, saveDocuments, saveDocuments, saveStoreAsSingleDocument, serialize, serialize, serialize, serialize, serialize, serializeToString, setFilteringURIs, setMatcher, setNamespaceBinding, setStoredNetworks, storeLoaderState, storeStub
 

Constructor Detail

StoreImpl

public StoreImpl(DBConnectionImpl connection,
                 String storeParentPath,
                 String dataCollectionName)
          throws XBRLException
Initialise the database connection.

Parameters:
connection - The live connection to the Xindice database.
storeParentPath - The full path to the container collection, which is the collection that will hold the data collection when it are created.
dataCollectionName - The name of the data collection.
Throws:
XBRLException - if the database connection is null or if the data or metadata collections could not be created or accessed or the indexes could not be created or the XPath services could not be established or if the storeParentPath does not end in a delimiter: /.
Method Detail

close

public void close()
           throws XBRLException
Close the data store by closing the data and metadata collections. Throws XBRLException if the collections cannot be closed.

Specified by:
close in interface Store
Overrides:
close in class BaseStoreImpl
Throws:
XBRLException

delete

public void delete()
            throws XBRLException
Description copied from interface: Store
Delete and close the data store.

Specified by:
delete in interface Store
Throws:
XBRLException - if the data store cannot be deleted.
See Also:
Store.delete()

storeFragment

public void storeFragment(Fragment fragment)
                   throws XBRLException
Add a fragment to the data store. The addition of a fragment to the data store involves: 1. Creating resources to hold the XML data and metadata 2. Serialising the data and the metadata from the fragment builder. 3. Storing the data and metadata in their respective resources. 4. Adding the data and metadata resources to the data store. 5. Getting the index to use for the new fragment being added. 6. Replaces the builder in the fragment with the new data and metadata resources. 7. Informs the fragment being stored that it is stored in this data store. TODO Modify Xindice StoreImpl so that existing fragments in the data store can be replaced.

Specified by:
storeFragment in interface Store
Parameters:
fragment - The fragment to be added to the DTS store.
Throws:
XBRLException - if the fragment is in the store already or the process of inserting its data and metadata fails or if the fragment properties cannot be updated as required to reflect that its data has been stored.

hasFragment

public boolean hasFragment(String index)
                    throws XBRLException
Test if a store contains a specific fragment, as identified by its index.

Specified by:
hasFragment in interface Store
Parameters:
index - The index of the fragment to test for.
Returns:
true iff the store contains a fragment with the specified fragment index.
Throws:
XBRLException - If the test cannot be conducted.

getFragment

public Fragment getFragment(String index)
                     throws XBRLException
Retrieves a fragment from an XBRL API data store. The fragment will be created as a fragment of the original fragment type but will be returned as a straight fragment.

Specified by:
getFragment in interface Store
Parameters:
index - The index of the fragment.
Returns:
The fragment corresponding to the specified index or null if the fragment is not in the store.
Throws:
XBRLException - if the fragment cannot be retrieved.

removeFragment

public void removeFragment(String index)
                    throws XBRLException
Remove a fragment from the DTS. If a fragment with the same ID does not already exist in the DTs then no action is required.

Specified by:
removeFragment in interface Store
Parameters:
index - The index of the fragment to be removed from the DTS store.
Throws:
XBRLException - if the fragment cannot be removed from the store.

query

public <F extends Fragment> FragmentList<F> query(String query)
                                       throws XBRLException
Run a query against the collection of all fragments in the DTS.

Specified by:
query in interface Store
Parameters:
query - The XPath query to run against the set of fragments in the DTS.
Returns:
a fragment list that contains each matching fragment.
Throws:
XBRLException - if the query cannot be executed.

queryForIndices

public Map<String,String> queryForIndices(String query)
                                   throws XBRLException
Description copied from interface: Store
Run a query against the collection of all fragments in the store.

Specified by:
queryForIndices in interface Store
Parameters:
query - The XPath query to run against the set of fragments.
Returns:
a map indexed by the indices of the fragments matching the query.
Throws:
XBRLException - if the query cannot be executed.
See Also:
Store.queryForIndices(String)

addIndex

public void addIndex(String name,
                     String type,
                     String pattern)
              throws XBRLException
Adds an index to the collection containing the DTS.

Parameters:
name - The name of the index.
type - The type of the index ('name' or 'value').
pattern - The pattern for the index (like the match attribute value in XSLT template elements.).
Throws:
XBRLException - if the index cannot be added.

deleteIndex

public void deleteIndex(String name)
                 throws XBRLException
Deletes an index to the collection containing the DTS.

Parameters:
name - The name of the index to be deleted.
Throws:
XBRLException - if the index cannot be added.

SourceForge Logo