1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
<?xml version="1.0" encoding="utf-8" ?>
<sqlMap>
<resultMap id="project-category-user" class="ProjectReport" GroupBy="ProjectID">
<result property="ProjectName" column="ProjectName" />
<result property="EstimateHours" column="ProjectEstimate" type="float"/>
<result property="EstimateCompletion" column="ProjectCompletion" type="DateTime" />
<result property="Categories" type="TList" resultMapping="category-user-report" />
</resultMap>
<resultMap id="category-user-report" class="CategoryReport" GroupBy="CategoryID" >
<result property="CategoryName" column="CategoryName" />
<result property="EstimateHours" column="CategoryEstimate" type="float" />
<result property="members" type="array" resultMapping="member-report" />
</resultMap>
<resultMap id="member-report" class="array">
<result property="username" column="Username" />
<result property="hours" column="ActualDuration" type="float" />
</resultMap>
<select id="GetTimeReportByProjectIDs" resultMap="project-category-user">
SELECT
categories.Name as CategoryName,
categories.CategoryID as CategoryID,
project.ProjectID as ProjectID,
categories.EstimateDuration as CategoryEstimate,
project.Name as ProjectName,
project.EstimateDuration as ProjectEstimate,
project.CompletionDate as ProjectCompletion,
time_entry.UserID as Username,
SUM(time_entry.Duration) as ActualDuration
FROM
project
LEFT JOIN categories ON categories.ProjectID = project.ProjectID
LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
WHERE
project.ProjectID IN ( $value$ )
GROUP BY
categories.ProjectID,
categories.CategoryID,
time_entry.UserID
ORDER BY
project.ProjectID
</select>
<resultMap id="time-entry-user-report" class="UserReport" GroupBy="Username">
<result property="Username" column="Username" />
<result property="Projects" resultMapping="project-user-report" />
</resultMap>
<resultMap id="project-user-report" class="UserProjectReport">
<result property="ProjectName" column="ProjectName" />
<result property="CategoryName" column="CategoryName" />
<result property="Duration" column="Duration" type="float" />
<result property="Description" column="Description" />
<result property="ReportDate" column="EntryDate" type="DateTime" />
</resultMap>
<select id="GetTimeReportByUsername" resultMap="time-entry-user-report">
SELECT
users.Username,
project.Name as ProjectName,
categories.Name as CategoryName,
time_entry.Duration,
time_entry.Description,
time_entry.EntryDate
FROM
users
LEFT JOIN time_entry ON time_entry.UserID = users.Username
AND time_entry.EntryDate BETWEEN
#startDate, typeHandler=DateTime# AND
#endDate, typeHandler=DateTime#
LEFT JOIN categories ON time_entry.CategoryID = categories.CategoryID
LEFT JOIN project ON categories.ProjectID = project.ProjectID
AND project.ProjectID in ($projects$)
WHERE
users.Username in ($members$)
ORDER BY
users.Username ASC,
time_entry.EntryDate ASC,
project.Name ASC,
categories.Name ASC
</select>
</sqlMap>
|