summaryrefslogtreecommitdiff
path: root/demos/time-tracker/protected/App_Data/Sqlite/projects.xml
diff options
context:
space:
mode:
authorwei <>2006-07-28 12:34:38 +0000
committerwei <>2006-07-28 12:34:38 +0000
commit171c239dc64b6d78c02fdf2f6316d607b2a4d6dc (patch)
tree23784db1aa30cccc33c8f73c76a8961e350700d0 /demos/time-tracker/protected/App_Data/Sqlite/projects.xml
parent9b1e347a0c4adeb344425017bf3ade06eb48d68e (diff)
add sqlite mapping
Diffstat (limited to 'demos/time-tracker/protected/App_Data/Sqlite/projects.xml')
-rw-r--r--demos/time-tracker/protected/App_Data/Sqlite/projects.xml159
1 files changed, 159 insertions, 0 deletions
diff --git a/demos/time-tracker/protected/App_Data/Sqlite/projects.xml b/demos/time-tracker/protected/App_Data/Sqlite/projects.xml
new file mode 100644
index 00000000..e5f52887
--- /dev/null
+++ b/demos/time-tracker/protected/App_Data/Sqlite/projects.xml
@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<sqlMap>
+
+<resultMap id="project-result" class="ProjectRecord">
+ <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 projects WHERE Name = #value#
+</select>
+
+<insert id="CreateNewProject" parameterClass="ProjectRecord">
+ INSERT INTO projects
+ (Name, Description, CreationDate, EstimateDuration, CompletionDate, CreatorID, ManagerID)
+ VALUES
+ (#Name#, #Description#, php('date', 'Y-m-d H:i:s'), #EstimateDuration#,
+ #CompletionDate, typeHandler=DateTime#,
+ #CreatorUserName#, #ManagerUserName#)
+ <selectKey property="ID" type="post" resultClass="int">
+ select LAST_INSERT_ROWID() as value
+ </selectKey>
+</insert>
+
+<select id="GetProjectByID" parameterClass="integer" resultMap="project-result">
+ SELECT
+ projects.ProjectID as ProjectID,
+ projects.Name as Name,
+ projects.Description as Description,
+ projects.CreationDate as CreationDate,
+ projects.EstimateDuration as EstimateDuration,
+ projects.CompletionDate as CompletionDate,
+ projects.CreatorID as CreatorID,
+ projects.ManagerID as ManagerID,
+ SUM(time_entry.Duration) as ActualDuration
+ FROM projects
+ LEFT JOIN categories ON projects.ProjectID = categories.ProjectID
+ LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
+ WHERE
+ projects.ProjectID = #value#
+ AND Disabled = 0
+ GROUP BY
+ projects.ProjectID
+ ORDER BY
+ projects.Name
+</select>
+
+<select id="GetAllProjects" resultMap="project-result">
+ SELECT
+ projects.ProjectID as ProjectID,
+ projects.Name as Name,
+ projects.Description as Description,
+ projects.CreationDate as CreationDate,
+ projects.EstimateDuration as EstimateDuration,
+ projects.CompletionDate as CompletionDate,
+ projects.CreatorID as CreatorID,
+ projects.ManagerID as ManagerID,
+ SUM(time_entry.Duration) as ActualDuration
+ FROM projects
+ LEFT JOIN categories ON projects.ProjectID = categories.ProjectID
+ LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
+ WHERE
+ Disabled = 0
+ GROUP BY
+ projects.ProjectID
+ ORDER BY
+ projects.ProjectID ASC
+</select>
+
+<select id="GetAllProjectsOrdered" resultMap="project-result" extends="GetAllProjects">
+ ORDER BY $sort$ $order$
+</select>
+
+<select id="GetProjectsByManagerName" resultMap="project-result">
+ SELECT
+ projects.ProjectID as ProjectID,
+ projects.Name as Name,
+ projects.Description as Description,
+ projects.CreationDate as CreationDate,
+ projects.EstimateDuration as EstimateDuration,
+ projects.CompletionDate as CompletionDate,
+ projects.CreatorID as CreatorID,
+ projects.ManagerID as ManagerID,
+ SUM(time_entry.Duration) as ActualDuration
+ FROM projects
+ LEFT JOIN categories ON projects.ProjectID = categories.ProjectID
+ LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID
+ WHERE
+ Disabled = 0
+ AND projects.ManagerID = #value#
+ GROUP BY
+ projects.ProjectID
+ ORDER BY
+ projects.Name
+</select>
+
+<select id="GetProjectsByUserName" resultMap="project-result">
+ SELECT
+ projects.ProjectID as ProjectID,
+ projects.Name as Name,
+ projects.Description as Description,
+ projects.CreationDate as CreationDate,
+ projects.EstimateDuration as EstimateDuration,
+ projects.CompletionDate as CompletionDate,
+ projects.CreatorID as CreatorID,
+ projects.ManagerID as ManagerID,
+ SUM(time_entry.Duration) as ActualDuration
+ FROM projects
+ LEFT JOIN categories ON projects.ProjectID = categories.ProjectID
+ LEFT JOIN time_entry ON categories.CategoryID = time_entry.CategoryID,
+ project_members
+ WHERE
+ project_members.ProjectID = projects.ProjectID
+ AND project_members.UserID = #value#
+ AND projects.Disabled = 0
+ GROUP BY
+ projects.ProjectID
+ ORDER BY
+ projects.Name
+</select>
+
+<update id="DeleteProject" parameterClass="integer">
+ UPDATE projects SET Disabled = 1 WHERE ProjectID = #value#
+</update>
+
+<select id="GetProjectMembers" parameterClass="integer">
+ SELECT UserID FROM project_members WHERE ProjectID = #value#
+ ORDER BY UserID
+</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="ProjectRecord">
+ UPDATE projects
+ SET
+ CompletionDate = #CompletionDate, typeHandler=DateTime#,
+ Description = #Description#,
+ EstimateDuration = #EstimateDuration#,
+ ManagerId =#ManagerUserName#,
+ Name = #Name#
+ WHERE
+ ProjectID = #ID#
+</update>
+
+</sqlMap> \ No newline at end of file