Changes between Version 5 and Version 6 of SERVER_DATABASE_PERSISTENCE


Ignore:
Timestamp:
02/19/10 15:09:07 (15 years ago)
Author:
meddle
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SERVER_DATABASE_PERSISTENCE

    v5 v6  
    8282     * commit() and rollback() methods for user made transactions that can be commited or rollbacked by the user, the use the ConnectionManager. 
    8383    * As you can see there are plenty of public methods some of which should be protected or private (the batch methods, the query and execute methods), They are public because the user may not be able to change the template but  wants to write qa query different from just insert/update one query or selllect one object or one list of objects, if you have oppinion on which of these methods should be private/protected, please write it in the review. 
    84    * Interface : SQLCallback<T> -> Represents a callback to the database using sql query. 
     84   * Interface : [browser:branches/private/tsachev/paragraphs/modules/org.sophie2.server.core/src/main/java/org/sophie2/server/core/persistence/db/jdbc/SQLCallback.java SQLCallback<T>] -> Represents a callback to the database using sql query. 
    8585     * Public methods: 
    8686      * {{{public T doSQL() throws SQLException}}} -> Executes a SQL query using the JDBC API, which can throw SQLException...  
     
    124124  === ResourceDAO === 
    125125  * DAOs (comes from Data Access Objects) are something like services that has simple methods for managing a database. They do contain only logic that keeps the data in database valid and logic for selecting of specified data. 
     126  * Our DAOs are ment to use the JDBCTemplate and the ConnectionManager to manage the database. 
     127  * There is only one DAO for now - ResourceDAO, in future there cаn be more, SecurityDAO for example... 
     128  * Class : [browser:branches/private/tsachev/paragraphs/modules/org.sophie2.server.core/src/main/java/org/sophie2/server/core/persistence/db/ResourceDAO.java ResourceDAO] -> Gives simple methods to persist/retrieve and edit resources, their keys and revisions (history). 
     129   * Keeps inner constants with the names of the queries stored in the queries.properties file in the server.core module. 
     130   * Uses the [browser:branches/private/tsachev/paragraphs/modules/org.sophie2.server.core/src/main/java/org/sophie2/server/core/persistence/db/SqlQueries.java SqlQueries] util to load the queries from the properties file. 
     131   * Can be constructed only with an instance of JDBCTemplate. So to use the DAO a developer needs to retrieve a JDBC DataSource to a database, construct from it JDBCTemplate and use the template to instantiate the DAO. 
     132   * Public methods: 
     133    * {{{public JdbcTemplate getJdbcTemplate()}}} -> Getter of the JDBCTemplate in the DAO. 
     134    * {{{public Long findResourceIdByPath(String resourcePath)}}} -> Finds the DB id of an resource by it's path on the server, for example "/resources/My Book.book.s2" is such path. With that id the resource can be edited, or viewed freely. 
     135    * {{{public Long createResource(final Long revisionId, DBResource resource)}}} -> Creates a resource in the database and flags it like 'alive'. Returns the DB id of the new resource. the DBResource POJO keeps the data of the new resource to be inserted. 
     136    * {{{public Long createRevision(DBRevision revision)}}} -> Creates a revision in the database, needed to be done before creating a resource for example,  
     137    * {{{public Long findOrCreateKey(String keyPath)}}} -> Retrieves the db id of a key, if the key does not exists creates a record for it in hte DB. Proper key paths are for example 'kind' or 'title'... 
     138    * {{{public void changeKeys(final Long revisionId, final Set<DBKeyChange> changes)}}} -> Changes specified key values in the DB, and for that change new revision for the resource owning the keys is  created. The revisions are global for now, so every revision changes the main resources directory. Only the sub resources that have changed keys are taken in mind retrieving the changes for the revision though... 
     139    * {{{public void readKeys(Long revisionId, List<Key<?>> reads)}}} -> Registers reads for specified keys at a given revision. 
     140    * {{{public void readKeys(Long revisionId, List<Key<?>> reads)}}} and {{{public Map<Key<?>, Long> getRevisionCausingWrites(String resourcePath, String revisionId)}}} -> Used to retrieve the changed and readed keys causing a specified revision. Used for the skip algorithm. 
     141    * {{{public Map<Key<?>, Long> getRevisionModel(String resourcePath, String revisionId)}}} -> Gets a model skeleton for a given revision of a given resource, this skeleton is usefull for building a lazy DB ResourceModel. {{{public String getValueForKey(Long valueId)}}} is used with the value ids in the result map corresponding to keys. 
     142    * {{{public String findRevisionNotAfter(String revisionId)}}} -> Finds the revision id of the revision which is the passed one, or if the passed one does not exist, the last existing one before it. Can be used with the FUTURE revision id to find the current revision on the server. 
     143    * {{{public String findValue(String resourcePath, String keyPath, String revisionId)}}} -> Finds a value of a key of specified resource at specified revision. 
     144    * {{{public String getPreviousRevision(String revId, String prefix)}}} -> Retrieves the previous revision of a resource with specified revision. 
     145    * {{{public SortedMap<String, String> findHistory(String resourcePath, String from, String to, Integer offset, Integer limit)}}} -> Retrieves a history for a resource (specified by its path) in the form of map containing revision ids as keys and the causing changes of the revisions for that ids (persisted to strings) as values. 
     146    * {{{public List<String> findChildResources(String resourcePath)}}} -> Retrieves the value of the ChildrenKey. 
     147    * {{{public List<String> findResourceKeys(String resourcePath)}}} Finds the names of all the modified keys for a resource. 
     148    * All these methods are created because of the needs of the resource model logic, like retrieving history, model at revision, skiping, changing and reading keys... 
     149   * Objects used to contain data for the ResourceDAO 
     150    * [browser:branches/private/tsachev/paragraphs/modules/org.sophie2.server.core/src/main/java/org/sophie2/server/core/persistence/db/params/DBKeyChange.java DBKeyChange] -> Contains a value for a key of a given resource, constructed by the DB ids of the key and the resource and the value as a IO Reader. The JDBC API persists streams... 
     151    * [browser:branches/private/tsachev/paragraphs/modules/org.sophie2.server.core/src/main/java/org/sophie2/server/core/persistence/db/params/DBResource.java DBResource] -> contains a name ofor a new resource and its parent resource DB id. 
     152    * [browser:branches/private/tsachev/paragraphs/modules/org.sophie2.server.core/src/main/java/org/sophie2/server/core/persistence/db/params/DBRevision.java DBRevision] -> contains a revision id for a new revision and it's causing change stored to a IO Reader. 
    126153 
    127154= Implementation =