Author: adrianc
Date: Sat Feb 8 19:32:18 2014 New Revision: 1566108 URL: http://svn.apache.org/r1566108 Log: Merged revision(s) 1566096 from ofbiz/trunk: Some bug fixes in Mini-language: 1. Updated schema to indicate required attributes. 2. Fixed inconsistent implementation of the alternate delegator feature: https://issues.apache.org/jira/browse/OFBIZ-5531 Added: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOperation.java - copied unchanged from r1566096, ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOperation.java Modified: ofbiz/branches/release13.07/ (props changed) ofbiz/branches/release13.07/framework/minilang/dtd/simple-methods-v2.xsd ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearCacheLine.java ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearEntityCaches.java ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/CreateValue.java ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOne.java ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeNextSeqId.java ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeValue.java ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RefreshValue.java ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveByAnd.java ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveList.java ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveRelated.java ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveValue.java ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/SequencedIdToEnv.java ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreList.java ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreValue.java Propchange: ofbiz/branches/release13.07/ ------------------------------------------------------------------------------ Merged /ofbiz/trunk:r1566096 Modified: ofbiz/branches/release13.07/framework/minilang/dtd/simple-methods-v2.xsd URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/dtd/simple-methods-v2.xsd?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/dtd/simple-methods-v2.xsd (original) +++ ofbiz/branches/release13.07/framework/minilang/dtd/simple-methods-v2.xsd Sat Feb 8 19:32:18 2014 @@ -210,6 +210,17 @@ under the License. </xs:attribute> </xs:attributeGroup> + <xs:attribute name="delegator-name" type="xs:string"> + <xs:annotation> + <xs:documentation> + An alternate delegator name. When specified, the entity operation will use the + alternate delegator instead of the current delegator. + + Optional. Attribute types: constant, ${expression}. + </xs:documentation> + </xs:annotation> + </xs:attribute> + <!-- ============================= ===== The Root Elements ===== @@ -583,7 +594,7 @@ under the License. <xs:element ref="field" /> <xs:element ref="string" /> </xs:choice> - <xs:attribute ref="field" /> + <xs:attribute ref="field" use="required" /> <xs:attribute name="class-name" type="javaClassName" use="required"> <xs:annotation> <xs:documentation> @@ -988,7 +999,7 @@ under the License. </xs:documentation> </xs:annotation> <xs:complexType> - <xs:attribute ref="field" /> + <xs:attribute ref="field" use="required" /> <xs:attribute type="xs:string" name="resource" use="required"> <xs:annotation> <xs:documentation> @@ -1095,7 +1106,7 @@ under the License. </xs:documentation> </xs:annotation> <xs:complexType> - <xs:attribute ref="field" /> + <xs:attribute ref="field" use="required" /> <xs:attribute type="xs:string" name="request-name"> <xs:annotation> <xs:documentation> @@ -1125,7 +1136,7 @@ under the License. </xs:documentation> </xs:annotation> <xs:complexType> - <xs:attribute ref="field" /> + <xs:attribute ref="field" use="required" /> <xs:attribute type="xs:string" name="session-name"> <xs:annotation> <xs:documentation> @@ -1248,7 +1259,7 @@ under the License. </xs:documentation> </xs:annotation> <xs:complexType> - <xs:attribute ref="field" /> + <xs:attribute ref="field" use="required" /> <xs:attribute type="xs:string" name="from"> <xs:annotation> <xs:documentation> @@ -1671,7 +1682,7 @@ under the License. </xs:documentation> </xs:annotation> <xs:complexType> - <xs:attribute ref="field" /> + <xs:attribute ref="field" use="required" /> <xs:attribute type="xs:string" name="resource" use="required"> <xs:annotation> <xs:documentation> @@ -2970,15 +2981,7 @@ under the License. </xs:documentation> </xs:annotation> </xs:attribute> - <xs:attribute name="delegator-name" type="xs:string"> - <xs:annotation> - <xs:documentation> - Overrides the current delegator by specifying a delegator name. - - Optional. Attribute type: constant, ${expression}. - </xs:documentation> - </xs:annotation> - </xs:attribute> + <xs:attribute ref="delegator-name" /> </xs:attributeGroup> <xs:element name="clear-cache-line" substitutionGroup="EntityValueOperations"> @@ -3010,6 +3013,7 @@ under the License. </xs:documentation> </xs:annotation> </xs:attribute> + <xs:attribute ref="delegator-name" /> </xs:complexType> </xs:element> @@ -3020,7 +3024,9 @@ under the License. This element should be used sparingly because of the performance impact. </xs:documentation> </xs:annotation> - <xs:complexType/> + <xs:complexType> + <xs:attribute ref="delegator-name" /> + </xs:complexType> </xs:element> <xs:element name="clone-value" substitutionGroup="EntityValueOperations"> @@ -3328,15 +3334,7 @@ under the License. </xs:documentation> </xs:annotation> </xs:attribute> - <xs:attribute name="delegator-name" type="xs:string"> - <xs:annotation> - <xs:documentation> - Overrides the current delegator by specifying a delegator name. - - Optional. Attribute type: constant, ${expression}. - </xs:documentation> - </xs:annotation> - </xs:attribute> + <xs:attribute ref="delegator-name" /> </xs:complexType> </xs:element> @@ -3385,15 +3383,7 @@ under the License. </xs:annotation> </xs:attribute> <xs:attribute ref="error-list-name" /> - <xs:attribute type="xs:string" name="delegator-name"> - <xs:annotation> - <xs:documentation> - Overrides the current delegator by specifying a delegator name. - - Optional. Attribute type: constant, ${expression}. - </xs:documentation> - </xs:annotation> - </xs:attribute> + <xs:attribute ref="delegator-name" /> </xs:complexType> </xs:element> @@ -3448,6 +3438,7 @@ under the License. </xs:documentation> </xs:annotation> </xs:attribute> + <xs:attribute ref="delegator-name" /> </xs:complexType> </xs:element> @@ -3671,15 +3662,7 @@ under the License. </xs:documentation> </xs:annotation> </xs:attribute> - <xs:attribute type="xs:string" name="delegator-name"> - <xs:annotation> - <xs:documentation> - Overrides the current delegator by specifying a delegator name. - - Optional. Attribute type: constant, ${expression}. - </xs:documentation> - </xs:annotation> - </xs:attribute> + <xs:attribute ref="delegator-name" /> </xs:complexType> </xs:element> @@ -3738,15 +3721,7 @@ under the License. </xs:documentation> </xs:annotation> </xs:attribute> - <xs:attribute type="xs:string" name="delegator-name"> - <xs:annotation> - <xs:documentation> - Overrides the current delegator by specifying a delegator name. - - Optional. Attribute type: constant, ${expression}. - </xs:documentation> - </xs:annotation> - </xs:attribute> + <xs:attribute ref="delegator-name" /> </xs:complexType> </xs:element> @@ -4041,6 +4016,7 @@ under the License. </xs:documentation> </xs:annotation> </xs:attribute> + <xs:attribute ref="delegator-name" /> </xs:complexType> </xs:element> @@ -4151,6 +4127,7 @@ under the License. </xs:documentation> </xs:annotation> </xs:attribute> + <xs:attribute ref="delegator-name" /> </xs:complexType> </xs:element> @@ -4181,6 +4158,7 @@ under the License. </xs:documentation> </xs:annotation> </xs:attribute> + <xs:attribute ref="delegator-name" /> </xs:complexType> </xs:element> @@ -4287,7 +4265,7 @@ under the License. </xs:documentation> </xs:annotation> </xs:attribute> - <xs:attribute ref="field" /> + <xs:attribute ref="field" use="required" /> <xs:attribute type="xs:string" name="stagger-max"> <xs:annotation> <xs:documentation> @@ -4309,6 +4287,7 @@ under the License. </xs:documentation> </xs:annotation> </xs:attribute> + <xs:attribute ref="delegator-name" /> </xs:complexType> </xs:element> @@ -4416,6 +4395,7 @@ under the License. </xs:documentation> </xs:annotation> </xs:attribute> + <xs:attribute ref="delegator-name" /> </xs:complexType> </xs:element> Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearCacheLine.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearCacheLine.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearCacheLine.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearCacheLine.java Sat Feb 8 19:32:18 2014 @@ -22,11 +22,11 @@ import java.util.Map; import org.ofbiz.base.util.collections.FlexibleMapAccessor; import org.ofbiz.base.util.string.FlexibleStringExpander; +import org.ofbiz.entity.Delegator; 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; /** @@ -34,7 +34,7 @@ import org.w3c.dom.Element; * * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Cclearcacheline%3E}}">Mini-language Reference</a> */ -public final class ClearCacheLine extends MethodOperation { +public final class ClearCacheLine extends EntityOperation { private final FlexibleStringExpander entityNameFse; private final FlexibleMapAccessor<Map<String, ? extends Object>> mapFma; @@ -42,9 +42,9 @@ public final class ClearCacheLine extend public ClearCacheLine(Element element, SimpleMethod simpleMethod) throws MiniLangException { super(element, simpleMethod); if (MiniLangValidate.validationOn()) { - MiniLangValidate.attributeNames(simpleMethod, element, "entity-name", "map"); + MiniLangValidate.attributeNames(simpleMethod, element, "entity-name", "map", "delegator-name"); MiniLangValidate.requiredAttributes(simpleMethod, element, "entity-name"); - MiniLangValidate.expressionAttributes(simpleMethod, element, "map"); + MiniLangValidate.expressionAttributes(simpleMethod, element, "map", "delegator-name"); MiniLangValidate.noChildElements(simpleMethod, element); } entityNameFse = FlexibleStringExpander.getInstance(element.getAttribute("entity-name")); @@ -53,12 +53,13 @@ public final class ClearCacheLine extend @Override public boolean exec(MethodContext methodContext) throws MiniLangException { + Delegator delegator = getDelegator(methodContext); String entityName = entityNameFse.expandString(methodContext.getEnvMap()); Map<String, ? extends Object> fieldsMap = mapFma.get(methodContext.getEnvMap()); if (fieldsMap == null) { - methodContext.getDelegator().clearCacheLine(entityName); + delegator.clearCacheLine(entityName); } else { - methodContext.getDelegator().clearCacheLine(entityName, fieldsMap); + delegator.clearCacheLine(entityName, fieldsMap); } return true; } Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearEntityCaches.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearEntityCaches.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearEntityCaches.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearEntityCaches.java Sat Feb 8 19:32:18 2014 @@ -18,36 +18,33 @@ *******************************************************************************/ package org.ofbiz.minilang.method.entityops; +import org.ofbiz.entity.Delegator; 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; -import org.w3c.dom.NamedNodeMap; /** * Implements the <clear-entity-caches> element. * * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Cclearentitycaches%3E}}">Mini-language Reference</a> */ -public final class ClearEntityCaches extends MethodOperation { +public final class ClearEntityCaches extends EntityOperation { public ClearEntityCaches(Element element, SimpleMethod simpleMethod) throws MiniLangException { super(element, simpleMethod); if (MiniLangValidate.validationOn()) { - NamedNodeMap nnm = element.getAttributes(); - for (int i = 0; i < nnm.getLength(); i++) { - String attributeName = nnm.item(i).getNodeName(); - MiniLangValidate.handleError("Attribute name \"" + attributeName + "\" is not valid.", simpleMethod, element); - } + MiniLangValidate.attributeNames(simpleMethod, element, "delegator-name"); + MiniLangValidate.expressionAttributes(simpleMethod, element, "delegator-name"); MiniLangValidate.noChildElements(simpleMethod, element); } } @Override public boolean exec(MethodContext methodContext) throws MiniLangException { - methodContext.getDelegator().clearAllCaches(); + Delegator delegator = getDelegator(methodContext); + delegator.clearAllCaches(); return true; } Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/CreateValue.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/CreateValue.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/CreateValue.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/CreateValue.java Sat Feb 8 19:32:18 2014 @@ -67,9 +67,9 @@ public final class CreateValue extends M } try { if (createOrStore) { - methodContext.getDelegator().createOrStore(value, doCacheClear); + value.getDelegator().createOrStore(value, doCacheClear); } else { - methodContext.getDelegator().create(value, doCacheClear); + value.getDelegator().create(value, doCacheClear); } } catch (GenericEntityException e) { String errMsg = "Exception thrown while creating the \"" + valueFma +"\" GenericValue: " + e.getMessage(); Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java Sat Feb 8 19:32:18 2014 @@ -27,7 +27,6 @@ import org.ofbiz.minilang.MiniLangValida import org.ofbiz.minilang.SimpleMethod; import org.ofbiz.minilang.artifact.ArtifactInfoContext; import org.ofbiz.minilang.method.MethodContext; -import org.ofbiz.minilang.method.MethodOperation; import org.w3c.dom.Element; /** @@ -35,7 +34,7 @@ import org.w3c.dom.Element; * * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Centityand%3E}}">Mini-language Reference</a> */ -public final class EntityAnd extends MethodOperation { +public final class EntityAnd extends EntityOperation { public static final String module = EntityAnd.class.getName(); @@ -56,7 +55,7 @@ public final class EntityAnd extends Met @Override public boolean exec(MethodContext methodContext) throws MiniLangException { try { - Delegator delegator = methodContext.getDelegator(); + Delegator delegator = getDelegator(methodContext); this.finder.runFind(methodContext.getEnvMap(), delegator); } catch (GeneralException e) { String errMsg = "Exception thrown while performing entity find: " + e.getMessage(); Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java Sat Feb 8 19:32:18 2014 @@ -27,7 +27,6 @@ import org.ofbiz.minilang.MiniLangValida import org.ofbiz.minilang.SimpleMethod; import org.ofbiz.minilang.artifact.ArtifactInfoContext; import org.ofbiz.minilang.method.MethodContext; -import org.ofbiz.minilang.method.MethodOperation; import org.w3c.dom.Element; /** @@ -35,7 +34,7 @@ import org.w3c.dom.Element; * * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Centitycondition%3E}}">Mini-language Reference</a> */ -public final class EntityCondition extends MethodOperation { +public final class EntityCondition extends EntityOperation { public static final String module = EntityCondition.class.getName(); @@ -46,7 +45,7 @@ public final class EntityCondition exten 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.expressionAttributes(simpleMethod, element, "list", "delegator-name"); 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"); } @@ -56,8 +55,8 @@ public final class EntityCondition exten @Override public boolean exec(MethodContext methodContext) throws MiniLangException { try { - Delegator delegator = methodContext.getDelegator(); - this.finder.runFind(methodContext.getEnvMap(), delegator); + Delegator delegator = getDelegator(methodContext); + finder.runFind(methodContext.getEnvMap(), delegator); } catch (GeneralException e) { String errMsg = "Exception thrown while performing entity find: " + e.getMessage(); Debug.logWarning(e, errMsg, module); Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java Sat Feb 8 19:32:18 2014 @@ -20,12 +20,10 @@ package org.ofbiz.minilang.method.entity import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; -import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; import org.ofbiz.base.util.collections.FlexibleMapAccessor; import org.ofbiz.base.util.string.FlexibleStringExpander; import org.ofbiz.entity.Delegator; -import org.ofbiz.entity.DelegatorFactory; import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.entity.finder.EntityFinderUtil.Condition; import org.ofbiz.entity.finder.EntityFinderUtil.ConditionExpr; @@ -37,7 +35,6 @@ import org.ofbiz.minilang.MiniLangValida import org.ofbiz.minilang.SimpleMethod; import org.ofbiz.minilang.artifact.ArtifactInfoContext; import org.ofbiz.minilang.method.MethodContext; -import org.ofbiz.minilang.method.MethodOperation; import org.w3c.dom.Element; /** @@ -45,12 +42,11 @@ import org.w3c.dom.Element; * * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Centitycount%3E}}">Mini-language Reference</a> */ -public final class EntityCount extends MethodOperation { +public final class EntityCount extends EntityOperation { public static final String module = EntityCount.class.getName(); private final FlexibleMapAccessor<Long> countFma; - private final FlexibleStringExpander delegatorNameFse; private final FlexibleStringExpander entityNameFse; private final Condition havingCondition; private final Condition whereCondition; @@ -60,12 +56,11 @@ public final class EntityCount extends M if (MiniLangValidate.validationOn()) { MiniLangValidate.attributeNames(simpleMethod, element, "entity-name", "count-field", "delegator-name"); MiniLangValidate.requiredAttributes(simpleMethod, element, "entity-name", "count-field"); - MiniLangValidate.expressionAttributes(simpleMethod, element, "count-field"); + MiniLangValidate.expressionAttributes(simpleMethod, element, "count-field", "delegator-name"); MiniLangValidate.childElements(simpleMethod, element, "condition-expr", "condition-list", "condition-object", "having-condition-list"); MiniLangValidate.requireAnyChildElement(simpleMethod, element, "condition-expr", "condition-list", "condition-object"); } this.entityNameFse = FlexibleStringExpander.getInstance(element.getAttribute("entity-name")); - this.delegatorNameFse = FlexibleStringExpander.getInstance(element.getAttribute("delegator-name")); this.countFma = FlexibleMapAccessor.getInstance(element.getAttribute("count-field")); int conditionElementCount = 0; Element conditionExprElement = UtilXml.firstChildElement(element, "condition-expr"); @@ -97,11 +92,7 @@ public final class EntityCount extends M @Override public boolean exec(MethodContext methodContext) throws MiniLangException { try { - String delegatorName = this.delegatorNameFse.expandString(methodContext.getEnvMap()); - Delegator delegator = methodContext.getDelegator(); - if (UtilValidate.isNotEmpty(delegatorName)) { - delegator = DelegatorFactory.getDelegator(delegatorName); - } + Delegator delegator = getDelegator(methodContext); String entityName = this.entityNameFse.expandString(methodContext.getEnvMap()); ModelEntity modelEntity = delegator.getModelEntity(entityName); EntityCondition whereEntityCondition = null; @@ -133,9 +124,6 @@ public final class EntityCount extends M StringBuilder sb = new StringBuilder("<entity-count "); sb.append("entity-name=\"").append(this.entityNameFse).append("\" "); sb.append("count-field=\"").append(this.countFma).append("\" "); - if (!this.delegatorNameFse.isEmpty()) { - sb.append("delegator-name=\"").append(this.delegatorNameFse).append("\" "); - } sb.append("/>"); return sb.toString(); } Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java Sat Feb 8 19:32:18 2014 @@ -44,11 +44,10 @@ import org.w3c.dom.Element; * * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Centitydata%3E}}">Mini-language Reference</a> */ -public final class EntityData extends MethodOperation { +public final class EntityData extends EntityOperation { public static final String module = EntityData.class.getName(); - private final FlexibleStringExpander delegatorNameFse; private final FlexibleMapAccessor<List<Object>> errorListFma; private final FlexibleStringExpander locationFse; private final String mode; @@ -59,11 +58,11 @@ public final class EntityData extends Me if (MiniLangValidate.validationOn()) { MiniLangValidate.attributeNames(simpleMethod, element, "location", "timeout", "delegator-name", "error-list-name", "mode"); MiniLangValidate.requiredAttributes(simpleMethod, element, "location"); + MiniLangValidate.expressionAttributes(simpleMethod, element, "delegator-name"); MiniLangValidate.constantAttributes(simpleMethod, element, "timeout", "mode"); MiniLangValidate.noChildElements(simpleMethod, element); } locationFse = FlexibleStringExpander.getInstance(element.getAttribute("location")); - delegatorNameFse = FlexibleStringExpander.getInstance(element.getAttribute("delegator-name")); mode = MiniLangValidate.checkAttribute(element.getAttribute("mode"), "load"); String timeoutAttribute = element.getAttribute("timeout"); if (!"load".equals(mode) && !timeoutAttribute.isEmpty()) { @@ -89,11 +88,7 @@ public final class EntityData extends Me errorListFma.put(methodContext.getEnvMap(), messages); } String location = this.locationFse.expandString(methodContext.getEnvMap()); - String delegatorName = this.delegatorNameFse.expandString(methodContext.getEnvMap()); - Delegator delegator = methodContext.getDelegator(); - if (UtilValidate.isNotEmpty(delegatorName)) { - delegator = DelegatorFactory.getDelegator(delegatorName); - } + Delegator delegator = getDelegator(methodContext); URL dataUrl = null; try { dataUrl = FlexibleLocation.resolveLocation(location, methodContext.getLoader()); @@ -135,9 +130,6 @@ public final class EntityData extends Me sb.append("location=\"").append(this.locationFse).append("\" "); sb.append("mode=\"").append(this.mode).append("\" "); sb.append("timeout=\"").append(this.timeout).append("\" "); - if (!this.delegatorNameFse.isEmpty()) { - sb.append("delegator-name=\"").append(this.delegatorNameFse).append("\" "); - } sb.append("error-list-name=\"").append(this.errorListFma).append("\" "); sb.append("/>"); return sb.toString(); Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOne.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOne.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOne.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOne.java Sat Feb 8 19:32:18 2014 @@ -27,7 +27,6 @@ import org.ofbiz.minilang.MiniLangValida import org.ofbiz.minilang.SimpleMethod; import org.ofbiz.minilang.artifact.ArtifactInfoContext; import org.ofbiz.minilang.method.MethodContext; -import org.ofbiz.minilang.method.MethodOperation; import org.w3c.dom.Element; /** @@ -35,7 +34,7 @@ import org.w3c.dom.Element; * * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Centityone%3E}}">Mini-language Reference</a> */ -public final class EntityOne extends MethodOperation { +public final class EntityOne extends EntityOperation { public static final String module = EntityOne.class.getName(); @@ -44,9 +43,9 @@ public final class EntityOne extends Met public EntityOne(Element element, SimpleMethod simpleMethod) throws MiniLangException { super(element, simpleMethod); if (MiniLangValidate.validationOn()) { - MiniLangValidate.attributeNames(simpleMethod, element, "entity-name", "use-cache", "auto-field-map", "value-field"); + MiniLangValidate.attributeNames(simpleMethod, element, "entity-name", "use-cache", "auto-field-map", "value-field", "delegator-name"); MiniLangValidate.requiredAttributes(simpleMethod, element, "entity-name", "value-field"); - MiniLangValidate.expressionAttributes(simpleMethod, element, "value-field"); + MiniLangValidate.expressionAttributes(simpleMethod, element, "value-field", "delegator-name"); MiniLangValidate.childElements(simpleMethod, element, "field-map", "select-field"); } this.finder = new PrimaryKeyFinder(element); @@ -55,7 +54,7 @@ public final class EntityOne extends Met @Override public boolean exec(MethodContext methodContext) throws MiniLangException { try { - Delegator delegator = methodContext.getDelegator(); + Delegator delegator = getDelegator(methodContext); this.finder.runFind(methodContext.getEnvMap(), delegator); } catch (GeneralException e) { String errMsg = "Exception thrown while performing entity find: " + e.getMessage(); Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java Sat Feb 8 19:32:18 2014 @@ -27,7 +27,6 @@ import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.collections.FlexibleMapAccessor; import org.ofbiz.base.util.string.FlexibleStringExpander; import org.ofbiz.entity.Delegator; -import org.ofbiz.entity.DelegatorFactory; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.minilang.MiniLangException; @@ -35,7 +34,6 @@ import org.ofbiz.minilang.MiniLangValida import org.ofbiz.minilang.SimpleMethod; import org.ofbiz.minilang.artifact.ArtifactInfoContext; import org.ofbiz.minilang.method.MethodContext; -import org.ofbiz.minilang.method.MethodOperation; import org.w3c.dom.Element; /** @@ -43,11 +41,10 @@ import org.w3c.dom.Element; * * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Cfindbyand%3E}}">Mini-language Reference</a> */ -public final class FindByAnd extends MethodOperation { +public final class FindByAnd extends EntityOperation { public static final String module = FindByAnd.class.getName(); - private final FlexibleStringExpander delegatorNameFse; private final FlexibleStringExpander entityNameFse; private final FlexibleMapAccessor<Collection<String>> fieldsToSelectListFma; private final FlexibleMapAccessor<Object> listFma; @@ -61,7 +58,7 @@ public final class FindByAnd extends Met if (MiniLangValidate.validationOn()) { MiniLangValidate.attributeNames(simpleMethod, element, "entity-name", "use-cache", "fields-to-select-list", "use-iterator", "list", "map", "order-by-list", "delegator-name"); MiniLangValidate.requiredAttributes(simpleMethod, element, "entity-name", "list", "map"); - MiniLangValidate.expressionAttributes(simpleMethod, element, "list", "map", "fields-to-select-list", "order-by-list"); + MiniLangValidate.expressionAttributes(simpleMethod, element, "list", "map", "fields-to-select-list", "order-by-list", "delegator-name"); MiniLangValidate.noChildElements(simpleMethod, element); } entityNameFse = FlexibleStringExpander.getInstance(element.getAttribute("entity-name")); @@ -71,21 +68,16 @@ public final class FindByAnd extends Met fieldsToSelectListFma = FlexibleMapAccessor.getInstance(element.getAttribute("fields-to-select-list")); useCacheFse = FlexibleStringExpander.getInstance(element.getAttribute("use-cache")); useIteratorFse = FlexibleStringExpander.getInstance(element.getAttribute("use-iterator")); - delegatorNameFse = FlexibleStringExpander.getInstance(element.getAttribute("delegator-name")); } @Override public boolean exec(MethodContext methodContext) throws MiniLangException { String entityName = entityNameFse.expandString(methodContext.getEnvMap()); - String delegatorName = delegatorNameFse.expandString(methodContext.getEnvMap()); boolean useCache = "true".equals(useCacheFse.expandString(methodContext.getEnvMap())); boolean useIterator = "true".equals(useIteratorFse.expandString(methodContext.getEnvMap())); List<String> orderByNames = orderByListFma.get(methodContext.getEnvMap()); Collection<String> fieldsToSelectList = fieldsToSelectListFma.get(methodContext.getEnvMap()); - Delegator delegator = methodContext.getDelegator(); - if (!delegatorName.isEmpty()) { - delegator = DelegatorFactory.getDelegator(delegatorName); - } + Delegator delegator = getDelegator(methodContext); try { EntityCondition whereCond = null; Map<String, ? extends Object> fieldMap = mapFma.get(methodContext.getEnvMap()); @@ -129,9 +121,6 @@ public final class FindByAnd extends Met if (!useIteratorFse.isEmpty()) { sb.append("use-iterator=\"").append(this.useIteratorFse).append("\" "); } - if (!delegatorNameFse.isEmpty()) { - sb.append("delegator-name=\"").append(this.delegatorNameFse).append("\" "); - } sb.append("/>"); return sb.toString(); } Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java Sat Feb 8 19:32:18 2014 @@ -26,7 +26,6 @@ import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.collections.FlexibleMapAccessor; import org.ofbiz.base.util.string.FlexibleStringExpander; import org.ofbiz.entity.Delegator; -import org.ofbiz.entity.DelegatorFactory; import org.ofbiz.entity.GenericEntity; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; @@ -36,7 +35,6 @@ import org.ofbiz.minilang.MiniLangValida import org.ofbiz.minilang.SimpleMethod; import org.ofbiz.minilang.artifact.ArtifactInfoContext; import org.ofbiz.minilang.method.MethodContext; -import org.ofbiz.minilang.method.MethodOperation; import org.w3c.dom.Element; /** @@ -44,11 +42,10 @@ import org.w3c.dom.Element; * * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Cfindbyprimarykey%3E}}">Mini-language Reference</a> */ -public final class FindByPrimaryKey extends MethodOperation { +public final class FindByPrimaryKey extends EntityOperation { public static final String module = FindByPrimaryKey.class.getName(); - private final FlexibleStringExpander delegatorNameFse; private final FlexibleStringExpander entityNameFse; private final FlexibleMapAccessor<Collection<String>> fieldsToSelectListFma; private final FlexibleMapAccessor<Map<String, ? extends Object>> mapFma; @@ -60,14 +57,13 @@ public final class FindByPrimaryKey exte if (MiniLangValidate.validationOn()) { MiniLangValidate.attributeNames(simpleMethod, element, "entity-name", "use-cache", "fields-to-select-list", "map", "value-field", "delegator-name"); MiniLangValidate.requiredAttributes(simpleMethod, element, "value-field", "map"); - MiniLangValidate.expressionAttributes(simpleMethod, element, "value-field", "map", "fields-to-select-list"); + MiniLangValidate.expressionAttributes(simpleMethod, element, "value-field", "map", "fields-to-select-list", "delegator-name"); MiniLangValidate.noChildElements(simpleMethod, element); } valueFma = FlexibleMapAccessor.getInstance(element.getAttribute("value-field")); entityNameFse = FlexibleStringExpander.getInstance(element.getAttribute("entity-name")); mapFma = FlexibleMapAccessor.getInstance(element.getAttribute("map")); fieldsToSelectListFma = FlexibleMapAccessor.getInstance(element.getAttribute("fields-to-select-list")); - delegatorNameFse = FlexibleStringExpander.getInstance(element.getAttribute("delegator-name")); useCacheFse = FlexibleStringExpander.getInstance(element.getAttribute("use-cache")); } @@ -75,11 +71,7 @@ public final class FindByPrimaryKey exte public boolean exec(MethodContext methodContext) throws MiniLangException { String entityName = entityNameFse.expandString(methodContext.getEnvMap()); boolean useCache = "true".equals(useCacheFse.expandString(methodContext.getEnvMap())); - Delegator delegator = methodContext.getDelegator(); - String delegatorName = delegatorNameFse.expandString(methodContext.getEnvMap()); - if (!delegatorName.isEmpty()) { - delegator = DelegatorFactory.getDelegator(delegatorName); - } + Delegator delegator = getDelegator(methodContext); Map<String, ? extends Object> inMap = mapFma.get(methodContext.getEnvMap()); if (inMap == null) { throw new MiniLangRuntimeException("Primary key map \"" + mapFma + "\" not found", this); @@ -124,9 +116,6 @@ public final class FindByPrimaryKey exte if (!useCacheFse.isEmpty()) { sb.append("use-cache=\"").append(this.useCacheFse).append("\" "); } - if (!delegatorNameFse.isEmpty()) { - sb.append("delegator-name=\"").append(this.delegatorNameFse).append("\" "); - } sb.append("/>"); return sb.toString(); } Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeNextSeqId.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeNextSeqId.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeNextSeqId.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeNextSeqId.java Sat Feb 8 19:32:18 2014 @@ -82,7 +82,7 @@ public final class MakeNextSeqId extends throw new MiniLangRuntimeException("Invalid number in \"increment-by\" attribute", this); } } - methodContext.getDelegator().setNextSubSeqId(value, seqFieldName, numericPadding, incrementBy); + value.getDelegator().setNextSubSeqId(value, seqFieldName, numericPadding, incrementBy); return true; } Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeValue.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeValue.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeValue.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeValue.java Sat Feb 8 19:32:18 2014 @@ -22,6 +22,7 @@ import java.util.Map; import org.ofbiz.base.util.collections.FlexibleMapAccessor; import org.ofbiz.base.util.string.FlexibleStringExpander; +import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericValue; import org.ofbiz.minilang.MiniLangException; import org.ofbiz.minilang.MiniLangRuntimeException; @@ -29,7 +30,6 @@ import org.ofbiz.minilang.MiniLangValida import org.ofbiz.minilang.SimpleMethod; import org.ofbiz.minilang.artifact.ArtifactInfoContext; import org.ofbiz.minilang.method.MethodContext; -import org.ofbiz.minilang.method.MethodOperation; import org.w3c.dom.Element; /** @@ -37,7 +37,7 @@ import org.w3c.dom.Element; * * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Cmakevalue%3E}}">Mini-language Reference</a> */ -public final class MakeValue extends MethodOperation { +public final class MakeValue extends EntityOperation { private final FlexibleStringExpander entityNameFse; private final FlexibleMapAccessor<Map<String, ? extends Object>> mapFma; @@ -46,9 +46,9 @@ public final class MakeValue extends Met public MakeValue(Element element, SimpleMethod simpleMethod) throws MiniLangException { super(element, simpleMethod); if (MiniLangValidate.validationOn()) { - MiniLangValidate.attributeNames(simpleMethod, element, "value-field", "entity-name", "map"); + MiniLangValidate.attributeNames(simpleMethod, element, "value-field", "entity-name", "map", "delegator-name"); MiniLangValidate.requiredAttributes(simpleMethod, element, "value-field", "entity-name"); - MiniLangValidate.expressionAttributes(simpleMethod, element, "value-field", "map"); + MiniLangValidate.expressionAttributes(simpleMethod, element, "value-field", "map", "delegator-name"); MiniLangValidate.noChildElements(simpleMethod, element); } valueFma = FlexibleMapAccessor.getInstance(element.getAttribute("value-field")); @@ -62,7 +62,8 @@ public final class MakeValue extends Met if (entityName.isEmpty()) { throw new MiniLangRuntimeException("Entity name not found.", this); } - valueFma.put(methodContext.getEnvMap(), methodContext.getDelegator().makeValidValue(entityName, mapFma.get(methodContext.getEnvMap()))); + Delegator delegator = getDelegator(methodContext); + valueFma.put(methodContext.getEnvMap(), delegator.makeValidValue(entityName, mapFma.get(methodContext.getEnvMap()))); return true; } Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RefreshValue.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RefreshValue.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RefreshValue.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RefreshValue.java Sat Feb 8 19:32:18 2014 @@ -63,7 +63,7 @@ public final class RefreshValue extends } boolean doCacheClear = !"false".equals(doCacheClearFse.expandString(methodContext.getEnvMap())); try { - methodContext.getDelegator().refresh(value, doCacheClear); + value.getDelegator().refresh(value, doCacheClear); } catch (GenericEntityException e) { String errMsg = "Exception thrown while refreshing value: " + e.getMessage(); Debug.logWarning(e, errMsg, module); Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveByAnd.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveByAnd.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveByAnd.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveByAnd.java Sat Feb 8 19:32:18 2014 @@ -23,13 +23,14 @@ import java.util.Map; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.collections.FlexibleMapAccessor; import org.ofbiz.base.util.string.FlexibleStringExpander; +import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.minilang.MiniLangException; +import org.ofbiz.minilang.MiniLangRuntimeException; import org.ofbiz.minilang.MiniLangValidate; import org.ofbiz.minilang.SimpleMethod; import org.ofbiz.minilang.artifact.ArtifactInfoContext; import org.ofbiz.minilang.method.MethodContext; -import org.ofbiz.minilang.method.MethodOperation; import org.w3c.dom.Element; /** @@ -37,7 +38,7 @@ import org.w3c.dom.Element; * * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Cremovebyand%3E}}">Mini-language Reference</a> */ -public final class RemoveByAnd extends MethodOperation { +public final class RemoveByAnd extends EntityOperation { public static final String module = RemoveByAnd.class.getName(); @@ -48,9 +49,9 @@ public final class RemoveByAnd extends M public RemoveByAnd(Element element, SimpleMethod simpleMethod) throws MiniLangException { super(element, simpleMethod); if (MiniLangValidate.validationOn()) { - MiniLangValidate.attributeNames(simpleMethod, element, "entity-name", "map", "do-cache-clear"); + MiniLangValidate.attributeNames(simpleMethod, element, "entity-name", "map", "do-cache-clear", "delegator-name"); MiniLangValidate.requiredAttributes(simpleMethod, element, "entity-name", "map"); - MiniLangValidate.expressionAttributes(simpleMethod, element, "map"); + MiniLangValidate.expressionAttributes(simpleMethod, element, "map", "delegator-name"); MiniLangValidate.noChildElements(simpleMethod, element); } entityNameFse = FlexibleStringExpander.getInstance(element.getAttribute("entity-name")); @@ -62,8 +63,12 @@ public final class RemoveByAnd extends M public boolean exec(MethodContext methodContext) throws MiniLangException { boolean doCacheClear = !"false".equals(doCacheClearFse.expandString(methodContext.getEnvMap())); String entityName = entityNameFse.expandString(methodContext.getEnvMap()); + if (entityName.isEmpty()) { + throw new MiniLangRuntimeException("Entity name not found.", this); + } try { - methodContext.getDelegator().removeByAnd(entityName, mapFma.get(methodContext.getEnvMap()), doCacheClear); + Delegator delegator = getDelegator(methodContext); + delegator.removeByAnd(entityName, mapFma.get(methodContext.getEnvMap()), doCacheClear); } catch (GenericEntityException e) { String errMsg = "Exception thrown while removing entities: " + e.getMessage(); Debug.logWarning(e, errMsg, module); Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveList.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveList.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveList.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveList.java Sat Feb 8 19:32:18 2014 @@ -23,6 +23,7 @@ import java.util.List; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.collections.FlexibleMapAccessor; import org.ofbiz.base.util.string.FlexibleStringExpander; +import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.minilang.MiniLangException; @@ -30,7 +31,6 @@ import org.ofbiz.minilang.MiniLangRuntim 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; /** @@ -38,7 +38,7 @@ import org.w3c.dom.Element; * * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Cremovelist%3E}}">Mini-language Reference</a> */ -public final class RemoveList extends MethodOperation { +public final class RemoveList extends EntityOperation { public static final String module = RemoveList.class.getName(); @@ -48,9 +48,9 @@ public final class RemoveList extends Me public RemoveList(Element element, SimpleMethod simpleMethod) throws MiniLangException { super(element, simpleMethod); if (MiniLangValidate.validationOn()) { - MiniLangValidate.attributeNames(simpleMethod, element, "list", "do-cache-clear"); + MiniLangValidate.attributeNames(simpleMethod, element, "list", "do-cache-clear", "delegator-name"); MiniLangValidate.requiredAttributes(simpleMethod, element, "list"); - MiniLangValidate.expressionAttributes(simpleMethod, element, "list"); + MiniLangValidate.expressionAttributes(simpleMethod, element, "list", "delegator-name"); MiniLangValidate.noChildElements(simpleMethod, element); } listFma = FlexibleMapAccessor.getInstance(element.getAttribute("list")); @@ -65,7 +65,8 @@ public final class RemoveList extends Me } boolean doCacheClear = !"false".equals(doCacheClearFse.expandString(methodContext.getEnvMap())); try { - methodContext.getDelegator().removeAll(values, doCacheClear); + Delegator delegator = getDelegator(methodContext); + delegator.removeAll(values, doCacheClear); } catch (GenericEntityException e) { String errMsg = "Exception thrown while removing entities: " + e.getMessage(); Debug.logWarning(e, errMsg, module); Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveRelated.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveRelated.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveRelated.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveRelated.java Sat Feb 8 19:32:18 2014 @@ -67,7 +67,7 @@ public final class RemoveRelated extends String relationName = relationNameFse.expandString(methodContext.getEnvMap()); boolean doCacheClear = !"false".equals(doCacheClearFse.expandString(methodContext.getEnvMap())); try { - methodContext.getDelegator().removeRelated(relationName, value, doCacheClear); + value.getDelegator().removeRelated(relationName, value, doCacheClear); } catch (GenericEntityException e) { String errMsg = "Exception thrown while removing related entities: " + e.getMessage(); Debug.logWarning(e, errMsg, module); Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveValue.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveValue.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveValue.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveValue.java Sat Feb 8 19:32:18 2014 @@ -63,7 +63,7 @@ public final class RemoveValue extends M } boolean doCacheClear = !"false".equals(doCacheClearFse.expandString(methodContext.getEnvMap())); try { - methodContext.getDelegator().removeValue(value, doCacheClear); + value.getDelegator().removeValue(value, doCacheClear); } catch (GenericEntityException e) { String errMsg = "Exception thrown while removing entity value: " + e.getMessage(); Debug.logWarning(e, errMsg, module); Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/SequencedIdToEnv.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/SequencedIdToEnv.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/SequencedIdToEnv.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/SequencedIdToEnv.java Sat Feb 8 19:32:18 2014 @@ -20,11 +20,11 @@ package org.ofbiz.minilang.method.entity import org.ofbiz.base.util.collections.FlexibleMapAccessor; import org.ofbiz.base.util.string.FlexibleStringExpander; +import org.ofbiz.entity.Delegator; 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; /** @@ -32,7 +32,7 @@ import org.w3c.dom.Element; * * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Csequencedid%3E}}">Mini-language Reference</a> */ -public final class SequencedIdToEnv extends MethodOperation { +public final class SequencedIdToEnv extends EntityOperation { private final FlexibleMapAccessor<Object> fieldFma; private final boolean getLongOnly; @@ -42,9 +42,9 @@ public final class SequencedIdToEnv exte public SequencedIdToEnv(Element element, SimpleMethod simpleMethod) throws MiniLangException { super(element, simpleMethod); if (MiniLangValidate.validationOn()) { - MiniLangValidate.attributeNames(simpleMethod, element, "sequence-name", "field", "get-long-only", "stagger-max"); + MiniLangValidate.attributeNames(simpleMethod, element, "sequence-name", "field", "get-long-only", "stagger-max", "delegator-name"); MiniLangValidate.requiredAttributes(simpleMethod, element, "sequence-name", "field"); - MiniLangValidate.expressionAttributes(simpleMethod, element, "field"); + MiniLangValidate.expressionAttributes(simpleMethod, element, "field", "delegator-name"); MiniLangValidate.noChildElements(simpleMethod, element); } sequenceNameFse = FlexibleStringExpander.getInstance(element.getAttribute("sequence-name")); @@ -68,10 +68,11 @@ public final class SequencedIdToEnv exte @Override public boolean exec(MethodContext methodContext) throws MiniLangException { String seqName = sequenceNameFse.expandString(methodContext.getEnvMap()); + Delegator delegator = getDelegator(methodContext); if (getLongOnly) { - fieldFma.put(methodContext.getEnvMap(), methodContext.getDelegator().getNextSeqIdLong(seqName, staggerMax)); + fieldFma.put(methodContext.getEnvMap(), delegator.getNextSeqIdLong(seqName, staggerMax)); } else { - fieldFma.put(methodContext.getEnvMap(), methodContext.getDelegator().getNextSeqId(seqName, staggerMax)); + fieldFma.put(methodContext.getEnvMap(), delegator.getNextSeqId(seqName, staggerMax)); } return true; } Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreList.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreList.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreList.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreList.java Sat Feb 8 19:32:18 2014 @@ -23,6 +23,7 @@ import java.util.List; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.collections.FlexibleMapAccessor; import org.ofbiz.base.util.string.FlexibleStringExpander; +import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.minilang.MiniLangException; @@ -30,7 +31,6 @@ import org.ofbiz.minilang.MiniLangRuntim 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; /** @@ -38,7 +38,7 @@ import org.w3c.dom.Element; * * @see <a href="https://cwiki.apache.org/OFBADMIN/mini-language-reference.html#Mini-languageReference-{{%3Cstorelist%3E}}">Mini-language Reference</a> */ -public final class StoreList extends MethodOperation { +public final class StoreList extends EntityOperation { public static final String module = StoreList.class.getName(); @@ -48,9 +48,9 @@ public final class StoreList extends Met public StoreList(Element element, SimpleMethod simpleMethod) throws MiniLangException { super(element, simpleMethod); if (MiniLangValidate.validationOn()) { - MiniLangValidate.attributeNames(simpleMethod, element, "list", "do-cache-clear"); + MiniLangValidate.attributeNames(simpleMethod, element, "list", "do-cache-clear", "delegator-name"); MiniLangValidate.requiredAttributes(simpleMethod, element, "list"); - MiniLangValidate.expressionAttributes(simpleMethod, element, "list"); + MiniLangValidate.expressionAttributes(simpleMethod, element, "list", "delegator-name"); MiniLangValidate.noChildElements(simpleMethod, element); } listFma = FlexibleMapAccessor.getInstance(element.getAttribute("list")); @@ -65,7 +65,8 @@ public final class StoreList extends Met } boolean doCacheClear = !"false".equals(doCacheClearFse.expandString(methodContext.getEnvMap())); try { - methodContext.getDelegator().storeAll(values, doCacheClear); + Delegator delegator = getDelegator(methodContext); + delegator.storeAll(values, doCacheClear); } catch (GenericEntityException e) { String errMsg = "Exception thrown while storing entities: " + e.getMessage(); Debug.logWarning(e, errMsg, module); Modified: ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreValue.java URL: http://svn.apache.org/viewvc/ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreValue.java?rev=1566108&r1=1566107&r2=1566108&view=diff ============================================================================== --- ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreValue.java (original) +++ ofbiz/branches/release13.07/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreValue.java Sat Feb 8 19:32:18 2014 @@ -63,7 +63,7 @@ public final class StoreValue extends Me } boolean doCacheClear = !"false".equals(doCacheClearFse.expandString(methodContext.getEnvMap())); try { - methodContext.getDelegator().store(value, doCacheClear); + value.getDelegator().store(value, doCacheClear); } catch (GenericEntityException e) { String errMsg = "Exception thrown while storing entity value: " + e.getMessage(); Debug.logWarning(e, errMsg, module); |
Free forum by Nabble | Edit this page |