com.wewebu.ow.server.util
Class OwStandardDBAttributeBagWriteableFactory

java.lang.Object
  extended by com.wewebu.ow.server.util.OwStandardDBAttributeBagWriteableFactory

public class OwStandardDBAttributeBagWriteableFactory
extends Object

Implements a factory for DB based writable attribute bags.
Retrieve a writable attribute bag with getBag(Name).
The factory has the advantage that all attribute bag data is loaded in one single SQL Query.
Uses the following attribute scheme to access the database e.g.:

(Number)User (String)Name (String)AttributeName (String)AttributeValue (String)
1OW_SITE_USERViewerSizeX100
2OW_SITE_USERViewerSizeY100
3UserNameSelectedClassAccount1
4UserNameSelectedClassCredit1
5UserNameSelectedClassDepot1

Alfresco Workdesk
Copyright (c) Alfresco Software, Inc.
All rights reserved.

For licensing information read the license.txt file or
go to: http://wiki.alfresco.com


Field Summary
static String ATTRIBUTE_ATTR_NAME
          DB attribute name of the attribute name
static String ATTRIBUTE_ATTR_VALUE
          DB attribute name of the attribute value
static String ATTRIBUTE_BAGNAME
          DB attribute name of the Name
static String ATTRIBUTE_INDEX
          DB attribute name of the User
static String ATTRIBUTE_USER
          DB attribute name of the User
static int LENGTH_LIMIT_ATTRIBUTE_NAME
          length limitation for the attribute name
static int LENGTH_LIMIT_ATTRIBUTE_VALUE
          length limitation for the attribute value
static int LENGTH_LIMIT_BAG_NAME
          length limitation for the bag name
static String SEQUENCE_NAME
          name of the oracle sequence
 
Constructor Summary
OwStandardDBAttributeBagWriteableFactory(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate_p, String strUser_p, String strTable_p)
          constructs the attribute bag with the given Database Use the following attribute scheme: [Index, User, Name, AttributeName, AttributeValue]
 
Method Summary
 int attributecount(String strBagName_p)
           
 void clear(String strBagName_p)
           
protected  com.wewebu.ow.server.util.OwStandardDBAttributeBagWriteableFactory.OwPreparedStatementCreator createStatementCreator()
          Create a class which is responsible for prepared statement creation, and also OwAttribute based SQL creation.
 Object getAttribute(int iIndex_p, String strBagName_p)
           
 Object getAttribute(String strName_p, String strBagName_p)
           
 Collection getAttributeNames(String strBagName_p)
           
 OwAttributeBagWriteable getBag(String sBagName_p)
          get a specific attribute bag
 Object getSafeAttribute(String strName_p, Object default_p, String strBagName_p)
          get the attribute with the given name, returns default if not found.
 boolean hasAttribute(String strName_p, String strBagName_p)
           
 void init()
          Load the tuples from the DB, transform them into a local objects representation and cache them.
protected  void initColumnLimit()
          (overridable) Initializing the limit of the columns, which will be used later before writing to data base.
 void remove(String strName_p, String strBagName_p)
           
 void save(String strBagName_p)
           
 void setAttribute(String strName_p, Object value_p, String sBagName_p)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTRIBUTE_INDEX

public static final String ATTRIBUTE_INDEX
DB attribute name of the User

See Also:
Constant Field Values

ATTRIBUTE_USER

public static final String ATTRIBUTE_USER
DB attribute name of the User

See Also:
Constant Field Values

ATTRIBUTE_BAGNAME

public static final String ATTRIBUTE_BAGNAME
DB attribute name of the Name

See Also:
Constant Field Values

ATTRIBUTE_ATTR_NAME

public static final String ATTRIBUTE_ATTR_NAME
DB attribute name of the attribute name

See Also:
Constant Field Values

ATTRIBUTE_ATTR_VALUE

public static final String ATTRIBUTE_ATTR_VALUE
DB attribute name of the attribute value

See Also:
Constant Field Values

SEQUENCE_NAME

public static final String SEQUENCE_NAME
name of the oracle sequence

See Also:
Constant Field Values

LENGTH_LIMIT_ATTRIBUTE_NAME

public static final int LENGTH_LIMIT_ATTRIBUTE_NAME
length limitation for the attribute name

See Also:
Constant Field Values

LENGTH_LIMIT_BAG_NAME

public static final int LENGTH_LIMIT_BAG_NAME
length limitation for the bag name

See Also:
Constant Field Values

LENGTH_LIMIT_ATTRIBUTE_VALUE

public static final int LENGTH_LIMIT_ATTRIBUTE_VALUE
length limitation for the attribute value

See Also:
Constant Field Values
Constructor Detail

OwStandardDBAttributeBagWriteableFactory

public OwStandardDBAttributeBagWriteableFactory(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate_p,
                                                String strUser_p,
                                                String strTable_p)
                                         throws OwDataSourceException
constructs the attribute bag with the given Database Use the following attribute scheme: [Index, User, Name, AttributeName, AttributeValue]

Parameters:
jdbcTemplate_p - The Spring JdbcTemplate to use for the database connectivity.
strUser_p - String optional user name to map the attribute bag to a specific user, can be null.
strTable_p - String table name
Throws:
OwDataSourceException
Method Detail

init

public void init()
          throws Exception
Load the tuples from the DB, transform them into a local objects representation and cache them.
Additional parts/caches of the class are initialized also here.

Throws:
Exception - if cannot retrieve information from DB

initColumnLimit

protected void initColumnLimit()
                        throws SQLException
(overridable) Initializing the limit of the columns, which will be used later before writing to data base.

Throws:
SQLException
Since:
3.1.0.3

setAttribute

public void setAttribute(String strName_p,
                         Object value_p,
                         String sBagName_p)
                  throws Exception
Throws:
Exception

save

public void save(String strBagName_p)
          throws Exception
Throws:
Exception

getAttribute

public Object getAttribute(int iIndex_p,
                           String strBagName_p)
                    throws Exception
Throws:
Exception

getAttribute

public Object getAttribute(String strName_p,
                           String strBagName_p)
                    throws Exception
Throws:
Exception

getSafeAttribute

public Object getSafeAttribute(String strName_p,
                               Object default_p,
                               String strBagName_p)
get the attribute with the given name, returns default if not found.


hasAttribute

public boolean hasAttribute(String strName_p,
                            String strBagName_p)

attributecount

public int attributecount(String strBagName_p)

getAttributeNames

public Collection getAttributeNames(String strBagName_p)

getBag

public OwAttributeBagWriteable getBag(String sBagName_p)
                               throws Exception
get a specific attribute bag

Parameters:
sBagName_p - String name that identifies the attribute bag
Returns:
OwStandardDBAttributeBagWriteable instance
Throws:
Exception

clear

public void clear(String strBagName_p)

remove

public void remove(String strName_p,
                   String strBagName_p)

createStatementCreator

protected com.wewebu.ow.server.util.OwStandardDBAttributeBagWriteableFactory.OwPreparedStatementCreator createStatementCreator()
Create a class which is responsible for prepared statement creation, and also OwAttribute based SQL creation.

Returns:
OwPreparedStatementCreator
Since:
3.1.0.3


Copyright © 2013 Alfresco Business Solutions. All Rights Reserved.