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 2013/12/28 02:17:40 UTC
svn commit: r1553776 - in /ofbiz/trunk/framework/minilang:
dtd/simple-methods-v2.xsd
src/org/ofbiz/minilang/method/callops/SetServiceFields.java
Author: adrianc
Date: Sat Dec 28 01:17:40 2013
New Revision: 1553776
URL: http://svn.apache.org/r1553776
Log:
An improvement to the Mini-language <set-service-fields> element - now you can specify the service attributes mode: IN or OUT.
Modified:
ofbiz/trunk/framework/minilang/dtd/simple-methods-v2.xsd
ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.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=1553776&r1=1553775&r2=1553776&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/dtd/simple-methods-v2.xsd (original)
+++ ofbiz/trunk/framework/minilang/dtd/simple-methods-v2.xsd Sat Dec 28 01:17:40 2013
@@ -564,7 +564,7 @@ under the License.
</xs:documentation>
</xs:annotation>
<xs:complexType>
- <xs:attribute ref="field" />
+ <xs:attribute ref="field" use="required" />
</xs:complexType>
</xs:element>
@@ -1456,7 +1456,7 @@ under the License.
<xs:element name="set-service-fields" substitutionGroup="CallOperations">
<xs:annotation>
<xs:documentation>
- Copies elements from a source map that match a service's IN attributes to a target map.
+ Copies elements from a source map that match a service's IN or OUT attributes to a target map.
</xs:documentation>
</xs:annotation>
<xs:complexType>
@@ -1464,7 +1464,7 @@ under the License.
<xs:annotation>
<xs:documentation>
The name of the service.
-
+
Required. Attribute types: constant, ${expression}.
</xs:documentation>
</xs:annotation>
@@ -1472,8 +1472,8 @@ under the License.
<xs:attribute type="xs:string" name="map" use="required">
<xs:annotation>
<xs:documentation>
- The map to copy the matching IN attributes from.
-
+ The map to copy the matching attributes from.
+
Required. Attribute type: expression.
</xs:documentation>
</xs:annotation>
@@ -1481,13 +1481,28 @@ under the License.
<xs:attribute type="xs:string" name="to-map" use="required">
<xs:annotation>
<xs:documentation>
- The map to copy the matching IN attributes to.
+ The map to copy the matching attributes to.
If the map does not exist, a new one will be created.
-
+
Required. Attribute type: expression.
</xs:documentation>
</xs:annotation>
</xs:attribute>
+ <xs:attribute name="mode">
+ <xs:annotation>
+ <xs:documentation>
+ The service attributes mode - IN or OUT. Defaults to "IN".
+
+ Optional. Attribute type: constant.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:simpleType>
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="IN" />
+ <xs:enumeration value="OUT" />
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:attribute>
</xs:complexType>
</xs:element>
Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java?rev=1553776&r1=1553775&r2=1553776&view=diff
==============================================================================
--- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java (original)
+++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/callops/SetServiceFields.java Sat Dec 28 01:17:40 2013
@@ -60,14 +60,16 @@ public final class SetServiceFields exte
private final FlexibleMapAccessor<Map<String, ? extends Object>> mapFma;
private final FlexibleStringExpander serviceNameFse;
private final FlexibleMapAccessor<Map<String, Object>> toMapFma;
+ private final String mode;
public SetServiceFields(Element element, SimpleMethod simpleMethod) throws MiniLangException {
super(element, simpleMethod);
if (MiniLangValidate.validationOn()) {
- MiniLangValidate.attributeNames(simpleMethod, element, "service-name", "map", "to-map");
+ MiniLangValidate.attributeNames(simpleMethod, element, "service-name", "map", "to-map", "mode");
MiniLangValidate.requiredAttributes(simpleMethod, element, "service-name", "map", "to-map");
MiniLangValidate.constantPlusExpressionAttributes(simpleMethod, element, "service-name");
MiniLangValidate.expressionAttributes(simpleMethod, element, "map", "to-map");
+ MiniLangValidate.constantAttributes(simpleMethod, element, "mode");
MiniLangValidate.noChildElements(simpleMethod, element);
}
boolean elementModified = autoCorrect(element);
@@ -77,6 +79,7 @@ public final class SetServiceFields exte
serviceNameFse = FlexibleStringExpander.getInstance(element.getAttribute("service-name"));
mapFma = FlexibleMapAccessor.getInstance(element.getAttribute("map"));
toMapFma = FlexibleMapAccessor.getInstance(element.getAttribute("to-map"));
+ mode = ModelService.OUT_PARAM.equals(element.getAttribute("mode")) ? ModelService.OUT_PARAM : ModelService.IN_PARAM;
}
@Override
@@ -101,7 +104,7 @@ public final class SetServiceFields exte
toMapFma.put(methodContext.getEnvMap(), toMap);
}
List<Object> errorMessages = new LinkedList<Object>();
- Map<String, Object> validAttributes = modelService.makeValid(fromMap, "IN", true, errorMessages, methodContext.getTimeZone(), methodContext.getLocale());
+ Map<String, Object> validAttributes = modelService.makeValid(fromMap, mode, true, errorMessages, methodContext.getTimeZone(), methodContext.getLocale());
if (errorMessages.size() > 0) {
for (Object obj : errorMessages) {
simpleMethod.addErrorMessage(methodContext, (String) obj);
@@ -129,6 +132,7 @@ public final class SetServiceFields exte
if (!this.toMapFma.isEmpty()) {
sb.append("to-map=\"").append(this.toMapFma).append("\" ");
}
+ sb.append("mode=\"").append(this.mode).append("\" ");
sb.append("/>");
return sb.toString();
}