Author: dabbous
Date: 2006-12-13 09:02:35-0800
New Revision: 10382
Modified:
branches/release/b21/src/java/org/tigris/scarab/om/AbstractScarabModule.java
branches/release/b21/src/java/org/tigris/scarab/tools/ScarabRequestTool.java
branches/release/b21/src/java/org/tigris/scarab/util/word/IssueSearch.java
Log:
When trying to edit the query, the exception occurs. I had to modify several places in order to get this more accurate.
i.e. now the method returns an inoperable Search instance instead of a null.
This needs further investigation but it may hold for the moment. Scarab still complains when date entries are
originally entered in one locale, but later edited in another locale. Here we need a better approach for syntax
checking, i.e. the date local must somehow be fixed or it must become a locale dependent multi value attribute.
But we currently have no concept here.
Modified: branches/release/b21/src/java/org/tigris/scarab/om/AbstractScarabModule.java
Url: http://scarab.tigris.org/source/browse/scarab/branches/release/b21/src/java/org/tigris/scarab/om/AbstractScarabModule.java?view=diff&rev=10382&p1=branches/release/b21/src/java/org/tigris/scarab/om/AbstractScarabModule.java&p2=branches/release/b21/src/java/org/tigris/scarab/om/AbstractScarabModule.java&r1=10381&r2=10382
==============================================================================
--- branches/release/b21/src/java/org/tigris/scarab/om/AbstractScarabModule.java (original)
+++ branches/release/b21/src/java/org/tigris/scarab/om/AbstractScarabModule.java 2006-12-13 09:02:35-0800
@@ -996,40 +996,33 @@
return rmo;
}
- public RModuleAttribute getRModuleAttribute(Attribute attribute,
- IssueType issueType)
- throws TorqueException
- {
- RModuleAttribute rma = null;
- List rmas = null;
- if (attribute.isUserAttribute())
- {
- rmas = getRModuleAttributes(issueType, false, USER);
- }
- else
- {
- rmas = getRModuleAttributes(issueType, false, NON_USER);
- }
- Iterator i = rmas.iterator();
- while (i.hasNext())
- {
- rma = (RModuleAttribute)i.next();
- if (rma.getAttribute().equals(attribute))
- {
- break;
- }
- else
- {
- rma = null;
- }
- }
- return rma;
- }
-
- /**
- * Overridden method. Calls the super method and if no results are
- * returned the call is passed on to the parent module.
- */
+ public RModuleAttribute getRModuleAttribute(Attribute attribute,
+ IssueType issueType) throws TorqueException {
+ RModuleAttribute rma = null;
+ if (attribute != null && issueType != null) {
+ List rmas = null;
+ if (attribute.isUserAttribute()) {
+ rmas = getRModuleAttributes(issueType, false, USER);
+ } else {
+ rmas = getRModuleAttributes(issueType, false, NON_USER);
+ }
+ Iterator i = rmas.iterator();
+ while (i.hasNext()) {
+ rma = (RModuleAttribute) i.next();
+ if (rma.getAttribute().equals(attribute)) {
+ break;
+ } else {
+ rma = null;
+ }
+ }
+ }
+ return rma;
+ }
+
+ /**
+ * Overridden method. Calls the super method and if no results are returned
+ * the call is passed on to the parent module.
+ */
public List getRModuleAttributes(IssueType issueType)
throws TorqueException
{
@@ -1148,34 +1141,42 @@
* @throws ScarabException
*/
public List getAllAttributeOptions(Integer attributeId)
- throws TorqueException, ScarabException
+ throws TorqueException, ScarabException
{
- int id = attributeId.intValue();
- Attribute attribute = Attribute.getInstance(id);
List result;
- if(attribute == null)
+ if (attributeId == null)
{
- this.getLog().warn("No options found for Attribute ["+attributeId+"]");
- //L10NMessage msg = new L10NMessage(L10NKeySet.AttributeNotInSession,""+attributeId);
- //throw new ScarabException(msg);
+ this.getLog().warn(
+ "No attribute specified while fetching attribute options.");
result = Collections.EMPTY_LIST;
- }
- else
+ } else
{
- //Integer attributeId = attribute.getAttributeId();
-
- Criteria crit = new Criteria();
- crit.add(AttributeOptionPeer.ATTRIBUTE_ID, attributeId);
- crit.add(AttributeOptionPeer.DELETED, false);
- result = AttributeOptionPeer.doSelect(crit);
+ int id = attributeId.intValue();
+ Attribute attribute = Attribute.getInstance(id);
+ if (attribute == null)
+ {
+ this.getLog().warn(
+ "No options found for Attribute [" + attributeId + "]");
+ // L10NMessage msg = new
+ // L10NMessage(L10NKeySet.AttributeNotInSession,""+attributeId);
+ // throw new ScarabException(msg);
+ result = Collections.EMPTY_LIST;
+ } else
+ {
+ // Integer attributeId = attribute.getAttributeId();
+
+ Criteria crit = new Criteria();
+ crit.add(AttributeOptionPeer.ATTRIBUTE_ID, attributeId);
+ crit.add(AttributeOptionPeer.DELETED, false);
+ result = AttributeOptionPeer.doSelect(crit);
+ }
}
return result;
}
/**
- * gets a list of all of the active Attributes.
- * ordered by name
- */
+ * gets a list of all of the active Attributes. ordered by name
+ */
public List getActiveAttributesByName(IssueType issueType,
String attributeType)
throws TorqueException
Modified: branches/release/b21/src/java/org/tigris/scarab/tools/ScarabRequestTool.java
Url: http://scarab.tigris.org/source/browse/scarab/branches/release/b21/src/java/org/tigris/scarab/tools/ScarabRequestTool.java?view=diff&rev=10382&p1=branches/release/b21/src/java/org/tigris/scarab/tools/ScarabRequestTool.java&p2=branches/release/b21/src/java/org/tigris/scarab/tools/ScarabRequestTool.java&r1=10381&r2=10382
==============================================================================
--- branches/release/b21/src/java/org/tigris/scarab/tools/ScarabRequestTool.java (original)
+++ branches/release/b21/src/java/org/tigris/scarab/tools/ScarabRequestTool.java 2006-12-13 09:02:35-0800
@@ -1704,7 +1704,9 @@
if (query == null)
{
setInfoMessage(L10NKeySet.EnterQuery);
- return null;
+ //IssueSearchFactory.INSTANCE.notifyDone();
+ //return null;
+ search.setIsOperable(false);
}
else
{
@@ -1712,7 +1714,9 @@
if (!intake.isAllValid())
{
- return null;
+ //IssueSearchFactory.INSTANCE.notifyDone();
+ //return null;
+ search.setIsOperable(false);
}
}
@@ -1738,51 +1742,58 @@
}
// Set intake properties
- boolean searchSuccess = true;
+ int dateFormatErrorCount = 0;
String queryKey = search.getQueryKey();
Group searchGroup = intake.get("SearchIssue", queryKey);
Field minDate = searchGroup.get("MinDate");
if (minDate != null && minDate.toString().length() > 0)
{
- searchSuccess = checkDate(search, minDate.toString());
+ dateFormatErrorCount += checkDate(search, minDate);
}
Field maxDate = searchGroup.get("MaxDate");
if (maxDate != null && maxDate.toString().length() > 0)
{
- searchSuccess = checkDate(search, maxDate.toString());
+ dateFormatErrorCount += checkDate(search, maxDate);
}
Field stateChangeFromDate = searchGroup.get("StateChangeFromDate");
if (stateChangeFromDate != null
&& stateChangeFromDate.toString().length() > 0)
{
- searchSuccess = checkDate(search, stateChangeFromDate.toString());
+ dateFormatErrorCount += checkDate(search, stateChangeFromDate);
}
Field stateChangeToDate = searchGroup.get("StateChangeToDate");
if (stateChangeToDate != null
&& stateChangeToDate.toString().length() > 0)
{
- searchSuccess = checkDate(search, stateChangeToDate.toString());
+ dateFormatErrorCount += checkDate(search, stateChangeToDate);
}
- if (!searchSuccess)
+ if (dateFormatErrorCount > 0)
{
- setAlertMessage(l10n.format("DateFormatPrompt",
- L10NKeySet.ShortDateDisplay));
- return null;
+ L10NMessage msg = new L10NMessage(L10NKeySet.DateFormatPrompt,L10NKeySet.ShortDateDisplay);
+ setAlertMessage(msg);
+ //IssueSearchFactory.INSTANCE.notifyDone();
+ //return null;
+ search.setIsOperable(false);
}
- try
+ if(search.isOperable())
{
- searchGroup.setProperties(search);
- }
- catch (Exception e)
- {
- setAlertMessage(l10n.getMessage(e));
- return null;
+ try
+ {
+ searchGroup.setProperties(search);
+ }
+ catch (Exception e)
+ {
+ setAlertMessage(l10n.getMessage(e));
+ //IssueSearchFactory.INSTANCE.notifyDone();
+ //return null;
+ search.setIsOperable(false);
+ }
}
Integer oldOptionId = search.getStateChangeFromOptionId();
@@ -1790,7 +1801,9 @@
&& oldOptionId.equals(search.getStateChangeToOptionId()))
{
setAlertMessage(L10NKeySet.StateChangeOldEqualNew);
- return null;
+ //IssueSearchFactory.INSTANCE.notifyDone();
+ //return null;
+ search.setIsOperable(false);
}
// Set attribute values to search on
@@ -1849,6 +1862,10 @@
search.setSortPolarity(sortPolarity);
}
+ // If an error occured, the search ios returned in an inoperable state.
+ // The caller must take care of this, since the search itself does not(!)
+ // obey its own inoperability.
+
return search;
}
@@ -2167,19 +2184,21 @@
/**
* Attempts to parse a date passed in the query page.
*/
- private boolean checkDate(IssueSearch search, String date)
+ private int checkDate(IssueSearch search, Field dateField)
throws Exception
{
- boolean success = true;
+ int errorCount = 0;
try
{
+ String date = dateField.toString();
search.parseDate(date, false);
}
catch (Exception e)
{
- success = false;
+ errorCount = 1;
+ dateField.setMessage("format error ["+e.getMessage()+"]");
}
- return success;
+ return errorCount;
}
Modified: branches/release/b21/src/java/org/tigris/scarab/util/word/IssueSearch.java
Url: http://scarab.tigris.org/source/browse/scarab/branches/release/b21/src/java/org/tigris/scarab/util/word/IssueSearch.java?view=diff&rev=10382&p1=branches/release/b21/src/java/org/tigris/scarab/util/word/IssueSearch.java&p2=branches/release/b21/src/java/org/tigris/scarab/util/word/IssueSearch.java&r1=10381&r2=10382
==============================================================================
--- branches/release/b21/src/java/org/tigris/scarab/util/word/IssueSearch.java (original)
+++ branches/release/b21/src/java/org/tigris/scarab/util/word/IssueSearch.java 2006-12-13 09:02:35-0800
@@ -314,6 +314,8 @@
private StringValueParser parser = null;
private ScarabLocalizationTool L10N = null;
+
+ private boolean isOperable = true;
IssueSearch(Issue issue, ScarabUser searcher)
throws Exception
@@ -385,6 +387,21 @@
}
}
+ public boolean isOperable()
+ {
+ return isOperable;
+ }
+
+ /**
+ * The issue can be flagged as inoperable. This can happen when
+ * a syntax check on the search criteria fails (e.g. invalid syntax on Date patterns)
+ * @param state
+ */
+ public void setIsOperable(boolean state)
+ {
+ isOperable = state;
+ }
+
public Locale getLocale() {
return this.locale;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.