| 1 |
lars |
1 |
<?xml version="1.0" encoding="utf-8" ?>
|
|
|
2 |
<sqlMap>
|
|
|
3 |
|
|
|
4 |
<insert id="AddNewTimeEntry" parameterClass="TimeEntryRecord">
|
|
|
5 |
INSERT INTO time_entry(
|
|
|
6 |
EntryCreated,
|
|
|
7 |
Duration,
|
|
|
8 |
Description,
|
|
|
9 |
CategoryID,
|
|
|
10 |
EntryDate,
|
|
|
11 |
CreatorID,
|
|
|
12 |
UserID
|
|
|
13 |
)
|
|
|
14 |
VALUES(
|
|
|
15 |
NOW(),
|
|
|
16 |
#Duration#,
|
|
|
17 |
#Description#,
|
|
|
18 |
#Category.ID#,
|
|
|
19 |
#ReportDate, typeHandler=DateTime#,
|
|
|
20 |
#CreatorUserName#,
|
|
|
21 |
#Username#
|
|
|
22 |
)
|
|
|
23 |
<selectKey property="ID" type="post" resultClass="int">
|
|
|
24 |
select LAST_INSERT_ID() as value
|
|
|
25 |
</selectKey>
|
|
|
26 |
</insert>
|
|
|
27 |
|
|
|
28 |
<resultMap id="time-entry-result" class="TimeEntryRecord">
|
|
|
29 |
<result property="ID" column="EntryID" type="integer" />
|
|
|
30 |
<result property="DateCreated" column="EntryCreated" typeHandler="DateTime" />
|
|
|
31 |
<result property="Duration" column="Duration" type="float" />
|
|
|
32 |
<result property="Description" column="Description" />
|
|
|
33 |
<result property="Category" column="CategoryID" />
|
|
|
34 |
<result property="ReportDate" column="EntryDate" typeHandler="DateTime" />
|
|
|
35 |
<result property="CreatorUserName" column="CreatorID" />
|
|
|
36 |
<result property="Username" column="UserID" />
|
|
|
37 |
</resultMap>
|
|
|
38 |
|
|
|
39 |
<resultMap id="time-entry-category-result" class="TimeEntryRecord">
|
|
|
40 |
<result property="ID" column="EntryID" type="integer" />
|
|
|
41 |
<result property="DateCreated" column="EntryCreated" typeHandler="DateTime" />
|
|
|
42 |
<result property="Duration" column="Duration" type="float" />
|
|
|
43 |
<result property="Description" column="Description" />
|
|
|
44 |
<result property="Category" resultMapping="entry-category" />
|
|
|
45 |
<result property="ReportDate" column="EntryDate" typeHandler="DateTime" />
|
|
|
46 |
<result property="CreatorUserName" column="CreatorID" />
|
|
|
47 |
<result property="Username" column="UserID" />
|
|
|
48 |
</resultMap>
|
|
|
49 |
|
|
|
50 |
<resultMap id="entry-category" class="CategoryRecord">
|
|
|
51 |
<result property="ID" column="CategoryID" />
|
|
|
52 |
<result property="Name" column="CategoryName" />
|
|
|
53 |
</resultMap>
|
|
|
54 |
|
|
|
55 |
<select id="GetTimeEntryByID" resultMap="time-entry-result">
|
|
|
56 |
SELECT
|
|
|
57 |
*
|
|
|
58 |
FROM
|
|
|
59 |
time_entry
|
|
|
60 |
WHERE
|
|
|
61 |
EntryID = #value#
|
|
|
62 |
</select>
|
|
|
63 |
|
|
|
64 |
<delete id="DeleteTimeEntry" parameterClass="integer">
|
|
|
65 |
DELETE FROM time_entry WHERE EntryID = #value#
|
|
|
66 |
</delete>
|
|
|
67 |
|
|
|
68 |
<select id="GetAllTimeEntriesByProjectIdAndUser" resultMap="time-entry-category-result">
|
|
|
69 |
SELECT
|
|
|
70 |
time_entry.*,
|
|
|
71 |
categories.Name as CategoryName
|
|
|
72 |
FROM
|
|
|
73 |
time_entry, categories
|
|
|
74 |
WHERE
|
|
|
75 |
time_entry.UserID = #username#
|
|
|
76 |
AND time_entry.CategoryID = categories.CategoryID
|
|
|
77 |
AND categories.ProjectID = #project#
|
|
|
78 |
ORDER BY
|
|
|
79 |
EntryID ASC
|
|
|
80 |
</select>
|
|
|
81 |
|
|
|
82 |
<update id="UpdateTimeEntry" parameterClass="TimeEntryRecord">
|
|
|
83 |
UPDATE time_entry SET
|
|
|
84 |
Duration = #Duration#,
|
|
|
85 |
Description = #Description#,
|
|
|
86 |
CategoryID = #Category.ID#,
|
|
|
87 |
EntryDate = #ReportDate, typeHandler=DateTime#,
|
|
|
88 |
UserID = #Username#
|
|
|
89 |
WHERE
|
|
|
90 |
EntryID = #ID#
|
|
|
91 |
</update>
|
|
|
92 |
|
|
|
93 |
</sqlMap>
|