You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Scott Gray <le...@gmail.com> on 2007/01/05 01:02:41 UTC

Re: svn commit: r492815 - in /ofbiz/trunk/framework/service: dtd/services.xsd src/org/ofbiz/service/ModelService.java src/org/ofbiz/service/ModelServiceReader.java

Hi Andrew

I can't be sure but does this commit reslove this jira issue?
https://issues.apache.org/jira/browse/OFBIZ-309

Thanks
Scott

jaz@apache.org wrote:
> Author: jaz
> Date: Thu Jan  4 15:45:08 2007
> New Revision: 492815
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=492815
> Log:
> changed which implement other services to specifiy if the parameters should be optional or default to the inherited service; rather than always being optional.
>
> Modified:
>     ofbiz/trunk/framework/service/dtd/services.xsd
>     ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java
>     ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java
>
> Modified: ofbiz/trunk/framework/service/dtd/services.xsd
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/dtd/services.xsd?view=diff&rev=492815&r1=492814&r2=492815
> ==============================================================================
> --- ofbiz/trunk/framework/service/dtd/services.xsd (original)
> +++ ofbiz/trunk/framework/service/dtd/services.xsd Thu Jan  4 15:45:08 2007
> @@ -145,6 +145,15 @@
>      </xs:element>
>      <xs:attributeGroup name="attlist.implements">
>          <xs:attribute type="xs:string" name="service" use="required"/>
> +        <xs:attribute type="xs:string" name="optional" default="true">
> +            <xs:simpleType>
> +                <xs:restriction base="xs:token">
> +                    <xs:enumeration value="true"/>
> +                    <xs:enumeration value="false"/>
> +                </xs:restriction>
> +            </xs:simpleType>
> +
> +        </xs:attribute>
>      </xs:attributeGroup>
>      <xs:element name="auto-attributes">
>          <xs:complexType>
>
> Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java?view=diff&rev=492815&r1=492814&r2=492815
> ==============================================================================
> --- ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java (original)
> +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java Thu Jan  4 15:45:08 2007
> @@ -824,7 +824,10 @@
>              if (implServices != null && implServices.size() > 0 && dctx != null) {
>                  Iterator implIter = implServices.iterator();
>                  while (implIter.hasNext()) {
> -                    String serviceName = (String) implIter.next();
> +                    ModelServiceIface iface = (ModelServiceIface) implIter.next();
> +                    String serviceName = iface.getService();
> +                    boolean optional = iface.isOptional();
> +
>                      ModelService model = dctx.getModelService(serviceName);
>                      if (model != null) {
>                          Iterator contextParamIter = model.contextParamList.iterator();
> @@ -836,12 +839,17 @@
>                              	// TODO: this is another case where having different optional/required settings for IN and OUT would be quite valuable...
>                              	if (!"INOUT".equals(existingParam.mode) && !existingParam.mode.equals(newParam.mode)) {
>                                      existingParam.mode = "INOUT";
> -                            		existingParam.optional = true;
> -                            	}
> +                                    if (existingParam.optional || newParam.optional) {
> +                                        existingParam.optional = true;
> +                                    }
> +                                }
>                              } else {
> -                                // instead of calling: addParamClone(param), do it here because we want to make the inputs optional and such because earlier services in a group may create the parameters for later
>                                  ModelParam newParamClone = new ModelParam(newParam);
> -                                newParamClone.optional = true;
> +                                if (optional) {
> +                                    // default option is to make this optional, however the service can override and
> +                                    // force the clone to use the parents setting. 
> +                                    newParamClone.optional = true;
> +                                }
>                                  this.addParam(newParamClone);
>                              }
>                          }
>
> Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java
> URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java?view=diff&rev=492815&r1=492814&r2=492815
> ==============================================================================
> --- ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java (original)
> +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelServiceReader.java Thu Jan  4 15:45:08 2007
> @@ -402,8 +402,10 @@
>          while (implIter.hasNext()) {
>              Element implement = (Element) implIter.next();
>              String serviceName = UtilXml.checkEmpty(implement.getAttribute("service"));
> +            boolean optional = UtilXml.checkBoolean(implement.getAttribute("optional"), false);
>              if (serviceName.length() > 0)
> -                service.implServices.add(serviceName);
> +                service.implServices.add(new ModelServiceIface(serviceName, optional));
> +                //service.implServices.add(serviceName);
>          }
>      }
>      
>
>
>
>