Re: SCB1381 - Scarab summary page
Johannes Hoechstaedter <[email protected]>
| Newsgroups | gmane.comp.java.scarab.devel |
|---|---|
| Message-ID | <[email protected]> |
ok :) here ist is, thank you Völker Ronny schrieb: > Hello Johannes, > > I think there should be a solution without an additional column. > Could you please post a patch with your current changes? > I will have a look at it. > > Ronny > > > -----Original Message----- > From: Johannes Hoechstaedter [mailto:[email protected]] > Sent: Monday, March 10, 2008 1:19 PM > To: [email protected] > Subject: Re: SCB1381 - Scarab summary page > > Hi guys > > I am tired in struggeling with the multi user ability of the default > report patch. Now I have the probelm, that a report is set to dirty only > for one user (because of the instance) I want to set the report dirty fo > all. Therefore I want to introduce a column in the database with a dirty > flag. Do you have any other ideas or is it ok? > > cheers > Johannes > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
defaultScarabReport_globalcaching.patch
(text/plain, 20.7 KB)
Index: src/conf/classes/ScarabBundle_de.properties
===================================================================
--- src/conf/classes/ScarabBundle_de.properties (revision 10539)
+++ src/conf/classes/ScarabBundle_de.properties (working copy)
@@ -691,6 +691,10 @@
StackTraceError=<pre>If the stack trace below has at the top a mention of "ResourceNotFoundException", that means that a template could not be found (404) and is probably the result of a broken link. If the stack trace has something else, please enter a copy of the stack trace <strong>and an explanation of what you did to cause it</strong> to the <a href="http://www.solitone.org/scarab/issues/">Issue Tracking System</a> for analysis. If you are a developer and think you know what the problem is, feel free to send in a patch to fix the problem. </pre>
## Reports
+ReportDeleted=Report ist gelöscht worden
+DefaultReport=Standard Report
+Report=Report
+DefaultReportSubtitle=Standard Modulreport
Update=aktualisieren
Group=Gruppe
Personal=persönlich
Index: src/conf/classes/ScarabBundle_en.properties
===================================================================
--- src/conf/classes/ScarabBundle_en.properties (revision 10539)
+++ src/conf/classes/ScarabBundle_en.properties (working copy)
@@ -754,6 +754,10 @@
NoErrorMessage=Sorry, there was no error message. \n Although, one common source of the error could be a result of not being able \n to find the requested template. Please try going back to the \n {0} screen and starting over.
## Reports
+ReportDeleted=Report deleted
+DefaultReport=Default Report
+Report=Report
+DefaultReportSubtitle=Predefined report for this module
Update=Update
Group=Group
Personal=personal
Index: src/java/org/tigris/scarab/actions/ConfigureReport.java
===================================================================
--- src/java/org/tigris/scarab/actions/ConfigureReport.java (revision 10539)
+++ src/java/org/tigris/scarab/actions/ConfigureReport.java (working copy)
@@ -61,9 +61,11 @@
import org.apache.turbine.TemplateContext;
import org.tigris.scarab.actions.base.RequireLoginFirstAction;
import org.tigris.scarab.om.AttributeValue;
+import org.tigris.scarab.om.Module;
import org.tigris.scarab.om.Report;
import org.tigris.scarab.om.ReportManager;
import org.tigris.scarab.om.ReportPeer;
+import org.tigris.scarab.om.ScarabModule;
import org.tigris.scarab.om.ScarabUser;
import org.tigris.scarab.reports.ReportAxis;
import org.tigris.scarab.reports.ReportBridge;
@@ -1211,6 +1213,7 @@
throws Exception
{
setup(data,context);
+
ScarabUser user = (ScarabUser)data.getUser();
String[] reportIds = data.getParameters().getStrings("report_id");
if (reportIds == null || reportIds.length == 0)
@@ -1230,6 +1233,7 @@
{
torqueReport.setDeleted(true);
torqueReport.save();
+
}
else
{
Index: src/java/org/tigris/scarab/actions/ModifyModule.java
===================================================================
--- src/java/org/tigris/scarab/actions/ModifyModule.java (revision 10539)
+++ src/java/org/tigris/scarab/actions/ModifyModule.java (working copy)
@@ -109,6 +109,7 @@
Group moduleGroup = intake.get
("Module",me.getQueryKey(), false);
+
if (moduleGroup == null)
{
setTarget(data, template);
@@ -221,6 +222,7 @@
storeGlobalParameter(GlobalParameter.ISSUE_REASON_REQUIRED, me, pp);
storeGlobalParameter(GlobalParameter.REQUIRED_ROLE_FOR_REQUESTING_ACCESS, me, pp);
storeGlobalParameter(GlobalParameter.COMMENT_RENDER_ENGINE, me, pp);
+ storeGlobalParameter(GlobalParameter.DEFAULT_REPORT, me, pp);
}
Index: src/java/org/tigris/scarab/om/ActivityManager.java
===================================================================
--- src/java/org/tigris/scarab/om/ActivityManager.java (revision 10539)
+++ src/java/org/tigris/scarab/om/ActivityManager.java (working copy)
@@ -322,12 +322,14 @@
Connection dbCon)
throws TorqueException
{
+
Activity activity = ActivityManager.getInstance();
activity.setIssue(issue);
if (attribute == null)
{
attribute = Attribute.getInstance(0);
}
+
activity.setAttribute(attribute);
activity.setActivitySet(activitySet);
activity.setOldNumericValue(oldNumericValue);
@@ -376,6 +378,14 @@
{
throw new TorqueException(e); //EXCEPTION
}
+
+ //set default report for current module to dirty
+ Module module=issue.getModule();
+
+ if(module instanceof ScarabModule){
+ ((ScarabModule)module).setDefaultReportDirty(true);
+ }
+
return activity;
}
}
Index: src/java/org/tigris/scarab/om/GlobalParameter.java
===================================================================
--- src/java/org/tigris/scarab/om/GlobalParameter.java (revision 10539)
+++ src/java/org/tigris/scarab/om/GlobalParameter.java (working copy)
@@ -70,5 +70,7 @@
"required-role-for-requesting-access";
public static final String COMMENT_RENDER_ENGINE =
"comment-render-engine";
+ public static final String DEFAULT_REPORT =
+ "default-report";
}
Index: src/java/org/tigris/scarab/om/ReportManager.java
===================================================================
--- src/java/org/tigris/scarab/om/ReportManager.java (revision 10539)
+++ src/java/org/tigris/scarab/om/ReportManager.java (working copy)
@@ -67,6 +67,7 @@
throws TorqueException
{
super();
+ setRegion(getClassName().replace('.', '_'));
}
}
@@ -75,3 +76,7 @@
+
+
+
+
Index: src/java/org/tigris/scarab/om/ScarabModule.java
===================================================================
--- src/java/org/tigris/scarab/om/ScarabModule.java (revision 10539)
+++ src/java/org/tigris/scarab/om/ScarabModule.java (working copy)
@@ -60,6 +60,7 @@
// Turbine classes
import org.apache.torque.TorqueException;
+import org.apache.torque.om.NumberKey;
import org.apache.torque.om.Persistent;
import org.apache.torque.util.Criteria;
import org.apache.torque.util.SqlEnum;
@@ -82,6 +83,7 @@
import org.tigris.scarab.util.ScarabException;
import org.tigris.scarab.util.ScarabPaginatedList;
import org.tigris.scarab.util.ScarabLocalizedTorqueException;
+import org.tigris.scarab.reports.ReportBridge;
import org.tigris.scarab.services.cache.ScarabCache;
// FIXME! do not like referencing servlet inside of business objects
@@ -122,8 +124,16 @@
private String port = null;
private String scheme = null;
private String scriptName = null;
-
+
+ private static final String GET_DEFAULTREPORT="getDefaultReport";
+
/**
+ * true if the cached report of this module has to be updated,
+ * because some attribute values had changed in the module.
+ */
+ private boolean defaultReportDirty=false;
+
+ /**
* Get the value of domain.
* @return value of domain.
*/
@@ -1102,5 +1112,99 @@
return '{' + super.toString() + " - ID=" + getModuleId() + " - "
+ getName() + '}';
}
+
+ /**
+ * Method returns all not deleted reports with scope module
+ * @return
+ */
+ public List getNotDeletedModuleReports(){
+ Criteria crit=new Criteria();
+
+ //not deleted
+ crit.add(ReportPeer.DELETED,false);
+
+// not deleted
+ crit.add(ReportPeer.MODULE_ID,this.getModuleId());
+
+ //scope module
+ crit.add(ReportPeer.SCOPE_ID,2);
+
+ List reports=null;
+
+ try {
+ reports=ReportPeer.doSelect(crit);
+ } catch (TorqueException e) {
+
+ reports=null;
+ }
+
+ return reports;
+ }
+
+ public boolean isDefaultReportDirty() {
+ return defaultReportDirty;
+ }
+
+ public void setDefaultReportDirty(boolean defaultReportDirty) {
+ this.defaultReportDirty = defaultReportDirty;
+ }
+
+ /**
+ * method returns the default report defined for the current module
+ * @author jhoech
+ */
+ public ReportBridge getDefaultReport(ScarabUser user)
+ throws Exception
+{
+ String id = GlobalParameterManager.getString(GlobalParameter.DEFAULT_REPORT,this);
+
+ ReportBridge defaultReport=null;
+
+ if(id != null && id.length() > 0){
+
+ defaultReport =(ReportBridge) ReportManager.getMethodResult().get(this,GET_DEFAULTREPORT,this,user);
+
+ if(this.isDefaultReportDirty()||defaultReport==null||!defaultReport.getReportId().toString().equals(id)){
+ defaultReport = new ReportBridge(ReportManager.getInstance(new NumberKey(id), true));
+ ReportManager.getMethodResult().put(defaultReport,this,GET_DEFAULTREPORT,this,user);
+ this.setDefaultReportDirty(false);
+ System.out.println("new report");
+ }
+ else{
+ System.out.println("report from cache");
+ }
+ }
+
+ Criteria crit =new Criteria();
+ crit.add(ReportPeer.REPORT_ID,id);
+ List l=ReportPeer.doSelect(crit);
+ Iterator iter=l.iterator();
+ boolean reportDeleted=false;
+
+ while(iter.hasNext()){
+ Report report=(Report) iter.next();
+ if(report.getDeleted())reportDeleted=true;
+ }
+
+ //return null if report is deleted
+ if(defaultReport!=null&&reportDeleted){
+ return null;
+ }
+ else{
+ return defaultReport;
+ }
+
}
+
+}
+
+
+
+
+
+
+
+
+
+
Index: src/java/org/tigris/scarab/reports/ReportBridge.java
===================================================================
--- src/java/org/tigris/scarab/reports/ReportBridge.java (revision 10539)
+++ src/java/org/tigris/scarab/reports/ReportBridge.java (working copy)
@@ -47,6 +47,7 @@
*/
// JDK classes
+
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
@@ -60,8 +61,11 @@
// Turbine classes
import org.apache.torque.TorqueException;
+
import org.tigris.scarab.tools.localization.L10NKeySet;
import org.tigris.scarab.util.word.IssueSearch;
+import org.tigris.scarab.om.ReportManager;
+import org.tigris.scarab.om.ScarabModule;
import org.tigris.scarab.om.ScarabUserManager;
import org.tigris.scarab.om.Module;
import org.tigris.scarab.om.IssueType;
@@ -97,7 +101,9 @@
private org.tigris.scarab.om.Report torqueReport;
private ReportDefinition reportDefn;
private ReportHeading newHeading;
-
+
+ private final String GET_CACHED_MODEL="getCachedModel";
+
public ReportBridge()
{
torqueReport = new org.tigris.scarab.om.Report();
@@ -605,11 +611,44 @@
return anyRemoved;
}
- public ReportTableModel getModel(ScarabUser searcher)
+ /**
+ * Method returns a refreshed instance of the cached table model
+ * @param searcher
+ * @return
+ * @throws Exception
+ */
+ public ReportTableModel getCachedModel(ScarabUser searcher)
throws Exception
- {
- return new ReportTableModel(this, getGeneratedDate(), searcher);
+ {
+ ScarabModule module=(ScarabModule)getModule();
+
+ ReportTableModel model=(ReportTableModel) ReportManager.getMethodResult().get(this,GET_CACHED_MODEL,searcher);
+
+ if(model==null){
+ generatedDate=new Date();
+ model=new ReportTableModel(this, getGeneratedDate(), searcher);
+ module.setDefaultReportDirty(false);
+
+ }
+ else{
+ System.out.println("model from cache");
+ }
+
+ ReportManager.getMethodResult().put(model,this,GET_CACHED_MODEL,searcher);
+
+ return model;
}
+
+ /**
+ * Returns a new table model of the report
+ * @param searcher
+ * @return
+ * @throws Exception
+ */
+ public ReportTableModel getModel(ScarabUser searcher) throws Exception
+ {
+ return new ReportTableModel(this, getGeneratedDate(), searcher);
+ }
public void save()
throws Exception
Index: src/java/org/tigris/scarab/reports/ReportTableModel.java
===================================================================
--- src/java/org/tigris/scarab/reports/ReportTableModel.java (revision 10539)
+++ src/java/org/tigris/scarab/reports/ReportTableModel.java (working copy)
@@ -47,6 +47,7 @@
*/
// JDK classes
+import java.io.Serializable;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
@@ -58,6 +59,7 @@
import org.tigris.scarab.om.ModuleManager;
import org.tigris.scarab.om.MITList;
import org.tigris.scarab.om.MITListItem;
+import org.tigris.scarab.om.ReportManager;
import org.tigris.scarab.om.ScarabUser;
import org.tigris.scarab.om.ActivityPeer;
import org.tigris.scarab.om.ActivitySetPeer;
@@ -73,7 +75,7 @@
* @version $Id$
*/
public class ReportTableModel
- extends TableModel
+ extends TableModel implements Serializable
{
private static final String ACT_ATTRIBUTE_ID =
ActivityPeer.ATTRIBUTE_ID.substring(
@@ -113,11 +115,13 @@
private Integer moduleId;
private Integer issueTypeId;
private MITList mitList;
-
+
private int[] colspan;
private int[] rowspan;
private boolean isSearchAllowed;
+ private final String GET_VALUE_AT="getValueAt";
+
ReportTableModel(ReportBridge report, Date date, ScarabUser searcher)
throws Exception
{
@@ -170,6 +174,7 @@
this.mitList = searchableList;
}
}
+
}
/**
@@ -301,10 +306,11 @@
}
return dataArray;
}
-
+
public Object getValueAt(int row, int column)
throws Exception
{
+
if (row < 0 || row >= getRowCount())
{
throw new IndexOutOfBoundsException("Row index was " + row); //EXCEPTION
@@ -315,46 +321,56 @@
throw new IndexOutOfBoundsException("Column index was " + column); //EXCEPTION
}
- Object contents = null;
- // could use a categories list to make this simpler
- if (columnHeadings != null && columnHeadings.size() == 1 &&
- ((ReportHeading)columnHeadings.get(0)).get(0) instanceof ReportDate)
- {
- Date date = ((ReportDate) ((ReportHeading) columnHeadings.get(0))
- .get(column)).dateValue();
- if (date.getTime() <= System.currentTimeMillis())
- {
- contents = new Integer(getIssueCount(getRowDataArray(row),
- date));
- }
- else
- {
- // Dates in the future are not applicable to reporting.
- contents = "";
- }
+ Object contents = ReportManager.getMethodResult().get(this,GET_VALUE_AT,new Integer(row),new Integer(column));
+
+ if(contents==null){
+
+ //could use a categories list to make this simpler
+ if (columnHeadings != null && columnHeadings.size() == 1 &&
+ ((ReportHeading)columnHeadings.get(0)).get(0) instanceof ReportDate)
+ {
+ Date date = ((ReportDate) ((ReportHeading) columnHeadings.get(0))
+ .get(column)).dateValue();
+ if (date.getTime() <= System.currentTimeMillis())
+ {
+ contents = new Integer(getIssueCount(getRowDataArray(row),
+ date));
+ }
+ else
+ {
+ // Dates in the future are not applicable to reporting.
+ contents = "";
+ }
+ }
+ else if (rowHeadings != null && rowHeadings.size() == 1 &&
+ ((ReportHeading)rowHeadings.get(0)).get(0) instanceof ReportDate)
+ {
+ Date date = ((ReportDate)((ReportHeading)rowHeadings.get(0))
+ .get(row)).dateValue();
+ if (date.getTime() <= System.currentTimeMillis())
+ {
+ contents = new Integer(getIssueCount(
+ getColumnDataArray(column), date));
+ }
+ else
+ {
+ // Dates in the future are not applicable to reporting.
+ contents = "";
+ }
+ }
+ else
+ {
+
+ contents = new Integer(getIssueCount(
+ getRowDataArray(row), getColumnDataArray(column), date));
+ }
}
- else if (rowHeadings != null && rowHeadings.size() == 1 &&
- ((ReportHeading)rowHeadings.get(0)).get(0) instanceof ReportDate)
- {
- Date date = ((ReportDate)((ReportHeading)rowHeadings.get(0))
- .get(row)).dateValue();
- if (date.getTime() <= System.currentTimeMillis())
- {
- contents = new Integer(getIssueCount(
- getColumnDataArray(column), date));
- }
- else
- {
- // Dates in the future are not applicable to reporting.
- contents = "";
- }
+ else{
+ System.out.println("value from cache"+contents);
}
- else
- {
- contents = new Integer(getIssueCount(
- getRowDataArray(row), getColumnDataArray(column), date));
- }
-
+
+ ReportManager.getMethodResult().put(contents,this,GET_VALUE_AT,new Integer(row),new Integer(column));
+
return contents;
}
Index: src/java/org/tigris/scarab/tools/ScarabRequestTool.java
===================================================================
--- src/java/org/tigris/scarab/tools/ScarabRequestTool.java (revision 10539)
+++ src/java/org/tigris/scarab/tools/ScarabRequestTool.java (working copy)
@@ -46,6 +46,7 @@
* individuals on behalf of Collab.Net.
*/
+import java.io.Serializable;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Arrays;
@@ -146,13 +147,13 @@
* This class is used by the Scarab API
*/
public class ScarabRequestTool
- implements ApplicationTool,Recyclable
+ implements ApplicationTool,Recyclable,Serializable
{
private static final String TIME_ZONE =
Turbine.getConfiguration().getString("scarab.timezone", "");
private static final String POS_IN_LIST = "posInList";
-
+
/**
* The disposed flag.
*/
@@ -2169,7 +2170,7 @@
return reportGenerator;
}
-
+
private ReportBridge getNewReport(MITList mitList)
throws Exception
{
@@ -3220,3 +3221,12 @@
}
+
+
+
+
+
+
+
+
+
Index: src/webapp/WEB-INF/templates/screens/admin/ModifyModule.vm
===================================================================
--- src/webapp/WEB-INF/templates/screens/admin/ModifyModule.vm (revision 10539)
+++ src/webapp/WEB-INF/templates/screens/admin/ModifyModule.vm (working copy)
@@ -120,6 +120,30 @@
</select>
</td>
</tr>
+ <tr>
+
+##Configuration of default report
+ <th>$l10n.DefaultReport</th>
+ <td>
+ <select name="$scarabG.ParameterName.DEFAULT_REPORT">
+
+ ##fetch all saved reports for the current user
+ #set ($reports = $editModule.getNotDeletedModuleReports())
+
+ ##fetch current default report
+ #set ($defaultReport = $editModule.getDefaultReport($data.User))
+
+ ##add an option for "no report" to the drop down
+ <option selected="selected" value="" >$l10n.None</option>
+
+ ##add reports to the drop down
+ #foreach ($report in $reports)
+ ##current default report should be preselected
+ <option value="$report.ReportId" #if ($report.ReportId == $defaultReport.ReportId) selected #end>$report.Name</option>
+ #end
+ </select>
+ </td>
+ </tr>
#end
#*
<tr>
Index: src/webapp/WEB-INF/templates/screens/home/EnterNew.vm
===================================================================
--- src/webapp/WEB-INF/templates/screens/home/EnterNew.vm (revision 10539)
+++ src/webapp/WEB-INF/templates/screens/home/EnterNew.vm (working copy)
@@ -116,4 +116,15 @@
</div>
-->
+##show default report
+#set ($report = $currentModule.getDefaultReport($data.User))
+#if($report)
+ <h3>$l10n.Report $report.Name</h3>
+ <div class="colbar">
+ $l10n.DefaultReportSubtitle
+ </div>
+ #set ($reportModel = $report.getCachedModel($data.User))
+ #reportTable($reportModel)
+#end
+
</div>