Aeg

From ICO wiki
Revision as of 18:43, 21 March 2016 by Mgorb (talk | contribs)
Jump to navigationJump to search


Meeskond "Aeg"
Õppeaine: Võrgurakendused II: hajussüsteemide ehitamine
Meeskonnaliige: Maksim Gorb
Juhendaja: Mait Poska
Semester: 2016 kevad kaugõpe

Eesmärk

Projekti eesmärgiks on luua rakendus aja träkkimiseks prjektides. Rakendus võimaldab tavakasutajal sisestada kulunud aja iga projektis tehtud taski kohta, mida hiljem administraator saab kinnitada või tagasi lükata.

XML andmefail

XML

<?xml version="1.0" encoding="utf-8" ?>
<TimeReports>
  <Timereport id="1" week="41" approved="false">
    <User id="1">
      <FirstName>Maksim</FirstName>
      <LastName>Gorb</LastName>
      <Departments>
        <Department id="1">Programmeerijad</Department>
        <Department id="2">Testija</Department>
      </Departments>
      <Roles>
        <Role id="1">Admin</Role>
        <Role id="2">Programmeerija</Role>
        <Role id="3">Testija</Role>
      </Roles>
    </User>
    <Logs>
      <Log id="1" date="21.03.2016">
        <Activity id="1">Task #134</Activity>
        <Time unit="h">8</Time>
      </Log>
      <Log id="2" date="22.03.2016">
        <Activity id="1">Task #134</Activity>
        <Time unit="h">8</Time>
      </Log>
      <Log id="3" date="23.03.2016">
        <Activity id="1">Task #134</Activity>
        <Time unit="h">8</Time>
      </Log>
      <Log id="4" date="24.03.2016">
        <Activity id="1">Task #134</Activity>
        <Time unit="h">8</Time>
      </Log>
      <Log id="5" date="25.03.2016">
        <Activity id="1">Task #134</Activity>
        <Time unit="h">8</Time>
      </Log>
    </Logs>
    <Comment>Läks aega</Comment>
  </Timereport>
  <Timereport id="2" week="41" approved="true">
    <User id="2">
      <FirstName>Juhan</FirstName>
      <LastName>Labidas</LastName>
      <Departments>
        <Department id="2">Testija</Department>
      </Departments>
      <Roles>
        <Role id="3">Testija</Role>
      </Roles>
    </User>
    <Logs>
      <Log id="1" date="21.03.2016">
        <Activity id="1">Task #454</Activity>
        <Time unit="h">8</Time>
      </Log>
      <Log id="2" date="22.03.2016">
        <Activity id="1">Task #454</Activity>
        <Time unit="h">8</Time>
      </Log>
      <Log id="3" date="23.03.2016">
        <Activity id="1">Task #454</Activity>
        <Time unit="h">8</Time>
      </Log>
      <Log id="4" date="24.03.2016">
        <Activity id="1">Task #545</Activity>
        <Time unit="h">8</Time>
      </Log>
      <Log id="5" date="25.03.2016">
        <Activity id="1">Task #214</Activity>
        <Time unit="h">8</Time>
      </Log>
    </Logs>
    <Comment></Comment>
  </Timereport>
</TimeReports>

XSD

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="TimeReports">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" name="Timereport">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="User">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="FirstName" type="xs:string" />
                    <xs:element name="LastName" type="xs:string" />
                    <xs:element name="Departments">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element maxOccurs="unbounded" name="Department">
                            <xs:complexType>
                              <xs:simpleContent>
                                <xs:extension base="xs:string">
                                  <xs:attribute name="id" type="xs:unsignedByte" use="required" />
                                </xs:extension>
                              </xs:simpleContent>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="Roles">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element maxOccurs="unbounded" name="Role">
                            <xs:complexType>
                              <xs:simpleContent>
                                <xs:extension base="xs:string">
                                  <xs:attribute name="id" type="xs:unsignedByte" use="required" />
                                </xs:extension>
                              </xs:simpleContent>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="id" type="xs:unsignedByte" use="required" />
                </xs:complexType>
              </xs:element>
              <xs:element name="Logs">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="Log">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="Activity">
                            <xs:complexType>
                              <xs:simpleContent>
                                <xs:extension base="xs:string">
                                  <xs:attribute name="id" type="xs:unsignedByte" use="required" />
                                </xs:extension>
                              </xs:simpleContent>
                            </xs:complexType>
                          </xs:element>
                          <xs:element name="Time">
                            <xs:complexType>
                              <xs:simpleContent>
                                <xs:extension base="xs:unsignedByte">
                                  <xs:attribute name="unit" type="xs:string" use="required" />
                                </xs:extension>
                              </xs:simpleContent>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                        <xs:attribute name="id" type="xs:unsignedByte" use="required" />
                        <xs:attribute name="date" type="xs:string" use="required" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="Comment" type="xs:string" />
            </xs:sequence>
            <xs:attribute name="id" type="xs:unsignedByte" use="required" />
            <xs:attribute name="week" type="xs:unsignedByte" use="required" />
            <xs:attribute name="approved" type="xs:boolean" use="required" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

XSLT

Summary

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
  <xsl:output method="xml" indent="yes"/>
  <xsl:template match="/">
    <TimeReports>
      <xsl:for-each select="TimeReports/Timereport">
        <Report>
          <Week>
            <xsl:value-of select='@week' />
          </Week>
          <User>
            <xsl:value-of select="User/FirstName"/>
            <xsl:text> </xsl:text>
            <xsl:value-of select="User/LastName"/>
          </User>
          <TotalHours>
            <xsl:value-of select="sum(Logs/Log/Time)"/>
          </TotalHours>
          <Approved>
            <xsl:value-of select='@approved' />
          </Approved>
          <Comment>
            <xsl:value-of select='Comment' />
          </Comment>
        </Report>
      </xsl:for-each>
    </TimeReports>
  </xsl:template>
</xsl:stylesheet>

Activities

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:output method="html" indent="yes"/>

  <xsl:template match="/">
    <html>
      <body>
        <h2>Time Reports</h2>
        <xsl:for-each select="/TimeReports/Timereport">
          <h3>
            <xsl:value-of select="User/FirstName"/>
            <xsl:text> </xsl:text>
            <xsl:value-of select="User/LastName"/>
            Week <xsl:value-of select="@week"/>
          </h3>
          <h4>
            <xsl:choose>
              <xsl:when test="@approved = 'true'">
                <xsl:text>Approved</xsl:text>
              </xsl:when>
              <xsl:otherwise>
                <xsl:text>Not approved</xsl:text>
              </xsl:otherwise>
            </xsl:choose>
          </h4>
          <table border="1">
            <tr>
              <th>
                <xsl:text>Date</xsl:text>
              </th>
              <th>
                <xsl:text>Activity</xsl:text>
              </th>
              <th>
                <xsl:text>Hours</xsl:text>
              </th>
            </tr>

            <xsl:for-each select="Logs/Log">
              <tr>
                <td>
                  <xsl:value-of select="@date"/>
                </td>
                <td>
                  <xsl:value-of select="Activity"/>
                </td>
                <td style="text-align:left">
                  <xsl:value-of select="Time"/>
                </td>
              </tr>
            </xsl:for-each>

          </table>

          <xsl:if test="Comment != ''">
            <h5>
              Comment: <xsl:value-of select="Comment"/>
            </h5>
          </xsl:if>
          <br/>
        </xsl:for-each>


      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

Changelog

21.märts 2016

Wiki leht. XML, XSD ja XSLT näidised.