Modified: ofbiz/branches/multitenant20100310/applications/product/widget/catalog/PromoForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/product/widget/catalog/PromoForms.xml?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/product/widget/catalog/PromoForms.xml (original) +++ ofbiz/branches/multitenant20100310/applications/product/widget/catalog/PromoForms.xml Wed Mar 24 09:23:07 2010 @@ -118,4 +118,46 @@ under the License. </hyperlink> </field> </form> + + <form name="EditProductPromoContentImage" type="upload" target="addImageContentForProductPromo" default-map-name="productPromoContent"> + <field name="productPromoId"><hidden/></field> + <field use-when="productPromoContent != null" name="contentId"><display/></field> + <field name="productPromoContentTypeId"><hidden value="ORIGINAL_IMAGE_URL"/></field> + <field name="fromDate" use-when="productPromoContent == null" title="${uiLabelMap.CommonFromDate}"><date-time/></field> + <field name="fromDate" use-when="productPromoContent != null" title="${uiLabelMap.CommonFromDate}"><display/></field> + <field name="thruDate" title="${uiLabelMap.CommonThruDate}"><date-time/></field> + <field name="uploadedFile" title="${uiLabelMap.ProductFile}"><file/></field> + <field use-when="productPromoContent == null" name="submitButton" title="${uiLabelMap.CommonCreate}" widget-style="smallSubmit"><submit button-type="button"/></field> + <field use-when="productPromoContent != null" name="submitButton" title="${uiLabelMap.CommonUpdate}" widget-style="smallSubmit"><submit button-type="button"/></field> + </form> + + <form name="ListProductPromoContent" type="list" list-name="productPromoContents" + odd-row-style="alternate-row" default-table-style="basic-table"> + <field name="editProductPromoContent" title="${uiLabelMap.ProductContent}" widget-style="buttontext"> + <hyperlink target="EditProductPromoContent" description="${description} [${contentId}]" also-hidden="false"> + <parameter param-name="productPromoId"/> + <parameter param-name="contentId"/> + <parameter param-name="productPromoContentTypeId"/> + <parameter param-name="fromDate"/> + </hyperlink> + </field> + <field name="productPromoContentTypeId" title="${uiLabelMap.ProductProductPromoContentType}"> + <display-entity entity-name="ProductContentType" key-field-name="productContentTypeId" also-hidden="false" description="${description}"/> + </field> + <field name="fromDate"><display/></field> + <field name="thruDate"><display/></field> + <field name="editContent" title="${uiLabelMap.ProductEditContent}" widget-style="buttontext"> + <hyperlink target="/content/control/EditContent" target-type="inter-app" description="${contentId}" also-hidden="false"> + <parameter param-name="contentId"/> + </hyperlink> + </field> + <field name="removeContent" title="${uiLabelMap.CommonEmptyHeader}" widget-style="buttontext"> + <hyperlink target="removeContentFromProductPromo" description="${uiLabelMap.CommonDelete}" also-hidden="false"> + <parameter param-name="productPromoId"/> + <parameter param-name="contentId"/> + <parameter param-name="productPromoContentTypeId"/> + <parameter param-name="fromDate"/> + </hyperlink> + </field> + </form> </forms> Modified: ofbiz/branches/multitenant20100310/applications/product/widget/catalog/PromoScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/product/widget/catalog/PromoScreens.xml?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/product/widget/catalog/PromoScreens.xml (original) +++ ofbiz/branches/multitenant20100310/applications/product/widget/catalog/PromoScreens.xml Wed Mar 24 09:23:07 2010 @@ -330,4 +330,35 @@ under the License. </widgets> </section> </screen> + + <screen name="EditProductPromoContent"> + <section> + <actions> + <set field="titleProperty" value="PageTitleEditProductPromoContent"/> + <set field="headerItem" value="promos"/> + <set field="tabButtonItem" value="EditProductPromoContent"/> + <set field="labelTitleProperty" value="ProductPromoContents"/> + <set field="productPromoId" from-field="parameters.productPromoId"/> + <set field="parameters.fromDate" type="Timestamp" from-field="parameters.fromDate"/> + <set field="parameters.thruDate" type="Timestamp" from-field="parameters.thruDate"/> + <entity-one entity-name="ProductPromo" value-field="productPromo"/> + <entity-one entity-name="ProductPromoContent" value-field="productPromoContent"/> + <entity-and list="productPromoContents" entity-name="ProductPromoContent"> + <field-map field-name="productPromoId" from-field="productPromoId"/> + </entity-and> + </actions> + <widgets> + <decorator-screen name="CommonPromoDecorator"> + <decorator-section name="body"> + <screenlet title="${uiLabelMap.PageTitleEditProductPromoContent}"> + <include-form name="EditProductPromoContentImage" location="component://product/widget/catalog/PromoForms.xml"/> + </screenlet> + <screenlet title="${uiLabelMap.ProductProductPromoContentList}"> + <include-form name="ListProductPromoContent" location="component://product/widget/catalog/PromoForms.xml"/> + </screenlet> + </decorator-section> + </decorator-screen> + </widgets> + </section> + </screen> </screens> Modified: ofbiz/branches/multitenant20100310/applications/securityext/email/default/passwordemail.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/securityext/email/default/passwordemail.ftl?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/securityext/email/default/passwordemail.ftl (original) +++ ofbiz/branches/multitenant20100310/applications/securityext/email/default/passwordemail.ftl Wed Mar 24 09:23:07 2010 @@ -22,7 +22,7 @@ under the License. </head> <body> <div>${uiLabelMap.EcommerceThisEmailIsInResponseToYourRequestToHave} <#if useEncryption>${uiLabelMap.EcommerceANew}<#else>${uiLabelMap.EcommerceYour}</#if> ${uiLabelMap.EcommercePasswordSentToYou}.</div> - <br/> + <br /> <div> <#if useEncryption> ${uiLabelMap.EcommerceNewPasswordMssgEncryptionOn} Modified: ofbiz/branches/multitenant20100310/applications/workeffort/data/WorkEffortTypeData.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/workeffort/data/WorkEffortTypeData.xml?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/workeffort/data/WorkEffortTypeData.xml (original) +++ ofbiz/branches/multitenant20100310/applications/workeffort/data/WorkEffortTypeData.xml Wed Mar 24 09:23:07 2010 @@ -37,6 +37,10 @@ under the License. <Enumeration description="Restricted, private access" enumCode="PRIVATE" enumId="WES_PRIVATE" sequenceId="02" enumTypeId="WORK_EFF_SCOPE"/> <Enumeration description="Very restricted, confidential access" enumCode="CONFIDENTIAL" enumId="WES_CONFIDENTIAL" sequenceId="03" enumTypeId="WORK_EFF_SCOPE"/> + <EnumerationType description="Calendar Type" enumTypeId="CALENDAR_TYPE" hasTable="N" parentTypeId=""/> + <Enumeration description="Personal Calendar" enumCode="PERSONAL" enumId="CAL_PERSONAL" sequenceId="01" enumTypeId="CALENDAR_TYPE"/> + <Enumeration description="Manufacturing Calendar" enumCode="MANUFACTURING" enumId="CAL_MANUFACTURING" sequenceId="02" enumTypeId="CALENDAR_TYPE"/> + <!-- workeffort status --> <StatusType description="WorkEffort Asset" hasTable="N" parentTypeId="" statusTypeId="WORK_EFF_ASSET_STTS"/> <StatusType description="WorkEffort Assignment" hasTable="N" parentTypeId="" statusTypeId="WORK_EFFORT_ASSIGN"/> Modified: ofbiz/branches/multitenant20100310/applications/workeffort/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/workeffort/servicedef/services.xml?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/workeffort/servicedef/services.xml (original) +++ ofbiz/branches/multitenant20100310/applications/workeffort/servicedef/services.xml Wed Mar 24 09:23:07 2010 @@ -226,6 +226,7 @@ under the License. If filterOutCanceledEvents is set to Boolean(true) then workEfforts with currentStatusId=EVENT_CANCELLED will not be returned. To limit the events to a particular partyId, specify the partyId. To limit the events to a set of partyIds, specify a Collection of partyIds. </description> + <attribute name="calendarType" type="String" mode="IN" optional="true"/> <attribute name="partyId" type="String" mode="IN" optional="true"/> <attribute name="partyIds" type="java.util.Collection" mode="IN" optional="true"/> <attribute name="facilityId" type="String" mode="IN" optional="true"/> Modified: ofbiz/branches/multitenant20100310/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java (original) +++ ofbiz/branches/multitenant20100310/applications/workeffort/src/org/ofbiz/workeffort/workeffort/WorkEffortServices.java Wed Mar 24 09:23:07 2010 @@ -349,42 +349,36 @@ public class WorkEffortServices { return resultMap; } - private static List<EntityCondition> getDefaultWorkEffortExprList(Collection<String> partyIds, String facilityId, String fixedAssetId, String workEffortTypeId, List<EntityCondition> cancelledCheckAndList) { - List<EntityCondition> entityExprList = UtilMisc.<EntityCondition>toList(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "CAL_CANCELLED"), EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "PRUN_CANCELLED")); + private static List<EntityCondition> getDefaultWorkEffortExprList(String calendarType, Collection<String> partyIds, String workEffortTypeId, List<EntityCondition> cancelledCheckAndList) { + List<EntityCondition> entityExprList = FastList.newInstance(); + if (cancelledCheckAndList != null) { + entityExprList.addAll(cancelledCheckAndList); + } List<EntityExpr> typesList = FastList.newInstance(); if (UtilValidate.isNotEmpty(workEffortTypeId)) { typesList.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, workEffortTypeId)); } - if (UtilValidate.isNotEmpty(partyIds)) { - // (non cancelled) public events, with a startdate + if ("CAL_PERSONAL".equals(calendarType)) { + // public events are always included to the "personal calendar" List<EntityCondition> publicEvents = UtilMisc.<EntityCondition>toList( EntityCondition.makeCondition("scopeEnumId", EntityOperator.EQUALS, "WES_PUBLIC"), EntityCondition.makeCondition("parentTypeId", EntityOperator.EQUALS, "EVENT") ); - - if (cancelledCheckAndList != null) { - publicEvents.addAll(cancelledCheckAndList); + if (UtilValidate.isNotEmpty(partyIds)) { + entityExprList.add( + EntityCondition.makeCondition(UtilMisc.toList( + EntityCondition.makeCondition("partyId", EntityOperator.IN, partyIds), + EntityCondition.makeCondition(publicEvents, EntityJoinOperator.AND) + ), EntityJoinOperator.OR)); } + } + if ("CAL_MANUFACTURING".equals(calendarType)) { entityExprList.add( EntityCondition.makeCondition(UtilMisc.toList( - EntityCondition.makeCondition("partyId", EntityOperator.IN, partyIds), - EntityCondition.makeCondition(publicEvents, EntityJoinOperator.AND) + EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "PROD_ORDER_HEADER"), + EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "PROD_ORDER_TASK") ), EntityJoinOperator.OR)); } - if (UtilValidate.isNotEmpty(facilityId)) { - entityExprList.add(EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId)); - typesList.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "PROD_ORDER_HEADER")); - entityExprList.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "PRUN_CREATED")); - entityExprList.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "PRUN_COMPLETED")); - entityExprList.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "PRUN_CLOSED")); - } - if (UtilValidate.isNotEmpty(fixedAssetId)) { - entityExprList.add(EntityCondition.makeCondition("fixedAssetId", EntityOperator.EQUALS, fixedAssetId)); -// typesList.add(EntityCondition.makeCondition("workEffortTypeId", EntityOperator.EQUALS, "PROD_ORDER_TASK")); -// entityExprList.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "PRUN_CREATED")); -// entityExprList.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "PRUN_COMPLETED")); - entityExprList.add(EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "PRUN_CLOSED")); - } EntityCondition typesCondition = null; if (typesList.size() == 0) { return entityExprList; @@ -463,6 +457,10 @@ public class WorkEffortServices { Timestamp startDay = (Timestamp) context.get("start"); Integer numPeriodsInteger = (Integer) context.get("numPeriods"); + String calendarType = (String) context.get("calendarType"); + if (UtilValidate.isEmpty(calendarType)) { + calendarType = "CAL_PERSONAL"; + } String partyId = (String) context.get("partyId"); Collection<String> partyIds = UtilGenerics.checkCollection(context.get("partyIds")); String facilityId = (String) context.get("facilityId"); @@ -507,8 +505,7 @@ public class WorkEffortServices { return ServiceUtil.returnError("You do not have permission to view information for party with ID [" + partyId + "], you must be logged in as a user associated with this party, or have the WORKEFFORTMGR_VIEW or WORKEFFORTMGR_ADMIN permissions."); } } else { - // if a facilityId or a fixedAssetId are not specified, don't set a default partyId... - if (UtilValidate.isEmpty(facilityId) && UtilValidate.isEmpty(fixedAssetId) && UtilValidate.isNotEmpty(userLogin.getString("partyId"))) { + if ("CAL_PERSONAL".equals(calendarType) && UtilValidate.isNotEmpty(userLogin.getString("partyId"))) { partyIdsToUse.add(userLogin.getString("partyId")); } } @@ -516,12 +513,20 @@ public class WorkEffortServices { // cancelled status id's List<EntityCondition> cancelledCheckAndList = UtilMisc.<EntityCondition>toList( EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "EVENT_CANCELLED"), - EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "CAL_CANCELLED")); + EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "CAL_CANCELLED"), + EntityCondition.makeCondition("currentStatusId", EntityOperator.NOT_EQUAL, "PRUN_CANCELLED")); List<EntityCondition> entityExprList = UtilGenerics.checkList(context.get("entityExprList")); if (entityExprList == null) { - entityExprList = getDefaultWorkEffortExprList(partyIdsToUse, facilityId, fixedAssetId, workEffortTypeId, cancelledCheckAndList); + entityExprList = getDefaultWorkEffortExprList(calendarType, partyIdsToUse, workEffortTypeId, cancelledCheckAndList); + } + + if (UtilValidate.isNotEmpty(facilityId)) { + entityExprList.add(EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId)); + } + if (UtilValidate.isNotEmpty(fixedAssetId)) { + entityExprList.add(EntityCondition.makeCondition("fixedAssetId", EntityOperator.EQUALS, fixedAssetId)); } // should have at least a start date @@ -578,35 +583,21 @@ public class WorkEffortServices { ), EntityJoinOperator.OR); List<String> orderByList = UtilMisc.toList("estimatedStartDate"); - if (partyIdsToUse.size() > 0 || UtilValidate.isNotEmpty(facilityId) || UtilValidate.isNotEmpty(fixedAssetId)) { - try { - List<GenericValue> tempWorkEfforts = null; - if (UtilValidate.isNotEmpty(partyIdsToUse)) { - // Debug.log("=====conditions for party: " + eclTotal); - tempWorkEfforts = EntityUtil.filterByDate(delegator.findList("WorkEffortAndPartyAssignAndType", eclTotal, null, orderByList, null, false)); - } else if (UtilValidate.isNotEmpty(fixedAssetId)) { - EntityConditionList<EntityCondition> ecl = - EntityCondition.makeCondition(UtilMisc.toList( - eclTotal, - EntityCondition.makeCondition("fixedAssetId", EntityOperator.EQUALS, fixedAssetId) - ), EntityJoinOperator.AND); - // Get "old style" work efforts and "new style" work efforts - // Debug.log("=====conditions for fixed asset: " + ecl); - tempWorkEfforts = delegator.findList("WorkEffort", ecl, null, orderByList, null, false); - tempWorkEfforts.addAll(EntityUtil.filterByDate(delegator.findList("WorkEffortAndFixedAssetAssign", ecl, null, orderByList, null, false))); - } else { - EntityConditionList<EntityCondition> ecl = - EntityCondition.makeCondition(UtilMisc.toList( - eclTotal, - EntityCondition.makeCondition("facilityId", EntityOperator.EQUALS, facilityId) - ), EntityJoinOperator.AND); - // Debug.log("=====conditions for facility: " + ecl); - tempWorkEfforts = delegator.findList("WorkEffort", ecl, null, UtilMisc.toList("estimatedStartDate"), null, false); - } - validWorkEfforts = WorkEffortWorker.removeDuplicateWorkEfforts(tempWorkEfforts); - } catch (GenericEntityException e) { - Debug.logWarning(e, module); + try { + List<GenericValue> tempWorkEfforts = null; + if (UtilValidate.isNotEmpty(partyIdsToUse)) { + // Debug.log("=====conditions for party: " + eclTotal); + tempWorkEfforts = EntityUtil.filterByDate(delegator.findList("WorkEffortAndPartyAssignAndType", eclTotal, null, orderByList, null, false)); + } else { + tempWorkEfforts = delegator.findList("WorkEffort", eclTotal, null, orderByList, null, false); + } + if (!"CAL_PERSONAL".equals(calendarType) && UtilValidate.isNotEmpty(fixedAssetId)) { + // Get "new style" work efforts + tempWorkEfforts.addAll(EntityUtil.filterByDate(delegator.findList("WorkEffortAndFixedAssetAssign", eclTotal, null, orderByList, null, false))); } + validWorkEfforts = WorkEffortWorker.removeDuplicateWorkEfforts(tempWorkEfforts); + } catch (GenericEntityException e) { + Debug.logWarning(e, module); } // Split the WorkEffort list into a map with entries for each period, period start is the key Modified: ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/CreateUrlParam.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/CreateUrlParam.groovy?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/CreateUrlParam.groovy (original) +++ ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/CreateUrlParam.groovy Wed Mar 24 09:23:07 2010 @@ -21,20 +21,37 @@ facilityId = parameters.facilityId; fixedAssetId = parameters.fixedAssetId; partyId = parameters.partyId; workEffortTypeId = parameters.workEffortTypeId; - -urlParam = null; +calendarType = parameters.calendarType; + +urlParam = ""; if (facilityId) { urlParam = "facilityId=" + facilityId; } if (fixedAssetId) { - urlParam = "fixedAssetId=" + fixedAssetId; + if (urlParam) { + urlParam = urlParam + "&"; + } + urlParam = urlParam + "fixedAssetId=" + fixedAssetId; } if (partyId) { - urlParam = "partyId=" + partyId; + if (urlParam) { + urlParam = urlParam + "&"; + } + urlParam = urlParam + "partyId=" + partyId; } if (workEffortTypeId) { - urlParam = "workEffortTypeId=" + workEffortTypeId; + if (urlParam) { + urlParam = urlParam + "&"; + } + urlParam = urlParam + "workEffortTypeId=" + workEffortTypeId; +} + +if (calendarType) { + if (urlParam) { + urlParam = urlParam + "&"; + } + urlParam = urlParam + "calendarType=" + calendarType; } if (urlParam) { Modified: ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Days.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Days.groovy?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Days.groovy (original) +++ ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Days.groovy Wed Mar 24 09:23:07 2010 @@ -31,6 +31,7 @@ facilityId = parameters.facilityId; fixedAssetId = parameters.fixedAssetId; partyId = parameters.partyId; workEffortTypeId = parameters.workEffortTypeId; +calendarType = parameters.calendarType; entityExprList = context.entityExprList; Timestamp start = null; @@ -49,7 +50,7 @@ Timestamp next = UtilDateTime.getDayStar context.nextMillis = new Long(next.getTime()).toString(); Map serviceCtx = UtilMisc.toMap("userLogin", userLogin,"start",start,"numPeriods",new Integer(24),"periodType",new Integer(Calendar.HOUR)); -serviceCtx.putAll(UtilMisc.toMap("partyId", partyId, "facilityId", facilityId, "fixedAssetId", fixedAssetId, "workEffortTypeId", workEffortTypeId, "locale", locale, "timeZone", timeZone)); +serviceCtx.putAll(UtilMisc.toMap("partyId", partyId, "facilityId", facilityId, "fixedAssetId", fixedAssetId, "workEffortTypeId", workEffortTypeId, "calendarType", calendarType, "locale", locale, "timeZone", timeZone)); if (entityExprList) { serviceCtx.putAll(["entityExprList" : entityExprList]); } Modified: ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy (original) +++ ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Month.groovy Wed Mar 24 09:23:07 2010 @@ -32,6 +32,7 @@ facilityId = parameters.facilityId; fixedAssetId = parameters.fixedAssetId; partyId = parameters.partyId; workEffortTypeId = parameters.workEffortTypeId; +calendarType = parameters.calendarType; entityExprList = context.entityExprList; start = null; @@ -75,7 +76,7 @@ if (followingMonthDays < 0) { numDays += followingMonthDays; serviceCtx = UtilMisc.toMap("userLogin", userLogin, "start", getFrom, "numPeriods", new Integer(numDays), "periodType", new Integer(Calendar.DATE)); -serviceCtx.putAll(UtilMisc.toMap("partyId", partyId, "facilityId", facilityId, "fixedAssetId", fixedAssetId, "workEffortTypeId", workEffortTypeId, "locale", locale, "timeZone", timeZone)); +serviceCtx.putAll(UtilMisc.toMap("partyId", partyId, "facilityId", facilityId, "fixedAssetId", fixedAssetId, "workEffortTypeId", workEffortTypeId, "calendarType", calendarType, "locale", locale, "timeZone", timeZone)); if (entityExprList) { serviceCtx.putAll(["entityExprList" : entityExprList]); } Modified: ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Upcoming.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Upcoming.groovy?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Upcoming.groovy (original) +++ ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Upcoming.groovy Wed Mar 24 09:23:07 2010 @@ -28,6 +28,7 @@ facilityId = parameters.get("facilityId" fixedAssetId = parameters.get("fixedAssetId"); partyId = parameters.get("partyId"); workEffortTypeId = parameters.get("workEffortTypeId"); +calendarType = parameters.calendarType; start = nowTimestamp.clone(); eventsParam = ""; if (facilityId != null) { @@ -44,7 +45,7 @@ if (workEffortTypeId != null) { } Map serviceCtx = UtilMisc.toMap("userLogin", userLogin, "start", start, "numPeriods", new Integer(7), "periodType", new Integer(Calendar.DATE)); -serviceCtx.putAll(UtilMisc.toMap("partyId", partyId, "facilityId", facilityId, "fixedAssetId", fixedAssetId, "workEffortTypeId", workEffortTypeId, "locale", locale, "timeZone", timeZone)); +serviceCtx.putAll(UtilMisc.toMap("partyId", partyId, "facilityId", facilityId, "fixedAssetId", fixedAssetId, "workEffortTypeId", workEffortTypeId, "calendarType", calendarType, "locale", locale, "timeZone", timeZone)); Map result = dispatcher.runSync("getWorkEffortEventsByPeriod",serviceCtx); context.put("days", result.get("periods")); Modified: ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Week.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Week.groovy?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Week.groovy (original) +++ ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/WEB-INF/actions/calendar/Week.groovy Wed Mar 24 09:23:07 2010 @@ -32,6 +32,7 @@ facilityId = parameters.facilityId; fixedAssetId = parameters.fixedAssetId; partyId = parameters.partyId; workEffortTypeId = parameters.workEffortTypeId; +calendarType = parameters.calendarType; entityExprList = (List) context.get("entityExprList"); filterOutCanceledEvents = parameters.filterOutCanceledEvents; if (!filterOutCanceledEvents) { @@ -58,7 +59,7 @@ Timestamp end = UtilDateTime.getDayStart Map serviceCtx = UtilMisc.toMap("userLogin", userLogin,"start",start,"numPeriods",new Integer(7), "periodType",new Integer(Calendar.DATE)); serviceCtx.putAll(UtilMisc.toMap("partyId", partyId, "facilityId", facilityId, - "fixedAssetId", fixedAssetId, "workEffortTypeId", workEffortTypeId, + "fixedAssetId", fixedAssetId, "workEffortTypeId", workEffortTypeId, "calendarType", calendarType, "locale", locale, "timeZone", timeZone)); if (entityExprList) { serviceCtx.putAll(["entityExprList" : entityExprList]); Modified: ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/calendar/day.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/calendar/day.ftl?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/calendar/day.ftl (original) +++ ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/calendar/day.ftl Wed Mar 24 09:23:07 2010 @@ -32,7 +32,7 @@ under the License. <#if (nowTimestamp >= period.start) && (nowTimestamp <= period.end)><#assign currentPeriod = true/></#if> <tr<#if currentPeriod> class="current-period"<#else><#if (period.calendarEntries?size > 0)> class="active-period"</#if></#if>> <td class="label"> - ${period.start?time?string.short}<br/> + ${period.start?time?string.short}<br /> <a href="<@ofbizUrl>${parameters._LAST_VIEW_NAME_}?period=day&form=edit&parentTypeId=${parentTypeId?if_exists}&start=${parameters.start?if_exists}¤tStatusId=CAL_TENTATIVE&estimatedStartDate=${period.start?string("yyyy-MM-dd HH:mm:ss")}&estimatedCompletionDate=${period.end?string("yyyy-MM-dd HH:mm:ss")}${urlParam?if_exists}${addlParam?if_exists}</@ofbizUrl>">${uiLabelMap.CommonAddNew}</a> </td> <#list period.calendarEntries as calEntry> @@ -68,7 +68,7 @@ under the License. <#else> ${startDate?time?string.short}-${completionDate?time?string.short} </#if> - <br/> + <br /> ${setRequestAttribute("periodType", "day")} ${setRequestAttribute("workEffortId", calEntry.workEffort.workEffortId)} ${screens.render("component://workeffort/widget/CalendarScreens.xml#calendarEventContent")} Modified: ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/calendar/month.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/calendar/month.ftl?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/calendar/month.ftl (original) +++ ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/calendar/month.ftl Wed Mar 24 09:23:07 2010 @@ -71,7 +71,7 @@ height: auto; <#if !completionDate?has_content && calEntry.workEffort.estimatedMilliSeconds?has_content> <#assign completionDate = calEntry.workEffort.estimatedStartDate + calEntry.workEffort.estimatedMilliSeconds> </#if> - <hr/> + <hr /> <#if (startDate.compareTo(period.start) <= 0 && completionDate?has_content && completionDate.compareTo(period.end) >= 0)> ${uiLabelMap.CommonAllDay} <#elseif startDate.before(period.start) && completionDate?has_content> @@ -83,11 +83,11 @@ height: auto; <#else> ${startDate?time?string.short}-${completionDate?time?string.short} </#if> - <br/> + <br /> ${setRequestAttribute("periodType", "month")} ${setRequestAttribute("workEffortId", calEntry.workEffort.workEffortId)} ${screens.render("component://workeffort/widget/CalendarScreens.xml#calendarEventContent")} - <br/> + <br /> </#list> </td> @@ -112,7 +112,7 @@ height: auto; <#else> ${calEntry.workEffort.estimatedStartDate?time?string.short}-${calEntry.workEffort.estimatedCompletionDate?time?string.short} </#if> - <br/> + <br /> <a href="<@ofbizUrl>WorkEffortSummary?workEffortId=${calEntry.workEffort.workEffortId}${addlParam?if_exists}</@ofbizUrl>" class="event">${calEntry.workEffort.workEffortName?default("Undefined")}</a> </td> </tr> Modified: ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/calendar/upcoming.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/calendar/upcoming.ftl?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/calendar/upcoming.ftl (original) +++ ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/calendar/upcoming.ftl Wed Mar 24 09:23:07 2010 @@ -28,7 +28,7 @@ under the License. <#list days as day> <#assign workEfforts = day.calendarEntries> <#if workEfforts?has_content> - <tr class="header-row"><th colspan="4"><hr/></th></tr> + <tr class="header-row"><th colspan="4"><hr /></th></tr> <#assign alt_row = false> <#list workEfforts as calendarEntry> <#assign workEffort = calendarEntry.workEffort> Modified: ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/calendar/week.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/calendar/week.ftl?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/calendar/week.ftl (original) +++ ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/calendar/week.ftl Wed Mar 24 09:23:07 2010 @@ -32,7 +32,7 @@ under the License. <#if (nowTimestamp >= period.start) && (nowTimestamp <= period.end)><#assign currentPeriod = true/></#if> <tr<#if currentPeriod> class="current-period"<#else><#if (period.calendarEntries?size > 0)> class="active-period"</#if></#if>> <td class="centered" width="1%"> - <a href="<@ofbizUrl>${parameters._LAST_VIEW_NAME_}?period=day&start=${period.start.time?string("#")}${urlParam?if_exists}${addlParam?if_exists}</@ofbizUrl>">${period.start?date?string("EEEE")?cap_first} ${period.start?date?string.short}</a><br/> + <a href="<@ofbizUrl>${parameters._LAST_VIEW_NAME_}?period=day&start=${period.start.time?string("#")}${urlParam?if_exists}${addlParam?if_exists}</@ofbizUrl>">${period.start?date?string("EEEE")?cap_first} ${period.start?date?string.short}</a><br /> <a href="<@ofbizUrl>${parameters._LAST_VIEW_NAME_}?period=week&form=edit&start=${parameters.start?if_exists}&parentTypeId=${parentTypeId?if_exists}¤tStatusId=CAL_TENTATIVE&estimatedStartDate=${period.start?string("yyyy-MM-dd HH:mm:ss")}&estimatedCompletionDate=${period.end?string("yyyy-MM-dd HH:mm:ss")}${addlParam?if_exists}${urlParam?if_exists}</@ofbizUrl>">${uiLabelMap.CommonAddNew}</a> </td> <#list period.calendarEntries as calEntry> @@ -70,7 +70,7 @@ under the License. <#else> ${startDate?time?string.short}-${completionDate?time?string.short} </#if> - <br/> + <br /> ${setRequestAttribute("periodType", "week")} ${setRequestAttribute("workEffortId", calEntry.workEffort.workEffortId)} ${screens.render("component://workeffort/widget/CalendarScreens.xml#calendarEventContent")} Modified: ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/find/WorkEffortSearchResults.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/find/WorkEffortSearchResults.ftl?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/find/WorkEffortSearchResults.ftl (original) +++ ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/find/WorkEffortSearchResults.ftl Wed Mar 24 09:23:07 2010 @@ -28,7 +28,7 @@ under the License. <div><a href="<@ofbizUrl>WorkEffortSearchOptions</@ofbizUrl>" class="buttontext">${uiLabelMap.CommonRefineSearch}</a></div> <#if !workEffortIds?has_content> - <br/><h2> ${uiLabelMap.ProductNoResultsFound}.</h2> + <br /><h2> ${uiLabelMap.ProductNoResultsFound}.</h2> </#if> <#if workEffortIds?has_content> Modified: ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/main.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/main.ftl?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/main.ftl (original) +++ ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/main.ftl Wed Mar 24 09:23:07 2010 @@ -27,7 +27,7 @@ under the License. <div class="screenlet-body"> <#if !userLogin?has_content> <div>${uiLabelMap.WorkEffortInterestingSure}.</div> - <br/> + <br /> </#if> <div class="label">${uiLabelMap.WorkEffortApplicationEventsTasksWorkflowActivities}.</div> </div> Modified: ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/task/mytasks.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/task/mytasks.ftl?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/task/mytasks.ftl (original) +++ ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/task/mytasks.ftl Wed Mar 24 09:23:07 2010 @@ -21,7 +21,7 @@ under the License. <a href="<@ofbizUrl>EditWorkEffort?workEffortTypeId=TASK&currentStatusId=CAL_NEEDS_ACTION</@ofbizUrl>" class="buttontext create">${uiLabelMap.WorkEffortNewTask}</a> </div> <h2>${uiLabelMap.WorkEffortAssignedTasks}</h2> - <br/> + <br /> <table class="basic-table hover-bar" cellspacing="0"> <tr class="header-row-2"> <td>${uiLabelMap.CommonStartDateTime}</td> @@ -42,7 +42,7 @@ under the License. </table> <#if (activities.size() > 0)> <h2>${uiLabelMap.WorkEffortWorkflowActivitiesUser}</h2> - <br/> + <br /> <table class="basic-table hover-bar" cellspacing="0"> <tr class="header-row-2"> <td>${uiLabelMap.CommonStartDateTime}</td> @@ -72,7 +72,7 @@ under the License. </#if> <#if (roleActivities.size() > 0)> <h2>${uiLabelMap.WorkEffortWorkflowActivitiesUserRole}</h2> - <br/> + <br /> <table class="basic-table hover-bar" cellspacing="0"> <tr class="header-row-2"> <td>${uiLabelMap.CommonStartDateTime}</td> @@ -102,7 +102,7 @@ under the License. </#if> <#if (groupActivities.size() > 0)> <h2>${uiLabelMap.WorkEffortWorkflowActivitiesUserGroup}</h2> - <br/> + <br /> <table class="basic-table hover-bar" cellspacing="0"> <tr class="header-row-2"> <td>${uiLabelMap.CommonStartDateTime}</td> Modified: ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/workeffort/EventReminderEmail.ftl URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/workeffort/EventReminderEmail.ftl?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/workeffort/EventReminderEmail.ftl (original) +++ ofbiz/branches/multitenant20100310/applications/workeffort/webapp/workeffort/workeffort/EventReminderEmail.ftl Wed Mar 24 09:23:07 2010 @@ -47,7 +47,7 @@ under the License. <tr><td class="label">${uiLabelMap.CommonType}</td><td>${(workEffortType.description)?default(" ")}</td></tr> <tr><td class="label">${uiLabelMap.CommonPurpose}</td><td>${(workEffortPurposeType.description)?default(" ")}</td></tr> <tr><td class="label">${uiLabelMap.CommonStatus}</td><td>${(currentStatusItem.description)?default(" ")}</td></tr> - <tr><td colspan="2"><hr/></td> + <tr><td colspan="2"><hr /></td> </table> <#if partyAssignments?has_content> <div><b>${uiLabelMap.PageTitleListWorkEffortPartyAssigns}</b></div> Modified: ofbiz/branches/multitenant20100310/applications/workeffort/widget/CalendarForms.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/workeffort/widget/CalendarForms.xml?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/workeffort/widget/CalendarForms.xml (original) +++ ofbiz/branches/multitenant20100310/applications/workeffort/widget/CalendarForms.xml Wed Mar 24 09:23:07 2010 @@ -20,6 +20,41 @@ under the License. <forms xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-form.xsd"> + <form name="FilterCalendarEvents" type="single" target="calendar"> + <field name="calendarType"> + <drop-down allow-empty="false"> + <entity-options entity-name="Enumeration" key-field-name="enumId" description="${description}"> + <entity-constraint name="enumTypeId" value="CALENDAR_TYPE"/> + <entity-order-by field-name="sequenceId"/> + </entity-options> + </drop-down> + </field> + <field name="partyId"> + <lookup target-form-name="LookupPartyName" size="16"/> + </field> + <field name="workEffortTypeId"> + <drop-down allow-empty="true"> + <entity-options entity-name="WorkEffortType" description="${description}"> + <entity-order-by field-name="description"/> + </entity-options> + </drop-down> + </field> + <field name="facilityId"> + <drop-down allow-empty="true"> + <entity-options entity-name="Facility" description="${facilityName}"> + <entity-order-by field-name="facilityName"/> + </entity-options> + </drop-down> + </field> + <field name="fixedAssetId"> + <drop-down allow-empty="true"> + <entity-options entity-name="FixedAsset" description="${fixedAssetId} - ${fixedAssetName}"> + <entity-order-by field-name="fixedAssetId"/> + </entity-options> + </drop-down> + </field> + <field name="viewButton" title="${uiLabelMap.CommonView}"><submit/></field> + </form> <!-- Forms Specific to portlet --> <form name="EditCalendar" extends="CommonPortletEdit" extends-resource="component://common/widget/PortletEditForms.xml"> <field name="initialView" entry-name="attributeMap.initialView"> Modified: ofbiz/branches/multitenant20100310/applications/workeffort/widget/CommonScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/applications/workeffort/widget/CommonScreens.xml?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/applications/workeffort/widget/CommonScreens.xml (original) +++ ofbiz/branches/multitenant20100310/applications/workeffort/widget/CommonScreens.xml Wed Mar 24 09:23:07 2010 @@ -147,22 +147,17 @@ under the License. <if-has-permission permission="WORKEFFORTMGR" action="_VIEW"/> </condition> <actions> - <entity-condition entity-name="Facility" list="allFacilities"> - <order-by field-name="facilityName"/> - </entity-condition> - <entity-condition entity-name="FixedAsset" list="allFixedAssets"> - <order-by field-name="fixedAssetId"/> - </entity-condition> - <entity-condition entity-name="WorkEffortType" list="allWorkEffortTypes"> - <order-by field-name="description"/> - </entity-condition> <script location="component://workeffort/webapp/workeffort/WEB-INF/actions/calendar/Days.groovy"/> </actions> <widgets> - <platform-specific> - <html><html-template location="component://workeffort/webapp/workeffort/calendar/eventsByForms.ftl"/></html> - </platform-specific> - <decorator-section-include name="body"/> + <decorator-screen name="FindScreenDecorator" location="component://common/widget/CommonScreens.xml"> + <decorator-section name="search-options"> + <include-form name="FilterCalendarEvents" location="component://workeffort/widget/CalendarForms.xml"/> + </decorator-section> + <decorator-section name="search-results"> + <decorator-section-include name="body"/> + </decorator-section> + </decorator-screen> </widgets> <fail-widgets> <label style="h3">${uiLabelMap.WorkEffortViewPermissionError}</label> Modified: ofbiz/branches/multitenant20100310/build.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/build.xml?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/build.xml (original) +++ ofbiz/branches/multitenant20100310/build.xml Wed Mar 24 09:23:07 2010 @@ -23,6 +23,7 @@ under the License. <property name="site.dir" value="../site"/> <property name="memory.initial.param" value="-Xms128M"/> <property name="memory.max.param" value="-Xmx512M"/> + <property name="pos.memory.max.param" value="-Xmx512M"/> <property name="memory.maxpermsize.param" value="-XX:MaxPermSize=128m"/> <available file="applications/build.xml" property="applications.present"/> @@ -327,7 +328,7 @@ under the License. description="This will start OFBiz"> <java jar="ofbiz.jar" fork="true"> <jvmarg value="${memory.initial.param}"/> - <jvmarg value="${memory.max.param}"/> + <jvmarg value="${pos.memory.max.param}"/> <jvmarg value="${memory.maxpermsize.param}"/> </java> </target> @@ -472,7 +473,7 @@ under the License. <arg value="-ant"/> </java> </target> - <target name="run-single-test" + <target name="run-single-test" depends="build" description="Run a single test"> <java jar="ofbiz.jar" fork="true" resultproperty="test.result"> <jvmarg value="${memory.initial.param}"/> @@ -495,7 +496,7 @@ under the License. </condition> </fail> </target> - <target name="run-single-test-suite" + <target name="run-single-test-suite" depends="build" description="Run a single test suite"> <java jar="ofbiz.jar" fork="true" resultproperty="test.result"> <jvmarg value="${memory.initial.param}"/> @@ -568,7 +569,7 @@ under the License. <equals arg1="${component-name}" arg2="" casesensitive="false" trim="yes"/> </condition> </fail> - <fail message="Resource name is mandatory"> + <fail message="Resource name is mandatory"> <condition> <equals arg1="${component-resource-name}" arg2="" casesensitive="false" trim="yes"/> </condition> @@ -583,7 +584,7 @@ under the License. <equals arg1="${base-permission}" arg2="" casesensitive="false" trim="yes"/> </condition> </fail> - <filterset id="replacePlaceholders"> + <filterset id="replacePlaceholders"> <filter token="component-name" value="${component-name}"/> <filter token="component-resource-name" value="${component-resource-name}"/> <filter token="base-permission" value="${base-permission}"/> Modified: ofbiz/branches/multitenant20100310/framework/base/build.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/framework/base/build.xml?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/framework/base/build.xml (original) +++ ofbiz/branches/multitenant20100310/framework/base/build.xml Wed Mar 24 09:23:07 2010 @@ -56,6 +56,7 @@ under the License. <file name="org/ofbiz/base/util/collections/test/GenericMapTest.java"/> <file name="org/ofbiz/base/concurrent/test/SyncTTLObjectTest.java"/> <file name="org/ofbiz/base/concurrent/test/AsyncTTLObjectTest.java"/> + <file name="org/ofbiz/base/concurrent/test/TTLCachedObjectTest.java"/> </filelist> <target name="init"> Modified: ofbiz/branches/multitenant20100310/framework/base/config/log4j.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/framework/base/config/log4j.xml?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/framework/base/config/log4j.xml (original) +++ ofbiz/branches/multitenant20100310/framework/base/config/log4j.xml Wed Mar 24 09:23:07 2010 @@ -137,15 +137,27 @@ </layout> </appender> + <category name="org.ofbiz.base.converter.Converters"> + <priority value="warn"/> + </category> + <category name="org.apache.catalina"> <priority value="warn"/> </category> + <category name="org.apache.commons.digester"> + <priority value="warn"/> + </category> + <!-- log4j category --> <category name="org.apache.log4j"> <priority value="warn"/> </category> + <category name="org.apache.tomcat"> + <priority value="warn"/> + </category> + <!-- log minerva to the special log > <category name="org.ofbiz.minerva"> <priority value="warn"/> Modified: ofbiz/branches/multitenant20100310/framework/base/dtd/ofbiz-component.xsd URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/framework/base/dtd/ofbiz-component.xsd?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/framework/base/dtd/ofbiz-component.xsd (original) +++ ofbiz/branches/multitenant20100310/framework/base/dtd/ofbiz-component.xsd Wed Mar 24 09:23:07 2010 @@ -252,6 +252,6 @@ under the License. <service-resource type="group" loader="maincomponent" location="service/groups_test.xml"/> <service-resource type="eca" loader="maincomponent" location="service/secas_test.xml"/> - <webapp name="webtools" title="WebTools" server="default" location="webtools" mount-point="/webtools"/> + <webapp name="webtools" title="WebTools" server="default" location="webtools" mount-point="/webtools"/> </ofbiz-component> --> Modified: ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/ExecutionPool.java URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/ExecutionPool.java?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/ExecutionPool.java (original) +++ ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/ExecutionPool.java Wed Mar 24 09:23:07 2010 @@ -27,6 +27,9 @@ import java.util.concurrent.ScheduledThr import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; +import org.ofbiz.base.lang.SourceMonitor; + +@SourceMonitor("Adam Heath") public final class ExecutionPool { protected static class ExecutionPoolThreadFactory implements ThreadFactory { private final String namePrefix; @@ -78,12 +81,14 @@ public final class ExecutionPool { delayQueue.remove(pulse); } - public static void pulseAll() { + public static void pulseAll(Class<? extends Pulse> match) { Iterator<Pulse> it = delayQueue.iterator(); while (it.hasNext()) { Pulse pulse = it.next(); - it.remove(); - pulse.run(); + if (match.isInstance(pulse)) { + it.remove(); + pulse.run(); + } } } @@ -113,18 +118,24 @@ public final class ExecutionPool { } public static abstract class Pulse implements Delayed, Runnable { - protected final long expireTime; + protected final long expireTimeNanos; + protected final long loadTimeNanos; + + protected Pulse(long delayNanos) { + this(System.nanoTime(), delayNanos); + } - protected Pulse(long delayInMillis) { - expireTime = System.nanoTime() + TimeUnit.NANOSECONDS.convert(delayInMillis, TimeUnit.MILLISECONDS); + protected Pulse(long loadTimeNanos, long delayNanos) { + this.loadTimeNanos = loadTimeNanos; + expireTimeNanos = loadTimeNanos + delayNanos; } public final long getDelay(TimeUnit unit) { - return unit.convert(expireTime - System.nanoTime(), TimeUnit.NANOSECONDS); + return unit.convert(expireTimeNanos - System.nanoTime(), TimeUnit.NANOSECONDS); } public final int compareTo(Delayed other) { - long r = (expireTime - ((Pulse) other).expireTime); + long r = (expireTimeNanos - ((Pulse) other).expireTimeNanos); if (r < 0) return -1; if (r > 0) return 1; return 0; Modified: ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java (original) +++ ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/TTLObject.java Wed Mar 24 09:23:07 2010 @@ -25,12 +25,15 @@ import java.util.concurrent.ConcurrentHa import java.util.concurrent.ExecutionException; import java.util.concurrent.FutureTask; import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; -import org.ofbiz.base.util.ObjectWrapper; +import org.ofbiz.base.lang.SourceMonitor; +import org.ofbiz.base.lang.ObjectWrapper; import org.ofbiz.base.util.UtilIO; +@SourceMonitor("Adam Heath") public abstract class TTLObject<T> implements ObjectWrapper<T> { private static final ScheduledExecutorService updateExecutor = ExecutionPool.getNewOptimalExecutor("TTLObject(async-update)"); @@ -77,10 +80,10 @@ public abstract class TTLObject<T> imple } public static void pulseAll() { - ExecutionPool.pulseAll(); + ExecutionPool.pulseAll(Pulse.class); } - public enum State { INVALID, REGEN, REGENERATING, GENERATE, GENERATING, GENERATING_INITIAL, VALID, ERROR, ERROR_INITIAL } + public enum State { INVALID, REGEN, REGENERATING, GENERATE, GENERATING, GENERATING_INITIAL, VALID, ERROR, ERROR_INITIAL, SET } private volatile ValueAndState<T> object = new StandardValueAndState<T>(this, null, null, State.INVALID, 0, null, null); private static final AtomicReferenceFieldUpdater<TTLObject, ValueAndState> objectAccessor = AtomicReferenceFieldUpdater.newUpdater(TTLObject.class, ValueAndState.class, "object"); private static final AtomicIntegerFieldUpdater<TTLObject> serialAccessor = AtomicIntegerFieldUpdater.newUpdater(TTLObject.class, "serial"); @@ -109,10 +112,14 @@ public abstract class TTLObject<T> imple return ttlObject.newValueAndState(getValue(), future, nextState, serial, null, null); } - protected ValueAndState<T> valid(T value) throws ObjectException { + protected ValueAndState<T> valid(T value) { return ttlObject.newValueAndState(value, null, State.VALID, serialAccessor.incrementAndGet(ttlObject), null, new Pulse(ttlObject)); } + protected ValueAndState<T> set(T value) { + return ttlObject.newValueAndState(value, null, State.SET, serialAccessor.incrementAndGet(ttlObject), null, null); + } + protected ValueAndState<T> submit(final T oldValue, State state) { return ttlObject.newValueAndState(getValue(), createTask(oldValue), state, serial, null, null); } @@ -125,7 +132,7 @@ public abstract class TTLObject<T> imple }); } - protected ValueAndState<T> error(Throwable t) throws ObjectException { + protected ValueAndState<T> error(Throwable t) { return ttlObject.newValueAndState(null, null, state != State.GENERATING_INITIAL ? State.ERROR : State.ERROR_INITIAL, serialAccessor.incrementAndGet(ttlObject), t, new Pulse(ttlObject)); } } @@ -150,8 +157,8 @@ public abstract class TTLObject<T> imple protected final static class Pulse extends ExecutionPool.Pulse { protected final TTLObject<?> ttlObject; - protected Pulse(TTLObject<?> ttlObject) throws ObjectException { - super(ttlObject.getTTL()); + protected Pulse(TTLObject<?> ttlObject) { + super(TimeUnit.NANOSECONDS.convert(ttlObject.getTTL(), TimeUnit.MILLISECONDS)); this.ttlObject = ttlObject; } @@ -174,29 +181,24 @@ public abstract class TTLObject<T> imple ValueAndState<T> nextContainer = null; do { container = getContainer(); - switch (container.state) { - case INVALID: - nextContainer = container.refresh(State.GENERATE); - break; - case REGENERATING: - nextContainer = container.refresh(State.REGEN); - break; - case GENERATING: - nextContainer = container.refresh(State.GENERATE); - break; - case ERROR_INITIAL: - nextContainer = container.refresh(State.INVALID); - break; - case ERROR: - case VALID: - nextContainer = container.refresh(getForeground() ? State.GENERATE : State.REGEN); - break; - case REGEN: - case GENERATE: - return; + if (container.state == State.INVALID) { + nextContainer = container.refresh(State.GENERATE); + } else if (container.state == State.REGENERATING) { + nextContainer = container.refresh(State.REGEN); + } else if (container.state == State.GENERATING) { + nextContainer = container.refresh(State.GENERATE); + } else if (container.state == State.ERROR_INITIAL) { + nextContainer = container.refresh(State.INVALID); + } else if (container.state == State.ERROR || container.state == State.VALID) { + nextContainer = container.refresh(getForeground() ? State.GENERATE : State.REGEN); + } else if (container.state == State.SET) { + nextContainer = container.refresh(getForeground() ? State.GENERATE : State.REGEN); + } else { + return; } - } while (!objectAccessor.compareAndSet(this, container, nextContainer)); - cancelFuture(container); + objectAccessor.compareAndSet(this, container, nextContainer); + cancelFuture(container); + } while (true); } public final int getSerial() { @@ -207,24 +209,17 @@ public abstract class TTLObject<T> imple return getContainer().serial != serial; } - protected final void setObject(T newObject) throws ObjectException { - ValueAndState<T> container, nextContainer; - State nextState; - do { - container = getContainer(); - nextContainer = container.valid(newObject); - } while (!objectAccessor.compareAndSet(this, container, nextContainer)); + protected final void setObject(T newObject) { + ValueAndState<T> container = getContainer(); + ValueAndState<T> nextContainer = container.set(newObject); + objectAccessor.compareAndSet(this, container, nextContainer); cancelFuture(container); - ExecutionPool.addPulse(nextContainer.pulse); } private void cancelFuture(ValueAndState<T> container) { ExecutionPool.removePulse(container.pulse); - switch (container.state) { - case REGENERATING: - case GENERATING: - container.future.cancel(false); - break; + if (container.state == State.REGENERATING || container.state == State.GENERATING) { + container.future.cancel(false); } } @@ -235,53 +230,42 @@ public abstract class TTLObject<T> imple do { do { container = getContainer(); - switch (container.state) { - case ERROR: - case ERROR_INITIAL: - throw container.t; - case VALID: - return container.getValue(); - case INVALID: - nextContainer = container.submit(getInitial(), State.GENERATING_INITIAL); - break; - case REGENERATING: - if (!container.future.isDone()) { + if (container.state == State.ERROR || container.state == State.ERROR_INITIAL) { + throw container.t; + } else if (container.state == State.VALID) { + return container.getValue(); + } else if (container.state == State.INVALID) { + nextContainer = container.submit(getInitial(), State.GENERATING_INITIAL); + } else if (container.state == State.SET) { + nextContainer = container.valid(container.getValue()); + } else if (container.state == State.REGENERATING || container.state == State.GENERATING || container.state == State.GENERATING_INITIAL) { + if (!container.future.isDone()) { + if (container.state == State.GENERATING || container.state == State.GENERATING_INITIAL) { + container.future.run(); + } else { return container.getValue(); } - case GENERATING: - case GENERATING_INITIAL: + } + try { try { - try { - nextContainer = container.valid(container.future.get()); - } catch (ExecutionException e) { - throw e.getCause(); - } - } catch (Throwable t) { - nextContainer = container.error(t); + nextContainer = container.valid(container.future.get()); + } catch (ExecutionException e) { + throw e.getCause(); } - break; - case REGEN: - nextContainer = container.submit(container.getValue(), State.REGENERATING); - break; - case GENERATE: - nextContainer = container.submit(container.getValue(), State.GENERATING); - break; + } catch (Throwable t) { + nextContainer = container.error(t); + } + } else if (container.state == State.REGEN) { + nextContainer = container.submit(container.getValue(), State.REGENERATING); + } else { + nextContainer = container.submit(container.getValue(), State.GENERATING); } } while (!objectAccessor.compareAndSet(this, container, nextContainer)); - switch (nextContainer.state) { - case GENERATING: - case GENERATING_INITIAL: - nextContainer.future.run(); - break; - case REGENERATING: - updateExecutor.submit(nextContainer.future); - break; - case ERROR_INITIAL: - case ERROR: - case VALID: - ExecutionPool.removePulse(container.pulse); - ExecutionPool.addPulse(nextContainer.pulse); - break; + if (nextContainer.state == State.REGENERATING) { + updateExecutor.submit(nextContainer.future); + } else if (nextContainer.pulse != null) { + ExecutionPool.removePulse(container.pulse); + ExecutionPool.addPulse(nextContainer.pulse); } } while (true); } catch (Throwable e) { Modified: ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/test/AsyncTTLObjectTest.java URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/test/AsyncTTLObjectTest.java?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/test/AsyncTTLObjectTest.java (original) +++ ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/test/AsyncTTLObjectTest.java Wed Mar 24 09:23:07 2010 @@ -22,8 +22,10 @@ import java.util.concurrent.Callable; import java.util.concurrent.Future; import org.ofbiz.base.concurrent.TTLObject; +import org.ofbiz.base.lang.SourceMonitor; import org.ofbiz.base.test.GenericTestCaseBase; +@SourceMonitor("Adam Heath") public class AsyncTTLObjectTest extends TTLObjectTest { public AsyncTTLObjectTest(String name) { super(name, false); @@ -69,6 +71,16 @@ public class AsyncTTLObjectTest extends assertGetObject("Refreshed with old data", "b", 3, 0, 100000000); Thread.sleep(350); assertGetObject("Refreshed with old data", "4", 5, 0, 100000000); + object.set("5"); + assertGetObject("set new data", "5", 5, 0, 100000000); + TTLObject.pulseAll(); + sleepTime = 200; + loadData = "c"; + object.set("5"); + object.refresh(); + assertGetObject("refresh after set", "5", 5, 0, 100000000); + Thread.sleep(300); + assertGetObject("refresh after set", "c", 6, 0, 100000000); } public void testSet() throws Exception { Modified: ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/test/SyncTTLObjectTest.java URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/test/SyncTTLObjectTest.java?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/test/SyncTTLObjectTest.java (original) +++ ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/test/SyncTTLObjectTest.java Wed Mar 24 09:23:07 2010 @@ -22,13 +22,53 @@ import java.util.concurrent.Callable; import java.util.concurrent.Future; import org.ofbiz.base.concurrent.TTLObject; +import org.ofbiz.base.lang.SourceMonitor; +import org.ofbiz.base.lang.ObjectWrapper; import org.ofbiz.base.test.GenericTestCaseBase; +@SourceMonitor("Adam Heath") public class SyncTTLObjectTest extends TTLObjectTest { public SyncTTLObjectTest(String name) { super(name, true); } + private static class TTLStaticRegistryObject extends TTLObject<String> { + protected String load(String old, int serial) { + return old; + } + } + + public void testTTLStaticRegistries() throws Exception { + ObjectWrapper.ConfigurationException caught = null; + try { + TTLObject.getTTLForClass(TTLStaticRegistryObject.class); + } catch (ObjectWrapper.ConfigurationException e) { + caught = e; + } finally { + assertNotNull("no ttl set", caught); + } + TTLObject.setDefaultTTLForClass(TTLStaticRegistryObject.class, 100); + assertEquals("ttl default", 100, TTLObject.getTTLForClass(TTLStaticRegistryObject.class)); + TTLObject.setDefaultTTLForClass(TTLStaticRegistryObject.class, 200); + assertEquals("can't override ttl default", 100, TTLObject.getTTLForClass(TTLStaticRegistryObject.class)); + TTLObject.setTTLForClass(TTLStaticRegistryObject.class, 200); + assertEquals("change ttl", 200, TTLObject.getTTLForClass(TTLStaticRegistryObject.class)); + TTLObject.setTTLForClass(TTLStaticRegistryObject.class, 300); + assertEquals("change ttl", 300, TTLObject.getTTLForClass(TTLStaticRegistryObject.class)); + caught = null; + assertTrue("default foreground", TTLObject.getForegroundForClass(TTLStaticRegistryObject.class)); + TTLObject.setDefaultForegroundForClass(TTLStaticRegistryObject.class, false); + assertFalse("set foreground", TTLObject.getForegroundForClass(TTLStaticRegistryObject.class)); + TTLObject.setDefaultForegroundForClass(TTLStaticRegistryObject.class, true); + assertFalse("can't override foreground", TTLObject.getForegroundForClass(TTLStaticRegistryObject.class)); + TTLObject.setForegroundForClass(TTLStaticRegistryObject.class, true); + assertTrue("set foreground true", TTLObject.getForegroundForClass(TTLStaticRegistryObject.class)); + TTLObject.setForegroundForClass(TTLStaticRegistryObject.class, false); + assertFalse("set foreground false", TTLObject.getForegroundForClass(TTLStaticRegistryObject.class)); + // this is only to cause coverage to be 100% + new TTLStaticRegistryObject().getObject(); + } + public void testRefresh() throws Exception { assertEquals("state:invalid", TTLObject.State.INVALID, object.getState()); assertEquals("no dones", 0, doneCount.get()); @@ -87,6 +127,13 @@ public class SyncTTLObjectTest extends T assertEquals("two dones", 3, doneCount.get()); object.getObject(); assertEquals("two dones", 4, doneCount.get()); + object.set("one"); + assertEquals("one", "one", object.getObject()); + assertEquals("two dones", 4, doneCount.get()); + object.set("two"); + object.refresh(); + assertEquals("two", (String) null, object.getObject()); + assertEquals("two dones", 5, doneCount.get()); } public void testGetTTL() throws Exception { @@ -138,6 +185,13 @@ public class SyncTTLObjectTest extends T } }, 50); assertGetObject("Refreshed with old data", "4", 5, 0, 100000000); + object.refresh(); + loadData = "5"; + assertGetObject("syncing after refresh", "5", 6, 0, 100000000); + loadData = "6"; + assertGetObject("no load after refresh", "5", 6, 0, 100000000); + TTLObject.pulseAll(); + assertGetObject("new data after pulse all", "6", 7, 0, 100000000); } public void testSetGetAbort() throws Exception { Modified: ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/test/TTLObjectTest.java URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/test/TTLObjectTest.java?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/test/TTLObjectTest.java (original) +++ ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/concurrent/test/TTLObjectTest.java Wed Mar 24 09:23:07 2010 @@ -29,8 +29,10 @@ import java.util.concurrent.atomic.Atomi import org.ofbiz.base.concurrent.ExecutionPool; import org.ofbiz.base.concurrent.TTLObject; +import org.ofbiz.base.lang.SourceMonitor; import org.ofbiz.base.test.GenericTestCaseBase; +@SourceMonitor("Adam Heath") public abstract class TTLObjectTest extends GenericTestCaseBase { static { TTLObject.setDefaultTTLForClass(TTLObjectTestTTLObject.class, 100); @@ -113,10 +115,8 @@ public abstract class TTLObjectTest exte Thread.sleep(10); if (checkSerial(serial)) break; } - Thrower thrower; - do { - thrower = (Thrower) throwException.get(); - } while (!throwException.compareAndSet(thrower, null)); + Thrower thrower = throwException.get(); + throwException.compareAndSet(thrower, null); if (thrower != null) { thrower.throwException(); } Modified: ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/conversion/Converters.java URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/conversion/Converters.java?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/conversion/Converters.java (original) +++ ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/conversion/Converters.java Wed Mar 24 09:23:07 2010 @@ -25,23 +25,19 @@ import java.util.ServiceLoader; import javolution.util.FastMap; import javolution.util.FastSet; +import org.ofbiz.base.lang.SourceMonitor; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.ObjectType; import org.ofbiz.base.util.UtilGenerics; /** A <code>Converter</code> factory and repository. */ +@SourceMonitor("Adam Heath") public class Converters { protected static final String module = Converters.class.getName(); protected static final String DELIMITER = "->"; protected static final FastMap<String, Converter<?, ?>> converterMap = FastMap.newInstance(); protected static final FastSet<ConverterCreator> creators = FastSet.newInstance(); protected static final FastSet<String> noConversions = FastSet.newInstance(); - /** Null converter used when the source and target java object - * types are the same. The <code>convert</code> method returns the - * source object. - * - */ - public static final Converter<Object, Object> nullConverter = new NullConverter(); static { converterMap.setShared(true); @@ -178,49 +174,10 @@ OUTER: sb.append("<null>"); } sb.append(DELIMITER); - if (targetClass != null) { - sb.append(targetClass.getName()); - } else { - sb.append("<null>"); - } + sb.append(targetClass.getName()); String key = sb.toString(); if (converterMap.putIfAbsent(key, converter) == null) { - if (Debug.verboseOn()) { - Debug.logVerbose("Registered converter " + converter.getClass().getName(), module); - } - } - } - - /** Null converter used when the source and target java object - * types are the same. The <code>convert</code> method returns the - * source object. - * - */ - protected static class NullConverter implements Converter<Object, Object> { - public NullConverter() { - } - - public boolean canConvert(Class<?> sourceClass, Class<?> targetClass) { - if (sourceClass.getName().equals(targetClass.getName()) || "java.lang.Object".equals(targetClass.getName())) { - return true; - } - return ObjectType.instanceOf(sourceClass, targetClass); - } - - public Object convert(Object obj) throws ConversionException { - return obj; - } - - public Object convert(Class<? extends Object> targetClass, Object obj) throws ConversionException { - return obj; - } - - public Class<?> getSourceClass() { - return Object.class; - } - - public Class<?> getTargetClass() { - return Object.class; + Debug.logVerbose("Registered converter " + converter.getClass().getName(), module); } } @@ -229,7 +186,7 @@ OUTER: } public <S, T> Converter<S, T> createConverter(Class<S> sourceClass, Class<T> targetClass) { - if (sourceClass == targetClass || targetClass == Object.class || ObjectType.instanceOf(sourceClass, targetClass)) { + if (ObjectType.instanceOf(sourceClass, targetClass)) { return new PassThruConverter<S, T>(sourceClass, targetClass); } else { return null; Modified: ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/conversion/MiscConverters.java URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/conversion/MiscConverters.java?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/conversion/MiscConverters.java (original) +++ ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/conversion/MiscConverters.java Wed Mar 24 09:23:07 2010 @@ -114,13 +114,15 @@ public class MiscConverters implements C } public String convert(Clob obj) throws ConversionException { - char[] charBuffer = null; + StringBuilder strBuf = new StringBuilder(); + char[] inCharBuffer = new char[CHAR_BUFFER_SIZE]; + int charsRead = 0; Reader clobReader = null; try { - int clobLength = (int) obj.length(); - charBuffer = new char[clobLength]; - clobReader = obj.getCharacterStream(); - clobReader.read(charBuffer, 0, clobLength); + clobReader = obj.getCharacterStream(); + while ((charsRead = clobReader.read(inCharBuffer, 0, CHAR_BUFFER_SIZE)) > 0) { + strBuf.append(inCharBuffer, 0, charsRead); + } } catch (Exception e) { throw new ConversionException(e); } @@ -131,7 +133,7 @@ public class MiscConverters implements C } catch (IOException e) {} } } - return new String(charBuffer); + return strBuf.toString(); } } @@ -336,12 +338,17 @@ public class MiscConverters implements C } } - public static class NotAConverter { - protected NotAConverter() { + public static class NotAConverter_Helper { + protected NotAConverter_Helper() { throw new Error("Should not be loaded"); } } + public static class NotAConverter { + public NotAConverter() { + } + } + public void loadConverters() { Converters.loadContainedConverters(MiscConverters.class); } Modified: ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/conversion/test/DateTimeTests.java URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/conversion/test/DateTimeTests.java?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/conversion/test/DateTimeTests.java (original) +++ ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/conversion/test/DateTimeTests.java Wed Mar 24 09:23:07 2010 @@ -20,9 +20,11 @@ package org.ofbiz.base.conversion.test; import org.ofbiz.base.conversion.Converter; import org.ofbiz.base.conversion.DateTimeConverters; +import org.ofbiz.base.lang.SourceMonitor; import org.ofbiz.base.test.GenericTestCaseBase; import org.ofbiz.base.util.UtilGenerics; +@SourceMonitor("Adam Heath") public class DateTimeTests extends GenericTestCaseBase { public DateTimeTests(String name) { Modified: ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/conversion/test/MiscTests.java URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/conversion/test/MiscTests.java?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/conversion/test/MiscTests.java (original) +++ ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/conversion/test/MiscTests.java Wed Mar 24 09:23:07 2010 @@ -33,13 +33,16 @@ import javolution.util.FastMap; import org.ofbiz.base.concurrent.TTLObject; import org.ofbiz.base.conversion.Converter; +import org.ofbiz.base.conversion.ConverterLoader; import org.ofbiz.base.conversion.Converters; import org.ofbiz.base.conversion.JSONResult; +import org.ofbiz.base.lang.SourceMonitor; import org.ofbiz.base.test.GenericTestCaseBase; import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.collections.LRUMap; +@SourceMonitor("Adam Heath") public class MiscTests extends GenericTestCaseBase { public MiscTests(String name) { @@ -52,6 +55,20 @@ public class MiscTests extends GenericTe assertEquals(label, wanted, converter.convert(UtilGenerics.<S>cast(source)).getResult()); } + public void testStaticHelperClass() throws Exception { + assertStaticHelperClass(Converters.class); + } + + public static class ConverterLoaderImpl implements ConverterLoader { + public void loadConverters() { + throw new RuntimeException(); + } + } + + public void testLoadContainedConvertersIgnoresException() { + Converters.loadContainedConverters(MiscTests.class); + } + public void testExtendsImplements() throws Exception { List<String> arraysList = Arrays.asList("a", "b", "c"); assertConversion("", "[\n \"a\",\n \"b\",\n \"c\"\n]", JSONResult.Indenting.class, arraysList, arraysList.getClass()); @@ -76,7 +93,7 @@ public class MiscTests extends GenericTe Converter<S, ? super S> converter = Converters.getConverter(sourceClass, targetClass); Object result = converter.convert(UtilGenerics.<S>cast(wanted)); assertEquals("pass thru convert", wanted, result); - assertTrue("pass thru exact equals", wanted == result); + assertSame("pass thru exact equals", wanted, result); assertTrue("pass thru can convert wanted", converter.canConvert(wanted.getClass(), targetClass)); assertTrue("pass thru can convert source", converter.canConvert(sourceClass, targetClass)); assertEquals("pass thru source class", wanted.getClass(), converter.getSourceClass()); Modified: ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/json/JSON.jj URL: http://svn.apache.org/viewvc/ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/json/JSON.jj?rev=926987&r1=926986&r2=926987&view=diff ============================================================================== --- ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/json/JSON.jj (original) +++ ofbiz/branches/multitenant20100310/framework/base/src/org/ofbiz/base/json/JSON.jj Wed Mar 24 09:23:07 2010 @@ -56,8 +56,8 @@ public class JSON { public JSON allowResolve(boolean allowResolve) { this.allowResolve = allowResolve; - token_source.SwitchTo(allowResolve ? RESOLVE : DEFAULT); - return this; + token_source.SwitchTo(allowResolve ? RESOLVE : DEFAULT); + return this; } } |
Free forum by Nabble | Edit this page |