Scarab commit: svn commit: r10816 - trunk: . src/java/org/tigris/scarab/attribute src/java/org/tigris/scarab/om src/webapp/WEB-INF/templates/screens src/webapp/skins
Hussayn Dabbous <[email protected]>
| Newsgroups | gmane.comp.java.scarab.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: dabbous
Date: 2009-07-20 13:36:02-0700
New Revision: 10816
Modified:
trunk/project.properties
trunk/src/java/org/tigris/scarab/attribute/DateAttribute.java
trunk/src/java/org/tigris/scarab/om/Issue.java
trunk/src/webapp/WEB-INF/templates/screens/IssueList.vm
trunk/src/webapp/skins/custom.css
Log:
SCB2989:
Added api functions to get issuestate isSealed() isOnHold() plus the necessary support methods
Added some system properties:
scarab.common.status.id=status
scarab.common.status.sealed=closed
scarab.common.status.onhold=onhold
scarab.common.status.onhold.dateProperty=reactivationDate
This information is needed by the isSealed() and isOnHold() methods
to find out the "state" of the issue. As this is only preparatory work
for now, nothing is actually seen on the frontend side and nothing happens
on the backend side. However the new API methods can be used to modify
the velocity templates through extension functions (as i do right now
for my project). I still intend to add a better integration maybe
customizable on module/or issueType scope and eventually allow colorized
issuelists etc. But there is still a lot to do before that works
in a feasible and meaningfull way.
Modified: trunk/project.properties
Url: http://scarab.tigris.org/source/browse/scarab/trunk/project.properties?view=diff&pathrev=10816&r1=10815&r2=10816
==============================================================================
--- trunk/project.properties (original)
+++ trunk/project.properties 2009-07-20 13:36:02-0700
@@ -880,6 +880,8 @@
# scarab.instance.id
# scarab.common.status.id
# scarab.common.status.sealed
+# scarab.common.status.onhold
+# scarab.common.status.onhold.dateProperty
# scarab.common.status.sealed.modifyPermission
#
# Helper properties for the workflow.
@@ -967,6 +969,9 @@
# ---------------------------
#
#
+# A sealed issue is meant to be immutable.
+# That could be because it is closed, or has put into an
+# "unchangeable" state or whatever else is required.
# The given issue is recognized as sealed when the status attribute
# been set to the given value. The default behaviour is:
# ue is sealed if (status == closed)
@@ -974,6 +979,32 @@
scarab.common.status.sealed=closed
+# ---------------------------
+# scarab.common.status.onhold
+# ---------------------------
+#
+#
+# An "onhold" issue is typically an issue, which can not be processed
+# right now, but has been postponed to a later time. onHold issues
+# typically also transport a "reactivation date". Note that the here
+# used model is very simplistic: An isue is recognized as onhold when
+# its state value has been set to "onhold", i.e. for the default settings:
+# Issue is onhold if (state=="onhold")
+#
+
+scarab.common.status.onhold=onhold
+
+# ----------------------------------------
+# scarab.common.status.onhold.dateProperty
+# ----------------------------------------
+#
+#
+# This is the attribute which contains the attribute name of
+# the reactivation date for "onhold" issues.
+#
+
+scarab.common.status.onhold.dateProperty=onhold
+
# --------------------------------------------
# scarab.common.status.sealed.modifyPermission
# --------------------------------------------
Modified: trunk/src/java/org/tigris/scarab/attribute/DateAttribute.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/attribute/DateAttribute.java?view=diff&pathrev=10816&r1=10815&r2=10816
==============================================================================
--- trunk/src/java/org/tigris/scarab/attribute/DateAttribute.java (original)
+++ trunk/src/java/org/tigris/scarab/attribute/DateAttribute.java 2009-07-20 13:36:02-0700
@@ -142,4 +142,16 @@
}
}
}
+
+ /**
+ * Receives a value in internal date format and returns it as Date instance
+ * @param vlaue
+ * @return
+ * @throws ParseException
+ */
+ public static Date toDate(String value) throws ParseException
+ {
+ Date result = internalFormat.parse(value);
+ return result;
+ }
}
Modified: trunk/src/java/org/tigris/scarab/om/Issue.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/om/Issue.java?view=diff&pathrev=10816&r1=10815&r2=10816
==============================================================================
--- trunk/src/java/org/tigris/scarab/om/Issue.java (original)
+++ trunk/src/java/org/tigris/scarab/om/Issue.java 2009-07-20 13:36:02-0700
@@ -50,6 +50,7 @@
import com.workingdogs.village.DataSetException;
import java.io.Serializable;
import java.sql.Connection;
+import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
@@ -74,6 +75,7 @@
import org.apache.torque.util.BasePeer;
import org.apache.torque.util.Criteria;
import org.apache.turbine.Turbine;
+import org.tigris.scarab.attribute.DateAttribute;
import org.tigris.scarab.attribute.OptionAttribute;
import org.tigris.scarab.attribute.TotalVotesAttribute;
import org.tigris.scarab.attribute.UserAttribute;
@@ -1577,6 +1579,62 @@
}
/**
+ * Return the number of hours since last Change date (or creation date if never changed)
+ *
+ * @return a <code>ScarabUser</code> value
+ * @throws ParseException
+ */
+ public long getHoursIdle() throws TorqueException, ParseException
+ {
+ Date now = new Date();
+ Date date = null;
+ Date onHoldUntil = null;
+ long diffHours = 0;
+
+ if (!isNew())
+ {
+ boolean onHold = isOnHold();
+ if(onHold)
+ {
+ onHoldUntil = getOnHoldUntil(); // on Hold until this date
+ if(onHoldUntil == null)
+ {
+ return 0; // we are on hold but there is no end date, so we wait forever.
+ }
+ diffHours = (now.getTime() - onHoldUntil.getTime()) / (1000*60*60);
+ if(diffHours < 0)
+ {
+ return 0; // onHoldDate not yet reached, so we are not idle by definition
+ }
+ }
+ ActivitySet t = getLastActivitySet();
+ if (t == null)
+ {
+ date = getCreatedDate();
+ }
+ else
+ {
+ date = t.getCreatedDate();
+ }
+
+ if(onHold)
+ {
+ if (date.before(onHoldUntil))
+ {
+ // The date of last activity was before the onHoldUntil date
+ // In that case we count the end of the onHold period as the
+ // event.
+ date = onHoldUntil;
+ }
+ }
+
+ }
+ // Return the difference in hours between now and the last date of activities:
+ diffHours = (now.getTime() - date.getTime()) / (1000*60*60);
+ return diffHours;
+ }
+
+ /**
* The last user to modify the issue.
*
* @return a <code>ScarabUser</code> value
@@ -4285,6 +4343,70 @@
return result;
}
+ /**
+ * Check if this issue is on hold. Currently we use the attribute
+ * which has been specified by the system property
+ * scarab.common.status.id as the relevant attribute to check.
+ * We tell this issue is on hold when the status-attribute contains
+ * the value specified by the system property "scarab.common.status.onhold"
+ * By default an issue is onhold if attribute "status" == "onhold")
+ * @return
+ * @throws TorqueException
+ */
+ public boolean isOnHold() throws TorqueException
+ {
+ boolean result = false;
+ String status = getProperty("scarab.common.status.id", null);
+ if (status != null)
+ {
+ String value = getProperty("scarab.common.status.onhold", null);
+ if(value != null)
+ {
+ AttributeValue attval = getAttributeValue(status);
+ if(attval != null && attval.getValue().equals(value))
+ {
+ result = true;
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Get the date until which this issue is onhold. This method searches
+ * for the attribute specified by the system property "scarab.common.status.onhold.dateProperty"
+ * And we expect this attribute to contain a Date value.
+ * @return
+ * @throws TorqueException
+ * @throws ParseException
+ */
+ public Date getOnHoldUntil() throws TorqueException, ParseException
+ {
+ Date date = null;
+ String attributeName = getProperty("scarab.common.status.onhold.dateProperty", null);
+
+ if (attributeName != null)
+ {
+ AttributeValue dateValue = this.getAttributeValue(attributeName);
+ if(dateValue!=null)
+ {
+ String value = dateValue.getValue();
+ if (value != null && value.length() > 0)
+ {
+ date = DateAttribute.toDate(value);
+ }
+ }
+ }
+ return date;
+ }
+
+
+ /**
+ * helper funtion to retrieve properties from the Turbine Configuration sysstem.
+ * @param prop
+ * @param def
+ * @return
+ */
private String getProperty(String prop, String def)
{
String result = (String)Turbine.getConfiguration().getProperty(prop);
Modified: trunk/src/webapp/WEB-INF/templates/screens/IssueList.vm
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/webapp/WEB-INF/templates/screens/IssueList.vm?view=diff&pathrev=10816&r1=10815&r2=10816
==============================================================================
--- trunk/src/webapp/WEB-INF/templates/screens/IssueList.vm (original)
+++ trunk/src/webapp/WEB-INF/templates/screens/IssueList.vm 2009-07-20 13:36:02-0700
@@ -164,15 +164,20 @@
</tr> <!-- END of HEADER -->
<tr> <!-- DATA -->
#foreach ($record in $qrIterator)
+ #set ($issue = $scarabR.getIssue($record.UniqueId))
$qrIterator.initializeLink($link)
- #indexedRows($velocityCount)
+ #if ($issue.isOnHold() || $issue.isSealed())
+ #indexedRows($velocityCount)
+ #else
+ #indexedRowsWithIdleHours($velocityCount $issue.HoursIdle)
+ #end
<td>
<input type="hidden" name="all_issue_ids" value="$record.UniqueId" />
<input type="checkbox" name="issue_ids" value="$record.UniqueId" />
</td>
<td><a href="$link">$record.UniqueId</a></td>
#if (!$record.AttributeValuesAsCSV)
- <td>$scarabR.getIssue($record.UniqueId).DefaultText</td>
+ <td>$issue.DefaultText</td>
#end
#foreach ($value in $record.AttributeValuesAsCSV)
<td>
Modified: trunk/src/webapp/skins/custom.css
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/webapp/skins/custom.css?view=diff&pathrev=10816&r1=10815&r2=10816
==============================================================================
--- trunk/src/webapp/skins/custom.css (original)
+++ trunk/src/webapp/skins/custom.css 2009-07-20 13:36:02-0700
@@ -118,8 +118,27 @@
color:red;
}
+// colrized issuelists
+// the schema is:
+//
+//
+
+.a_attention1 td {background: #fee378;}
+.b_attention1 td {background: #fdebad;}
+.a_attention2 td {background: #ffb573;}
+.b_attention2 td {background: #fec08e;}
+.a_attention3 td {background: #ffb573;}
+.b_attention3 td {background: #fec08e;}
+.a_attention4 td {background: #ffb573;}
+.b_attention4 td {background: #fec08e;}
+.a_attention5 td {background: #fa686b;}
+.b_attention5 td {background: #fc8689;}
+
+
// experimental stuff will be removed later.
.wiedervorlagedatum {
color:red;
-}
\ No newline at end of file
+}
+
+
------------------------------------------------------
http://scarab.tigris.org/ds/viewMessage.do?dsForumId=3577&dsMessageId=2372722