diff options
author | wei <> | 2006-07-18 23:41:18 +0000 |
---|---|---|
committer | wei <> | 2006-07-18 23:41:18 +0000 |
commit | 63e66acd2ed45300d095d5428ebdfff7652070ea (patch) | |
tree | 12822afc580f479bdb6ff4b451d6824fac1286fc /demos/time-tracker/protected/App_Data/mysql-maps/projects.xml | |
parent | 2fbc53d1f5d9e0a000717642d02558453bc610a8 (diff) |
Add mappings for time-tracker
Diffstat (limited to 'demos/time-tracker/protected/App_Data/mysql-maps/projects.xml')
-rw-r--r-- | demos/time-tracker/protected/App_Data/mysql-maps/projects.xml | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/demos/time-tracker/protected/App_Data/mysql-maps/projects.xml b/demos/time-tracker/protected/App_Data/mysql-maps/projects.xml new file mode 100644 index 00000000..8fa28b64 --- /dev/null +++ b/demos/time-tracker/protected/App_Data/mysql-maps/projects.xml @@ -0,0 +1,154 @@ +<?xml version="1.0" encoding="utf-8" ?>
+<sqlMap>
+
+<resultMap ID="project-result" class="Project">
+ <result property="ID" column="ProjectID" type="integer"/>
+ <result property="Name" column="Name" />
+ <result property="Description" column="Description" />
+ <result property="DateCreated" column="CreationDate" typeHandler="DateTime" />
+ <result property="EstimateDuration" column="EstimateDuration" type="float" />
+ <result property="CompletionDate" column="CompletionDate" typeHandler="DateTime" />
+ <result property="CreatorUserName" column="CreatorID" />
+ <result property="ManagerUserName" column="ManagerID" />
+ <result property="ActualDuration" column="ActualDuration" type="float" />
+</resultMap>
+
+<select ID="ProjectNameExists" resultClass="boolean">
+ SELECT COUNT(Name) FROM project WHERE Name = #value#
+</select>
+
+<insert ID="CreateNewProject" parameterClass="Project">
+ INSERT INTO project
+ (Name, Description, CreationDate, EstimateDuration, CompletionDate, CreatorID, ManagerID)
+ VALUES
+ (#Name#, #Description#, NOW(), #EstimateDuration#,
+ #CompletionDate, typeHandler=DateTime#,
+ #CreatorUserName#, #ManagerUserName#)
+ <selectKey property="ID" type="post" resultClass="int">
+ select LAST_INSERT_ID() as value
+ </selectKey>
+</insert>
+
+<select ID="GetProjectByID" parameterClass="integer" resultMap="project-result">
+ SELECT
+ project.ProjectID as ProjectID,
+ project.Name as Name,
+ project.Description as Description,
+ project.CreationDate as CreationDate,
+ project.EstimateDuration as EstimateDuration,
+ project.CompletionDate as CompletionDate,
+ project.CreatorID as CreatorID,
+ project.ManagerID as ManagerID,
+ SUM(time_entry.Duration) as ActualDuration
+ FROM project
+ LEFT JOIN categories ON project.ProjectID = categories.ProjectID
+ LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
+ WHERE
+ project.ProjectID = #value#
+ AND Disabled = 0
+ GROUP BY
+ project.ProjectID
+ ORDER BY
+ project.Name
+</select>
+
+<select ID="GetAllProjects" resultMap="project-result">
+ SELECT
+ project.ProjectID as ProjectID,
+ project.Name as Name,
+ project.Description as Description,
+ project.CreationDate as CreationDate,
+ project.EstimateDuration as EstimateDuration,
+ project.CompletionDate as CompletionDate,
+ project.CreatorID as CreatorID,
+ project.ManagerID as ManagerID,
+ SUM(time_entry.Duration) as ActualDuration
+ FROM project
+ LEFT JOIN categories ON project.ProjectID = categories.ProjectID
+ LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
+ WHERE
+ Disabled = 0
+ GROUP BY
+ project.ProjectID
+ ORDER BY
+ project.Name
+</select>
+
+<select ID="GetProjectsByManagerName" resultMap="project-result">
+ SELECT
+ project.ProjectID as ProjectID,
+ project.Name as Name,
+ project.Description as Description,
+ project.CreationDate as CreationDate,
+ project.EstimateDuration as EstimateDuration,
+ project.CompletionDate as CompletionDate,
+ project.CreatorID as CreatorID,
+ project.ManagerID as ManagerID,
+ SUM(time_entry.Duration) as ActualDuration
+ FROM project
+ LEFT JOIN categories ON project.ProjectID = categories.ProjectID
+ LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
+ WHERE
+ Disabled = 0
+ AND project.ManagerID = #value#
+ GROUP BY
+ project.ProjectID
+ ORDER BY
+ project.Name
+</select>
+
+<select ID="GetProjectsByUserName" resultMap="project-result">
+ SELECT
+ project.ProjectID as ProjectID,
+ project.Name as Name,
+ project.Description as Description,
+ project.CreationDate as CreationDate,
+ project.EstimateDuration as EstimateDuration,
+ project.CompletionDate as CompletionDate,
+ project.CreatorID as CreatorID,
+ project.ManagerID as ManagerID,
+ SUM(time_entry.Duration) as ActualDuration
+ FROM project
+ LEFT JOIN categories ON project.ProjectID = categories.ProjectID
+ LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID,
+ project_members
+ WHERE
+ project_members.ProjectID = project.ProjectID
+ AND project_members.UserID = #value#
+ AND project.Disabled = 0
+ GROUP BY
+ project.ProjectID
+ ORDER BY
+ project.Name
+</select>
+
+<update ID="DeleteProject" parameterClass="integer">
+ UPDATE project SET Disabled = 1 WHERE ProjectID = #value#
+</update>
+
+<select ID="GetProjectMembers" parameterClass="integer">
+ SELECT UserID FROM project_members WHERE ProjectID = #value#
+</select>
+
+<insert ID="AddUserToProject" parameterClass="array">
+ INSERT INTO project_members (UserID, ProjectID)
+ VALUES(#username#, #project#)
+</insert>
+
+<delete ID="RemoveUserFromProject" parameterClass="array">
+ DELETE FROM project_members WHERE ProjectID = #project# AND UserID = #username#
+</delete>
+
+<update ID="UpdateProject" parameterClass="Project">
+ UPDATE project
+ SET
+ CompletionDate = #CompletionDate, typeHandler=DateTime#,
+ Description = #Description#,
+ EstimateDuration = #EstimateDuration#,
+ ManagerId =#ManagerUserName#,
+ Name = #Name#
+ WHERE
+ ProjectID = #ID#
+</update>
+
+</sqlMap>
\ No newline at end of file |