Clover.NET coverage report - Coverage for s2dao.net

Coverage timestamp: 2006年5月30日 11:48:56

File Stats: LOC: 114   Methods: 3
NCLOC: 91 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Seasar.Dao.Impl\BeanListMetaDataDataReaderHandler.cs 63.6% 82.6% 100.0% 77.5%
coverage coverage
1   #region Copyright
2   /*
3   * Copyright 2005 the Seasar Foundation and the Others.
4   *
5   * Licensed under the Apache License, Version 2.0 (the "License");
6   * you may not use this file except in compliance with the License.
7   * You may obtain a copy of the License at
8   *
9   * http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14   * either express or implied. See the License for the specific language
15   * governing permissions and limitations under the License.
16   */
17   #endregion
18  
19   using System;
20   using System.Collections;
21   using System.Data;
22   using System.Reflection;
23   using Seasar.Extension.ADO;
24  
25   namespace Seasar.Dao.Impl
26   {
27   public class BeanListMetaDataDataReaderHandler
28   : AbstractBeanMetaDataDataReaderHandler
29   {
30 36 public BeanListMetaDataDataReaderHandler(IBeanMetaData beanMetaData)
31   : base(beanMetaData)
32   {
33   }
34  
35 6 public override object Handle(IDataReader dataReader)
36   {
37 6 IList columnNames = CreateColumnNames(dataReader.GetSchemaTable());
38 6 ArrayList list = new ArrayList();
39 6 int relSize = BeanMetaData.RelationPropertyTypeSize;
40 6 RelationRowCache relRowCache = new RelationRowCache(relSize);
41 60 while(dataReader.Read())
42   {
43 54 object row = CreateRow(dataReader, columnNames);
44 92 for(int i = 0; i < relSize; ++i)
45   {
46 38 IRelationPropertyType rpt = BeanMetaData.GetRelationPropertyType(i);
47 0 if(rpt == null) continue;
48  
49 38 object relRow = null;
50 38 Hashtable relKeyValues = new Hashtable();
51 38 RelationKey relKey = CreateRelationKey(dataReader, rpt, columnNames,
52   relKeyValues);
53 38 if(relKey != null)
54   {
55 38 relRow = relRowCache.GetRelationRow(i, relKey);
56 38 if(relRow == null)
57   {
58 8 relRow = CreateRelationRow(dataReader, rpt, columnNames,
59   relKeyValues);
60 8 relRowCache.AddRelationRow(i, relKey, relRow);
61   }
62   }
63 38 if(relRow != null)
64   {
65 38 PropertyInfo pi = rpt.PropertyInfo;
66 38 pi.SetValue(row, relRow, null);
67   }
68   }
69 54 list.Add(row);
70   }
71 6 return list;
72   }
73  
74 38 protected RelationKey CreateRelationKey(IDataReader reader,
75   IRelationPropertyType rpt, IList columnNames, Hashtable relKeyValues)
76   {
77 38 ArrayList keyList = new ArrayList();
78 38 IBeanMetaData bmd = rpt.BeanMetaData;
79 76 for(int i = 0; i < rpt.KeySize; ++i)
80   {
81 38 IValueType valueType = null;
82 38 string columnName = rpt.GetMyKey(i);
83 38 IPropertyType pt;
84 38 if(columnNames.Contains(columnName))
85   {
86 38 pt = BeanMetaData.GetPropertyTypeByColumnName(columnName);
87 38 valueType = pt.ValueType;
88   }
89   else
90   {
91 0 pt = bmd.GetPropertyTypeByColumnName(rpt.GetYourKey(i));
92 0 columnName = pt.ColumnName + "_" + rpt.RelationNo;
93 0 if(columnNames.Contains(columnName))
94   valueType = pt.ValueType;
95   else
96   return null;
97   }
98 38 object value = valueType.GetValue(reader, columnName);
99 0 if(value == null) return null;
100  
101 38 relKeyValues[columnName] = value;
102 38 keyList.Add(value);
103   }
104 38 if(keyList.Count > 0)
105   {
106 38 object[] keys = keyList.ToArray();
107 38 return new RelationKey(keys);
108   }
109 0 else return null;
110   }
111  
112   }
113   }
114