Author: ktlili
Date: Tue Sep 4 16:13:27 2007
New Revision: 115
URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D115&repname=
=3Dtimereporting
Log:
- timesheet new features
Added:
trunk/war/src/java/org/jahia/tools/xml/
trunk/war/src/java/org/jahia/tools/xml/ProjectElement.java
trunk/war/src/java/org/jahia/tools/xml/TemplateDocumentsHandler.java
trunk/war/src/java/org/jahia/webapps/timereporting/Currency.java
trunk/war/src/java/org/jahia/webapps/timereporting/EmployeePrice.java
trunk/war/src/java/org/jahia/webapps/timereporting/EmployeePriceCurrenc=
y.java
trunk/war/src/java/org/jahia/webapps/timereporting/GlobalLabel.java
trunk/war/src/java/org/jahia/webapps/timereporting/ProjectLabel.java
Added: trunk/war/src/java/org/jahia/tools/xml/ProjectElement.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/trunk/war/src/=
java/org/jahia/tools/xml/ProjectElement.java&rev=3D115&repname=3Dtimereport=
ing
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/war/src/java/org/jahia/tools/xml/ProjectElement.java (added)
+++ trunk/war/src/java/org/jahia/tools/xml/ProjectElement.java Tue Sep 4 1=
6:13:27 2007
@@ -0,0 +1,62 @@
+package org.jahia.tools.xml;
+
+import org.jdom.*;
+
+import java.util.*;
+
+/**
+ * Created by Jahia.
+ * User: ktlili
+ * Date: 27 juin 2007
+ * Time: 15:00:50
+ * To change this template use File | Settings | File Templates.
+ */
+public class ProjectElement {
+ private Element ele;
+
+
+ public ProjectElement(Element ele) {
+ this.ele =3D ele;
+ }
+
+ public String getProjectName() {
+ return getValue("name");
+ }
+
+ public String getProjectDescription() {
+ return getValue("description");
+ }
+
+ public String getProjectType() {
+ return getValue("type");
+ }
+
+ public String getProjectPath() {
+ if (ele !=3D null) {
+ return ele.getAttributeValue("path");
+ }
+ return null;
+ }
+
+ public List getChildren(String name) {
+ if (ele =3D=3D null) {
+ return new ArrayList();
+ }
+ return ele.getChildren(name);
+ }
+
+ public List getChildren() {
+ if (ele =3D=3D null) {
+ return new ArrayList();
+ }
+ return ele.getChildren();
+ }
+
+ private String getValue(String name) {
+ if (ele !=3D null) {
+ return ele.getAttributeValue(name);
+ }
+ return "";
+ }
+
+}
Added: trunk/war/src/java/org/jahia/tools/xml/TemplateDocumentsHandler.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/trunk/war/src/=
java/org/jahia/tools/xml/TemplateDocumentsHandler.java&rev=3D115&repname=3D=
timereporting
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/war/src/java/org/jahia/tools/xml/TemplateDocumentsHandler.java (a=
dded)
+++ trunk/war/src/java/org/jahia/tools/xml/TemplateDocumentsHandler.java Tu=
e Sep 4 16:13:27 2007
@@ -0,0 +1,117 @@
+package org.jahia.tools.xml;
+
+import org.jdom.*;
+import org.jdom.input.SAXBuilder;
+
+import java.util.*;
+import java.io.FileInputStream;
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Created by Jahia.
+ * User: ktlili
+ * Date: 27 juin 2007
+ * Time: 14:33:15
+ * To change this template use File | Settings | File Templates.
+ */
+public class TemplateDocumentsHandler {
+ private static org.apache.log4j.Logger logger =3D org.apache.log4j.Log=
ger.getLogger(TemplateDocumentsHandler.class);
+ private static Hashtable documentHash =3D new Hashtable();
+ private static String templatesPath;
+ private Document doc;
+
+
+ public static void init(String templatesPath) {
+ logger.debug("... init(...)");
+ TemplateDocumentsHandler.templatesPath =3D templatesPath;
+ loadListNameTemplatesFromXmlDirectory();
+ }
+
+ public static void reset() {
+ logger.debug("... reset(...)");
+ documentHash =3D new Hashtable();
+ loadListNameTemplatesFromXmlDirectory();
+ }
+
+ public void setName(String templateName) {
+ doc =3D (Document) documentHash.get(templateName);
+ }
+
+
+ public List getProjects(ProjectElement parentPEle) {
+ // get children as Elements list
+ List childrenEle;
+ if (parentPEle =3D=3D null) {
+ childrenEle =3D doc.getRootElement().getChildren();
+ } else {
+ childrenEle =3D parentPEle.getChildren();
+ }
+
+ // populate children
+ List children =3D new ArrayList();
+ for (int i =3D 0; i < childrenEle.size(); i++) {
+ Element ele =3D (Element) childrenEle.get(i);
+ ProjectElement pEle =3D new ProjectElement(ele);
+ children.add(pEle);
+ }
+
+ return children;
+ }
+
+ public Enumeration getTemplatesName() {
+ if (documentHash !=3D null) {
+ return documentHash.keys();
+ }
+ return null;
+ }
+
+ private static Document buildFromPath(String path) {
+ try {
+ SAXBuilder builder =3D new SAXBuilder();
+ return builder.build(new FileInputStream(new File(path)));
+ }
+ catch (IOException ex) {
+ logger.error("[ Path is: " + path + " ]", ex);
+ }
+ catch (JDOMException ex) {
+ logger.error("[ Path is: " + path + " ]", ex);
+ }
+ return null;
+
+ }
+
+ private static void loadListNameTemplatesFromXmlDirectory() {
+ // get the path of the clippers directory
+ logger.debug("[Path is: " + templatesPath + " ]");
+
+ //test
+ File directory =3D new File(templatesPath);
+ if (!directory.isDirectory()) {
+ logger.error("[ The specified path is not a directory: " + dir=
ectory.getAbsolutePath() + " ]");
+ return;
+ }
+
+ //load
+ File[] descriptors =3D directory.listFiles();
+ for (int i =3D 0; i < descriptors.length; i++) {
+ File f =3D descriptors[i];
+ if (!f.isDirectory() && f.getAbsolutePath().endsWith(".xml")) {
+ String name =3D f.getName();
+ logger.debug("[ Found template with name " + name + " ]");
+ //get template name
+ Document doc =3D buildFromPath(f.getAbsolutePath());
+
+ Attribute templateNameAtt =3D doc.getRootElement().getAttr=
ibute("name");
+ if (templateNameAtt !=3D null) {
+ String temlpateName =3D templateNameAtt.getValue();
+ documentHash.put(temlpateName, doc);
+ } else {
+ logger.error("Attribute name not found");
+ }
+ }
+ }
+
+ }
+
+}
Added: trunk/war/src/java/org/jahia/webapps/timereporting/Currency.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/trunk/war/src/=
java/org/jahia/webapps/timereporting/Currency.java&rev=3D115&repname=3Dtime=
reporting
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/war/src/java/org/jahia/webapps/timereporting/Currency.java (added)
+++ trunk/war/src/java/org/jahia/webapps/timereporting/Currency.java Tue Se=
p 4 16:13:27 2007
@@ -0,0 +1,49 @@
+package org.jahia.webapps.timereporting;
+
+/**
+ * Created by Jahia.
+ * User: ktlili
+ * Date: 29 ao=C3=83=C2=BBt 2007
+ * Time: 10:01:13
+ * To change this template use File | Settings | File Templates.
+ */
+public class Currency implements java.io.Serializable {
+ private int contextId;
+ private int id;
+ private String name;
+ private String description;
+
+
+ public int getContextId() {
+ return contextId;
+ }
+
+ public void setContextId(int contextId) {
+ this.contextId =3D contextId;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id =3D id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name =3D name;
+ }
+
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description =3D description;
+ }
+}
Added: trunk/war/src/java/org/jahia/webapps/timereporting/EmployeePrice.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/trunk/war/src/=
java/org/jahia/webapps/timereporting/EmployeePrice.java&rev=3D115&repname=
=3Dtimereporting
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/war/src/java/org/jahia/webapps/timereporting/EmployeePrice.java (=
added)
+++ trunk/war/src/java/org/jahia/webapps/timereporting/EmployeePrice.java T=
ue Sep 4 16:13:27 2007
@@ -0,0 +1,40 @@
+package org.jahia.webapps.timereporting;
+
+/**
+ * Created by Jahia.
+ * User: ktlili
+ * Date: 29 ao=C3=83=C2=BBt 2007
+ * Time: 09:55:01
+ * To change this template use File | Settings | File Templates.
+ */
+public class EmployeePrice implements java.io.Serializable {
+ private int contextId;
+ private int id;
+ private String label;
+
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id =3D id;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label =3D label;
+ }
+
+
+ public int getContextId() {
+ return contextId;
+ }
+
+ public void setContextId(int contextId) {
+ this.contextId =3D contextId;
+ }
+}
Added: trunk/war/src/java/org/jahia/webapps/timereporting/EmployeePriceCurr=
ency.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/trunk/war/src/=
java/org/jahia/webapps/timereporting/EmployeePriceCurrency.java&rev=3D115&r=
epname=3Dtimereporting
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/war/src/java/org/jahia/webapps/timereporting/EmployeePriceCurrenc=
y.java (added)
+++ trunk/war/src/java/org/jahia/webapps/timereporting/EmployeePriceCurrenc=
y.java Tue Sep 4 16:13:27 2007
@@ -0,0 +1,58 @@
+package org.jahia.webapps.timereporting;
+
+/**
+ * Created by Jahia.
+ * User: ktlili
+ * Date: 29 ao=C3=83=C2=BBt 2007
+ * Time: 10:00:41
+ * To change this template use File | Settings | File Templates.
+ */
+public class EmployeePriceCurrency implements java.io.Serializable {
+ private int contextId;
+ private int id;
+ private int employeePriceId;
+ private int currenyId;
+ private int value;
+
+
+ public int getContextId() {
+ return contextId;
+ }
+
+ public void setContextId(int contextId) {
+ this.contextId =3D contextId;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id =3D id;
+ }
+
+ public int getEmployeePriceId() {
+ return employeePriceId;
+ }
+
+ public void setEmployeePriceId(int employeePriceId) {
+ this.employeePriceId =3D employeePriceId;
+ }
+
+ public int getCurrenyId() {
+ return currenyId;
+ }
+
+ public void setCurrenyId(int currenyId) {
+ this.currenyId =3D currenyId;
+ }
+
+
+ public int getValue() {
+ return value;
+ }
+
+ public void setValue(int value) {
+ this.value =3D value;
+ }
+}
Added: trunk/war/src/java/org/jahia/webapps/timereporting/GlobalLabel.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/trunk/war/src/=
java/org/jahia/webapps/timereporting/GlobalLabel.java&rev=3D115&repname=3Dt=
imereporting
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/war/src/java/org/jahia/webapps/timereporting/GlobalLabel.java (ad=
ded)
+++ trunk/war/src/java/org/jahia/webapps/timereporting/GlobalLabel.java Tue=
Sep 4 16:13:27 2007
@@ -0,0 +1,116 @@
+package org.jahia.webapps.timereporting;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.CompareToBuilder;
+
+import java.util.List;
+
+/**
+ * Created by Jahia.
+ * User: ktlili
+ * Date: 30 mai 2007
+ * Time: 15:23:32
+ * To change this template use File | Settings | File Templates.
+ */
+public class GlobalLabel implements Comparable, java.io.Serializable {
+ private int contextId;
+ private int labelId;
+ private String name;
+ private String description;
+ private String code;
+ private List projectIds;
+ private boolean archive;
+
+
+ public GlobalLabel() {
+ }
+
+
+ public int getContextId() {
+ return contextId;
+ }
+
+ public void setContextId(int contextId) {
+ this.contextId =3D contextId;
+ }
+
+ public int getLabelId() {
+ return labelId;
+ }
+
+ public void setLabelId(int labelId) {
+ this.labelId =3D labelId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name =3D name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description =3D description;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public void setCode(String code) {
+ this.code =3D code;
+ }
+
+ public List getProjectIds() {
+ return projectIds;
+ }
+
+ public void setProjectIds(List projectIds) {
+ this.projectIds =3D projectIds;
+ }
+
+ public boolean isArchive() {
+ return archive;
+ }
+
+ public void setArchive(boolean archive) {
+ this.archive =3D archive;
+ }
+
+ public String toString() {
+ return getName();
+ }
+
+ public boolean equals(Object obj) {
+ if (this =3D=3D obj) return true;
+
+ if (obj !=3D null && this.getClass() =3D=3D obj.getClass()) {
+ final GlobalLabel castOther =3D (GlobalLabel) obj;
+ return new EqualsBuilder()
+ .append(contextId, castOther.getContextId())
+ .append(labelId, castOther.getLabelId())
+ .isEquals();
+ }
+ return false;
+ }
+
+ public int hashCode() {
+ return new HashCodeBuilder()
+ .append(contextId)
+ .append(labelId)
+ .toHashCode();
+ }
+
+ public int compareTo(Object obj) {
+ final GlobalLabel castOther =3D (GlobalLabel) obj;
+ Integer it =3D new Integer(labelId);
+ Integer it2 =3D new Integer(castOther.getLabelId());
+ return it.compareTo(it2);
+ }
+}
Added: trunk/war/src/java/org/jahia/webapps/timereporting/ProjectLabel.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/trunk/war/src/=
java/org/jahia/webapps/timereporting/ProjectLabel.java&rev=3D115&repname=3D=
timereporting
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/war/src/java/org/jahia/webapps/timereporting/ProjectLabel.java (a=
dded)
+++ trunk/war/src/java/org/jahia/webapps/timereporting/ProjectLabel.java Tu=
e Sep 4 16:13:27 2007
@@ -0,0 +1,57 @@
+package org.jahia.webapps.timereporting;
+
+/**
+ * Created by Jahia.
+ * User: ktlili
+ * Date: 26 juin 2007
+ * Time: 12:29:10
+ * To change this template use File | Settings | File Templates.
+ */
+public class ProjectLabel {
+ private int id;
+ /**
+ * the context id
+ */
+ private int contextId =3D -1;
+ /**
+ * the user login
+ */
+ private int labelId =3D -1;
+ /**
+ * the project id (set to -1 if the project is a root project)
+ */
+ private int projectId =3D -2; //used -2 to have an out of domain initi=
al val
+
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id =3D id;
+ }
+
+ public int getContextId() {
+ return contextId;
+ }
+
+ public void setContextId(int contextId) {
+ this.contextId =3D contextId;
+ }
+
+ public int getLabelId() {
+ return labelId;
+ }
+
+ public void setLabelId(int labelId) {
+ this.labelId =3D labelId;
+ }
+
+ public int getProjectId() {
+ return projectId;
+ }
+
+ public void setProjectId(int projectId) {
+ this.projectId =3D projectId;
+ }
+}
_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list