Java Doc for BaseDbSingleStorage.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.BaseDbSingleStorage

BaseDbSingleStorage
public class BaseDbSingleStorage (Code)

BaseDbSingleStorage 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
- a resource's reference is based on no more than the resource id
- a resource's 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
protected  booleanm_caseInsensitive
     If set, we treat reasource ids as case insensitive.
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_resourceTableIdField
     The field in the resource table that holds the resource id.
protected  Stringm_resourceTableName
     Table name for resource records.
protected  String[]m_resourceTableOtherFields
    
protected  SqlServicem_sql
     Injected (by constructor) SqlService.
protected  StorageUserm_user
     The StorageUser to callback for new Resource and Edit objects.

Constructor Summary
public  BaseDbSingleStorage(String resourceTableName, String resourceTableIdField, String[] resourceTableOtherFields, boolean locksInDb, String resourceEntryName, StorageUser user, SqlService sqlService)
     Construct.

Method Summary
public  voidcancelResource(Edit edit)
     Cancel the changes and release the lock.
protected  StringcaseId(String id)
     Fix the case of resource ids to support case insensitive ids if enabled
Parameters:
  The - id to fix.
public  booleancheckResource(String id)
     Check if a Resource by this id exists.
Parameters:
  id - The id.
public  voidclose()
     Close.
public  voidcommitDeleteResource(Edit edit, String uuid)
    
public  voidcommitResource(Edit edit)
     Commit the changes and release the lock.
public  intcountAllResources()
    
public  intcountSelectedResourcesWhere(String sqlWhere)
    
public  EditeditResource(String id)
     Get a lock on the Resource with this id, or null if a lock cannot be gotten.
Parameters:
  id - The user id.
public  ListgetAllResources()
    
public  ListgetAllResources(int first, int last)
    
public  ListgetAllResourcesWhere(String field, String value)
     Get all Resources where the given field matches the given value.
Parameters:
  field - The db field name for the selection.
Parameters:
  value - The value to select.
public  ListgetAllResourcesWhereLike(String field, String value)
    
public  EntitygetResource(String id)
     Get the Resource with this id, or null if not found.
Parameters:
  id - The id.
public  ListgetSelectedResources(Filter filter)
     Get selected Resources, filtered by a test on the id field
Parameters:
  filter - A filter to select what gets returned.
public  ListgetSelectedResourcesWhere(String sqlWhere)
     Get selected Resources, using a supplied where clause
Parameters:
  sqlWhere - The SQL where clause.
protected  StringinsertDeleteFields(String before, String[] fields, String uuid, String date, String userId, String after)
    
protected  StringinsertFields(String before, 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:
  before - The first field name.
Parameters:
  values - The extra field names, in the middle.
Parameters:
  after - The last field name.
public  booleanisEmpty()
    
protected  ListloadResources(String sql, Object[] fields)
    
public  voidopen()
     Open and be ready to read / write.
public  EditputDeleteResource(String id, String uuid, String userId, Object[] others)
    
public  EditputResource(String id, Object[] others)
     Add a new Resource with this id.
protected  EntityreadResource(String xml)
     Read one Resource from xml
Parameters:
  xml - An string containing the xml which describes the resource.
public  voidremoveResource(Edit edit)
     Remove this (locked) Resource.
protected  voidsetCaseInsensitivity(boolean setting)
     Enable / disable case insensitive ids.
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_caseInsensitive
protected boolean m_caseInsensitive(Code)
If set, we treat reasource ids as case insensitive.



m_locks
protected Hashtable m_locks(Code)
Locks, keyed by reference, holding Connections (or, if locks are done locally, holding an Edit).



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_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_resourceTableOtherFields
protected String[] m_resourceTableOtherFields(Code)
The additional field names in the resource table that go between the two ids and the xml



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
BaseDbSingleStorage
public BaseDbSingleStorage(String resourceTableName, String resourceTableIdField, String[] resourceTableOtherFields, boolean locksInDb, String resourceEntryName, StorageUser user, SqlService sqlService)(Code)
Construct.
Parameters:
  resourceTableName - Table name for resources.
Parameters:
  resourceTableIdField - The field in the resource table that holds the id.
Parameters:
  resourceTableOtherFields - The other fields in the resource table (between the two id and the xml fields).
Parameters:
  locksInDb - If true, we do our locks in the remote database, otherwise we do them here.
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
cancelResource
public void cancelResource(Edit edit)(Code)
Cancel the changes and release the lock.
Parameters:
  user - The Edit to cancel.



caseId
protected String caseId(String id)(Code)
Fix the case of resource ids to support case insensitive ids if enabled
Parameters:
  The - id to fix. The id, case modified as needed.



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



close
public void close()(Code)
Close.



commitDeleteResource
public void commitDeleteResource(Edit edit, String uuid)(Code)
update XML attribute on properties and remove locks



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



countAllResources
public int countAllResources()(Code)



countSelectedResourcesWhere
public int countSelectedResourcesWhere(String sqlWhere)(Code)



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



getAllResources
public List getAllResources()(Code)



getAllResources
public List getAllResources(int first, int last)(Code)



getAllResourcesWhere
public List getAllResourcesWhere(String field, String value)(Code)
Get all Resources where the given field matches the given value.
Parameters:
  field - The db field name for the selection.
Parameters:
  value - The value to select. The list of all Resources that meet the criteria.



getAllResourcesWhereLike
public List getAllResourcesWhereLike(String field, String value)(Code)



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



getSelectedResources
public List getSelectedResources(Filter filter)(Code)
Get selected Resources, filtered by a test on the id field
Parameters:
  filter - A filter to select what gets returned. The list of selected Resources.



getSelectedResourcesWhere
public List getSelectedResourcesWhere(String sqlWhere)(Code)
Get selected Resources, using a supplied where clause
Parameters:
  sqlWhere - The SQL where clause. The list of selected Resources.



insertDeleteFields
protected String insertDeleteFields(String before, String[] fields, String uuid, String date, String userId, String after)(Code)
Construct the SQL statement



insertFields
protected String insertFields(String before, 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:
  before - The first 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.



isEmpty
public boolean isEmpty()(Code)



loadResources
protected List loadResources(String sql, Object[] fields)(Code)



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



putDeleteResource
public Edit putDeleteResource(String id, String uuid, String userId, Object[] others)(Code)
store the record in content_resource_delete table along with resource_uuid and date



putResource
public Edit putResource(String id, Object[] others)(Code)
Add a new Resource with this id.
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.



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



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



setCaseInsensitivity
protected void setCaseInsensitivity(boolean setting)(Code)
Enable / disable case insensitive ids.
Parameters:
  setting - true to set case insensitivity, false to set case sensitivity.



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.