svn commit: r492878 - in /ofbiz/trunk/applications/workeffort: servicedef/services.xml src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r492878 - in /ofbiz/trunk/applications/workeffort: servicedef/services.xml src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java

jaz-3
Author: jaz
Date: Thu Jan  4 19:03:12 2007
New Revision: 492878

URL: http://svn.apache.org/viewvc?view=rev&rev=492878
Log:
updated workeffort content wrapper w/ additional methods

Modified:
    ofbiz/trunk/applications/workeffort/servicedef/services.xml
    ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java

Modified: ofbiz/trunk/applications/workeffort/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/servicedef/services.xml?view=diff&rev=492878&r1=492877&r2=492878
==============================================================================
--- ofbiz/trunk/applications/workeffort/servicedef/services.xml (original)
+++ ofbiz/trunk/applications/workeffort/servicedef/services.xml Thu Jan  4 19:03:12 2007
@@ -411,6 +411,8 @@
             and a work effort (e.g. a production run task)</description>
         <auto-attributes include="pk" mode="IN" optional="false" />
     </service>
+
+    <!-- work effort content services -->
     <service name="createWorkEffortContent" engine="simple"
         location="org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml"
         invoke="createWorkEffortContent"
@@ -436,6 +438,8 @@
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
+
+    <!-- work effort review services -->
     <service name="createWorkEffortReview" default-entity-name="WorkEffortReview" engine="simple"
                 location="org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml" invoke="createWorkEffortReview" auth="true">
         <description>Create a Work Effort Review</description>

Modified: ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java?view=diff&rev=492878&r1=492877&r2=492878
==============================================================================
--- ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java (original)
+++ ofbiz/trunk/applications/workeffort/src/org/ofbiz/workeffort/content/WorkEffortContentWrapper.java Thu Jan  4 19:03:12 2007
@@ -66,17 +66,27 @@
         this.mimeTypeId = "text/html";
     }
 
-    // interface implementation
+    // interface implementation(s)
     public String get(String workEffortContentId, boolean useCache) {
         return getWorkEffortContentAsText(workEffort, workEffortContentId, locale, mimeTypeId, workEffort.getDelegator(), useCache);
     }
 
-    public String get(String workEffortContentId) {
-        return get(workEffortContentId, true);
+    /**
+     * Get the most current content data by the defined type
+     * @param contentTypeId Type of content to return
+     * @return String containing the content data
+     */
+    public String get(String contentTypeId) {
+        return get(contentTypeId, true);
     }
 
-    public String getId(String workEffortContentId) {
-        GenericValue workEffortContent = getFirstWorkEffortContentByType(null, workEffort, workEffortContentId, workEffort.getDelegator());
+    /**
+     * Get the ID from the most current content data by the defined type
+     * @param contentTypeId Type of content to return
+     * @return String containing the contentId
+     */
+    public String getId(String contentTypeId) {
+        GenericValue workEffortContent = getFirstWorkEffortContentByType(null, workEffort, contentTypeId, workEffort.getDelegator());
         if (workEffortContent != null) {
             return workEffortContent.getString("contentId");
         } else {
@@ -84,8 +94,37 @@
         }
     }
 
-    public Timestamp getFromDate(String workEffortContentId) {
-        GenericValue workEffortContent = getFirstWorkEffortContentByType(null, workEffort, workEffortContentId, workEffort.getDelegator());
+    /**
+     * Get the name of the most current content data by the defined type
+     * @param contentTypeId Type of content to return
+     * @return String containing the name of the content record
+     */
+    public String getName(String contentTypeId) {
+        GenericValue workEffortContent = getFirstWorkEffortContentByType(null, workEffort, contentTypeId, workEffort.getDelegator());
+        if (workEffortContent != null) {
+            GenericValue content;
+            try {
+                content = workEffortContent.getRelatedOne("Content");
+            } catch (GeneralException e) {
+                Debug.logError(e, module);
+                return null;
+            }
+
+            if (content != null) {
+                return content.getString("contentName");
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * Get the fromDate from teh most current content data by the defined type
+     * @param contentTypeId Type of content to return
+     * @return Timestamp of the fromDate field for this content type
+     */
+    public Timestamp getFromDate(String contentTypeId) {
+        GenericValue workEffortContent = getFirstWorkEffortContentByType(null, workEffort, contentTypeId, workEffort.getDelegator());
         if (workEffortContent != null) {
             return workEffortContent.getTimestamp("fromDate");
         } else {
@@ -100,6 +139,28 @@
             Debug.logError(e, module);
             return null;
         }
+    }
+
+    public String getTypeDescription(String contentTypeId) {
+        GenericDelegator delegator = null;
+        if (workEffort != null) {
+            delegator = workEffort.getDelegator();
+        }
+
+        if (delegator != null) {
+            GenericValue contentType = null;
+            try {
+                contentType = delegator.findByPrimaryKeyCache("WorkEffortContentType", UtilMisc.toMap("workEffortContentTypeId", contentTypeId));
+            } catch (GeneralException e) {
+                Debug.logError(e, module);
+            }
+
+            if (contentType != null) {
+                return contentType.getString("description");
+            }
+        }
+
+        return null;        
     }
 
     public String getContent(String contentId, boolean useCache) {