EMMA Coverage Report (generated Fri Jan 30 13:20:29 EST 2009)
[all classes][org.springframework.batch.item.database]

COVERAGE SUMMARY FOR SOURCE FILE [IbatisDrivingQueryItemReader.java]

nameclass, %method, %block, %line, %
IbatisDrivingQueryItemReader.java100% (1/1)100% (4/4)100% (28/28)100% (9/9)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class IbatisDrivingQueryItemReader100% (1/1)100% (4/4)100% (28/28)100% (9/9)
IbatisDrivingQueryItemReader (): void 100% (1/1)100% (3/3)100% (1/1)
read (): Object 100% (1/1)100% (14/14)100% (4/4)
setDetailsQueryId (String): void 100% (1/1)100% (4/4)100% (2/2)
setSqlMapClient (SqlMapClient): void 100% (1/1)100% (7/7)100% (2/2)

1/*
2 * Copyright 2006-2007 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.springframework.batch.item.database;
17 
18import org.springframework.batch.item.database.support.IbatisKeyCollector;
19import org.springframework.orm.ibatis.SqlMapClientTemplate;
20 
21import com.ibatis.sqlmap.client.SqlMapClient;
22 
23/**
24 * Extension of {@link DrivingQueryItemReader} that maps keys to objects. An
25 * iBatis query id must be set to map and return each 'detail record'.
26 * 
27 * The writer is thread safe after its properties are set (normal singleton
28 * behaviour).
29 * 
30 * @author Lucas Ward
31 * @see IbatisKeyCollector
32 */
33public class IbatisDrivingQueryItemReader extends DrivingQueryItemReader {
34 
35        private String detailsQueryId;
36 
37        private SqlMapClientTemplate sqlMapClientTemplate;
38 
39        /**
40         * Overridden read() that uses the returned key as arguments to the details
41         * query.
42         * 
43         * @see org.springframework.batch.item.database.DrivingQueryItemReader#read()
44         */
45        public Object read() {
46                Object key = super.read();
47                if (key == null) {
48                        return null;
49                }
50                return sqlMapClientTemplate.queryForObject(detailsQueryId, key);
51        }
52 
53        /**
54         * @param detailsQueryId id of the iBATIS select statement that will used to
55         * retrieve an object for a single primary key from the list returned by
56         * driving query
57         */
58        public void setDetailsQueryId(String detailsQueryId) {
59                this.detailsQueryId = detailsQueryId;
60        }
61 
62        /**
63         * Set the {@link SqlMapClientTemplate} to use for this input source.
64         * 
65         * @param sqlMapClient
66         */
67        public void setSqlMapClient(SqlMapClient sqlMapClient) {
68                this.sqlMapClientTemplate = new SqlMapClientTemplate(sqlMapClient);
69        }
70}

[all classes][org.springframework.batch.item.database]
EMMA 2.0.5312 (C) Vladimir Roubtsov