EMMA Coverage Report (generated Sun May 02 20:42:29 CEST 2010)
[all classes][hu.netmind.beankeeper.type.impl]

COVERAGE SUMMARY FOR SOURCE FILE [ListHandler.java]

nameclass, %method, %block, %line, %
ListHandler.java100% (1/1)100% (2/2)84%  (103/122)80%  (24.9/31)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ListHandler100% (1/1)100% (2/2)84%  (103/122)80%  (24.9/31)
ensureTableExists (ClassInfo, String, boolean): void 100% (1/1)83%  (90/109)77%  (19.9/26)
ListHandler (Class): void 100% (1/1)100% (13/13)100% (5/5)

1/**
2 * Copyright (C) 2007 NetMind Consulting Bt.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 3 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 */
18 
19package hu.netmind.beankeeper.type.impl;
20 
21import java.util.*;
22import hu.netmind.beankeeper.parser.*;
23import hu.netmind.beankeeper.common.StoreException;
24import hu.netmind.beankeeper.model.*;
25import hu.netmind.beankeeper.transaction.Transaction;
26import hu.netmind.beankeeper.transaction.TransactionTracker;
27import hu.netmind.beankeeper.db.Database;
28import hu.netmind.beankeeper.schema.SchemaManager;
29 
30/**
31 * List handler implementation.
32 * @author Brautigam Robert
33 * @version Revision: $Revision$
34 */
35public class ListHandler extends CollectionHandler
36{
37   private TransactionTracker transactionTracker = null; // Injected
38   private Database database = null; // Injected
39   private SchemaManager schemaManager = null; // Injected
40 
41   /**
42    * Constructor.
43    */
44   public ListHandler(Class collectionClass)
45   {
46      super(collectionClass);
47   }
48 
49   /**
50    * Create the subtable for the list.
51    */
52   public void ensureTableExists(ClassInfo parentInfo, String attributeName, boolean create)
53   {
54      Transaction tx = transactionTracker.getTransaction(TransactionTracker.TX_REQUIRED);
55      tx.begin();
56      try 
57      {
58         // Ensure map helper table
59         HashMap listAttributeTypes = new HashMap();
60         listAttributeTypes.put("persistence_id",Long.class);
61         listAttributeTypes.put("persistence_start",Long.class);
62         listAttributeTypes.put("persistence_end",Long.class);
63         listAttributeTypes.put("persistence_txstartid",Long.class);
64         listAttributeTypes.put("persistence_txstart",Long.class);
65         listAttributeTypes.put("persistence_txendid",Long.class);
66         listAttributeTypes.put("persistence_txend",Long.class);
67         listAttributeTypes.put("value",Long.class);
68         listAttributeTypes.put("container_index",Long.class);
69         ArrayList listKeys = new ArrayList();
70         listKeys.add("persistence_id");
71         listKeys.add("persistence_txstart");
72         listKeys.add("container_index");
73         database.ensureTable(
74               tx,schemaManager.getTableName(
75                  parentInfo.getAttributeClassEntry(attributeName),attributeName),
76               listAttributeTypes,listKeys,create);
77      } catch ( StoreException e ) {
78         tx.markRollbackOnly();
79         throw e;
80      } catch ( Throwable e ) {
81         tx.markRollbackOnly();
82         throw new StoreException("Unknown exception",e);
83      } finally {
84         tx.commit();
85      }
86   }
87 
88}
89 
90 

[all classes][hu.netmind.beankeeper.type.impl]
EMMA 2.0.5312debian (C) Vladimir Roubtsov