You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2007/10/19 16:17:07 UTC
svn commit: r586467 - in
/ofbiz/trunk/framework/service/src/org/ofbiz/service: ModelParam.java
ModelPermGroup.java ModelPermission.java ServiceValidationException.java
calendar/RecurrenceInfo.java calendar/RecurrenceRule.java
calendar/RecurrenceUtil.java
Author: doogie
Date: Fri Oct 19 07:17:07 2007
New Revision: 586467
URL: http://svn.apache.org/viewvc?rev=586467&view=rev
Log:
Start of java 1.5 markup.
Modified:
ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelParam.java
ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelPermGroup.java
ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelPermission.java
ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceValidationException.java
ofbiz/trunk/framework/service/src/org/ofbiz/service/calendar/RecurrenceInfo.java
ofbiz/trunk/framework/service/src/org/ofbiz/service/calendar/RecurrenceRule.java
ofbiz/trunk/framework/service/src/org/ofbiz/service/calendar/RecurrenceUtil.java
Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelParam.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelParam.java?rev=586467&r1=586466&r2=586467&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelParam.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelParam.java Fri Oct 19 07:17:07 2007
@@ -63,7 +63,7 @@
public String stringListSuffix;
/** Validation methods */
- public List validators;
+ public List<ModelParamValidator> validators;
/** Default value */
private String defaultValue = null;
@@ -109,7 +109,7 @@
public String getPrimaryFailMessage(Locale locale) {
if (validators != null && validators.size() > 0) {
- return ((ModelParamValidator) validators.get(0)).getFailMessage(locale);
+ return validators.get(0).getFailMessage(locale);
} else {
return null;
}
Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelPermGroup.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelPermGroup.java?rev=586467&r1=586466&r2=586467&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelPermGroup.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelPermGroup.java Fri Oct 19 07:17:07 2007
@@ -34,15 +34,13 @@
public static final String PERM_JOIN_AND = "AND";
public static final String PERM_JOIN_OR = "OR";
- public List permissions = new LinkedList();
+ public List<ModelPermission> permissions = new LinkedList<ModelPermission>();
public String joinType;
public boolean evalPermissions(DispatchContext dctx, Map context) {
if (permissions != null && permissions.size() > 0) {
boolean foundOne = false;
- Iterator i = permissions.iterator();
- while (i.hasNext()) {
- ModelPermission perm = (ModelPermission) i.next();
+ for (ModelPermission perm: permissions) {
if (perm.evalPermission(dctx, context)) {
foundOne = true;
} else {
Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelPermission.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelPermission.java?rev=586467&r1=586466&r2=586467&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelPermission.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelPermission.java Fri Oct 19 07:17:07 2007
@@ -92,7 +92,7 @@
return false;
}
GenericDelegator delegator = userLogin.getDelegator();
- List partyRoles = null;
+ List<GenericValue> partyRoles = null;
try {
partyRoles = delegator.findByAnd("PartyRole", "roleTypeId", nameOrRole, "partyId", userLogin.get("partyId"));
} catch (GenericEntityException e) {
Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceValidationException.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceValidationException.java?rev=586467&r1=586466&r2=586467&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceValidationException.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceValidationException.java Fri Oct 19 07:17:07 2007
@@ -27,13 +27,13 @@
*/
public class ServiceValidationException extends GenericServiceException {
- protected List messages = new ArrayList();
- protected List missingFields = new ArrayList();
- protected List extraFields = new ArrayList();
+ protected List<String> messages = new ArrayList<String>();
+ protected List<String> missingFields = new ArrayList<String>();
+ protected List<String> extraFields = new ArrayList<String>();
protected String errorMode = null;
protected ModelService service = null;
- public ServiceValidationException(ModelService service, List missingFields, List extraFields, String errorMode) {
+ public ServiceValidationException(ModelService service, List<String> missingFields, List<String> extraFields, String errorMode) {
super();
this.service = service;
this.errorMode = errorMode;
@@ -50,7 +50,7 @@
this.service = service;
}
- public ServiceValidationException(String str, ModelService service, List missingFields, List extraFields, String errorMode) {
+ public ServiceValidationException(String str, ModelService service, List<String> missingFields, List<String> extraFields, String errorMode) {
super(str);
this.service = service;
this.errorMode = errorMode;
@@ -67,7 +67,7 @@
this.service = service;
}
- public ServiceValidationException(String str, Throwable nested, ModelService service, List missingFields, List extraFields, String errorMode) {
+ public ServiceValidationException(String str, Throwable nested, ModelService service, List<String> missingFields, List<String> extraFields, String errorMode) {
super(str, nested);
this.service = service;
this.errorMode = errorMode;
@@ -79,7 +79,7 @@
}
}
- public ServiceValidationException(List messages, ModelService service, List missingFields, List extraFields, String errorMode) {
+ public ServiceValidationException(List<String> messages, ModelService service, List<String> missingFields, List<String> extraFields, String errorMode) {
super();
this.messages = messages;
this.service = service;
@@ -92,19 +92,19 @@
}
}
- public ServiceValidationException(List messages, ModelService service, String errorMode) {
+ public ServiceValidationException(List<String> messages, ModelService service, String errorMode) {
this(messages, service, null, null, errorMode);
}
- public List getExtraFields() {
+ public List<String> getExtraFields() {
return extraFields;
}
- public List getMissingFields() {
+ public List<String> getMissingFields() {
return missingFields;
}
- public List getMessageList() {
+ public List<String> getMessageList() {
if (this.messages == null || this.messages.size() == 0) {
return null;
}
@@ -134,9 +134,8 @@
if (msg != null) {
sb.append(msg).append('\n');
}
- Iterator i = this.messages.iterator();
- while (i.hasNext()) {
- sb.append(i.next());
+ for (String m: this.messages) {
+ sb.append(m);
}
msg = sb.toString();
}
Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/calendar/RecurrenceInfo.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/calendar/RecurrenceInfo.java?rev=586467&r1=586466&r2=586467&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/calendar/RecurrenceInfo.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/calendar/RecurrenceInfo.java Fri Oct 19 07:17:07 2007
@@ -41,10 +41,10 @@
protected GenericValue info;
protected Date startDate;
- protected List rRulesList;
- protected List eRulesList;
- protected List rDateList;
- protected List eDateList;;
+ protected List<RecurrenceRule> rRulesList;
+ protected List<RecurrenceRule> eRulesList;
+ protected List<Date> rDateList;
+ protected List<Date> eDateList;;
/** Creates new RecurrenceInfo */
public RecurrenceInfo(GenericValue info) throws RecurrenceInfoException {
@@ -74,12 +74,9 @@
// Get the recurrence rules objects
try {
- Collection c = info.getRelated("RecurrenceRule");
- Iterator i = c.iterator();
-
- rRulesList = new ArrayList();
- while (i.hasNext()) {
- rRulesList.add(new RecurrenceRule((GenericValue) i.next()));
+ rRulesList = new ArrayList<RecurrenceRule>();
+ for (GenericValue value: info.getRelated("RecurrenceRule")) {
+ rRulesList.add(new RecurrenceRule(value));
}
} catch (GenericEntityException gee) {
rRulesList = null;
@@ -89,12 +86,9 @@
// Get the exception rules objects
try {
- Collection c = info.getRelated("ExceptionRecurrenceRule");
- Iterator i = c.iterator();
-
- eRulesList = new ArrayList();
- while (i.hasNext()) {
- eRulesList.add(new RecurrenceRule((GenericValue) i.next()));
+ eRulesList = new ArrayList<RecurrenceRule>();
+ for (GenericValue value: info.getRelated("ExceptionRecurrenceRule")) {
+ eRulesList.add(new RecurrenceRule(value));
}
} catch (GenericEntityException gee) {
eRulesList = null;
@@ -128,22 +122,22 @@
}
/** Returns a recurrence rule iterator */
- public Iterator getRecurrenceRuleIterator() {
+ public Iterator<RecurrenceRule> getRecurrenceRuleIterator() {
return rRulesList.iterator();
}
/** Returns a sorted recurrence date iterator */
- public Iterator getRecurrenceDateIterator() {
+ public Iterator<Date> getRecurrenceDateIterator() {
return rDateList.iterator();
}
/** Returns a exception recurrence iterator */
- public Iterator getExceptionRuleIterator() {
+ public Iterator<RecurrenceRule> getExceptionRuleIterator() {
return eRulesList.iterator();
}
/** Returns a sorted exception date iterator */
- public Iterator getExceptionDateIterator() {
+ public Iterator<Date> getExceptionDateIterator() {
return eDateList.iterator();
}
@@ -171,15 +165,14 @@
/** Removes the recurrence from persistant store. */
public void remove() throws RecurrenceInfoException {
- List rulesList = new ArrayList();
+ List<RecurrenceRule> rulesList = new ArrayList<RecurrenceRule>();
rulesList.addAll(rRulesList);
rulesList.addAll(eRulesList);
- Iterator i = rulesList.iterator();
try {
- while (i.hasNext())
- ((RecurrenceRule) i.next()).remove();
+ for (RecurrenceRule rule: rulesList)
+ rule.remove();
info.remove();
} catch (RecurrenceRuleException rre) {
throw new RecurrenceInfoException(rre.getMessage(), rre);
@@ -226,9 +219,9 @@
boolean hasNext = true;
// Get the next recurrence from the rule(s).
- Iterator rulesIterator = getRecurrenceRuleIterator();
+ Iterator<RecurrenceRule> rulesIterator = getRecurrenceRuleIterator();
while (rulesIterator.hasNext()) {
- RecurrenceRule rule = (RecurrenceRule) rulesIterator.next();
+ RecurrenceRule rule = rulesIterator.next();
while (hasNext) {
// Gets the next recurrence time from the rule.
nextRuleTime = getNextTime(rule, nextRuleTime);
@@ -247,15 +240,11 @@
return checkDateList(rDateList, nextTime, fromTime);
}
- private long checkDateList(List dateList, long time, long fromTime) {
+ private long checkDateList(List<Date> dateList, long time, long fromTime) {
long nextTime = time;
if (dateList != null && dateList.size() > 0) {
- Iterator dateIterator = dateList.iterator();
-
- while (dateIterator.hasNext()) {
- Date thisDate = (Date) dateIterator.next();
-
+ for (Date thisDate: dateList) {
if (nextTime > 0 && thisDate.getTime() < nextTime && thisDate.getTime() > fromTime)
nextTime = thisDate.getTime();
else if (nextTime == 0 && thisDate.getTime() > fromTime)
@@ -266,10 +255,10 @@
}
private boolean isValid(long time) {
- Iterator exceptRulesIterator = getExceptionRuleIterator();
+ Iterator<RecurrenceRule> exceptRulesIterator = getExceptionRuleIterator();
while (exceptRulesIterator.hasNext()) {
- RecurrenceRule except = (RecurrenceRule) exceptRulesIterator.next();
+ RecurrenceRule except = exceptRulesIterator.next();
if (except.isValid(getStartTime(), time) || eDateList.contains(new Date(time)))
return false;
Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/calendar/RecurrenceRule.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/calendar/RecurrenceRule.java?rev=586467&r1=586466&r2=586467&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/calendar/RecurrenceRule.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/calendar/RecurrenceRule.java Fri Oct 19 07:17:07 2007
@@ -656,8 +656,8 @@
GenericValue value = delegator.makeValue("RecurrenceRule");
value.set("frequency", freqStr);
- value.set("intervalNumber", new Long(interval));
- value.set("countNumber", new Long(count));
+ value.set("intervalNumber", interval);
+ value.set("countNumber", count);
if (endTime > 0) {
value.set("untilDateTime", new java.sql.Timestamp(endTime));
}
Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/calendar/RecurrenceUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/calendar/RecurrenceUtil.java?rev=586467&r1=586466&r2=586467&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/calendar/RecurrenceUtil.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/calendar/RecurrenceUtil.java Fri Oct 19 07:17:07 2007
@@ -49,15 +49,13 @@
}
/** Returns a List of parsed date strings. */
- public static List parseDateList(List dateList) {
- List newList = new ArrayList();
+ public static List<Date> parseDateList(List<String> dateList) {
+ List<Date> newList = new ArrayList<Date>();
if (dateList == null)
return newList;
- Iterator i = dateList.iterator();
-
- while (i.hasNext())
- newList.add(parseDate((String) i.next()));
+ for (String value: dateList)
+ newList.add(parseDate(value));
return newList;
}
@@ -77,12 +75,10 @@
}
/** Returns a Llist of date strings from a List of Date objects */
- public static List formatDateList(List dateList) {
- List newList = new ArrayList();
- Iterator i = dateList.iterator();
-
- while (i.hasNext())
- newList.add(formatDate((Date) i.next()));
+ public static List<String> formatDateList(List<Date> dateList) {
+ List<String> newList = new ArrayList<String>();
+ for (Date date: dateList)
+ newList.add(formatDate(date));
return newList;
}