| 1 |
lars |
1 |
<?xml version="1.0" encoding="utf-8" ?>
|
|
|
2 |
<sqlMap>
|
|
|
3 |
|
|
|
4 |
<resultMap id="project-result" class="ProjectRecord">
|
|
|
5 |
<result property="ID" column="ProjectID" type="integer"/>
|
|
|
6 |
<result property="Name" column="Name" />
|
|
|
7 |
<result property="Description" column="Description" />
|
|
|
8 |
<result property="DateCreated" column="CreationDate" typeHandler="DateTime" />
|
|
|
9 |
<result property="EstimateDuration" column="EstimateDuration" type="float" />
|
|
|
10 |
<result property="CompletionDate" column="CompletionDate" typeHandler="DateTime" />
|
|
|
11 |
<result property="CreatorUserName" column="CreatorID" />
|
|
|
12 |
<result property="ManagerUserName" column="ManagerID" />
|
|
|
13 |
<result property="ActualDuration" column="ActualDuration" type="float" />
|
|
|
14 |
</resultMap>
|
|
|
15 |
|
|
|
16 |
<select id="ProjectNameExists" resultClass="boolean">
|
|
|
17 |
SELECT COUNT(Name) FROM projects WHERE Name = #value#
|
|
|
18 |
</select>
|
|
|
19 |
|
|
|
20 |
<insert id="CreateNewProject" parameterClass="ProjectRecord">
|
|
|
21 |
INSERT INTO projects
|
|
|
22 |
(Name, Description, CreationDate, EstimateDuration, CompletionDate, CreatorID, ManagerID)
|
|
|
23 |
VALUES
|
|
|
24 |
(#Name#, #Description#, strftime('%s', 'now'), #EstimateDuration#,
|
|
|
25 |
#CompletionDate, typeHandler=DateTime#,
|
|
|
26 |
#CreatorUserName#, #ManagerUserName#)
|
|
|
27 |
<selectKey property="ID" type="post" resultClass="int">
|
|
|
28 |
select LAST_INSERT_ROWID() as value
|
|
|
29 |
</selectKey>
|
|
|
30 |
</insert>
|
|
|
31 |
|
|
|
32 |
<select id="GetProjectByID" parameterClass="integer" resultMap="project-result">
|
|
|
33 |
SELECT
|
|
|
34 |
projects.ProjectID as ProjectID,
|
|
|
35 |
projects.Name as Name,
|
|
|
36 |
projects.Description as Description,
|
|
|
37 |
projects.CreationDate as CreationDate,
|
|
|
38 |
projects.EstimateDuration as EstimateDuration,
|
|
|
39 |
projects.CompletionDate as CompletionDate,
|
|
|
40 |
projects.CreatorID as CreatorID,
|
|
|
41 |
projects.ManagerID as ManagerID,
|
|
|
42 |
SUM(time_entry.Duration) as ActualDuration
|
|
|
43 |
FROM projects
|
|
|
44 |
LEFT JOIN categories ON projects.ProjectID = categories.ProjectID
|
|
|
45 |
LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
|
|
|
46 |
WHERE
|
|
|
47 |
projects.ProjectID = #value#
|
|
|
48 |
AND Disabled = 0
|
|
|
49 |
GROUP BY
|
|
|
50 |
projects.ProjectID
|
|
|
51 |
ORDER BY
|
|
|
52 |
projects.Name
|
|
|
53 |
</select>
|
|
|
54 |
|
|
|
55 |
<select id="GetAllProjects" resultMap="project-result">
|
|
|
56 |
SELECT
|
|
|
57 |
projects.ProjectID as ProjectID,
|
|
|
58 |
projects.Name as Name,
|
|
|
59 |
projects.Description as Description,
|
|
|
60 |
projects.CreationDate as CreationDate,
|
|
|
61 |
projects.EstimateDuration as EstimateDuration,
|
|
|
62 |
projects.CompletionDate as CompletionDate,
|
|
|
63 |
projects.CreatorID as CreatorID,
|
|
|
64 |
projects.ManagerID as ManagerID,
|
|
|
65 |
SUM(time_entry.Duration) as ActualDuration
|
|
|
66 |
FROM projects
|
|
|
67 |
LEFT JOIN categories ON projects.ProjectID = categories.ProjectID
|
|
|
68 |
LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
|
|
|
69 |
WHERE
|
|
|
70 |
Disabled = 0
|
|
|
71 |
GROUP BY
|
|
|
72 |
projects.ProjectID
|
|
|
73 |
ORDER BY
|
|
|
74 |
projects.ProjectID ASC
|
|
|
75 |
</select>
|
|
|
76 |
|
|
|
77 |
<select id="GetAllProjectsOrdered" resultMap="project-result" extends="GetAllProjects">
|
|
|
78 |
ORDER BY $sort$ $order$
|
|
|
79 |
</select>
|
|
|
80 |
|
|
|
81 |
<select id="GetProjectsByManagerName" resultMap="project-result">
|
|
|
82 |
SELECT
|
|
|
83 |
projects.ProjectID as ProjectID,
|
|
|
84 |
projects.Name as Name,
|
|
|
85 |
projects.Description as Description,
|
|
|
86 |
projects.CreationDate as CreationDate,
|
|
|
87 |
projects.EstimateDuration as EstimateDuration,
|
|
|
88 |
projects.CompletionDate as CompletionDate,
|
|
|
89 |
projects.CreatorID as CreatorID,
|
|
|
90 |
projects.ManagerID as ManagerID,
|
|
|
91 |
SUM(time_entry.Duration) as ActualDuration
|
|
|
92 |
FROM projects
|
|
|
93 |
LEFT JOIN categories ON projects.ProjectID = categories.ProjectID
|
|
|
94 |
LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
|
|
|
95 |
WHERE
|
|
|
96 |
Disabled = 0
|
|
|
97 |
AND projects.ManagerID = #value#
|
|
|
98 |
GROUP BY
|
|
|
99 |
projects.ProjectID
|
|
|
100 |
ORDER BY
|
|
|
101 |
projects.Name
|
|
|
102 |
</select>
|
|
|
103 |
|
|
|
104 |
<select id="GetProjectsByUserName" resultMap="project-result">
|
|
|
105 |
SELECT
|
|
|
106 |
projects.ProjectID as ProjectID,
|
|
|
107 |
projects.Name as Name,
|
|
|
108 |
projects.Description as Description,
|
|
|
109 |
projects.CreationDate as CreationDate,
|
|
|
110 |
projects.EstimateDuration as EstimateDuration,
|
|
|
111 |
projects.CompletionDate as CompletionDate,
|
|
|
112 |
projects.CreatorID as CreatorID,
|
|
|
113 |
projects.ManagerID as ManagerID,
|
|
|
114 |
SUM(time_entry.Duration) as ActualDuration
|
|
|
115 |
FROM projects
|
|
|
116 |
LEFT JOIN categories ON projects.ProjectID = categories.ProjectID
|
|
|
117 |
LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID,
|
|
|
118 |
project_members
|
|
|
119 |
WHERE
|
|
|
120 |
project_members.ProjectID = projects.ProjectID
|
|
|
121 |
AND project_members.UserID = #value#
|
|
|
122 |
AND projects.Disabled = 0
|
|
|
123 |
GROUP BY
|
|
|
124 |
projects.ProjectID
|
|
|
125 |
ORDER BY
|
|
|
126 |
projects.Name
|
|
|
127 |
</select>
|
|
|
128 |
|
|
|
129 |
<update id="DeleteProject" parameterClass="integer">
|
|
|
130 |
UPDATE projects SET Disabled = 1 WHERE ProjectID = #value#
|
|
|
131 |
</update>
|
|
|
132 |
|
|
|
133 |
<select id="GetProjectMembers" parameterClass="integer">
|
|
|
134 |
SELECT UserID FROM project_members WHERE ProjectID = #value#
|
|
|
135 |
ORDER BY UserID
|
|
|
136 |
</select>
|
|
|
137 |
|
|
|
138 |
<insert id="AddUserToProject" parameterClass="array">
|
|
|
139 |
INSERT INTO project_members (UserID, ProjectID)
|
|
|
140 |
VALUES(#username#, #project#)
|
|
|
141 |
</insert>
|
|
|
142 |
|
|
|
143 |
<delete id="RemoveUserFromProject" parameterClass="array">
|
|
|
144 |
DELETE FROM project_members WHERE ProjectID = #project# AND UserID = #username#
|
|
|
145 |
</delete>
|
|
|
146 |
|
|
|
147 |
<update id="UpdateProject" parameterClass="ProjectRecord">
|
|
|
148 |
UPDATE projects
|
|
|
149 |
SET
|
|
|
150 |
CompletionDate = #CompletionDate, typeHandler=DateTime#,
|
|
|
151 |
Description = #Description#,
|
|
|
152 |
EstimateDuration = #EstimateDuration#,
|
|
|
153 |
ManagerId =#ManagerUserName#,
|
|
|
154 |
Name = #Name#
|
|
|
155 |
WHERE
|
|
|
156 |
ProjectID = #ID#
|
|
|
157 |
</update>
|
|
|
158 |
|
|
|
159 |
</sqlMap>
|