Java Doc for BaseDbDoubleStorage.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » sakai » org.sakaiproject.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.sakaiproject.util.BaseDbDoubleStorage

BaseDbDoubleStorage
public class BaseDbDoubleStorage (Code)

BaseDbDoubleStorage is a class that stores Resources (of some type) in a database,
provides locked access, and generally implements a services "storage" class. The
service's storage class can extend this to provide covers to turn Resource and
Edit into something more type specific to the service.

Note: the methods here are all "id" based, with the following assumptions:

  • just the Resource Id field is enough to distinguish one Resource from another (or, for resource, the container's id and the resource id).
  • a resource's reference is based on no more than the resource id, for containers
  • and no more than resource and container id for resources
  • a resource's id and container id cannot change


In order to handle Unicode characters properly, the SQL statements executed by this class should not embed Unicode characters into the SQL statement text;
rather, Unicode values should be inserted as fields in a PreparedStatement. Databases handle Unicode better in fields.



Field Summary
final protected static  String[]M_containerExtraFields
    
protected  Stringm_containerEntryTagName
     The xml tag name for the element holding each actual container entry.
protected  Stringm_containerTableIdField
     The field in the table that holds the container id.
protected  Stringm_containerTableName
     Table name for container records.
protected  Hashtablem_locks
     Locks, keyed by reference, holding Connections (or, if locks are done locally, holding an Edit).
protected  booleanm_locksAreInDb
     If true, we do our locks in the remote database.
protected  booleanm_locksAreInTable
     If true, we do our locks in the remove database using a separate locking table.
protected  Stringm_resourceEntryTagName
     The xml tag name for the element holding each actual resource entry.
protected  Stringm_resourceTableContainerIdField
     The field in the resource table that holds the container id.
protected  Stringm_resourceTableDraftField
     The field in the record that has the draft indicator ('0' for no, '1' for yes).
protected  Stringm_resourceTableIdField
     The field in the resource table that holds the resource id.
protected  Stringm_resourceTableName
     Table name for resource records.
protected  Stringm_resourceTableOrderField
     The field name in the resource table for ordering.
protected  String[]m_resourceTableOtherFields
     The additional field names in the resource table that go between the two ids and the xml.
protected  Stringm_resourceTableOwnerField
     The field in the record that has the user id of the resource owner.
protected  Stringm_resourceTablePubViewField
     The field in the record that has the pubview indicator ('0' for no, '1' for yes).
protected  SqlServicem_sql
     Injected (by constructor) SqlService.
protected  StorageUserm_user
     The StorageUser to callback for new Resource and Edit objects.

Constructor Summary
public  BaseDbDoubleStorage(String containerTableName, String containerTableIdField, String resourceTableName, String resourceTableIdField, String resourceTableContainerIdField, String resourceTableOrderField, String resourceTableOwnerField, String resourceTableDraftField, String resourceTablePubViewField, String[] resourceTableOtherFields, boolean locksInDb, String containerEntryName, String resourceEntryName, StorageUser user, SqlService sqlService)
     Construct.

Method Summary
public  voidcancelContainer(Edit edit)
     Cancel the changes and release the lock.
public  voidcancelResource(Entity container, Edit edit)
     Cancel the changes and release the lock.
public  booleancheckContainer(String ref)
     Check if a Container by this id exists.
Parameters:
  ref - The container reference.
public  booleancheckResource(Entity container, String id)
     Check if a Resource by this id exists.
Parameters:
  container - The container for this resource.
Parameters:
  id - The id.
public  voidclose()
     Close.
public  voidcommitContainer(Edit edit)
     Commit the changes and release the lock.
public  voidcommitResource(Entity container, Edit edit)
     Commit the changes and release the lock.
public  EditeditContainer(String ref)
     Get a lock on the Container with this id, or null if a lock cannot be gotten.
Parameters:
  ref - The container reference.
public  EditeditResource(Entity container, String id)
     Get a lock on the Resource with this id, or null if a lock cannot be gotten.
Parameters:
  container - The container for this resource.
Parameters:
  id - The user id.
public  ListgetAllContainers()
     Get all Containers.
public  ListgetAllResources(Entity container)
     Get all Resources.
Parameters:
  container - The container for this resource.
public  EntitygetContainer(String ref)
     Get the Container with this id, or null if not found.
Parameters:
  ref - The container reference.
public  ListgetContainerIdsMatching(String root)
     Access a list of container ids match (start with) the root.
Parameters:
  context - The id root to match.
public  EntitygetResource(Entity container, String id)
     Get the Resource with this id, or null if not found.
Parameters:
  container - The container for this resource.
Parameters:
  id - The id.
public  ListgetResources(Entity container, Time afterDate, int limitedToLatest, String draftsForId, boolean pubViewOnly)
     Get resources filtered by date and count and drafts, in descending (latest first) order
Parameters:
  afterDate - if null, no date limit, else limited to only messages after this date.
Parameters:
  limitedToLatest - if 0, no count limit, else limited to only the latest this number of messages.
Parameters:
  draftsForId - how to handle drafts: null means no drafts, "*" means all, otherwise drafts only if created by this userId.
Parameters:
  pubViewOnly - if true, include only messages marked pubview, else include any.
protected  StringinsertFields(String before1, String before2, String[] fields, String after)
     Form a string of (field, field, field), for sql insert statements, one for each item in the fields array, plus one before, and one after.
Parameters:
  before1 - The first field name.
Parameters:
  before2 - (options) second field name.
Parameters:
  values - The extra field names, in the middle.
Parameters:
  after - The last field name.
public  voidopen()
     Open and be ready to read / write.
public  EditputContainer(String ref)
     Add a new Container with this id.
Parameters:
  ref - The container reference.
public  EditputResource(Entity container, String id, Object[] others)
     Add a new Resource with this id.
protected  EntityreadContainer(String xml)
     Read one Container Resource from xml
Parameters:
  xml - An string containing the xml which describes the Container resource.
protected  EntityreadResource(Entity container, String xml)
     Read one Resource from xml
Parameters:
  container - The container for this resource.
Parameters:
  xml - An string containing the xml which describes the resource.
public  voidremoveContainer(Edit edit)
     Remove this (locked) Container.
public  voidremoveResource(Entity container, Edit edit)
     Remove this (locked) Resource.
protected  StringupdateSet(String[] fields)
     Form a string of n name=?, for sql update set statements, one for each item in the values array, or an empty string if null.
Parameters:
  values - The values to be inserted into the sql statement.
protected  StringvaluesParams(String[] fields)
     Form a string of n question marks with commas, for sql value statements, one for each item in the values array, or an empty string if null.
Parameters:
  values - The values to be inserted into the sql statement.

Field Detail
M_containerExtraFields
final protected static String[] M_containerExtraFields(Code)
For container, the extra field is (no longer used) NEXT_ID



m_containerEntryTagName
protected String m_containerEntryTagName(Code)
The xml tag name for the element holding each actual container entry.



m_containerTableIdField
protected String m_containerTableIdField(Code)
The field in the table that holds the container id.



m_containerTableName
protected String m_containerTableName(Code)
Table name for container records.



m_locks
protected Hashtable m_locks(Code)
Locks, keyed by reference, holding Connections (or, if locks are done locally, holding an Edit). Note: keying by reference allows botu container and resource locks to be stored, the reference distinguishes them.



m_locksAreInDb
protected boolean m_locksAreInDb(Code)
If true, we do our locks in the remote database.



m_locksAreInTable
protected boolean m_locksAreInTable(Code)
If true, we do our locks in the remove database using a separate locking table.



m_resourceEntryTagName
protected String m_resourceEntryTagName(Code)
The xml tag name for the element holding each actual resource entry.



m_resourceTableContainerIdField
protected String m_resourceTableContainerIdField(Code)
The field in the resource table that holds the container id.



m_resourceTableDraftField
protected String m_resourceTableDraftField(Code)
The field in the record that has the draft indicator ('0' for no, '1' for yes).



m_resourceTableIdField
protected String m_resourceTableIdField(Code)
The field in the resource table that holds the resource id.



m_resourceTableName
protected String m_resourceTableName(Code)
Table name for resource records.



m_resourceTableOrderField
protected String m_resourceTableOrderField(Code)
The field name in the resource table for ordering.



m_resourceTableOtherFields
protected String[] m_resourceTableOtherFields(Code)
The additional field names in the resource table that go between the two ids and the xml.



m_resourceTableOwnerField
protected String m_resourceTableOwnerField(Code)
The field in the record that has the user id of the resource owner.



m_resourceTablePubViewField
protected String m_resourceTablePubViewField(Code)
The field in the record that has the pubview indicator ('0' for no, '1' for yes).



m_sql
protected SqlService m_sql(Code)
Injected (by constructor) SqlService.



m_user
protected StorageUser m_user(Code)
The StorageUser to callback for new Resource and Edit objects.




Constructor Detail
BaseDbDoubleStorage
public BaseDbDoubleStorage(String containerTableName, String containerTableIdField, String resourceTableName, String resourceTableIdField, String resourceTableContainerIdField, String resourceTableOrderField, String resourceTableOwnerField, String resourceTableDraftField, String resourceTablePubViewField, String[] resourceTableOtherFields, boolean locksInDb, String containerEntryName, String resourceEntryName, StorageUser user, SqlService sqlService)(Code)
Construct.
Parameters:
  containerTableName - Table name for containers.
Parameters:
  containerTableIdField - The field in the container table that holds the id.
Parameters:
  resourceTableName - Table name for resources.
Parameters:
  resourceTableIdField - The field in the resource table that holds the id.
Parameters:
  resourceTableContainerIdField - The field in the resource table that holds the container id.
Parameters:
  resourceTableOrderField - The field in the resource table that is used for ordering results.
Parameters:
  resourceTableOtherFields - The other fields in the resource table (between the two id fields and the xml field).
Parameters:
  locksInDb - If true, we do our locks in the remote database, otherwise we do them here.
Parameters:
  containerEntryName - The xml tag name for the element holding each actual container entry.
Parameters:
  resourceEntryName - The xml tag name for the element holding each actual resource entry.
Parameters:
  user - The StorageUser class to call back for creation of Resource and Edit objects.
Parameters:
  sqlService - The SqlService.




Method Detail
cancelContainer
public void cancelContainer(Edit edit)(Code)
Cancel the changes and release the lock.
Parameters:
  user - The Edit to cancel.



cancelResource
public void cancelResource(Entity container, Edit edit)(Code)
Cancel the changes and release the lock.
Parameters:
  container - The container for this resource.
Parameters:
  user - The Edit to cancel.



checkContainer
public boolean checkContainer(String ref)(Code)
Check if a Container by this id exists.
Parameters:
  ref - The container reference. true if a Container by this id exists, false if not.



checkResource
public boolean checkResource(Entity container, String id)(Code)
Check if a Resource by this id exists.
Parameters:
  container - The container for this resource.
Parameters:
  id - The id. true if a Resource by this id exists, false if not.



close
public void close()(Code)
Close.



commitContainer
public void commitContainer(Edit edit)(Code)
Commit the changes and release the lock.
Parameters:
  user - The Edit to commit.



commitResource
public void commitResource(Entity container, Edit edit)(Code)
Commit the changes and release the lock.
Parameters:
  container - The container for this resource.
Parameters:
  user - The Edit to commit.



editContainer
public Edit editContainer(String ref)(Code)
Get a lock on the Container with this id, or null if a lock cannot be gotten.
Parameters:
  ref - The container reference. The locked Container with this id, or null if this cannot be locked.



editResource
public Edit editResource(Entity container, String id)(Code)
Get a lock on the Resource with this id, or null if a lock cannot be gotten.
Parameters:
  container - The container for this resource.
Parameters:
  id - The user id. The locked Resource with this id, or null if this records cannot be locked.



getAllContainers
public List getAllContainers()(Code)
Get all Containers. The list (Resource) of all Containers.



getAllResources
public List getAllResources(Entity container)(Code)
Get all Resources.
Parameters:
  container - The container for this resource. The list (Resource) of all Resources.



getContainer
public Entity getContainer(String ref)(Code)
Get the Container with this id, or null if not found.
Parameters:
  ref - The container reference. The Container with this id, or null if not found.



getContainerIdsMatching
public List getContainerIdsMatching(String root)(Code)
Access a list of container ids match (start with) the root.
Parameters:
  context - The id root to match. A List (String) of container id which match the root.



getResource
public Entity getResource(Entity container, String id)(Code)
Get the Resource with this id, or null if not found.
Parameters:
  container - The container for this resource.
Parameters:
  id - The id. The Resource with this id, or null if not found.



getResources
public List getResources(Entity container, Time afterDate, int limitedToLatest, String draftsForId, boolean pubViewOnly)(Code)
Get resources filtered by date and count and drafts, in descending (latest first) order
Parameters:
  afterDate - if null, no date limit, else limited to only messages after this date.
Parameters:
  limitedToLatest - if 0, no count limit, else limited to only the latest this number of messages.
Parameters:
  draftsForId - how to handle drafts: null means no drafts, "*" means all, otherwise drafts only if created by this userId.
Parameters:
  pubViewOnly - if true, include only messages marked pubview, else include any. A list of Message objects that meet the criteria; may be empty



insertFields
protected String insertFields(String before1, String before2, String[] fields, String after)(Code)
Form a string of (field, field, field), for sql insert statements, one for each item in the fields array, plus one before, and one after.
Parameters:
  before1 - The first field name.
Parameters:
  before2 - (options) second field name.
Parameters:
  values - The extra field names, in the middle.
Parameters:
  after - The last field name. A sql statement fragment for the insert fields.



open
public void open()(Code)
Open and be ready to read / write.



putContainer
public Edit putContainer(String ref)(Code)
Add a new Container with this id.
Parameters:
  ref - The container reference. The locked Container object with this id, or null if the id is in use.



putResource
public Edit putResource(Entity container, String id, Object[] others)(Code)
Add a new Resource with this id.
Parameters:
  container - The container for this resource.
Parameters:
  id - The id.
Parameters:
  others - Other fields for the newResource call The locked Resource object with this id, or null if the id is in use.



readContainer
protected Entity readContainer(String xml)(Code)
Read one Container Resource from xml
Parameters:
  xml - An string containing the xml which describes the Container resource. The Container Resource object created from the xml.



readResource
protected Entity readResource(Entity container, String xml)(Code)
Read one Resource from xml
Parameters:
  container - The container for this resource.
Parameters:
  xml - An string containing the xml which describes the resource. The Resource object created from the xml.



removeContainer
public void removeContainer(Edit edit)(Code)
Remove this (locked) Container.
Parameters:
  user - The Edit to remove.



removeResource
public void removeResource(Entity container, Edit edit)(Code)
Remove this (locked) Resource.
Parameters:
  container - The container for this resource.
Parameters:
  user - The Edit to remove.



updateSet
protected String updateSet(String[] fields)(Code)
Form a string of n name=?, for sql update set statements, one for each item in the values array, or an empty string if null.
Parameters:
  values - The values to be inserted into the sql statement. A sql statement fragment for the values part of an insert, one for each value in the array.



valuesParams
protected String valuesParams(String[] fields)(Code)
Form a string of n question marks with commas, for sql value statements, one for each item in the values array, or an empty string if null.
Parameters:
  values - The values to be inserted into the sql statement. A sql statement fragment for the values part of an insert, one for each value in the array.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.