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