|
Author: erwan
Date: Sun May 20 08:34:13 2012 New Revision: 1340639 URL: http://svn.apache.org/viewvc?rev=1340639&view=rev Log: merging 1340445 to 1340637 in portlet widget branch Modified: ofbiz/branches/20120329_portletWidget/ (props changed) ofbiz/branches/20120329_portletWidget/applications/order/script/org/ofbiz/order/customer/CheckoutMapProcs.xml (props changed) ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancialHistory.groovy (props changed) ofbiz/branches/20120329_portletWidget/applications/product/script/org/ofbiz/product/test/InventoryTests.xml (props changed) ofbiz/branches/20120329_portletWidget/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java ofbiz/branches/20120329_portletWidget/framework/common/widget/HelpScreens.xml (props changed) ofbiz/branches/20120329_portletWidget/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java ofbiz/branches/20120329_portletWidget/framework/minilang/dtd/simple-methods-v2.xsd ofbiz/branches/20120329_portletWidget/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java ofbiz/branches/20120329_portletWidget/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java ofbiz/branches/20120329_portletWidget/framework/security/data/PasswordSecurityData.xml (props changed) ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/event/WfsEventHandler.java ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/ftl/FreeMarkerViewHandler.java ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/ftl/FreeMarkerViewRenderer.java ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/view/WfsViewHandler.java ofbiz/branches/20120329_portletWidget/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java ofbiz/branches/20120329_portletWidget/specialpurpose/ebaystore/lib/ (props changed) ofbiz/branches/20120329_portletWidget/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/Facilities.groovy (props changed) ofbiz/branches/20120329_portletWidget/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy (props changed) ofbiz/branches/20120329_portletWidget/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy (props changed) ofbiz/branches/20120329_portletWidget/tools/mergefromtrunk.bat (props changed) ofbiz/branches/20120329_portletWidget/tools/mergefromtrunk.sh (props changed) Propchange: ofbiz/branches/20120329_portletWidget/ ------------------------------------------------------------------------------ Merged /ofbiz/trunk:r1340446-1340637 Propchange: ofbiz/branches/20120329_portletWidget/applications/order/script/org/ofbiz/order/customer/CheckoutMapProcs.xml ------------------------------------------------------------------------------ Merged /ofbiz/trunk/applications/order/script/org/ofbiz/order/customer/CheckoutMapProcs.xml:r1340446-1340637 Propchange: ofbiz/branches/20120329_portletWidget/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancialHistory.groovy ------------------------------------------------------------------------------ Merged /ofbiz/trunk/applications/party/webapp/partymgr/WEB-INF/actions/party/PartyFinancialHistory.groovy:r1340446-1340637 Propchange: ofbiz/branches/20120329_portletWidget/applications/product/script/org/ofbiz/product/test/InventoryTests.xml ------------------------------------------------------------------------------ Merged /ofbiz/trunk/applications/product/script/org/ofbiz/product/test/InventoryTests.xml:r1340446-1340637 Modified: ofbiz/branches/20120329_portletWidget/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java?rev=1340639&r1=1340638&r2=1340639&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java (original) +++ ofbiz/branches/20120329_portletWidget/framework/base/src/org/ofbiz/base/util/template/FreeMarkerWorker.java Sun May 20 08:34:13 2012 @@ -76,7 +76,8 @@ public class FreeMarkerWorker { // use soft references for this so that things from Content records don't kill all of our memory, or maybe not for performance reasons... hmmm, leave to config file... public static UtilCache<String, Template> cachedTemplates = UtilCache.createUtilCache("template.ftl.general", 0, 0, false); - protected static Configuration defaultOfbizConfig = makeConfiguration(new BeansWrapper()); + private static final BeansWrapper defaultOfbizWrapper = new BeansWrapper(); + private static final Configuration defaultOfbizConfig = makeConfiguration(defaultOfbizWrapper); public static Configuration makeConfiguration(BeansWrapper wrapper) { Configuration newConfig = new Configuration(); @@ -117,6 +118,10 @@ public class FreeMarkerWorker { return newConfig; } + public static BeansWrapper getDefaultOfbizWrapper() { + return defaultOfbizWrapper; + } + /** * Protected helper method. */ @@ -616,10 +621,9 @@ public class FreeMarkerWorker { } public static TemplateModel autoWrap(Object obj, Environment env) { - BeansWrapper wrapper = BeansWrapper.getDefaultInstance(); TemplateModel templateModelObj = null; try { - templateModelObj = wrapper.wrap(obj); + templateModelObj = getDefaultOfbizWrapper().wrap(obj); } catch (TemplateModelException e) { throw new RuntimeException(e.getMessage()); } Propchange: ofbiz/branches/20120329_portletWidget/framework/common/widget/HelpScreens.xml ------------------------------------------------------------------------------ Merged /ofbiz/trunk/framework/common/widget/HelpScreens.xml:r1340446-1340637 Modified: ofbiz/branches/20120329_portletWidget/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java?rev=1340639&r1=1340638&r2=1340639&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java (original) +++ ofbiz/branches/20120329_portletWidget/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java Sun May 20 08:34:13 2012 @@ -42,6 +42,7 @@ import org.ofbiz.base.util.Base64; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; +import org.ofbiz.base.util.template.FreeMarkerWorker; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; @@ -56,7 +57,6 @@ import org.w3c.dom.Node; import org.xml.sax.ErrorHandler; import org.xml.sax.SAXException; -import freemarker.ext.beans.BeansWrapper; import freemarker.ext.dom.NodeModel; import freemarker.template.Configuration; import freemarker.template.Template; @@ -345,15 +345,14 @@ public class EntitySaxReader implements StringWriter outWriter = new StringWriter(); Configuration config = new Configuration(); - config.setObjectWrapper(BeansWrapper.getDefaultInstance()); + config.setObjectWrapper(FreeMarkerWorker.getDefaultOfbizWrapper()); config.setSetting("datetime_format", "yyyy-MM-dd HH:mm:ss.SSS"); Template template = new Template("FMImportFilter", templateReader, config); NodeModel nodeModel = NodeModel.wrap(this.rootNodeForTemplate); Map<String, Object> context = FastMap.newInstance(); - BeansWrapper wrapper = BeansWrapper.getDefaultInstance(); - TemplateHashModel staticModels = wrapper.getStaticModels(); + TemplateHashModel staticModels = FreeMarkerWorker.getDefaultOfbizWrapper().getStaticModels(); context.put("Static", staticModels); context.put("doc", nodeModel); Modified: ofbiz/branches/20120329_portletWidget/framework/minilang/dtd/simple-methods-v2.xsd URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/minilang/dtd/simple-methods-v2.xsd?rev=1340639&r1=1340638&r2=1340639&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/framework/minilang/dtd/simple-methods-v2.xsd (original) +++ ofbiz/branches/20120329_portletWidget/framework/minilang/dtd/simple-methods-v2.xsd Sun May 20 08:34:13 2012 @@ -206,6 +206,82 @@ under the License. </xs:simpleType> </xs:attribute> + <xs:attributeGroup name="attlist.entityFindOperations"> + <xs:attribute name="entity-name" type="xs:string" use="required"> + <xs:annotation> + <xs:documentation> + Name of entity to search in. + <br/><br/> + Required. Attribute type: constant, ${expression}. + </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute name="list" type="xs:string" use="required"> + <xs:annotation> + <xs:documentation> + Name of the list where to put results. + <br/><br/> + Required. Attribute type: expression. + </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute name="filter-by-date" default="false"> + <xs:annotation> + <xs:documentation> + Look for from-date and through-date fields in the list of results coming back + and filters by the current date and time if set to true. + Defaults to "false". + <br/><br/> + Optional. Attribute type: constant, ${expression}. + </xs:documentation> + </xs:annotation> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="true" /> + <xs:enumeration value="false" /> + <xs:enumeration value="by-name" /> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="distinct" default="false"> + <xs:annotation> + <xs:documentation> + Filter the results making sure that all of them are unique. + Defaults to "false". + <br/><br/> + Optional. Attribute type: constant, ${expression}. + </xs:documentation> + </xs:annotation> + <xs:simpleType> + <xs:restriction base="xs:token"> + <xs:enumeration value="true"/> + <xs:enumeration value="false"/> + </xs:restriction> + </xs:simpleType> + </xs:attribute> + <xs:attribute name="use-cache" type="xs:string" default="false"> + <xs:annotation> + <xs:documentation> + Specifies whether or not the delegator's cache should be searched before going to the database. + This results in much faster retrieval times, but can return stale data that is not the most current in the database. + Must be "true" or "false", defaults to "false". + <br/><br/> + Optional. Attribute type: constant, ${expression}. + </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute name="delegator-name" type="xs:string"> + <xs:annotation> + <xs:documentation> + Name of a delegator to use. + By default uses the delegator associated with that instance of the service engine. + <br/><br/> + Optional. Attribute type: constant, ${expression}. + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:attributeGroup> + <!-- ELEMENTS start here --> <xs:element name="field"> <xs:annotation> @@ -587,7 +663,7 @@ under the License. <xs:documentation> Name of the service to call. <br/><br/> - Required. Attribute type: constant, expression. + Required. Attribute type: constant, ${expression}. </xs:documentation> </xs:annotation> </xs:attribute> @@ -906,7 +982,7 @@ under the License. <xs:documentation> Name of the service to call. <br/><br/> - Required. Attribute type: constant, expression. + Required. Attribute type: constant, ${expression}. </xs:documentation> </xs:annotation> </xs:attribute> @@ -2203,75 +2279,39 @@ under the License. <xs:element name="entity-and" substitutionGroup="EntityFindOperations"> <xs:annotation> <xs:documentation> - Does a find-by-and, returns a list of GenericValues if any are found, otherwise returns an empty list. + Does a find-by-and, returns a list of entity values if any are found, otherwise returns an empty list. Uses name/value pairs, that will be used for the query and will all be "anded" together. - The result-set-type by default is scroll which is flexible so you can go forward. + The result-set-type by default is scroll which is flexible so you can go + forward. </xs:documentation> </xs:annotation> <xs:complexType> <xs:sequence> - <xs:element maxOccurs="unbounded" ref="field-map"/> + <xs:element maxOccurs="unbounded" ref="field-map" /> <xs:element minOccurs="0" maxOccurs="unbounded" ref="select-field"> - <xs:annotation><xs:documentation>Specify fields to select, otherwise all fields will be selected.</xs:documentation></xs:annotation> + <xs:annotation> + <xs:documentation>Specify fields to select, otherwise all fields will be selected.</xs:documentation> + </xs:annotation> </xs:element> <xs:element minOccurs="0" maxOccurs="unbounded" ref="order-by"> - <xs:annotation><xs:documentation>Defines fields to order list by.</xs:documentation></xs:annotation> + <xs:annotation> + <xs:documentation>Defines fields to order list by.</xs:documentation> + </xs:annotation> </xs:element> <xs:choice minOccurs="0"> - <xs:element ref="limit-range"/> - <xs:element ref="limit-view"/> - <xs:element ref="use-iterator"/> + <xs:element ref="limit-range" /> + <xs:element ref="limit-view" /> + <xs:element ref="use-iterator" /> </xs:choice> </xs:sequence> - <xs:attributeGroup ref="attlist.entity-and"/> + <xs:attributeGroup ref="attlist.entityFindOperations"/> </xs:complexType> </xs:element> - <xs:attributeGroup name="attlist.entity-and"> - <xs:attribute name="entity-name" type="xs:string" use="required"> - <xs:annotation> - <xs:documentation> - Name of entity to search in. - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:attribute name="use-cache" type="xs:string" default="false"> - <xs:annotation> - <xs:documentation> - Specifies whether or not the delegator's cache should be searched before going to the database. - This results in much faster retrieval times, but can return stale data that is not the most current in the database. - Must be "true" or "false", defaults to "false". - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:attribute name="filter-by-date" default="false"> - <xs:annotation> - <xs:documentation> - Look for from-date and through-date fields in the list of results coming back - and filters by the current date and time if set to true. - Defaults to false. - </xs:documentation> - </xs:annotation> - <xs:simpleType> - <xs:restriction base="xs:token"> - <xs:enumeration value="true"/> - <xs:enumeration value="false"/> - <xs:enumeration value="by-name"/> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="list" type="xs:string" use="required"> - <xs:annotation> - <xs:documentation> - Name of the list where to put results. - </xs:documentation> - </xs:annotation> - </xs:attribute> - </xs:attributeGroup> <xs:element name="entity-condition" substitutionGroup="EntityFindOperations"> <xs:annotation> <xs:documentation> - Like entity-and returns a list of Generic values if any are found, otherwise returns an empty list. + Returns a list of entity values based on a condition expression, otherwise returns an empty list. Uses any of condition-expression, condition-list and condition-object. </xs:documentation> </xs:annotation> @@ -2297,72 +2337,9 @@ under the License. <xs:element ref="use-iterator"/> </xs:choice> </xs:sequence> - <xs:attributeGroup ref="attlist.entity-condition"/> + <xs:attributeGroup ref="attlist.entityFindOperations"/> </xs:complexType> </xs:element> - <xs:attributeGroup name="attlist.entity-condition"> - <xs:attribute name="entity-name" type="xs:string" use="required"> - <xs:annotation> - <xs:documentation> - Name of entity to search in. - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:attribute type="xs:string" name="use-cache" default="false"> - <xs:annotation> - <xs:documentation> - Specifies whether or not the delegator's cache should be searched before going to the database. - This results in much faster retrieval times, but can return stale data that is not the most current in the database. - Must be "true" or "false", defaults to "false". - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:attribute name="filter-by-date" default="false"> - <xs:annotation> - <xs:documentation> - Look for from date and through date fields in the list of results coming back - and filters by the current date and time if set to true. - Defaults to false. - </xs:documentation> - </xs:annotation> - <xs:simpleType> - <xs:restriction base="xs:token"> - <xs:enumeration value="true"/> - <xs:enumeration value="false"/> - <xs:enumeration value="by-name"/> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="distinct" default="false"> - <xs:annotation> - <xs:documentation> - Filter the results making sure that all of them are unique. - Defaults to false. - </xs:documentation> - </xs:annotation> - <xs:simpleType> - <xs:restriction base="xs:token"> - <xs:enumeration value="true"/> - <xs:enumeration value="false"/> - </xs:restriction> - </xs:simpleType> - </xs:attribute> - <xs:attribute name="delegator-name" type="xs:string"> - <xs:annotation> - <xs:documentation> - Name of a delegator to use. - By default uses the delegator associated with that instance of the service engine. - </xs:documentation> - </xs:annotation> - </xs:attribute> - <xs:attribute name="list" type="xs:string" use="required"> - <xs:annotation> - <xs:documentation> - Name of the list where to put results. - </xs:documentation> - </xs:annotation> - </xs:attribute> - </xs:attributeGroup> <xs:element name="condition-list"> <xs:annotation> <xs:documentation> @@ -3316,7 +3293,27 @@ under the License. </xs:documentation> </xs:annotation> <xs:complexType> - <xs:attributeGroup ref="attlist.clear-cache-line"/> + <xs:attribute type="xs:string" name="entity-name" use="required"> + <xs:annotation> + <xs:documentation> + The name of the entity. + <br/><br/> + Required. Attribute type: constant, ${expression}. + </xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute type="xs:string" name="map"> + <xs:annotation> + <xs:documentation> + The name of a map in the method environment that will be used for the entity fields. + If the fields in the map form the full primary key the entry will be removed from the byPrimaryKey cache. + If the map exists but the fields do not include a full primary key the entry will be removed from the byAnd cache. + If no map name is specified the entry will be removed from the all caches. + <br/><br/> + Optional. Attribute type: expression. + </xs:documentation> + </xs:annotation> + </xs:attribute> </xs:complexType> </xs:element> <xs:attributeGroup name="attlist.clear-cache-line"> Modified: ofbiz/branches/20120329_portletWidget/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java?rev=1340639&r1=1340638&r2=1340639&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java (original) +++ ofbiz/branches/20120329_portletWidget/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java Sun May 20 08:34:13 2012 @@ -21,25 +21,34 @@ package org.ofbiz.minilang.method.entity import org.ofbiz.minilang.artifact.ArtifactInfoContext; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; +import org.ofbiz.base.util.string.FlexibleStringExpander; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.finder.ByAndFinder; import org.ofbiz.minilang.MiniLangException; +import org.ofbiz.minilang.MiniLangValidate; import org.ofbiz.minilang.SimpleMethod; import org.ofbiz.minilang.method.MethodContext; import org.ofbiz.minilang.method.MethodOperation; import org.w3c.dom.Element; /** - * Uses the delegator to find entity values by a condition + * Implements the <entity-and> element. */ -public class EntityAnd extends MethodOperation { +public final class EntityAnd extends MethodOperation { public static final String module = EntityAnd.class.getName(); - protected ByAndFinder finder; + private final ByAndFinder finder; public EntityAnd(Element element, SimpleMethod simpleMethod) throws MiniLangException { super(element, simpleMethod); + if (MiniLangValidate.validationOn()) { + MiniLangValidate.attributeNames(simpleMethod, element, "entity-name", "use-cache", "filter-by-date", "list", "distinct", "delegator-name"); + MiniLangValidate.requiredAttributes(simpleMethod, element, "entity-name", "list"); + MiniLangValidate.expressionAttributes(simpleMethod, element, "list"); + MiniLangValidate.childElements(simpleMethod, element, "field-map", "order-by", "limit-range", "limit-view", "use-iterator"); + MiniLangValidate.requiredChildElements(simpleMethod, element, "field-map"); + } this.finder = new ByAndFinder(element); } @@ -49,15 +58,9 @@ public class EntityAnd extends MethodOpe Delegator delegator = methodContext.getDelegator(); this.finder.runFind(methodContext.getEnvMap(), delegator); } catch (GeneralException e) { - Debug.logError(e, module); - String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process: " + e.getMessage(); - if (methodContext.getMethodType() == MethodContext.EVENT) { - methodContext.putEnv(simpleMethod.getEventErrorMessageName(), errMsg); - methodContext.putEnv(simpleMethod.getEventResponseCodeName(), simpleMethod.getDefaultErrorCode()); - } else if (methodContext.getMethodType() == MethodContext.SERVICE) { - methodContext.putEnv(simpleMethod.getServiceErrorMessageName(), errMsg); - methodContext.putEnv(simpleMethod.getServiceResponseMessageName(), simpleMethod.getDefaultErrorCode()); - } + String errMsg = "Exception thrown while performing entity find: " + e.getMessage(); + Debug.logWarning(e, errMsg, module); + simpleMethod.addErrorMessage(methodContext, errMsg); return false; } return true; @@ -65,8 +68,7 @@ public class EntityAnd extends MethodOpe @Override public String expandedString(MethodContext methodContext) { - // TODO: something more than a stub/dummy - return this.rawString(); + return FlexibleStringExpander.expandString(toString(), methodContext.getEnvMap()); } @Override @@ -76,10 +78,19 @@ public class EntityAnd extends MethodOpe @Override public String rawString() { - // TODO: something more than the empty tag - return "<entity-and/>"; + return toString(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("<entity-and "); + sb.append("entity-name=\"").append(this.finder.getEntityName()).append("\" />"); + return sb.toString(); } + /** + * A factory for the <entity-and> element. + */ public static final class EntityAndFactory implements Factory<EntityAnd> { public EntityAnd createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException { return new EntityAnd(element, simpleMethod); Modified: ofbiz/branches/20120329_portletWidget/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java?rev=1340639&r1=1340638&r2=1340639&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java (original) +++ ofbiz/branches/20120329_portletWidget/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java Sun May 20 08:34:13 2012 @@ -21,25 +21,34 @@ package org.ofbiz.minilang.method.entity import org.ofbiz.minilang.artifact.ArtifactInfoContext; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; +import org.ofbiz.base.util.string.FlexibleStringExpander; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.finder.ByConditionFinder; import org.ofbiz.minilang.MiniLangException; +import org.ofbiz.minilang.MiniLangValidate; import org.ofbiz.minilang.SimpleMethod; import org.ofbiz.minilang.method.MethodContext; import org.ofbiz.minilang.method.MethodOperation; import org.w3c.dom.Element; /** - * Uses the delegator to find entity values by a condition + * Implements the <entity-and> element. */ -public class EntityCondition extends MethodOperation { +public final class EntityCondition extends MethodOperation { public static final String module = EntityCondition.class.getName(); - protected ByConditionFinder finder; + private final ByConditionFinder finder; public EntityCondition(Element element, SimpleMethod simpleMethod) throws MiniLangException { super(element, simpleMethod); + if (MiniLangValidate.validationOn()) { + MiniLangValidate.attributeNames(simpleMethod, element, "entity-name", "use-cache", "filter-by-date", "list", "distinct", "delegator-name"); + MiniLangValidate.requiredAttributes(simpleMethod, element, "entity-name", "list"); + MiniLangValidate.expressionAttributes(simpleMethod, element, "list"); + MiniLangValidate.childElements(simpleMethod, element, "condition-expr", "condition-list", "condition-object", "having-condition-list", "select-field", "order-by", "limit-range", "limit-view", "use-iterator"); + MiniLangValidate.requireAnyChildElement(simpleMethod, element, "condition-expr", "condition-list", "condition-object"); + } this.finder = new ByConditionFinder(element); } @@ -49,15 +58,9 @@ public class EntityCondition extends Met Delegator delegator = methodContext.getDelegator(); this.finder.runFind(methodContext.getEnvMap(), delegator); } catch (GeneralException e) { - Debug.logError(e, module); - String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process: " + e.getMessage(); - if (methodContext.getMethodType() == MethodContext.EVENT) { - methodContext.putEnv(simpleMethod.getEventErrorMessageName(), errMsg); - methodContext.putEnv(simpleMethod.getEventResponseCodeName(), simpleMethod.getDefaultErrorCode()); - } else if (methodContext.getMethodType() == MethodContext.SERVICE) { - methodContext.putEnv(simpleMethod.getServiceErrorMessageName(), errMsg); - methodContext.putEnv(simpleMethod.getServiceResponseMessageName(), simpleMethod.getDefaultErrorCode()); - } + String errMsg = "Exception thrown while performing entity find: " + e.getMessage(); + Debug.logWarning(e, errMsg, module); + simpleMethod.addErrorMessage(methodContext, errMsg); return false; } return true; @@ -65,8 +68,7 @@ public class EntityCondition extends Met @Override public String expandedString(MethodContext methodContext) { - // TODO: something more than a stub/dummy - return this.rawString(); + return FlexibleStringExpander.expandString(toString(), methodContext.getEnvMap()); } @Override @@ -76,8 +78,14 @@ public class EntityCondition extends Met @Override public String rawString() { - // TODO: something more than the empty tag - return "<entity-condition/>"; + return toString(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("<entity-condition "); + sb.append("entity-name=\"").append(this.finder.getEntityName()).append("\" />"); + return sb.toString(); } public static final class EntityConditionFactory implements Factory<EntityCondition> { Propchange: ofbiz/branches/20120329_portletWidget/framework/security/data/PasswordSecurityData.xml ------------------------------------------------------------------------------ Merged /ofbiz/trunk/framework/security/data/PasswordSecurityData.xml:r1340446-1340637 Modified: ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java?rev=1340639&r1=1340638&r2=1340639&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java (original) +++ ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java Sun May 20 08:34:13 2012 @@ -38,6 +38,7 @@ import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilJ2eeCompat; import org.ofbiz.base.util.UtilTimer; import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.base.util.template.FreeMarkerWorker; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.DelegatorFactory; import org.ofbiz.entity.GenericDelegator; @@ -50,7 +51,6 @@ import org.ofbiz.service.LocalDispatcher import org.ofbiz.webapp.stats.ServerHitBin; import org.ofbiz.webapp.stats.VisitHandler; -import freemarker.ext.beans.BeansWrapper; import freemarker.ext.servlet.ServletContextHashModel; /** @@ -197,7 +197,7 @@ public class ControlServlet extends Http request.setAttribute("_REQUEST_HANDLER_", requestHandler); - ServletContextHashModel ftlServletContext = new ServletContextHashModel(this, BeansWrapper.getDefaultInstance()); + ServletContextHashModel ftlServletContext = new ServletContextHashModel(this, FreeMarkerWorker.getDefaultOfbizWrapper()); request.setAttribute("ftlServletContext", ftlServletContext); // setup some things that should always be there Modified: ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/event/WfsEventHandler.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/event/WfsEventHandler.java?rev=1340639&r1=1340638&r2=1340639&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/event/WfsEventHandler.java (original) +++ ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/event/WfsEventHandler.java Sun May 20 08:34:13 2012 @@ -42,6 +42,7 @@ import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; +import org.ofbiz.base.util.template.FreeMarkerWorker; import org.ofbiz.entity.GenericValue; import org.ofbiz.minilang.MiniLangException; import org.ofbiz.minilang.SimpleMethod; @@ -53,7 +54,6 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.xml.sax.SAXException; -import freemarker.ext.beans.BeansWrapper; import freemarker.ext.dom.NodeModel; import freemarker.template.Configuration; import freemarker.template.Template; @@ -183,7 +183,7 @@ public class WfsEventHandler implements public static Configuration makeDefaultOfbizConfig() throws TemplateException, IOException { Configuration config = new Configuration(); - config.setObjectWrapper(BeansWrapper.getDefaultInstance()); + config.setObjectWrapper(FreeMarkerWorker.getDefaultOfbizWrapper()); config.setSetting("datetime_format", "yyyy-MM-dd HH:mm:ss.SSS"); Configuration defaultOfbizConfig = config; return defaultOfbizConfig; Modified: ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/ftl/FreeMarkerViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/ftl/FreeMarkerViewHandler.java?rev=1340639&r1=1340638&r2=1340639&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/ftl/FreeMarkerViewHandler.java (original) +++ ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/ftl/FreeMarkerViewHandler.java Sun May 20 08:34:13 2012 @@ -33,7 +33,6 @@ import org.ofbiz.base.util.template.Free import org.ofbiz.webapp.view.AbstractViewHandler; import org.ofbiz.webapp.view.ViewHandlerException; -import freemarker.ext.beans.BeansWrapper; import freemarker.ext.jsp.TaglibFactory; import freemarker.ext.servlet.HttpRequestHashModel; import freemarker.ext.servlet.HttpSessionHashModel; @@ -85,8 +84,6 @@ public class FreeMarkerViewHandler exten ServletContext servletContext = (ServletContext) request.getAttribute("servletContext"); HttpSession session = request.getSession(); - BeansWrapper wrapper = BeansWrapper.getDefaultInstance(); - // add in the OFBiz objects root.put("delegator", request.getAttribute("delegator")); root.put("dispatcher", request.getAttribute("dispatcher")); @@ -101,19 +98,19 @@ public class FreeMarkerViewHandler exten root.put("application", servletContext); // add the servlet context -- this has been deprecated, and now requires servlet, do we really need it? - //root.put("applicationAttributes", new ServletContextHashModel(servletContext, BeansWrapper.getDefaultInstance())); + //root.put("applicationAttributes", new ServletContextHashModel(servletContext, FreeMarkerWorker.defaultOfbizWrapper)); // add the session object (for transforms) to the context as a BeanModel root.put("session", session); // add the session - root.put("sessionAttributes", new HttpSessionHashModel(session, wrapper)); + root.put("sessionAttributes", new HttpSessionHashModel(session, FreeMarkerWorker.getDefaultOfbizWrapper())); // add the request object (for transforms) to the context as a BeanModel root.put("request", request); // add the request - root.put("requestAttributes", new HttpRequestHashModel(request, wrapper)); + root.put("requestAttributes", new HttpRequestHashModel(request, FreeMarkerWorker.getDefaultOfbizWrapper())); // add the request parameters -- this now uses a Map from UtilHttp Map<String, Object> requestParameters = UtilHttp.getParameterMap(request); Modified: ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/ftl/FreeMarkerViewRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/ftl/FreeMarkerViewRenderer.java?rev=1340639&r1=1340638&r2=1340639&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/ftl/FreeMarkerViewRenderer.java (original) +++ ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/ftl/FreeMarkerViewRenderer.java Sun May 20 08:34:13 2012 @@ -26,7 +26,6 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import freemarker.ext.beans.BeansWrapper; import freemarker.template.SimpleHash; import freemarker.template.Template; import freemarker.template.WrappingTemplateModel; @@ -39,6 +38,7 @@ import org.jpublish.Page; import org.jpublish.SiteContext; import org.jpublish.page.PageInstance; import org.jpublish.view.ViewRenderException; +import org.ofbiz.base.util.template.FreeMarkerWorker; /** * JPublish View Renderer For Freemarker Template Engine @@ -59,10 +59,9 @@ public class FreeMarkerViewRenderer exte HttpServletRequest request = context.getRequest(); HttpServletResponse response = context.getResponse(); - BeansWrapper wrapper = BeansWrapper.getDefaultInstance(); - WrappingTemplateModel.setDefaultObjectWrapper(wrapper); + WrappingTemplateModel.setDefaultObjectWrapper(FreeMarkerWorker.getDefaultOfbizWrapper()); Map contextMap = new HashMap(); - SimpleHash root = new SimpleHash(wrapper); + SimpleHash root = new SimpleHash(FreeMarkerWorker.getDefaultOfbizWrapper()); try { Object[] keys = context.getKeys(); for (int i = 0; i < keys.length; i++) { @@ -71,13 +70,13 @@ public class FreeMarkerViewRenderer exte if (value != null) { contextMap.put(key, value); //no longer wrapping; let FM do it if needed, more efficient - //root.put(key, wrapper.wrap(value)); + //root.put(key, FreeMarkerWorker.getDefaultOfbizWrapper().wrap(value)); root.put(key, value); } } - root.put("context", wrapper.wrap(contextMap)); + root.put("context", FreeMarkerWorker.getDefaultOfbizWrapper().wrap(contextMap)); root.put("cachedInclude", new JpCacheIncludeTransform()); // only adding this in for JP! - //root.put("jpublishContext", wrapper.wrap(context)); + //root.put("jpublishContext", FreeMarkerWorker.getDefaultOfbizWrapper().wrap(context)); FreeMarkerViewHandler.prepOfbizRoot(root, request, response); } catch (Exception e) { throw new ViewRenderException(e); @@ -91,7 +90,7 @@ public class FreeMarkerViewRenderer exte Object viewContext = createViewContext(context, path); Template template = fmConfig.getTemplate(path, UtilHttp.getLocale(context.getRequest())); - template.setObjectWrapper(BeansWrapper.getDefaultInstance()); + template.setObjectWrapper(FreeMarkerWorker.getDefaultOfbizWrapper()); /* NEVER add content to the beginning of templates; this effects XML processing which requires the first line remain intact. Modified: ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/view/WfsViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/view/WfsViewHandler.java?rev=1340639&r1=1340638&r2=1340639&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/view/WfsViewHandler.java (original) +++ ofbiz/branches/20120329_portletWidget/framework/webapp/src/org/ofbiz/webapp/view/WfsViewHandler.java Sun May 20 08:34:13 2012 @@ -39,9 +39,9 @@ import org.ofbiz.base.location.FlexibleL import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.base.util.template.FreeMarkerWorker; import org.ofbiz.entity.GenericValue; -import freemarker.ext.beans.BeansWrapper; import freemarker.template.Configuration; import freemarker.template.SimpleSequence; import freemarker.template.Template; @@ -110,7 +110,7 @@ public class WfsViewHandler extends Abst public static Configuration makeDefaultOfbizConfig() throws TemplateException, IOException { Configuration config = new Configuration(); - config.setObjectWrapper(BeansWrapper.getDefaultInstance()); + config.setObjectWrapper(FreeMarkerWorker.getDefaultOfbizWrapper()); config.setSetting("datetime_format", "yyyy-MM-dd HH:mm:ss.SSS"); Configuration defaultOfbizConfig = config; return defaultOfbizConfig; Modified: ofbiz/branches/20120329_portletWidget/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java?rev=1340639&r1=1340638&r2=1340639&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java (original) +++ ofbiz/branches/20120329_portletWidget/framework/webtools/src/org/ofbiz/webtools/WebToolsServices.java Sun May 20 08:34:13 2012 @@ -59,6 +59,7 @@ import org.ofbiz.base.util.UtilPropertie import org.ofbiz.base.util.UtilURL; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilProperties.UtilResourceBundle; +import org.ofbiz.base.util.template.FreeMarkerWorker; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.DelegatorFactory; import org.ofbiz.entity.GenericEntityException; @@ -89,7 +90,6 @@ import org.ofbiz.webtools.artifactinfo.S import org.xml.sax.InputSource; import org.xml.sax.SAXException; -import freemarker.ext.beans.BeansWrapper; import freemarker.ext.dom.NodeModel; import freemarker.template.Configuration; import freemarker.template.Template; @@ -171,8 +171,7 @@ public class WebToolsServices { } } fmcontext.put("doc", nodeModel); - BeansWrapper wrapper = BeansWrapper.getDefaultInstance(); - TemplateHashModel staticModels = wrapper.getStaticModels(); + TemplateHashModel staticModels = FreeMarkerWorker.getDefaultOfbizWrapper().getStaticModels(); fmcontext.put("Static", staticModels); template.process(fmcontext, outWriter); Modified: ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java?rev=1340639&r1=1340638&r2=1340639&view=diff ============================================================================== --- ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java (original) +++ ofbiz/branches/20120329_portletWidget/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java Sun May 20 08:34:13 2012 @@ -44,6 +44,7 @@ import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.collections.MapStack; +import org.ofbiz.base.util.template.FreeMarkerWorker; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntity; import org.ofbiz.entity.GenericValue; @@ -58,7 +59,6 @@ import org.ofbiz.widget.cache.ScreenCach import org.ofbiz.widget.cache.WidgetContextCacheKey; import org.xml.sax.SAXException; -import freemarker.ext.beans.BeansWrapper; import freemarker.ext.jsp.TaglibFactory; import freemarker.ext.servlet.HttpRequestHashModel; import freemarker.ext.servlet.HttpSessionHashModel; @@ -238,9 +238,8 @@ public class ScreenRenderer { context.put("javaScriptEnabled", Boolean.valueOf(UtilHttp.isJavaScriptEnabled(request))); // these ones are FreeMarker specific and will only work in FTL templates, mainly here for backward compatibility - BeansWrapper wrapper = BeansWrapper.getDefaultInstance(); - context.put("sessionAttributes", new HttpSessionHashModel(session, wrapper)); - context.put("requestAttributes", new HttpRequestHashModel(request, wrapper)); + context.put("sessionAttributes", new HttpSessionHashModel(session, FreeMarkerWorker.getDefaultOfbizWrapper())); + context.put("requestAttributes", new HttpRequestHashModel(request, FreeMarkerWorker.getDefaultOfbizWrapper())); TaglibFactory JspTaglibs = new TaglibFactory(servletContext); context.put("JspTaglibs", JspTaglibs); context.put("requestParameters", UtilHttp.getParameterMap(request)); Propchange: ofbiz/branches/20120329_portletWidget/specialpurpose/ebaystore/lib/ ------------------------------------------------------------------------------ Merged /ofbiz/trunk/specialpurpose/ebaystore/lib:r1340446-1340637 Propchange: ofbiz/branches/20120329_portletWidget/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/Facilities.groovy ------------------------------------------------------------------------------ Merged /ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/Facilities.groovy:r1340446-1340637 Propchange: ofbiz/branches/20120329_portletWidget/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy ------------------------------------------------------------------------------ Merged /ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductList.groovy:r1340446-1340637 Propchange: ofbiz/branches/20120329_portletWidget/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy ------------------------------------------------------------------------------ Merged /ofbiz/trunk/specialpurpose/hhfacility/webapp/hhfacility/WEB-INF/actions/ProductStockTake.groovy:r1340446-1340637 Propchange: ofbiz/branches/20120329_portletWidget/tools/mergefromtrunk.bat ------------------------------------------------------------------------------ Merged /ofbiz/trunk/tools/mergefromtrunk.bat:r1340446-1340637 Propchange: ofbiz/branches/20120329_portletWidget/tools/mergefromtrunk.sh ------------------------------------------------------------------------------ Merged /ofbiz/trunk/tools/mergefromtrunk.sh:r1340446-1340637 |
| Free forum by Nabble | Edit this page |
