EMMA Coverage Report (generated Thu Jan 24 13:37:04 CST 2013)
[all classes][org.springframework.batch.core.explore.support]

COVERAGE SUMMARY FOR SOURCE FILE [SimpleJobExplorer.java]

nameclass, %method, %block, %line, %
SimpleJobExplorer.java100% (1/1)91%  (10/11)93%  (174/187)90%  (41.6/46)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SimpleJobExplorer100% (1/1)91%  (10/11)93%  (174/187)90%  (41.6/46)
SimpleJobExplorer (): void 0%   (0/1)0%   (0/3)0%   (0/2)
getJobExecution (Long): JobExecution 100% (1/1)70%  (23/33)73%  (6.6/9)
SimpleJobExplorer (JobInstanceDao, JobExecutionDao, StepExecutionDao, Executi... 100% (1/1)100% (15/15)100% (6/6)
findRunningJobExecutions (String): Set 100% (1/1)100% (36/36)100% (6/6)
getJobExecutionDependencies (JobExecution): void 100% (1/1)100% (19/19)100% (5/5)
getJobExecutions (JobInstance): List 100% (1/1)100% (36/36)100% (6/6)
getJobInstance (Long): JobInstance 100% (1/1)100% (5/5)100% (1/1)
getJobInstances (String, int, int): List 100% (1/1)100% (7/7)100% (1/1)
getJobNames (): List 100% (1/1)100% (4/4)100% (1/1)
getStepExecution (Long, Long): StepExecution 100% (1/1)100% (20/20)100% (6/6)
getStepExecutionDependencies (StepExecution): void 100% (1/1)100% (9/9)100% (3/3)

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 */
16 
17package org.springframework.batch.core.explore.support;
18 
19import java.util.List;
20import java.util.Set;
21 
22import org.springframework.batch.core.JobExecution;
23import org.springframework.batch.core.JobInstance;
24import org.springframework.batch.core.StepExecution;
25import org.springframework.batch.core.explore.JobExplorer;
26import org.springframework.batch.core.repository.dao.ExecutionContextDao;
27import org.springframework.batch.core.repository.dao.JobExecutionDao;
28import org.springframework.batch.core.repository.dao.JobInstanceDao;
29import org.springframework.batch.core.repository.dao.StepExecutionDao;
30 
31/**
32 * Implementation of {@link JobExplorer} using the injected DAOs.
33 * 
34 * @author Dave Syer
35 * @author Lucas Ward
36 * 
37 * @see JobExplorer
38 * @see JobInstanceDao
39 * @see JobExecutionDao
40 * @see StepExecutionDao
41 * @since 2.0
42 */
43public class SimpleJobExplorer implements JobExplorer {
44 
45        private JobInstanceDao jobInstanceDao;
46 
47        private JobExecutionDao jobExecutionDao;
48 
49        private StepExecutionDao stepExecutionDao;
50 
51        private ExecutionContextDao ecDao;
52 
53        /**
54         * Provide default constructor with low visibility in case user wants to use
55         * use aop:proxy-target-class="true" for AOP interceptor.
56         */
57        SimpleJobExplorer() {
58        }
59 
60        public SimpleJobExplorer(JobInstanceDao jobInstanceDao, JobExecutionDao jobExecutionDao,
61                        StepExecutionDao stepExecutionDao, ExecutionContextDao ecDao) {
62                super();
63                this.jobInstanceDao = jobInstanceDao;
64                this.jobExecutionDao = jobExecutionDao;
65                this.stepExecutionDao = stepExecutionDao;
66                this.ecDao = ecDao;
67        }
68 
69        /*
70         * (non-Javadoc)
71         * 
72         * @see
73         * org.springframework.batch.core.explore.JobExplorer#findJobExecutions(
74         * org.springframework.batch.core.JobInstance)
75         */
76        public List<JobExecution> getJobExecutions(JobInstance jobInstance) {
77                List<JobExecution> executions = jobExecutionDao.findJobExecutions(jobInstance);
78                for (JobExecution jobExecution : executions) {
79                        getJobExecutionDependencies(jobExecution);
80                        for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
81                                getStepExecutionDependencies(stepExecution);
82                        }
83                }
84                return executions;
85        }
86 
87        /*
88         * (non-Javadoc)
89         * 
90         * @see
91         * org.springframework.batch.core.explore.JobExplorer#findRunningJobExecutions
92         * (java.lang.String)
93         */
94        public Set<JobExecution> findRunningJobExecutions(String jobName) {
95                Set<JobExecution> executions = jobExecutionDao.findRunningJobExecutions(jobName);
96                for (JobExecution jobExecution : executions) {
97                        getJobExecutionDependencies(jobExecution);
98                        for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
99                                getStepExecutionDependencies(stepExecution);
100                        }
101                }
102                return executions;
103        }
104 
105        /*
106         * (non-Javadoc)
107         * 
108         * @see
109         * org.springframework.batch.core.explore.JobExplorer#getJobExecution(java
110         * .lang.Long)
111         */
112        public JobExecution getJobExecution(Long executionId) {
113                if (executionId == null) {
114                        return null;
115                }
116                JobExecution jobExecution = jobExecutionDao.getJobExecution(executionId);
117                if (jobExecution == null) {
118                        return null;
119                }
120                getJobExecutionDependencies(jobExecution);
121                for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
122                        getStepExecutionDependencies(stepExecution);
123                }
124                return jobExecution;
125        }
126 
127        /*
128         * (non-Javadoc)
129         * 
130         * @see
131         * org.springframework.batch.core.explore.JobExplorer#getStepExecution(java
132         * .lang.Long)
133         */
134        public StepExecution getStepExecution(Long jobExecutionId, Long executionId) {
135                JobExecution jobExecution = jobExecutionDao.getJobExecution(jobExecutionId);
136                if (jobExecution == null) {
137                        return null;
138                }
139                StepExecution stepExecution = stepExecutionDao.getStepExecution(jobExecution, executionId);
140                getStepExecutionDependencies(stepExecution);
141                return stepExecution;
142        }
143 
144        /*
145         * (non-Javadoc)
146         * 
147         * @see
148         * org.springframework.batch.core.explore.JobExplorer#getJobInstance(java
149         * .lang.Long)
150         */
151        public JobInstance getJobInstance(Long instanceId) {
152                return jobInstanceDao.getJobInstance(instanceId);
153        }
154 
155        /*
156         * (non-Javadoc)
157         * 
158         * @see
159         * org.springframework.batch.core.explore.JobExplorer#getLastJobInstances
160         * (java.lang.String, int)
161         */
162        public List<JobInstance> getJobInstances(String jobName, int start, int count) {
163                return jobInstanceDao.getJobInstances(jobName, start, count);
164        }
165 
166        /*
167         * (non-Javadoc)
168         * 
169         * @see org.springframework.batch.core.explore.JobExplorer#getJobNames()
170         */
171        public List<String> getJobNames() {
172                return jobInstanceDao.getJobNames();
173        }
174 
175        /*
176         * Find all dependencies for a JobExecution, including JobInstance (which
177         * requires JobParameters) plus StepExecutions
178         */
179        private void getJobExecutionDependencies(JobExecution jobExecution) {
180 
181                JobInstance jobInstance = jobInstanceDao.getJobInstance(jobExecution);
182                stepExecutionDao.addStepExecutions(jobExecution);
183                jobExecution.setJobInstance(jobInstance);
184                jobExecution.setExecutionContext(ecDao.getExecutionContext(jobExecution));
185 
186        }
187 
188        private void getStepExecutionDependencies(StepExecution stepExecution) {
189                if (stepExecution != null) {
190                        stepExecution.setExecutionContext(ecDao.getExecutionContext(stepExecution));
191                }
192        }
193 
194}

[all classes][org.springframework.batch.core.explore.support]
EMMA 2.0.5312 (C) Vladimir Roubtsov