| 1 |
lars |
1 |
<?xml version="1.0" encoding="utf-8" ?>
|
|
|
2 |
<sqlMap>
|
|
|
3 |
|
|
|
4 |
<resultMap id="category-result" class="CategoryRecord">
|
|
|
5 |
<result property="Name" column="Name" />
|
|
|
6 |
<result property="EstimateDuration" column="EstimateDuration" type="float" />
|
|
|
7 |
<result property="ProjectID" column="ProjectID" type="integer" />
|
|
|
8 |
<result property="Abbreviation" column="Abbreviation" />
|
|
|
9 |
<result property="ID" column="CategoryID" type="integer" />
|
|
|
10 |
<result property="ActualDuration" column="ActualDuration" type="float" />
|
|
|
11 |
</resultMap>
|
|
|
12 |
|
|
|
13 |
<insert id="AddNewCategory" parameterClass="CategoryRecord">
|
|
|
14 |
INSERT INTO categories
|
|
|
15 |
(Name, ProjectID, Abbreviation, EstimateDuration)
|
|
|
16 |
VALUES(#Name#, #ProjectID#, #Abbreviation#, #EstimateDuration#)
|
|
|
17 |
<selectKey property="ID" type="post" resultClass="int">
|
|
|
18 |
select LAST_INSERT_ID() as value
|
|
|
19 |
</selectKey>
|
|
|
20 |
</insert>
|
|
|
21 |
|
|
|
22 |
<select id="GetCategoryByID" parameterClass="integer" resultMap="category-result">
|
|
|
23 |
SELECT
|
|
|
24 |
categories.*,
|
|
|
25 |
sum(time_entry.Duration) as ActualDuration
|
|
|
26 |
FROM
|
|
|
27 |
categories
|
|
|
28 |
LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
|
|
|
29 |
WHERE
|
|
|
30 |
categories.CategoryID = #value#
|
|
|
31 |
GROUP BY
|
|
|
32 |
categories.CategoryID
|
|
|
33 |
ORDER BY
|
|
|
34 |
categories.Name
|
|
|
35 |
</select>
|
|
|
36 |
|
|
|
37 |
<select id="GetAllCategories" resultMap="category-result">
|
|
|
38 |
SELECT
|
|
|
39 |
categories.*,
|
|
|
40 |
sum(time_entry.Duration) as ActualDuration
|
|
|
41 |
FROM
|
|
|
42 |
categories
|
|
|
43 |
LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
|
|
|
44 |
GROUP BY
|
|
|
45 |
categories.CategoryID
|
|
|
46 |
ORDER BY
|
|
|
47 |
categories.Name
|
|
|
48 |
</select>
|
|
|
49 |
|
|
|
50 |
<delete id="DeleteCategory" parameterClass="integer">
|
|
|
51 |
DELETE FROM categories WHERE CategoryID = #value#
|
|
|
52 |
</delete>
|
|
|
53 |
|
|
|
54 |
<select id="GetCategoriesByProjectID" resultMap="category-result">
|
|
|
55 |
SELECT
|
|
|
56 |
categories.*,
|
|
|
57 |
sum(time_entry.Duration) as ActualDuration
|
|
|
58 |
FROM
|
|
|
59 |
categories
|
|
|
60 |
LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
|
|
|
61 |
WHERE
|
|
|
62 |
categories.ProjectID = #value#
|
|
|
63 |
GROUP BY
|
|
|
64 |
categories.CategoryID
|
|
|
65 |
ORDER BY
|
|
|
66 |
categories.Name
|
|
|
67 |
</select>
|
|
|
68 |
|
|
|
69 |
<select id="GetCategoryByNameInProject" parameterClass="array" resultMap="category-result">
|
|
|
70 |
SELECT
|
|
|
71 |
categories.*,
|
|
|
72 |
sum(time_entry.Duration) as ActualDuration
|
|
|
73 |
FROM
|
|
|
74 |
categories
|
|
|
75 |
LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
|
|
|
76 |
WHERE
|
|
|
77 |
categories.ProjectID = #project#
|
|
|
78 |
AND categories.Name = #category#
|
|
|
79 |
GROUP BY
|
|
|
80 |
categories.CategoryID
|
|
|
81 |
</select>
|
|
|
82 |
|
|
|
83 |
<update id="UpdateCategory" parameterClass="CategoryRecord">
|
|
|
84 |
UPDATE categories SET
|
|
|
85 |
Abbreviation = #Abbreviation#,
|
|
|
86 |
EstimateDuration = #EstimateDuration#,
|
|
|
87 |
Name = #Name#,
|
|
|
88 |
ProjectId = #ProjectID#
|
|
|
89 |
WHERE
|
|
|
90 |
CategoryID = #ID#
|
|
|
91 |
</update>
|
|
|
92 |
|
|
|
93 |
</sqlMap>
|