You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2014/02/08 19:59:04 UTC
svn commit: r1566096 - in /ofbiz/trunk/framework/minilang: dtd/
src/org/ofbiz/minilang/method/entityops/
Author: adrianc
Date: Sat Feb 8 18:59:03 2014
New Revision: 1566096
URL: http://svn.apache.org/r1566096
Log:
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/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOperation.java (with props)
Modified:
ofbiz/trunk/framework/minilang/dtd/simple-methods-v2.xsd
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearCacheLine.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearEntityCaches.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/CreateValue.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOne.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeNextSeqId.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeValue.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RefreshValue.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveByAnd.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveList.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveRelated.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveValue.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/SequencedIdToEnv.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreList.java
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreValue.java
Modified: ofbiz/trunk/framework/minilang/dtd/simple-methods-v2.xsd
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/dtd/simple-methods-v2.xsd?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/dtd/simple-methods-v2.xsd (original)
+++ ofbiz/trunk/framework/minilang/dtd/simple-methods-v2.xsd Sat Feb 8 18:59:03 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>
@@ -1686,7 +1697,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>
@@ -2985,15 +2996,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">
@@ -3025,6 +3028,7 @@ under the License.
</xs:documentation>
</xs:annotation>
</xs:attribute>
+ <xs:attribute ref="delegator-name" />
</xs:complexType>
</xs:element>
@@ -3035,7 +3039,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">
@@ -3343,15 +3349,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>
@@ -3400,15 +3398,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>
@@ -3463,6 +3453,7 @@ under the License.
</xs:documentation>
</xs:annotation>
</xs:attribute>
+ <xs:attribute ref="delegator-name" />
</xs:complexType>
</xs:element>
@@ -3686,15 +3677,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>
@@ -3753,15 +3736,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>
@@ -4056,6 +4031,7 @@ under the License.
</xs:documentation>
</xs:annotation>
</xs:attribute>
+ <xs:attribute ref="delegator-name" />
</xs:complexType>
</xs:element>
@@ -4166,6 +4142,7 @@ under the License.
</xs:documentation>
</xs:annotation>
</xs:attribute>
+ <xs:attribute ref="delegator-name" />
</xs:complexType>
</xs:element>
@@ -4196,6 +4173,7 @@ under the License.
</xs:documentation>
</xs:annotation>
</xs:attribute>
+ <xs:attribute ref="delegator-name" />
</xs:complexType>
</xs:element>
@@ -4302,7 +4280,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>
@@ -4324,6 +4302,7 @@ under the License.
</xs:documentation>
</xs:annotation>
</xs:attribute>
+ <xs:attribute ref="delegator-name" />
</xs:complexType>
</xs:element>
@@ -4431,6 +4410,7 @@ under the License.
</xs:documentation>
</xs:annotation>
</xs:attribute>
+ <xs:attribute ref="delegator-name" />
</xs:complexType>
</xs:element>
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearCacheLine.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearCacheLine.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearCacheLine.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearCacheLine.java Sat Feb 8 18:59:03 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/confluence/display/OFBADMIN/Mini-language+Reference#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/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearEntityCaches.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearEntityCaches.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearEntityCaches.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/ClearEntityCaches.java Sat Feb 8 18:59:03 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/confluence/display/OFBADMIN/Mini-language+Reference#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/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/CreateValue.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/CreateValue.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/CreateValue.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/CreateValue.java Sat Feb 8 18:59:03 2014
@@ -68,9 +68,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/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityAnd.java Sat Feb 8 18:59:03 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/confluence/display/OFBADMIN/Mini-language+Reference#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/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCondition.java Sat Feb 8 18:59:03 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/confluence/display/OFBADMIN/Mini-language+Reference#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/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityCount.java Sat Feb 8 18:59:03 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/confluence/display/OFBADMIN/Mini-language+Reference#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/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityData.java Sat Feb 8 18:59:03 2014
@@ -44,11 +44,10 @@ import org.w3c.dom.Element;
*
* @see <a href="https://cwiki.apache.org/confluence/display/OFBADMIN/Mini-language+Reference#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/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOne.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOne.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOne.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOne.java Sat Feb 8 18:59:03 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/confluence/display/OFBADMIN/Mini-language+Reference#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();
Added: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOperation.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOperation.java?rev=1566096&view=auto
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOperation.java (added)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOperation.java Sat Feb 8 18:59:03 2014
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.minilang.method.entityops;
+
+import org.ofbiz.base.util.string.FlexibleStringExpander;
+import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.DelegatorFactory;
+import org.ofbiz.minilang.MiniLangException;
+import org.ofbiz.minilang.SimpleMethod;
+import org.ofbiz.minilang.method.MethodContext;
+import org.ofbiz.minilang.method.MethodOperation;
+import org.w3c.dom.Element;
+
+/**
+ * An abstract base class for entity operations.
+ */
+public abstract class EntityOperation extends MethodOperation {
+
+ private final FlexibleStringExpander delegatorNameFse;
+
+ public EntityOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException {
+ super(element, simpleMethod);
+ this.delegatorNameFse = FlexibleStringExpander.getInstance(element.getAttribute("delegator-name"));
+ }
+
+ protected final Delegator getDelegator(MethodContext methodContext) {
+ String delegatorName = delegatorNameFse.expandString(methodContext.getEnvMap());
+ if (!delegatorName.isEmpty()) {
+ return DelegatorFactory.getDelegator(delegatorName);
+ }
+ return methodContext.getDelegator();
+ }
+}
Propchange: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOperation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/EntityOperation.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Rev URL
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByAnd.java Sat Feb 8 18:59:03 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/confluence/display/OFBADMIN/Mini-language+Reference#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/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java Sat Feb 8 18:59:03 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/confluence/display/OFBADMIN/Mini-language+Reference#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/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeNextSeqId.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeNextSeqId.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeNextSeqId.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeNextSeqId.java Sat Feb 8 18:59:03 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/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeValue.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeValue.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeValue.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/MakeValue.java Sat Feb 8 18:59:03 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/confluence/display/OFBADMIN/Mini-language+Reference#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/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RefreshValue.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RefreshValue.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RefreshValue.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RefreshValue.java Sat Feb 8 18:59:03 2014
@@ -64,7 +64,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/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveByAnd.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveByAnd.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveByAnd.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveByAnd.java Sat Feb 8 18:59:03 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/confluence/display/OFBADMIN/Mini-language+Reference#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();
@Deprecated
@@ -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"));
@@ -63,8 +64,12 @@ public final class RemoveByAnd extends M
@Deprecated
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/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveList.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveList.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveList.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveList.java Sat Feb 8 18:59:03 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/confluence/display/OFBADMIN/Mini-language+Reference#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();
@Deprecated
@@ -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"));
@@ -66,7 +66,8 @@ public final class RemoveList extends Me
@Deprecated
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/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveRelated.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveRelated.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveRelated.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveRelated.java Sat Feb 8 18:59:03 2014
@@ -68,7 +68,7 @@ public final class RemoveRelated extends
@Deprecated
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/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveValue.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveValue.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveValue.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/RemoveValue.java Sat Feb 8 18:59:03 2014
@@ -64,7 +64,7 @@ public final class RemoveValue extends M
@Deprecated
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/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/SequencedIdToEnv.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/SequencedIdToEnv.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/SequencedIdToEnv.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/SequencedIdToEnv.java Sat Feb 8 18:59:03 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/confluence/display/OFBADMIN/Mini-language+Reference#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/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreList.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreList.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreList.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreList.java Sat Feb 8 18:59:03 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/confluence/display/OFBADMIN/Mini-language+Reference#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();
@Deprecated
@@ -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"));
@@ -66,7 +66,8 @@ public final class StoreList extends Met
@Deprecated
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/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreValue.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreValue.java?rev=1566096&r1=1566095&r2=1566096&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreValue.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/StoreValue.java Sat Feb 8 18:59:03 2014
@@ -64,7 +64,7 @@ public final class StoreValue extends Me
@Deprecated
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);