|
On 06/03/2012 06:13 AM, [hidden email] wrote:
> Author: adrianc > Date: Sun Jun 3 11:13:32 2012 > New Revision: 1345652 > > URL: http://svn.apache.org/viewvc?rev=1345652&view=rev > Log: > Overhauled a bunch of Mini-language elements. What did you do? Details. And, this should probably be split into smaller, one-step-at-a-time changes. When I look at just this commit, it doesn't stand alone. I see no reference to any previous discussions, no issue tracker url, nothing. Those things should *not* be part of this commit message, so that means the description needs to talk about them. Then, because so many things have been done in this commit, the message would get overly long; that means it's time to split the commit up. > > Removed: > ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/NowDateToEnv.java > ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/NowTimestampToEnv.java > Modified: > ofbiz/trunk/framework/minilang/dtd/simple-methods-v2.xsd > ofbiz/trunk/framework/minilang/src/META-INF/services/org.ofbiz.minilang.method.MethodOperation$Factory > ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java > ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelated.java > ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelatedOne.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/OrderValueList.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/envops/Now.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=1345652&r1=1345651&r2=1345652&view=diff > ============================================================================== > --- ofbiz/trunk/framework/minilang/dtd/simple-methods-v2.xsd (original) > +++ ofbiz/trunk/framework/minilang/dtd/simple-methods-v2.xsd Sun Jun 3 11:13:32 2012 > @@ -128,9 +128,9 @@ under the License. > <xs:documentation> > The comparison operator. The operator describes the l-value compared to the r-value. > <br/><br/> > - The"contains" operator returns true if the l-value contains the r-value. > + The "contains" operator returns true if the l-value contains the r-value. > This operator does not perform type conversions. > - The l-value must be a collection type or a String. A null l-value returns false. > + The l-value must be a collection type or a String. A null l-value evaluates to false. > <br/><br/> > Required. Attribute type: constant. > </xs:documentation> > @@ -155,11 +155,11 @@ under the License. > <xs:documentation> > The comparison operator. The operator describes the l-value compared to the r-value. > <br/><br/> > - The"contains" operator returns true if the l-value contains the r-value. > - This operator does not perform type conversions - the"type" attribute will be ignored. > + The "contains" operator returns true if the l-value contains the r-value. > + This operator does not perform type conversions. > The l-value must be a collection type or a String. A null l-value evaluates to false. > <br/><br/> > - The"is-null","is-not-null", and"is-empty" operators > + The "is-null", "is-not-null", and "is-empty" operators > do not require an r-value. Any r-values will be ignored. > <br/><br/> > Required. Attribute type: constant. > @@ -273,8 +273,7 @@ under the License. > <xs:attribute name="delegator-name" type="xs:string"> > <xs:annotation> > <xs:documentation> > - Name of a delegator to use. > - By default uses the delegator associated with that instance of the service engine. > + Overrides the delegator by specifying a delegator name. > <br/><br/> > Optional. Attribute type: constant, ${expression}. > </xs:documentation> > @@ -1885,118 +1884,101 @@ under the License. > <xs:element name="sequenced-id" substitutionGroup="EntityMiscOperations"> > <xs:annotation> > <xs:documentation> > - The sequenced-id tag gets a sequenced ID from the Entity Engine (through the delegator) and puts it in the specified method environment field. > - The object will be a java.lang.Long, but can of course be converted to a String. > + Generates a unique numeric sequence value. Sequence values are unique per sequence name. > </xs:documentation> > </xs:annotation> > <xs:complexType> > -<xs:attributeGroup ref="attlist.sequenced-id"/> > +<xs:attribute type="xs:string" name="sequence-name" use="required"> > +<xs:annotation> > +<xs:documentation> > + The sequence name. In most cases, this is the name of the entity the sequence value > + will be used in, but any name can be used. > +<br/><br/> > + Required. Attribute type: constant, ${expression}. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute ref="field" /> > +<xs:attribute type="xs:string" name="stagger-max"> > +<xs:annotation> > +<xs:documentation> > + Sequence stagger maximum. If set to "1" the sequence value will be incremented by 1, > + otherwise the sequence value will be incremented by an amount between 1 and the > + stagger maximum. Defaults to "1". > +<br/><br/> > + Optional. Attribute type: constant. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute name="get-long-only"> > +<xs:annotation> > +<xs:documentation> > + Preserve the sequence type - a numeric long. If set to "false" the sequence > + value will be converted to a string. Defaults to "false". > +<br/><br/> > + Optional. Attribute type: constant. > +</xs:documentation> > +</xs:annotation> > +<xs:simpleType> > +<xs:restriction base="xs:token"> > +<xs:enumeration value="false" /> > +<xs:enumeration value="true" /> > +</xs:restriction> > +</xs:simpleType> > +</xs:attribute> > </xs:complexType> > </xs:element> > -<xs:attributeGroup name="attlist.sequenced-id"> > -<xs:attribute type="xs:string" name="sequence-name" use="required"> > -<xs:annotation> > -<xs:documentation> > - The name of the sequence to pass to the delegator. > - The same name must always be used for sequenced IDs that will be used for a certain entity field otherwise non-unique keys may result. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="field" use="required"> > -<xs:annotation> > -<xs:documentation> > - The name of the method environment field the sequenced ID will be put in. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute name="get-long-only" default="false"> > -<xs:annotation> > -<xs:documentation> > - Get a numerical long value and put it there, so it does not do that by default. > - By default getlong-only is false. If you want it to just get a long number > - then you can set that to true. That's in there for supporting lower level functionality, > - but that's not the typical pattern used in OFBiz as we do use strings for sequencing. > -</xs:documentation> > -</xs:annotation> > -<xs:simpleType> > -<xs:restriction base="xs:token"> > -<xs:enumeration value="true"/> > -<xs:enumeration value="false"/> > -</xs:restriction> > -</xs:simpleType> > -</xs:attribute> > -<xs:attribute type="xs:string" name="stagger-max"> > -<xs:annotation> > -<xs:documentation> > - By default this is one. But if you want to have sequenced Ids that are staggered, instead > - of consecutive, then you can set this to something like twenty. And then it will do a random staggering for > - each sequenced id; instead of picking the next value all the time it will pick something between the next value > - and twenty away from the next value, if stagger-max is set to twenty. > - So that can be used to make the sequenced Ids more difficult to guess. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -</xs:attributeGroup> > <xs:element name="make-next-seq-id" substitutionGroup="EntityMiscOperations"> > <xs:annotation> > <xs:documentation> > - sequenced-id is the primary key sequencer. > - Make-next-seq-id is the secondary key sequencer. So > - this would be something like an orderId for example, > - where we're sequencing an orderId automatically. And > - this would be something like an orderItemSequenceId, > - where we have a sub-sequence that varies for order > - item records related back to an orderHeader. So all of > - them will have the same orderId. > + Generates a sequence string and uses it to update the specified entity value. > + The sequence is generated by scanning all similar values in the entity and adding > + an increment amount to the highest sequence value found. > +<br/><br/> > + This element is typically used to generate sequences for the child entity in a > + parent-child relationship - like order items or invoice items. > </xs:documentation> > </xs:annotation> > <xs:complexType> > -<xs:attributeGroup ref="attlist.make-next-seq-id"/> > +<xs:attribute type="xs:string" name="value-field" use="required"> > +<xs:annotation> > +<xs:documentation> > + The name of the field that contains the entity value to update. > +<br/><br/> > + Required. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute type="xs:string" name="seq-field-name" use="required"> > +<xs:annotation> > +<xs:documentation> > + The entity value field that will receive the sub-sequenced value. > +<br/><br/> > + Required. Attribute type: constant, ${expression}. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute type="xs:string" name="numeric-padding"> > +<xs:annotation> > +<xs:documentation> > + Left-pad the sequence string with the specified number of zeros. > + Defaults to "5". > +<br/><br/> > + Optional. Attribute type: constant, ${expression}. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute type="xs:string" name="increment-by"> > +<xs:annotation> > +<xs:documentation> > + Sequence increment amount. Defaults to "1". > +<br/><br/> > + Optional. Attribute type: constant, ${expression}. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > </xs:complexType> > </xs:element> > -<xs:attributeGroup name="attlist.make-next-seq-id"> > -<xs:attribute type="xs:string" name="value-field" use="required"> > -<xs:annotation> > -<xs:documentation> > - Specify the name of the entity for a sequenced-id preparing the primarySequencedId. > - The name of the entity is typically what we use for the sequenced name, but you can use anything > - you want if you want to have different sets of sequences. > - > - The risk of course of many different sets of sequences > - for the same entity is unless you somehow prefix or > - suffix the value, you could have a key conflict. So we > - just use the entity name for these primary sequences. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="seq-field-name" use="required"> > -<xs:annotation> > -<xs:documentation> > - The field that will have the sub-sequenced value. > - We use the seqId suffix on the field names in the OFBiz > - data model to denote that that field is a secondary sequenced ID > - and should therefore be maintained for this sort of operation. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="numeric-padding" default="5"> > -<xs:annotation> > -<xs:documentation> > - Since these are eventually strings we do numeric-padding so that the sort is consistent, > - By default we pad it with five positions. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="increment-by" default="1"> > -<xs:annotation> > -<xs:documentation> > - Default to 1. > - If you want to leave some space in the sub-sequence you > - can use a greater increment. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -</xs:attributeGroup> > > <xs:element name="entity-data" substitutionGroup="EntityMiscOperations"> > <xs:annotation> > @@ -2046,7 +2028,8 @@ under the License. > <xs:attribute type="xs:string" name="delegator-name"> > <xs:annotation> > <xs:documentation> > - Overrides the delegator or default context by specifying a delegator-name. > + Overrides the delegator by specifying a delegator name. > +<br/><br/> > Optional. Attribute type: constant, ${expression}. > </xs:documentation> > </xs:annotation> > @@ -2056,61 +2039,70 @@ under the License. > <xs:element name="find-by-primary-key" substitutionGroup="EntityFindOperations"> > <xs:annotation> > <xs:documentation> > - The find-by-primary-key tag uses the delegator to find an entity value by its primary key. > - The resulting GenericValue object will be placed in the method environment using the specified value-field. > + Returns a single entity value that is retrieved from the database by using the primary key. > + The primary key used for the search is contained in a map. > </xs:documentation> > </xs:annotation> > <xs:complexType> > -<xs:attributeGroup ref="attlist.find-by-primary-key"/> > +<xs:attribute type="xs:string" name="entity-name"> > +<xs:annotation> > +<xs:documentation> > + The name of the entity to search in. If the primary key map is an entity value, > + then the value's entity name can be used instead of this attribute. > +<br/><br/> > + Optional if the entity name comes from the primary key map. Attribute type: constant, ${expression}. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute type="xs:string" name="value-field" use="required"> > +<xs:annotation> > +<xs:documentation> > + The name of the field that will contain the entity value. > +<br/><br/> > + Required. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute type="xs:string" name="map" use="required"> > +<xs:annotation> > +<xs:documentation> > + The name of a map in the method environment that will be used for the entity fields. > +<br/><br/> > + Required. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute type="xs:string" name="fields-to-select-list"> > +<xs:annotation> > +<xs:documentation> > + List containing name of fields to select, if empty defaults to all entity fields. > +<br/><br/> > + Optional. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute type="xs:string" name="use-cache"> > +<xs:annotation> > +<xs:documentation> > + Specifies whether or not the delegator's cache should be searched before going to the database. > + This results in much faster retrieval times, but can return stale data that is not the most current in the database. > + Must be "true" or "false", defaults to "false". > +<br/><br/> > + Optional. Attribute type: constant, ${expression}. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute type="xs:string" name="delegator-name"> > +<xs:annotation> > +<xs:documentation> > + Overrides the delegator by specifying a delegator name. > +<br/><br/> > + Optional. Attribute type: constant, ${expression}. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > </xs:complexType> > </xs:element> > -<xs:attributeGroup name="attlist.find-by-primary-key"> > -<xs:attribute type="xs:string" name="entity-name" use="optional"> > -<xs:annotation> > -<xs:documentation> > - The name of the entity to find an instance of. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="map" use="required"> > -<xs:annotation> > -<xs:documentation> > - The name of a map in the method environment that will be used for the entity fields. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="value-field" use="required"> > -<xs:annotation> > -<xs:documentation> > - The name of the method environment field that will contain the GenericValue object. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="use-cache" default="false"> > -<xs:annotation> > -<xs:documentation> > - Specifies whether or not the delegator's cache should be searched before going to the database. > - This results in much faster retrieval times, but can return stale data that is not the most current in the database. > - Must be "true" or "false", defaults to "false". > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="fields-to-select-list"> > -<xs:annotation> > -<xs:documentation> > - List containing name of fields to select, if empty defaults to all entity fields. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="delegator-name"> > -<xs:annotation> > -<xs:documentation> > - By default this operation is done using the delegator that is part of the simple-method calling context. > - This allows you to override the default delegator by naming an alternate delegator. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -</xs:attributeGroup> > <xs:element name="find-by-and" substitutionGroup="EntityFindOperations"> > <xs:annotation> > <xs:documentation> > @@ -2140,7 +2132,8 @@ under the License. > <xs:attribute type="xs:string" name="map" use="required"> > <xs:annotation> > <xs:documentation> > - The name of the field containing a map that will be used for the entity fields. > + The name of the field containing a map that will be used for the search. > + The map name/value pairs will be combined using a boolean AND. > <br/><br/> > Required. Attribute type: expression. > </xs:documentation> > @@ -2721,156 +2714,160 @@ under the License. > <xs:element name="get-related-one" substitutionGroup="EntityFindOperations"> > <xs:annotation> > <xs:documentation> > - If you have a generic value object sitting in the context and you want to get a related entity > - following one of the type one relationships in the data model, then you can specify the name of the value > - here, the relation-name, the name of the relationship between the two entities, and the to-value where it > - should put the result, and you can tell it to use-cache or not, by default it doesn't. > + Finds an entity value that is related to an existing entity value. > </xs:documentation> > </xs:annotation> > <xs:complexType> > -<xs:attributeGroup ref="attlist.get-related-one"/> > +<xs:attribute name="value-field" type="xs:string" use="required"> > +<xs:annotation> > +<xs:documentation> > + The name of the field containing the entity value. > +<br/><br/> > + Required. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute name="relation-name" type="xs:string" use="required"> > +<xs:annotation> > +<xs:documentation> > + The name of the entity value relation to use. > +<br/><br/> > + Required. Attribute type: constant, ${expression}. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute name="to-value-field" type="xs:string" use="required"> > +<xs:annotation> > +<xs:documentation> > + The name of the field that will contain the related entity value. > +<br/><br/> > + Required. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute name="use-cache" type="xs:string" default="false"> > +<xs:annotation> > +<xs:documentation> > + Specifies whether or not the delegator's cache should be searched before going to the database. > + This results in much faster retrieval times, but can return stale data that is not the most current in the database. > + Must be "true" or "false", defaults to "false". > +<br/><br/> > + Optional. Attribute type: constant, ${expression}. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > </xs:complexType> > </xs:element> > -<xs:attributeGroup name="attlist.get-related-one"> > -<xs:attribute name="value-field" type="xs:string" use="required"> > -<xs:annotation> > -<xs:documentation> > - Name of a generic value sitting in the context from where you want to get a related-one generic value. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute name="relation-name" type="xs:string" use="required"> > -<xs:annotation> > -<xs:documentation> > - Name of the one-relation to use to relate generic value in value-field to generic value in to-value. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute name="use-cache" type="xs:string" default="false"> > -<xs:annotation> > -<xs:documentation> > - Specifies whether or not the delegator's cache should be searched before going to the database. > - This results in much faster retrieval times, but can return stale data that is not the most current in the database. > - Must be "true" or "false", defaults to "false". > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute name="to-value-field" type="xs:string" use="required"> > -<xs:annotation> > -<xs:documentation> > - Name of a generic value where to put the result. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -</xs:attributeGroup> > <xs:element name="get-related" substitutionGroup="EntityFindOperations"> > <xs:annotation> > <xs:documentation> > - Get-related is just like get-related-one, > - except that instead of getting a single value back to put in the to-value, > - it gets a full list back. > - > - You start with the the value object, specify the name of the relationship. > - You can specify the name of a map that will restrain the query further, > - beyond the field mappings and their relationship. > - > - You can also specify how you want to order it. > - > - Use-cache true or false, list-name for the output. > + Finds entity values that are related to an existing entity value. Returns an empty list > + if no related entity values are found. > </xs:documentation> > </xs:annotation> > <xs:complexType> > -<xs:attributeGroup ref="attlist.get-related"/> > +<xs:attribute type="xs:string" name="value-field" use="required"> > +<xs:annotation> > +<xs:documentation> > + The name of the field containing the entity value. > +<br/><br/> > + Required. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute type="xs:string" name="relation-name" use="required"> > +<xs:annotation> > +<xs:documentation> > + The name of the entity value relation to use. > +<br/><br/> > + Required. Attribute type: constant, ${expression}. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute type="xs:string" name="list" use="required"> > +<xs:annotation> > +<xs:documentation> > + The name of the field that will contain the search results list. > +<br/><br/> > + Required. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute type="xs:string" name="map"> > +<xs:annotation> > +<xs:documentation> > + The name of the field containing a map that will be used for the search. > + The map name/value pairs will be combined using a boolean AND. > +<br/><br/> > + Optional. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute type="xs:string" name="order-by-list"> > +<xs:annotation> > +<xs:documentation> > + The name of the field containing a list that contains field names that you want the find operation to order the results by. > + Each entry in the list is a field name. The field name can be preceded by a plus or a minus sign to specify an > + ascending or descending sort for that field. The default is ascending sort. > +<br/><br/> > + Optional. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute type="xs:string" name="use-cache"> > +<xs:annotation> > +<xs:documentation> > + Specifies whether or not the delegator's cache should be searched before going to the database. > + This results in much faster retrieval times, but can return stale data that is not the most current in the database. > + Must be "true" or "false", defaults to "false". > +<br/><br/> > + Optional. Attribute type: constant, ${expression}. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > </xs:complexType> > </xs:element> > -<xs:attributeGroup name="attlist.get-related"> > -<xs:attribute type="xs:string" name="value-field" use="required"> > -<xs:annotation> > -<xs:documentation> > - Name of a generic value sitting in the context from where you want to get a related generic value. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="relation-name" use="required"> > -<xs:annotation> > -<xs:documentation> > - Name of the relation to use to relate generic value in value-field to generic value in to-value. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="map"> > -<xs:annotation> > -<xs:documentation> > - Name of a map that will restrain the query further, > - beyond the field mappings and their relationship. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="order-by-list"> > -<xs:annotation> > -<xs:documentation> > - This will be a list sitting in the context that has string entries in it for each field that you want it to order by/ > - Each field in the list, or each entry in the list, will just be a string with a field name. > - It can be preceded by a plus or a minus to specify an ascending or descending sort for that. > - The default is ascending sort, so you just put a minus in front of the field-name if you want it to be descending. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="use-cache" default="false"> > -<xs:annotation> > -<xs:documentation> > - Specifies whether or not the delegator's cache should be searched before going to the database. > - This results in much faster retrieval times, but can return stale data that is not the most current in the database. > - Must be "true" or "false", defaults to "false". > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="list" use="required"> > -<xs:annotation> > -<xs:documentation> > - Name of a list where to put the result in. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -</xs:attributeGroup> > <xs:element name="order-value-list" substitutionGroup="EntityFindOperations"> > <xs:annotation> > <xs:documentation> > - Order-value-list does not actually do anything with the database. > - It takes an exiting list that has been returned and sorts it. > + Performs an in-memory sort of a list of entity values. > </xs:documentation> > </xs:annotation> > <xs:complexType> > -<xs:attributeGroup ref="attlist.order-value-list"/> > +<xs:attribute type="xs:string" name="list" use="required"> > +<xs:annotation> > +<xs:documentation> > + The name of the field that contains the list of entity values. > + If the source list is not found, the target field will be set to null. > +<br/><br/> > + Required. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute type="xs:string" name="order-by-list" use="required"> > +<xs:annotation> > +<xs:documentation> > + The name of the field that contains the list of field names to sort on. > + Field names can be preceded by a plus symbol (+) or a minus symbol (-) to specify an ascending or descending sort for that field. > + The default is ascending sort. > + If the order-by-list is not found the target field will be set to a copy of the source list > +<br/><br/> > + Required. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute type="xs:string" name="to-list"> > +<xs:annotation> > +<xs:documentation> > + The name of the field that will contain the sorted list. Defaults to the field specified > + in the list attribute. > +<br/><br/> > + Optional. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > </xs:complexType> > </xs:element> > -<xs:attributeGroup name="attlist.order-value-list"> > -<xs:attribute type="xs:string" name="list" use="required"> > -<xs:annotation> > -<xs:documentation> > - Name of the list of generic value objects that we want to sort. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="to-list"> > -<xs:annotation> > -<xs:documentation> > - Name of the output list. If it is empty, as it is optional, it will simply use the list-name. > - In other words it will take the ordered list and put it over top of the resource list. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="order-by-list" use="required"> > -<xs:annotation> > -<xs:documentation> > - This will be a list sitting in the context that has string entries in it for each field that you want it to order by. > - Each field in the list, or each entry in the list, will just be a string with a field name. > - It can be preceded by a plus or a minus to specify an ascending or descending sort for that. > - The default is ascending sort, so you just put a minus in front of the field-name if you want it to be descending. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -</xs:attributeGroup> > <xs:element name="filter-list-by-and" substitutionGroup="EntityFindOperations"> > <xs:annotation> > <xs:documentation> > @@ -2975,38 +2972,41 @@ under the License. > <xs:element name="make-value" substitutionGroup="EntityValueOperations"> > <xs:annotation> > <xs:documentation> > - The make-value tag uses the delegator to construct an entity value. > - The resulting value will not necessarily exist in the database, but will simply be assembled using the entity-name and fields map. > - The resulting GenericValue object will be placed in the method environment using the specified value-field. > + Creates a new entity value. > + The new entity value exists only in memory - it is not persisted in the database until it is stored. > </xs:documentation> > </xs:annotation> > <xs:complexType> > -<xs:attributeGroup ref="attlist.make-value"/> > +<xs:attribute type="xs:string" name="entity-name" use="required"> > +<xs:annotation> > +<xs:documentation> > + The entity name. > +<br/><br/> > + Required. Attribute type: constant, ${expression}. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute type="xs:string" name="value-field" use="required"> > +<xs:annotation> > +<xs:documentation> > + The name of the field that will contain the entity value. > +<br/><br/> > + Required. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute type="xs:string" name="map"> > +<xs:annotation> > +<xs:documentation> > + The name of the field that contains a map that is used to initialize the entity value fields. > + Map values whose key matches one of the entity value fields will be copied to the entity value. > +<br/><br/> > + Optional. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > </xs:complexType> > </xs:element> > -<xs:attributeGroup name="attlist.make-value"> > -<xs:attribute type="xs:string" name="value-field" use="required"> > -<xs:annotation> > -<xs:documentation> > - The name of the method environment field that contains the GenericValue object. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="entity-name" use="required"> > -<xs:annotation> > -<xs:documentation> > - The name of the entity to construct an instance of. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="map"> > -<xs:annotation> > -<xs:documentation> > - The name of a map in the method environment that will be used for the entity fields. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -</xs:attributeGroup> > <xs:element name="clone-value" substitutionGroup="EntityValueOperations"> > <xs:annotation> > <xs:documentation> > @@ -3017,7 +3017,7 @@ under the License. > <xs:attribute type="xs:string" name="value-field" use="required"> > <xs:annotation> > <xs:documentation> > - The name of the field that contains the GenericValue object. > + The name of the field that contains the entity value. > <br/><br/> > Required. Attribute type: expression. > </xs:documentation> > @@ -3119,172 +3119,158 @@ under the License. > <xs:element name="refresh-value" substitutionGroup="EntityValueOperations"> > <xs:annotation> > <xs:documentation> > - Refresh from database the value given in value-field. > + Refresh an entity value from the database. > </xs:documentation> > </xs:annotation> > <xs:complexType> > -<xs:attributeGroup ref="attlist.refresh-value"/> > +<xs:attribute type="xs:string" name="value-field" use="required"> > +<xs:annotation> > +<xs:documentation> > + The name of the field that contains the entity value. > +<br/><br/> > + Required. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute name="do-cache-clear"> > +<xs:annotation> > +<xs:documentation> > + Clear the cache. Defaults to "true". > +<br/><br/> > + Optional. Attribute type: constant, ${expression}. > +</xs:documentation> > +</xs:annotation> > +<xs:simpleType> > +<xs:restriction base="xs:token"> > +<xs:enumeration value="true" /> > +<xs:enumeration value="false" /> > +</xs:restriction> > +</xs:simpleType> > +</xs:attribute> > </xs:complexType> > </xs:element> > -<xs:attributeGroup name="attlist.refresh-value"> > -<xs:attribute type="xs:string" name="value-field" use="required"> > -<xs:annotation> > -<xs:documentation> > - Name of the value to refresh from database. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute name="do-cache-clear" default="true"> > -<xs:annotation> > -<xs:documentation> > - Clear the cache, defaults to true. > -</xs:documentation> > -</xs:annotation> > -<xs:simpleType> > -<xs:restriction base="xs:token"> > -<xs:enumeration value="true"/> > -<xs:enumeration value="false"/> > -</xs:restriction> > -</xs:simpleType> > -</xs:attribute> > -</xs:attributeGroup> > <xs:element name="remove-value" substitutionGroup="EntityValueOperations"> > <xs:annotation> > <xs:documentation> > - The remove-value tag removes the specified GenericValue object by removing the instance of the entity in the datasource. > - An error will result if an instance of the entity does not exist in the datasource with the same primary key. > + Removes an entity value from the database. > </xs:documentation> > </xs:annotation> > <xs:complexType> > -<xs:attributeGroup ref="attlist.remove-value"/> > +<xs:attribute name="value-field" type="xs:string" use="required"> > +<xs:annotation> > +<xs:documentation> > + The name of the field containing the entity value. > +<br/><br/> > + Required. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute name="do-cache-clear"> > +<xs:annotation> > +<xs:documentation> > + Clear the cache. Defaults to "true". > +<br/><br/> > + Optional. Attribute type: constant, ${expression}. > +</xs:documentation> > +</xs:annotation> > +<xs:simpleType> > +<xs:restriction base="xs:token"> > +<xs:enumeration value="true" /> > +<xs:enumeration value="false" /> > +</xs:restriction> > +</xs:simpleType> > +</xs:attribute> > </xs:complexType> > </xs:element> > -<xs:attributeGroup name="attlist.remove-value"> > -<xs:attribute type="xs:string" name="value-field" use="required"> > -<xs:annotation> > -<xs:documentation> > - The name of the method environment field that contains the GenericValue object. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute name="do-cache-clear" default="true"> > -<xs:annotation> > -<xs:documentation> > - Clear the cache, defaults to true > -</xs:documentation> > -</xs:annotation> > -<xs:simpleType> > -<xs:restriction base="xs:token"> > -<xs:enumeration value="true"/> > -<xs:enumeration value="false"/> > -</xs:restriction> > -</xs:simpleType> > -</xs:attribute> > -</xs:attributeGroup> > <xs:element name="remove-related" substitutionGroup="EntityValueOperations"> > <xs:annotation> > <xs:documentation> > - Given a value name and a relationship name, > - follows the relationship and remove all related > - records, whether they be a type one or type many > - relationship. > - > - For a type one relationship it will remove a > - single record if it exists, and for a type many relationship > - it will remove all the records that are related to it. > - > - This of course can be dangerous, for example if you > - have a product-type entity and you do a remove-related > - with a certain product type value object here, and the > - relation name product here, it will remove all products > - of that type. This is of more value when you're doing > - something like removing an order or removing a product, > - and you want to remove all related elements before > - removing the product to resolve foreign key issues. > - > - Usually the best practice for that, for removing a product > - for example, is to do a remove-related on certain > - types of information related to the product, and then try > - to remove the product but not remove all related tables. > - > - In many cases, if the product has been ordered for example, > - then you do not want to remove the product, > - and so you can do all these remove-relateds. > + Removes entity values from the database that are related to an existing entity value. > + For a one-to-one relationship it will remove a single entity value if it exists, > + and for a one-to-many relationship it will remove all related entity values. > </xs:documentation> > </xs:annotation> > <xs:complexType> > -<xs:attributeGroup ref="attlist.remove-related"/> > +<xs:attribute name="value-field" type="xs:string" use="required"> > +<xs:annotation> > +<xs:documentation> > + The name of the field containing the entity value. > +<br/><br/> > + Required. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute name="relation-name" type="xs:string" use="required"> > +<xs:annotation> > +<xs:documentation> > + The name of the entity value relation to use. > +<br/><br/> > + Required. Attribute type: constant, ${expression}. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute name="do-cache-clear"> > +<xs:annotation> > +<xs:documentation> > + Clear the cache. Defaults to "true". > +<br/><br/> > + Optional. Attribute type: constant, ${expression}. > +</xs:documentation> > +</xs:annotation> > +<xs:simpleType> > +<xs:restriction base="xs:token"> > +<xs:enumeration value="true" /> > +<xs:enumeration value="false" /> > +</xs:restriction> > +</xs:simpleType> > +</xs:attribute> > </xs:complexType> > </xs:element> > -<xs:attributeGroup name="attlist.remove-related"> > -<xs:attribute type="xs:string" name="value-field" use="required"> > -<xs:annotation> > -<xs:documentation> > - Name of a generic value to remove all related records. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="relation-name" use="required"> > -<xs:annotation> > -<xs:documentation> > - Name of a relation to use to remove related records. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute name="do-cache-clear" default="true"> > -<xs:annotation> > -<xs:documentation> > - Clear the cache, defaults to true > -</xs:documentation> > -</xs:annotation> > -<xs:simpleType> > -<xs:restriction base="xs:token"> > -<xs:enumeration value="true"/> > -<xs:enumeration value="false"/> > -</xs:restriction> > -</xs:simpleType> > -</xs:attribute> > -</xs:attributeGroup> > <xs:element name="remove-by-and" substitutionGroup="EntityValueOperations"> > <xs:annotation> > <xs:documentation> > - The remove-by-and tag uses the delegator to remove entity values from the datasource and is constrained by anding the fields passed in the map. > - Make sure the map contains something, or all values will be removed. > + Removes entity values from the datasource. > + Uses a map of name/value pairs that will be combined using a boolean AND to constrain the removal. > </xs:documentation> > </xs:annotation> > <xs:complexType> > -<xs:attributeGroup ref="attlist.remove-by-and"/> > +<xs:attribute type="xs:string" name="entity-name" use="required"> > +<xs:annotation> > +<xs:documentation> > + The name of the entity. > +<br/><br/> > + Required. Attribute type: constant, ${expression}. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute type="xs:string" name="map" use="required"> > +<xs:annotation> > +<xs:documentation> > + The name of the field containing a map that will be used for the constraint. > + The map name/value pairs will be combined using a boolean AND. > + If the map is missing or empty, then all entity values will be removed. > +<br/><br/> > + Required. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute name="do-cache-clear"> > +<xs:annotation> > +<xs:documentation> > + Clear the cache. Defaults to "true". > +<br/><br/> > + Optional. Attribute type: constant, ${expression}. > +</xs:documentation> > +</xs:annotation> > +<xs:simpleType> > +<xs:restriction base="xs:token"> > +<xs:enumeration value="true" /> > +<xs:enumeration value="false" /> > +</xs:restriction> > +</xs:simpleType> > +</xs:attribute> > </xs:complexType> > </xs:element> > -<xs:attributeGroup name="attlist.remove-by-and"> > -<xs:attribute type="xs:string" name="entity-name" use="required"> > -<xs:annotation> > -<xs:documentation> > - The name of the entity to remove instances of. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute type="xs:string" name="map" use="required"> > -<xs:annotation> > -<xs:documentation> > - The name of a map in the method environment that will be used for the entity fields. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute name="do-cache-clear" default="true"> > -<xs:annotation> > -<xs:documentation> > - Clear the cache, defaults to true > -</xs:documentation> > -</xs:annotation> > -<xs:simpleType> > -<xs:restriction base="xs:token"> > -<xs:enumeration value="true"/> > -<xs:enumeration value="false"/> > -</xs:restriction> > -</xs:simpleType> > -</xs:attribute> > -</xs:attributeGroup> > <xs:element name="clear-cache-line" substitutionGroup="EntityValueOperations"> > <xs:annotation> > <xs:documentation> > @@ -3441,36 +3427,38 @@ under the License. > <xs:element name="remove-list" substitutionGroup="EntityListOperations"> > <xs:annotation> > <xs:documentation> > - The remove-list tag uses the delegator to remove all entity values in the list. > - For each value in the list if it is a primary key just that entity instance will be removed, but if it is not a full primary key all entity instances will be removed from the datasource that match the constraint of the field map. > + Removes from the database all entity values in a list. > + If an entity value in the list is a complete primary key, then just that entity value will be removed from the database. > + If an entity value in the list is not a complete primary key, then all matching entity values will be removed from the database. > </xs:documentation> > </xs:annotation> > <xs:complexType> > -<xs:attributeGroup ref="attlist.remove-list"/> > +<xs:attribute type="xs:string" name="list" use="required"> > +<xs:annotation> > +<xs:documentation> > + The name of the field that contains the list of entity values. > +<br/><br/> > + Required. Attribute type: expression. > +</xs:documentation> > +</xs:annotation> > +</xs:attribute> > +<xs:attribute name="do-cache-clear"> > +<xs:annotation> > +<xs:documentation> > + Clear the cache. Defaults to "true". > +<br/><br/> > + Optional. Attribute type: constant, ${expression}. > +</xs:documentation> > +</xs:annotation> > +<xs:simpleType> > +<xs:restriction base="xs:token"> > +<xs:enumeration value="true" /> > +<xs:enumeration value="false" /> > +</xs:restriction> > +</xs:simpleType> > +</xs:attribute> > </xs:complexType> > </xs:element> > -<xs:attributeGroup name="attlist.remove-list"> > -<xs:attribute type="xs:string" name="list" use="required"> > -<xs:annotation> > -<xs:documentation> > - The name of the method environment field that contains the list of GenericValue objects. > -</xs:documentation> > -</xs:annotation> > -</xs:attribute> > -<xs:attribute name="do-cache-clear" default="true"> > -<xs:annotation> > -<xs:documentation> > - Clear the cache, defaults to true > -</xs:documentation> > -</xs:annotation> > -<xs:simpleType> > -<xs:restriction base="xs:token"> > -<xs:enumeration value="true"/> > -<xs:enumeration value="false"/> > -</xs:restriction> > -</xs:simpleType> > -</xs:attribute> > -</xs:attributeGroup> > > <!-- =================== CONTROL OPERATIONS =================== --> > <xs:element name="iterate" substitutionGroup="ControlOperations"> > > Modified: ofbiz/trunk/framework/minilang/src/META-INF/services/org.ofbiz.minilang.method.MethodOperation$Factory > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/META-INF/services/org.ofbiz.minilang.method.MethodOperation%24Factory?rev=1345652&r1=1345651&r2=1345652&view=diff > ============================================================================== > --- ofbiz/trunk/framework/minilang/src/META-INF/services/org.ofbiz.minilang.method.MethodOperation$Factory (original) > +++ ofbiz/trunk/framework/minilang/src/META-INF/services/org.ofbiz.minilang.method.MethodOperation$Factory Sun Jun 3 11:13:32 2012 > @@ -49,15 +49,12 @@ org.ofbiz.minilang.method.entityops.GetR > org.ofbiz.minilang.method.entityops.GetRelatedOne$GetRelatedOneFactory > org.ofbiz.minilang.method.entityops.MakeNextSeqId$MakeNextSeqIdFactory > org.ofbiz.minilang.method.entityops.MakeValue$MakeValueFactory > -org.ofbiz.minilang.method.entityops.NowDateToEnv$NowDateToEnvFactory > -org.ofbiz.minilang.method.entityops.NowTimestampToEnv$NowTimestampFactory > org.ofbiz.minilang.method.entityops.OrderValueList$OrderValueListFactory > org.ofbiz.minilang.method.entityops.RefreshValue$RefreshValueFactory > org.ofbiz.minilang.method.entityops.RemoveByAnd$RemoveByAndFactory > org.ofbiz.minilang.method.entityops.RemoveList$RemoveListFactory > org.ofbiz.minilang.method.entityops.RemoveRelated$RemoveRelatedFactory > org.ofbiz.minilang.method.entityops.RemoveValue$RemoveValueFactory > -org.ofbiz.minilang.method.entityops.SequencedIdToEnv$SequencedIdToEnvFactory > org.ofbiz.minilang.method.entityops.SequencedIdToEnv$SequencedIdFactory > org.ofbiz.minilang.method.entityops.SetCurrentUserLogin$SetCurrentUserLoginFactory > org.ofbiz.minilang.method.entityops.SetNonpkFields$SetNonpkFieldsFactory > @@ -83,6 +80,8 @@ org.ofbiz.minilang.method.envops.ListToL > org.ofbiz.minilang.method.envops.Loop$LoopFactory > org.ofbiz.minilang.method.envops.MapToMap$MapToMapFactory > org.ofbiz.minilang.method.envops.Now$NowFactory > +org.ofbiz.minilang.method.envops.Now$NowDateToEnvFactory > +org.ofbiz.minilang.method.envops.Now$NowTimestampFactory > org.ofbiz.minilang.method.envops.OrderMapList$OrderMapListFactory > org.ofbiz.minilang.method.envops.SetCalendar$SetCalendarFactory > org.ofbiz.minilang.method.envops.SetOperation$SetOperationFactory > > 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=1345652&r1=1345651&r2=1345652&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 Sun Jun 3 11:13:32 2012 > @@ -21,75 +21,85 @@ package org.ofbiz.minilang.method.entity > import java.util.Collection; > import java.util.Map; > > -import org.ofbiz.minilang.artifact.ArtifactInfoContext; > import org.ofbiz.base.util.Debug; > import org.ofbiz.base.util.UtilMisc; > -import org.ofbiz.base.util.UtilValidate; > +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; > import org.ofbiz.minilang.MiniLangException; > +import org.ofbiz.minilang.MiniLangRuntimeException; > +import org.ofbiz.minilang.MiniLangValidate; > import org.ofbiz.minilang.SimpleMethod; > -import org.ofbiz.minilang.method.ContextAccessor; > +import org.ofbiz.minilang.artifact.ArtifactInfoContext; > import org.ofbiz.minilang.method.MethodContext; > import org.ofbiz.minilang.method.MethodOperation; > import org.w3c.dom.Element; > > /** > - * Uses the delegator to find an entity value by its primary key > + * Implements the<find-by-primary-key> element. > */ > -public class FindByPrimaryKey extends MethodOperation { > +public final class FindByPrimaryKey extends MethodOperation { > > public static final String module = FindByPrimaryKey.class.getName(); > > - String delegatorName; > - String entityName; > - ContextAccessor<Collection<String>> fieldsToSelectListAcsr; > - ContextAccessor<Map<String, ? extends Object>> mapAcsr; > - String useCacheStr; > - ContextAccessor<GenericValue> valueAcsr; > + private final FlexibleStringExpander delegatorNameFse; > + private final FlexibleStringExpander entityNameFse; > + private final FlexibleMapAccessor<Collection<String>> fieldsToSelectListFma; > + private final FlexibleMapAccessor<Map<String, ? extends Object>> mapFma; > + private final FlexibleStringExpander useCacheFse; > + private final FlexibleMapAccessor<GenericValue> valueFma; > > public FindByPrimaryKey(Element element, SimpleMethod simpleMethod) throws MiniLangException { > super(element, simpleMethod); > - valueAcsr = new ContextAccessor<GenericValue>(element.getAttribute("value-field"), element.getAttribute("value-name")); > - entityName = element.getAttribute("entity-name"); > - mapAcsr = new ContextAccessor<Map<String, ? extends Object>>(element.getAttribute("map"), element.getAttribute("map-name")); > - fieldsToSelectListAcsr = new ContextAccessor<Collection<String>>(element.getAttribute("fields-to-select-list")); > - delegatorName = element.getAttribute("delegator-name"); > - useCacheStr = element.getAttribute("use-cache"); > + 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.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")); > } > > @Override > public boolean exec(MethodContext methodContext) throws MiniLangException { > - String entityName = methodContext.expandString(this.entityName); > - String delegatorName = methodContext.expandString(this.delegatorName); > - String useCacheStr = methodContext.expandString(this.useCacheStr); > - boolean useCache = "true".equals(useCacheStr); > + String entityName = entityNameFse.expandString(methodContext.getEnvMap()); > + boolean useCache = "true".equals(useCacheFse.expandString(methodContext.getEnvMap())); > Delegator delegator = methodContext.getDelegator(); > - if (UtilValidate.isNotEmpty(delegatorName)) { > + String delegatorName = delegatorNameFse.expandString(methodContext.getEnvMap()); > + if (!delegatorName.isEmpty()) { > delegator = DelegatorFactory.getDelegator(delegatorName); > } > - Map<String, ? extends Object> inMap = mapAcsr.get(methodContext); > - if (UtilValidate.isEmpty(entityName)&& inMap instanceof GenericEntity) { > + Map<String, ? extends Object> inMap = mapFma.get(methodContext.getEnvMap()); > + if (inMap == null) { > + throw new MiniLangRuntimeException("Primary key map \"" + mapFma + "\" not found", this); > + } > + if (entityName.isEmpty()&& inMap instanceof GenericEntity) { > GenericEntity inEntity = (GenericEntity) inMap; > entityName = inEntity.getEntityName(); > } > - Collection<String> fieldsToSelectList = null; > - if (!fieldsToSelectListAcsr.isEmpty()) { > - fieldsToSelectList = fieldsToSelectListAcsr.get(methodContext); > + if (entityName.isEmpty()) { > + throw new MiniLangRuntimeException("Entity name not found", this); > } > + Collection<String> fieldsToSelectList = fieldsToSelectListFma.get(methodContext.getEnvMap()); > try { > if (fieldsToSelectList != null) { > - valueAcsr.put(methodContext, delegator.findByPrimaryKeyPartial(delegator.makePK(entityName, inMap), UtilMisc.makeSetWritable(fieldsToSelectList))); > + valueFma.put(methodContext.getEnvMap(), delegator.findByPrimaryKeyPartial(delegator.makePK(entityName, inMap), UtilMisc.makeSetWritable(fieldsToSelectList))); > } else { > - valueAcsr.put(methodContext, delegator.findOne(entityName, inMap, useCache)); > + valueFma.put(methodContext.getEnvMap(), delegator.findOne(entityName, inMap, useCache)); > } > } catch (GenericEntityException e) { > - Debug.logError(e, module); > - String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process [problem finding the " + entityName + " entity: " + e.getMessage() + "]"; > - methodContext.setErrorReturn(errMsg, simpleMethod); > + String errMsg = "Exception thrown while performing entity find: " + e.getMessage(); > + Debug.logWarning(e, errMsg, module); > + simpleMethod.addErrorMessage(methodContext, errMsg); > return false; > } > return true; > @@ -97,26 +107,48 @@ public class FindByPrimaryKey extends Me > > @Override > public String expandedString(MethodContext methodContext) { > - // TODO: something more than a stub/dummy > - return this.rawString(); > + return FlexibleStringExpander.expandString(toString(), methodContext.getEnvMap()); > } > > @Override > public void gatherArtifactInfo(ArtifactInfoContext aic) { > - aic.addEntityName(entityName); > + aic.addEntityName(entityNameFse.toString()); > } > > @Override > public String rawString() { > - // TODO: something more than the empty tag > - return "<find-by-primary-key/>"; > + return toString(); > } > > + @Override > + public String toString() { > + StringBuilder sb = new StringBuilder("<find-by-primary-key "); > + sb.append("entity-name=\"").append(this.entityNameFse).append("\" "); > + sb.append("value-field=\"").append(this.valueFma).append("\" "); > + sb.append("map=\"").append(this.mapFma).append("\" "); > + if (!fieldsToSelectListFma.isEmpty()) { > + sb.append("fields-to-select-list=\"").append(this.fieldsToSelectListFma).append("\" "); > + } > + 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(); > + } > + > + /** > + * A factory for the<find-by-primary-key> element. > + */ > public static final class FindByPrimaryKeyFactory implements Factory<FindByPrimaryKey> { > + @Override > public FindByPrimaryKey createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException { > return new FindByPrimaryKey(element, simpleMethod); > } > > + @Override > public String getName() { > return "find-by-primary-key"; > } > > Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelated.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelated.java?rev=1345652&r1=1345651&r2=1345652&view=diff > ============================================================================== > --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelated.java (original) > +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelated.java Sun Jun 3 11:13:32 2012 > @@ -21,65 +21,66 @@ package org.ofbiz.minilang.method.entity > import java.util.List; > import java.util.Map; > > -import org.ofbiz.minilang.artifact.ArtifactInfoContext; > import org.ofbiz.base.util.Debug; > +import org.ofbiz.base.util.collections.FlexibleMapAccessor; > +import org.ofbiz.base.util.string.FlexibleStringExpander; > import org.ofbiz.entity.GenericEntityException; > import org.ofbiz.entity.GenericValue; > import org.ofbiz.minilang.MiniLangException; > +import org.ofbiz.minilang.MiniLangRuntimeException; > +import org.ofbiz.minilang.MiniLangValidate; > import org.ofbiz.minilang.SimpleMethod; > -import org.ofbiz.minilang.method.ContextAccessor; > +import org.ofbiz.minilang.artifact.ArtifactInfoContext; > import org.ofbiz.minilang.method.MethodContext; > import org.ofbiz.minilang.method.MethodOperation; > import org.w3c.dom.Element; > > /** > - * Gets a list of related entity instance according to the specified relation-name > + * Implements the<get-related> element. > */ > -public class GetRelated extends MethodOperation { > +public final class GetRelated extends MethodOperation { > > public static final String module = GetRelated.class.getName(); > > - ContextAccessor<List<GenericValue>> listAcsr; > - ContextAccessor<Map<String, ? extends Object>> mapAcsr; > - ContextAccessor<List<String>> orderByListAcsr; > - String relationName; > - String useCacheStr; > - ContextAccessor<GenericValue> valueAcsr; > + private final FlexibleMapAccessor<Object> listFma; > + private final FlexibleMapAccessor<Map<String, ? extends Object>> mapFma; > + private final FlexibleMapAccessor<List<String>> orderByListFma; > + private final FlexibleStringExpander relationNameFse; > + private final FlexibleStringExpander useCacheFse; > + private final FlexibleMapAccessor<GenericValue> valueFma; > > public GetRelated(Element element, SimpleMethod simpleMethod) throws MiniLangException { > super(element, simpleMethod); > - valueAcsr = new ContextAccessor<GenericValue>(element.getAttribute("value-field"), element.getAttribute("value-name")); > - relationName = element.getAttribute("relation-name"); > - listAcsr = new ContextAccessor<List<GenericValue>>(element.getAttribute("list"), element.getAttribute("list-name")); > - mapAcsr = new ContextAccessor<Map<String, ? extends Object>>(element.getAttribute("map"), element.getAttribute("map-name")); > - orderByListAcsr = new ContextAccessor<List<String>>(element.getAttribute("order-by-list"), element.getAttribute("order-by-list-name")); > - useCacheStr = element.getAttribute("use-cache"); > + if (MiniLangValidate.validationOn()) { > + MiniLangValidate.attributeNames(simpleMethod, element, "value-field", "relation-name", "list", "map", "order-by-list", "use-cache"); > + MiniLangValidate.requiredAttributes(simpleMethod, element, "value-field", "relation-name", "list"); > + MiniLangValidate.expressionAttributes(simpleMethod, element, "value-field", "list", "map", "order-by-list"); > + MiniLangValidate.noChildElements(simpleMethod, element); > + } > + valueFma = FlexibleMapAccessor.getInstance(element.getAttribute("value-field")); > + relationNameFse = FlexibleStringExpander.getInstance(element.getAttribute("relation-name")); > + listFma = FlexibleMapAccessor.getInstance(element.getAttribute("list")); > + mapFma = FlexibleMapAccessor.getInstance(element.getAttribute("map")); > + orderByListFma = FlexibleMapAccessor.getInstance(element.getAttribute("order-by-list")); > + useCacheFse = FlexibleStringExpander.getInstance(element.getAttribute("use-cache")); > } > > @Override > public boolean exec(MethodContext methodContext) throws MiniLangException { > - String relationName = methodContext.expandString(this.relationName); > - String useCacheStr = methodContext.expandString(this.useCacheStr); > - boolean useCache = "true".equals(useCacheStr); > - List<String> orderByNames = null; > - if (!orderByListAcsr.isEmpty()) { > - orderByNames = orderByListAcsr.get(methodContext); > - } > - Map<String, ? extends Object> constraintMap = null; > - if (!mapAcsr.isEmpty()) { > - constraintMap = mapAcsr.get(methodContext); > - } > - GenericValue value = valueAcsr.get(methodContext); > + GenericValue value = valueFma.get(methodContext.getEnvMap()); > if (value == null) { > - Debug.logWarning("Value not found with name: " + valueAcsr + ", not getting related...", module); > - return true; > + throw new MiniLangRuntimeException("Entity value not found with name: " + valueFma, this); > } > + String relationName = relationNameFse.expandString(methodContext.getEnvMap()); > + boolean useCache = "true".equals(useCacheFse.expandString(methodContext.getEnvMap())); > + List<String> orderByNames = orderByListFma.get(methodContext.getEnvMap()); > + Map<String, ? extends Object> constraintMap = mapFma.get(methodContext.getEnvMap()); > try { > - listAcsr.put(methodContext, value.getRelated(relationName, constraintMap, orderByNames, useCache)); > + listFma.put(methodContext.getEnvMap(), value.getRelated(relationName, constraintMap, orderByNames, useCache)); > } catch (GenericEntityException e) { > - String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process [problem getting related from entity with name " + value.getEntityName() + " for the relation-name: " + relationName + ": " + e.getMessage() + "]"; > - Debug.logError(e, errMsg, module); > - methodContext.setErrorReturn(errMsg, simpleMethod); > + String errMsg = "Exception thrown while finding related values: " + e.getMessage(); > + Debug.logWarning(e, errMsg, module); > + simpleMethod.addErrorMessage(methodContext, errMsg); > return false; > } > return true; > @@ -87,26 +88,48 @@ public class GetRelated extends MethodOp > > @Override > public String expandedString(MethodContext methodContext) { > - // TODO: something more than a stub/dummy > - return this.rawString(); > + return FlexibleStringExpander.expandString(toString(), methodContext.getEnvMap()); > } > > @Override > public void gatherArtifactInfo(ArtifactInfoContext aic) { > - aic.addEntityName(relationName); > + aic.addEntityName(relationNameFse.toString()); > } > > @Override > public String rawString() { > - // TODO: something more than the empty tag > - return "<get-related/>"; > + return toString(); > } > > + @Override > + public String toString() { > + StringBuilder sb = new StringBuilder("<get-related "); > + sb.append("value-field=\"").append(this.valueFma).append("\" "); > + sb.append("relation-name=\"").append(this.relationNameFse).append("\" "); > + sb.append("list=\"").append(this.listFma).append("\" "); > + if (!mapFma.isEmpty()) { > + sb.append("map=\"").append(this.mapFma).append("\" "); > + } > + if (!orderByListFma.isEmpty()) { > + sb.append("order-by-list=\"").append(this.orderByListFma).append("\" "); > + } > + if (!useCacheFse.isEmpty()) { > + sb.append("use-cache=\"").append(this.useCacheFse).append("\" "); > + } > + sb.append("/>"); > + return sb.toString(); > + } > + > + /** > + * A factory for the<get-related> element. > + */ > public static final class GetRelatedFactory implements Factory<GetRelated> { > + @Override > public GetRelated createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException { > return new GetRelated(element, simpleMethod); > } > > + @Override > public String getName() { > return "get-related"; > } > > Modified: ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelatedOne.java > URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelatedOne.java?rev=1345652&r1=1345651&r2=1345652&view=diff > ============================================================================== > --- ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelatedOne.java (original) > +++ ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelatedOne.java Sun Jun 3 11:13:32 2012 > @@ -18,60 +18,60 @@ > *******************************************************************************/ > package org.ofbiz.minilang.method.entityops; > > -import org.ofbiz.minilang.artifact.ArtifactInfoContext; > import org.ofbiz.base.util.Debug; > +import org.ofbiz.base.util.collections.FlexibleMapAccessor; > +import org.ofbiz.base.util.string.FlexibleStringExpander; > import org.ofbiz.entity.GenericEntityException; > import org.ofbiz.entity.GenericValue; > import org.ofbiz.minilang.MiniLangException; > +import org.ofbiz.minilang.MiniLangRuntimeException; > +import org.ofbiz.minilang.MiniLangValidate; > import org.ofbiz.minilang.SimpleMethod; > -import org.ofbiz.minilang.method.ContextAccessor; > +import org.ofbiz.minilang.artifact.ArtifactInfoContext; > import org.ofbiz.minilang.method.MethodContext; > import org.ofbiz.minilang.method.MethodOperation; > import org.w3c.dom.Element; > > /** > - * Gets a list of related entity instance according to the specified relation-name > + * Implements the<get-related-one> element. > */ > -public class GetRelatedOne extends MethodOperation { > +public final class GetRelatedOne extends MethodOperation { > > public static final String module = GetRelatedOne.class.getName(); > > - String relationName; > - ContextAccessor<GenericValue> toValueAcsr; > - String useCacheStr; > - ContextAccessor<Object> valueAcsr; > + private final FlexibleStringExpander relationNameFse; > + private final FlexibleMapAccessor<GenericValue> toValueFma; > + private final FlexibleStringExpander useCacheFse; > + private final FlexibleMapAccessor<GenericValue> valueFma; > > public GetRelatedOne(Element element, SimpleMethod simpleMethod) throws MiniLangException { > super(element, simpleMethod); > - valueAcsr = new ContextAccessor<Object>(element.getAttribute("value-field"), element.getAttribute("value-name")); > - toValueAcsr = new ContextAccessor<GenericValue>(element.getAttribute("to-value-field"), element.getAttribute("to-value-name")); > - relationName = element.getAttribute("relation-name"); > - useCacheStr = element.getAttribute("use-cache"); > + if (MiniLangValidate.validationOn()) { > + MiniLangValidate.attributeNames(simpleMethod, element, "value-field", "relation-name", "to-value-field", "use-cache"); > + MiniLangValidate.requiredAttributes(simpleMethod, element, "value-field", "relation-name", "to-value-field"); > + MiniLangValidate.expressionAttributes(simpleMethod, element, "value-field", "to-value-field"); > + MiniLangValidate.noChildElements(simpleMethod, element); > + } > + valueFma = FlexibleMapAccessor.getInstance(element.getAttribute("value-field")); > + relationNameFse = FlexibleStringExpander.getInstance(element.getAttribute("relation-name")); > + toValueFma = FlexibleMapAccessor.getInstance(element.getAttribute("to-value-field")); > + useCacheFse = FlexibleStringExpander.getInstance(element.getAttribute("use-cache")); > } > > @Override > public boolean exec(MethodContext methodContext) throws MiniLangException { > - String relationName = methodContext.expandString(this.relationName); > - String useCacheStr = methodContext.expandString(this.useCacheStr); > - boolean useCache = "true".equals(useCacheStr); > - Object valueObject = valueAcsr.get(methodContext); > - if (!(valueObject instanceof GenericValue)) { > - String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process [env variable for value-name " + valueAcsr.toString() + " is not a GenericValue object; for the relation-name: " + relationName + "]"; > - Debug.logError(errMsg, module); > - methodContext.setErrorReturn(errMsg, simpleMethod); > - return false; > - } > - GenericValue value = (GenericValue) valueObject; > + GenericValue value = valueFma.get(methodContext.getEnvMap()); > if (value == null) { > - Debug.logWarning("Value not found with name: " + valueAcsr + ", not getting related...", module); > - return true; > + throw new MiniLangRuntimeException("Entity value not found with name: " + valueFma, this); > } > + String relationName = relationNameFse.expandString(methodContext.getEnvMap()); > + boolean useCache = "true".equals(useCacheFse.expandString(methodContext.getEnvMap())); > try { > - toValueAcsr.put(methodContext, value.getRelatedOne(relationName, useCache)); > + toValueFma.put(methodContext.getEnvMap(), value.getRelatedOne(relationName, useCache)); > } catch (GenericEntityException e) { > - String errMsg = "ERROR: Could not complete the " + simpleMethod.getShortDescription() + " process [problem getting related one from entity with name " + value.getEntityName() + " for the relation-name: " + relationName + ": " + e.getMessage() + "]"; > - Debug.logError(e, errMsg, module); > - methodContext.setErrorReturn(errMsg, simpleMethod); > + String errMsg = "Exception thrown while finding related value: " + e.getMessage(); > + Debug.logWarning(e, errMsg, module); > + simpleMethod.addErrorMessage(methodContext, errMsg); > return false; > } > return true; > @@ -79,26 +79,42 @@ public class GetRelatedOne extends Metho > > @Override > public String expandedString(MethodContext methodContext) { > - // TODO: something more than a stub/dummy > - return this.rawString(); > + return FlexibleStringExpander.expandString(toString(), methodContext.getEnvMap()); > } > > @Override > public void gatherArtifactInfo(ArtifactInfoContext aic) { > - aic.addEntityName(relationName); > + aic.addEntityName(relationNameFse.toString()); > } > > @Override > public String rawString() { > - // TODO: something more than the empty tag > - return "<get-related-one/>"; > + return toString(); > + } > + > + @Override > + public String toString() { > + StringBuilder sb = new StringBuilder("<get-related-one "); > + sb.append("value-field=\"").append(this.valueFma).append("\" "); > + sb.append("relation-name=\"").append(this.relationNameFse).append("\" "); > + sb.append("to-value-field=\"").append(this.toValueFma).append("\" "); > + if (!useCacheFse.isEmpty()) { > + sb.append("use-cache=\"").append(this.useCacheFse).append("\" "); > + } > + sb.append("/>"); > + return sb.toString(); > } > > + /** > + * A factory for the<get-related-one> element. > + */ > public static final class GetRelatedOneFactory implements Factory<GetRelatedOne> { > + @Override > public GetRelatedOne createMethodOperation(Element element, SimpleMethod simpleMethod) throws MiniLangException { > return new GetRelatedOne(element, simpleMethod); > } > > + @Override > public String getName() { > return "get-related-one"; > } > > |
|
This commit is one of many similar commits that have been made over the
last three months. There was a Mini-language overhaul discussion on the dev mailing list. I will update the commit message with the elements that were worked on. -Adrian On 6/3/2012 7:29 PM, Adam Heath wrote: > On 06/03/2012 06:13 AM, [hidden email] wrote: >> Author: adrianc >> Date: Sun Jun 3 11:13:32 2012 >> New Revision: 1345652 >> >> URL: http://svn.apache.org/viewvc?rev=1345652&view=rev >> Log: >> Overhauled a bunch of Mini-language elements. > > What did you do? Details. And, this should probably be split into > smaller, one-step-at-a-time changes. > > When I look at just this commit, it doesn't stand alone. I see no > reference to any previous discussions, no issue tracker url, nothing. > Those things should *not* be part of this commit message, so that > means the description needs to talk about them. > > Then, because so many things have been done in this commit, the > message would get overly long; that means it's time to split the > commit up. > >> >> Removed: >> >> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/NowDateToEnv.java >> >> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/NowTimestampToEnv.java >> Modified: >> ofbiz/trunk/framework/minilang/dtd/simple-methods-v2.xsd >> >> ofbiz/trunk/framework/minilang/src/META-INF/services/org.ofbiz.minilang.method.MethodOperation$Factory >> >> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/FindByPrimaryKey.java >> >> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelated.java >> >> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelatedOne.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/OrderValueList.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/envops/Now.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=1345652&r1=1345651&r2=1345652&view=diff >> ============================================================================== >> >> --- ofbiz/trunk/framework/minilang/dtd/simple-methods-v2.xsd (original) >> +++ ofbiz/trunk/framework/minilang/dtd/simple-methods-v2.xsd Sun Jun >> 3 11:13:32 2012 >> @@ -128,9 +128,9 @@ under the License. >> <xs:documentation> >> The comparison operator. The operator describes >> the l-value compared to the r-value. >> <br/><br/> >> - The"contains" operator returns true if >> the l-value contains the r-value. >> + The "contains" operator returns true if the >> l-value contains the r-value. >> This operator does not perform type conversions. >> - The l-value must be a collection type or a >> String. A null l-value returns false. >> + The l-value must be a collection type or a >> String. A null l-value evaluates to false. >> <br/><br/> >> Required. Attribute type: constant. >> </xs:documentation> >> @@ -155,11 +155,11 @@ under the License. >> <xs:documentation> >> The comparison operator. The operator describes >> the l-value compared to the r-value. >> <br/><br/> >> - The"contains" operator returns true if >> the l-value contains the r-value. >> - This operator does not perform type conversions >> - the"type" attribute will be ignored. >> + The "contains" operator returns true if the >> l-value contains the r-value. >> + This operator does not perform type conversions. >> The l-value must be a collection type or a >> String. A null l-value evaluates to false. >> <br/><br/> >> - The"is-null","is-not-null", >> and"is-empty" operators >> + The "is-null", "is-not-null", and "is-empty" >> operators >> do not require an r-value. Any r-values will be >> ignored. >> <br/><br/> >> Required. Attribute type: constant. >> @@ -273,8 +273,7 @@ under the License. >> <xs:attribute name="delegator-name" type="xs:string"> >> <xs:annotation> >> <xs:documentation> >> - Name of a delegator to use. >> - By default uses the delegator associated with >> that instance of the service engine. >> + Overrides the delegator by specifying a >> delegator name. >> <br/><br/> >> Optional. Attribute type: constant, ${expression}. >> </xs:documentation> >> @@ -1885,118 +1884,101 @@ under the License. >> <xs:element name="sequenced-id" >> substitutionGroup="EntityMiscOperations"> >> <xs:annotation> >> <xs:documentation> >> - The sequenced-id tag gets a sequenced ID from the >> Entity Engine (through the delegator) and puts it in the specified >> method environment field. >> - The object will be a java.lang.Long, but can of >> course be converted to a String. >> + Generates a unique numeric sequence value. Sequence >> values are unique per sequence name. >> </xs:documentation> >> </xs:annotation> >> <xs:complexType> >> -<xs:attributeGroup ref="attlist.sequenced-id"/> >> +<xs:attribute type="xs:string" name="sequence-name" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The sequence name. In most cases, this is >> the name of the entity the sequence value >> + will be used in, but any name can be used. >> +<br/><br/> >> + Required. Attribute type: constant, >> ${expression}. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute ref="field" /> >> +<xs:attribute type="xs:string" name="stagger-max"> >> +<xs:annotation> >> +<xs:documentation> >> + Sequence stagger maximum. If set to "1" the >> sequence value will be incremented by 1, >> + otherwise the sequence value will be >> incremented by an amount between 1 and the >> + stagger maximum. Defaults to "1". >> +<br/><br/> >> + Optional. Attribute type: constant. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute name="get-long-only"> >> +<xs:annotation> >> +<xs:documentation> >> + Preserve the sequence type - a numeric long. >> If set to "false" the sequence >> + value will be converted to a string. >> Defaults to "false". >> +<br/><br/> >> + Optional. Attribute type: constant. >> +</xs:documentation> >> +</xs:annotation> >> +<xs:simpleType> >> +<xs:restriction base="xs:token"> >> +<xs:enumeration value="false" /> >> +<xs:enumeration value="true" /> >> +</xs:restriction> >> +</xs:simpleType> >> +</xs:attribute> >> </xs:complexType> >> </xs:element> >> -<xs:attributeGroup name="attlist.sequenced-id"> >> -<xs:attribute type="xs:string" name="sequence-name" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - The name of the sequence to pass to the delegator. >> - The same name must always be used for sequenced >> IDs that will be used for a certain entity field otherwise non-unique >> keys may result. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="field" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - The name of the method environment field the >> sequenced ID will be put in. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute name="get-long-only" default="false"> >> -<xs:annotation> >> -<xs:documentation> >> - Get a numerical long value and put it there, so >> it does not do that by default. >> - By default getlong-only is false. If you want it >> to just get a long number >> - then you can set that to true. That's in there >> for supporting lower level functionality, >> - but that's not the typical pattern used in OFBiz >> as we do use strings for sequencing. >> -</xs:documentation> >> -</xs:annotation> >> -<xs:simpleType> >> -<xs:restriction base="xs:token"> >> -<xs:enumeration value="true"/> >> -<xs:enumeration value="false"/> >> -</xs:restriction> >> -</xs:simpleType> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="stagger-max"> >> -<xs:annotation> >> -<xs:documentation> >> - By default this is one. But if you want to have >> sequenced Ids that are staggered, instead >> - of consecutive, then you can set this to >> something like twenty. And then it will do a random staggering for >> - each sequenced id; instead of picking the next >> value all the time it will pick something between the next value >> - and twenty away from the next value, if >> stagger-max is set to twenty. >> - So that can be used to make the sequenced Ids >> more difficult to guess. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -</xs:attributeGroup> >> <xs:element name="make-next-seq-id" >> substitutionGroup="EntityMiscOperations"> >> <xs:annotation> >> <xs:documentation> >> - sequenced-id is the primary key sequencer. >> - Make-next-seq-id is the secondary key sequencer. So >> - this would be something like an orderId for example, >> - where we're sequencing an orderId automatically. And >> - this would be something like an orderItemSequenceId, >> - where we have a sub-sequence that varies for order >> - item records related back to an orderHeader. So all of >> - them will have the same orderId. >> + Generates a sequence string and uses it to update >> the specified entity value. >> + The sequence is generated by scanning all similar >> values in the entity and adding >> + an increment amount to the highest sequence value >> found. >> +<br/><br/> >> + This element is typically used to generate sequences >> for the child entity in a >> + parent-child relationship - like order items or >> invoice items. >> </xs:documentation> >> </xs:annotation> >> <xs:complexType> >> -<xs:attributeGroup ref="attlist.make-next-seq-id"/> >> +<xs:attribute type="xs:string" name="value-field" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the field that contains the >> entity value to update. >> +<br/><br/> >> + Required. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute type="xs:string" name="seq-field-name" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The entity value field that will receive the >> sub-sequenced value. >> +<br/><br/> >> + Required. Attribute type: constant, >> ${expression}. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute type="xs:string" name="numeric-padding"> >> +<xs:annotation> >> +<xs:documentation> >> + Left-pad the sequence string with the >> specified number of zeros. >> + Defaults to "5". >> +<br/><br/> >> + Optional. Attribute type: constant, >> ${expression}. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute type="xs:string" name="increment-by"> >> +<xs:annotation> >> +<xs:documentation> >> + Sequence increment amount. Defaults to "1". >> +<br/><br/> >> + Optional. Attribute type: constant, >> ${expression}. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> </xs:complexType> >> </xs:element> >> -<xs:attributeGroup name="attlist.make-next-seq-id"> >> -<xs:attribute type="xs:string" name="value-field" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - Specify the name of the entity for a >> sequenced-id preparing the primarySequencedId. >> - The name of the entity is typically what we use >> for the sequenced name, but you can use anything >> - you want if you want to have different sets of >> sequences. >> - >> - The risk of course of many different sets of >> sequences >> - for the same entity is unless you somehow prefix or >> - suffix the value, you could have a key conflict. >> So we >> - just use the entity name for these primary >> sequences. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="seq-field-name" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - The field that will have the sub-sequenced value. >> - We use the seqId suffix on the field names in >> the OFBiz >> - data model to denote that that field is a >> secondary sequenced ID >> - and should therefore be maintained for this sort >> of operation. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="numeric-padding" default="5"> >> -<xs:annotation> >> -<xs:documentation> >> - Since these are eventually strings we do >> numeric-padding so that the sort is consistent, >> - By default we pad it with five positions. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="increment-by" default="1"> >> -<xs:annotation> >> -<xs:documentation> >> - Default to 1. >> - If you want to leave some space in the >> sub-sequence you >> - can use a greater increment. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -</xs:attributeGroup> >> >> <xs:element name="entity-data" substitutionGroup="EntityMiscOperations"> >> <xs:annotation> >> @@ -2046,7 +2028,8 @@ under the License. >> <xs:attribute type="xs:string" name="delegator-name"> >> <xs:annotation> >> <xs:documentation> >> - Overrides the delegator or default context >> by specifying a delegator-name. >> + Overrides the delegator by specifying a >> delegator name. >> +<br/><br/> >> Optional. Attribute type: constant, >> ${expression}. >> </xs:documentation> >> </xs:annotation> >> @@ -2056,61 +2039,70 @@ under the License. >> <xs:element name="find-by-primary-key" >> substitutionGroup="EntityFindOperations"> >> <xs:annotation> >> <xs:documentation> >> - The find-by-primary-key tag uses the delegator to >> find an entity value by its primary key. >> - The resulting GenericValue object will be placed in >> the method environment using the specified value-field. >> + Returns a single entity value that is retrieved from >> the database by using the primary key. >> + The primary key used for the search is contained in >> a map. >> </xs:documentation> >> </xs:annotation> >> <xs:complexType> >> -<xs:attributeGroup ref="attlist.find-by-primary-key"/> >> +<xs:attribute type="xs:string" name="entity-name"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the entity to search in. If the >> primary key map is an entity value, >> + then the value's entity name can be used >> instead of this attribute. >> +<br/><br/> >> + Optional if the entity name comes from the >> primary key map. Attribute type: constant, ${expression}. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute type="xs:string" name="value-field" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the field that will contain the >> entity value. >> +<br/><br/> >> + Required. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute type="xs:string" name="map" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of a map in the method environment >> that will be used for the entity fields. >> +<br/><br/> >> + Required. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute type="xs:string" name="fields-to-select-list"> >> +<xs:annotation> >> +<xs:documentation> >> + List containing name of fields to select, if >> empty defaults to all entity fields. >> +<br/><br/> >> + Optional. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute type="xs:string" name="use-cache"> >> +<xs:annotation> >> +<xs:documentation> >> + Specifies whether or not the delegator's >> cache should be searched before going to the database. >> + This results in much faster retrieval times, >> but can return stale data that is not the most current in the database. >> + Must be "true" or "false", defaults to "false". >> +<br/><br/> >> + Optional. Attribute type: constant, >> ${expression}. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute type="xs:string" name="delegator-name"> >> +<xs:annotation> >> +<xs:documentation> >> + Overrides the delegator by specifying a >> delegator name. >> +<br/><br/> >> + Optional. Attribute type: constant, >> ${expression}. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> </xs:complexType> >> </xs:element> >> -<xs:attributeGroup name="attlist.find-by-primary-key"> >> -<xs:attribute type="xs:string" name="entity-name" use="optional"> >> -<xs:annotation> >> -<xs:documentation> >> - The name of the entity to find an instance of. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="map" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - The name of a map in the method environment that >> will be used for the entity fields. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="value-field" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - The name of the method environment field that >> will contain the GenericValue object. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="use-cache" default="false"> >> -<xs:annotation> >> -<xs:documentation> >> - Specifies whether or not the delegator's cache >> should be searched before going to the database. >> - This results in much faster retrieval times, but >> can return stale data that is not the most current in the database. >> - Must be "true" or "false", defaults to "false". >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="fields-to-select-list"> >> -<xs:annotation> >> -<xs:documentation> >> - List containing name of fields to select, if >> empty defaults to all entity fields. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="delegator-name"> >> -<xs:annotation> >> -<xs:documentation> >> - By default this operation is done using the >> delegator that is part of the simple-method calling context. >> - This allows you to override the default >> delegator by naming an alternate delegator. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -</xs:attributeGroup> >> <xs:element name="find-by-and" substitutionGroup="EntityFindOperations"> >> <xs:annotation> >> <xs:documentation> >> @@ -2140,7 +2132,8 @@ under the License. >> <xs:attribute type="xs:string" name="map" use="required"> >> <xs:annotation> >> <xs:documentation> >> - The name of the field containing a map that >> will be used for the entity fields. >> + The name of the field containing a map that >> will be used for the search. >> + The map name/value pairs will be combined >> using a boolean AND. >> <br/><br/> >> Required. Attribute type: expression. >> </xs:documentation> >> @@ -2721,156 +2714,160 @@ under the License. >> <xs:element name="get-related-one" >> substitutionGroup="EntityFindOperations"> >> <xs:annotation> >> <xs:documentation> >> - If you have a generic value object sitting in the >> context and you want to get a related entity >> - following one of the type one relationships in the >> data model, then you can specify the name of the value >> - here, the relation-name, the name of the >> relationship between the two entities, and the to-value where it >> - should put the result, and you can tell it to >> use-cache or not, by default it doesn't. >> + Finds an entity value that is related to an existing >> entity value. >> </xs:documentation> >> </xs:annotation> >> <xs:complexType> >> -<xs:attributeGroup ref="attlist.get-related-one"/> >> +<xs:attribute name="value-field" type="xs:string" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the field containing the entity >> value. >> +<br/><br/> >> + Required. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute name="relation-name" type="xs:string" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the entity value relation to use. >> +<br/><br/> >> + Required. Attribute type: constant, >> ${expression}. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute name="to-value-field" type="xs:string" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the field that will contain the >> related entity value. >> +<br/><br/> >> + Required. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute name="use-cache" type="xs:string" default="false"> >> +<xs:annotation> >> +<xs:documentation> >> + Specifies whether or not the delegator's >> cache should be searched before going to the database. >> + This results in much faster retrieval times, >> but can return stale data that is not the most current in the database. >> + Must be "true" or "false", defaults to "false". >> +<br/><br/> >> + Optional. Attribute type: constant, >> ${expression}. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> </xs:complexType> >> </xs:element> >> -<xs:attributeGroup name="attlist.get-related-one"> >> -<xs:attribute name="value-field" type="xs:string" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - Name of a generic value sitting in the context >> from where you want to get a related-one generic value. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute name="relation-name" type="xs:string" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - Name of the one-relation to use to relate >> generic value in value-field to generic value in to-value. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute name="use-cache" type="xs:string" default="false"> >> -<xs:annotation> >> -<xs:documentation> >> - Specifies whether or not the delegator's cache >> should be searched before going to the database. >> - This results in much faster retrieval times, but >> can return stale data that is not the most current in the database. >> - Must be "true" or "false", defaults to "false". >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute name="to-value-field" type="xs:string" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - Name of a generic value where to put the result. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -</xs:attributeGroup> >> <xs:element name="get-related" substitutionGroup="EntityFindOperations"> >> <xs:annotation> >> <xs:documentation> >> - Get-related is just like get-related-one, >> - except that instead of getting a single value back >> to put in the to-value, >> - it gets a full list back. >> - >> - You start with the the value object, specify the >> name of the relationship. >> - You can specify the name of a map that will restrain >> the query further, >> - beyond the field mappings and their relationship. >> - >> - You can also specify how you want to order it. >> - >> - Use-cache true or false, list-name for the output. >> + Finds entity values that are related to an existing >> entity value. Returns an empty list >> + if no related entity values are found. >> </xs:documentation> >> </xs:annotation> >> <xs:complexType> >> -<xs:attributeGroup ref="attlist.get-related"/> >> +<xs:attribute type="xs:string" name="value-field" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the field containing the entity >> value. >> +<br/><br/> >> + Required. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute type="xs:string" name="relation-name" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the entity value relation to use. >> +<br/><br/> >> + Required. Attribute type: constant, >> ${expression}. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute type="xs:string" name="list" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the field that will contain the >> search results list. >> +<br/><br/> >> + Required. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute type="xs:string" name="map"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the field containing a map that >> will be used for the search. >> + The map name/value pairs will be combined >> using a boolean AND. >> +<br/><br/> >> + Optional. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute type="xs:string" name="order-by-list"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the field containing a list that >> contains field names that you want the find operation to order the >> results by. >> + Each entry in the list is a field name. The >> field name can be preceded by a plus or a minus sign to specify an >> + ascending or descending sort for that field. >> The default is ascending sort. >> +<br/><br/> >> + Optional. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute type="xs:string" name="use-cache"> >> +<xs:annotation> >> +<xs:documentation> >> + Specifies whether or not the delegator's >> cache should be searched before going to the database. >> + This results in much faster retrieval times, >> but can return stale data that is not the most current in the database. >> + Must be "true" or "false", defaults to "false". >> +<br/><br/> >> + Optional. Attribute type: constant, >> ${expression}. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> </xs:complexType> >> </xs:element> >> -<xs:attributeGroup name="attlist.get-related"> >> -<xs:attribute type="xs:string" name="value-field" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - Name of a generic value sitting in the context >> from where you want to get a related generic value. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="relation-name" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - Name of the relation to use to relate generic >> value in value-field to generic value in to-value. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="map"> >> -<xs:annotation> >> -<xs:documentation> >> - Name of a map that will restrain the query further, >> - beyond the field mappings and their relationship. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="order-by-list"> >> -<xs:annotation> >> -<xs:documentation> >> - This will be a list sitting in the context that >> has string entries in it for each field that you want it to order by/ >> - Each field in the list, or each entry in the >> list, will just be a string with a field name. >> - It can be preceded by a plus or a minus to >> specify an ascending or descending sort for that. >> - The default is ascending sort, so you just put a >> minus in front of the field-name if you want it to be descending. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="use-cache" default="false"> >> -<xs:annotation> >> -<xs:documentation> >> - Specifies whether or not the delegator's cache >> should be searched before going to the database. >> - This results in much faster retrieval times, but >> can return stale data that is not the most current in the database. >> - Must be "true" or "false", defaults to "false". >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="list" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - Name of a list where to put the result in. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -</xs:attributeGroup> >> <xs:element name="order-value-list" >> substitutionGroup="EntityFindOperations"> >> <xs:annotation> >> <xs:documentation> >> - Order-value-list does not actually do anything with >> the database. >> - It takes an exiting list that has been returned and >> sorts it. >> + Performs an in-memory sort of a list of entity values. >> </xs:documentation> >> </xs:annotation> >> <xs:complexType> >> -<xs:attributeGroup ref="attlist.order-value-list"/> >> +<xs:attribute type="xs:string" name="list" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the field that contains the list >> of entity values. >> + If the source list is not found, the target >> field will be set to null. >> +<br/><br/> >> + Required. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute type="xs:string" name="order-by-list" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the field that contains the list >> of field names to sort on. >> + Field names can be preceded by a plus symbol >> (+) or a minus symbol (-) to specify an ascending or descending sort >> for that field. >> + The default is ascending sort. >> + If the order-by-list is not found the target >> field will be set to a copy of the source list >> +<br/><br/> >> + Required. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute type="xs:string" name="to-list"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the field that will contain the >> sorted list. Defaults to the field specified >> + in the list attribute. >> +<br/><br/> >> + Optional. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> </xs:complexType> >> </xs:element> >> -<xs:attributeGroup name="attlist.order-value-list"> >> -<xs:attribute type="xs:string" name="list" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - Name of the list of generic value objects that >> we want to sort. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="to-list"> >> -<xs:annotation> >> -<xs:documentation> >> - Name of the output list. If it is empty, as it >> is optional, it will simply use the list-name. >> - In other words it will take the ordered list and >> put it over top of the resource list. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="order-by-list" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - This will be a list sitting in the context that >> has string entries in it for each field that you want it to order by. >> - Each field in the list, or each entry in the >> list, will just be a string with a field name. >> - It can be preceded by a plus or a minus to >> specify an ascending or descending sort for that. >> - The default is ascending sort, so you just put a >> minus in front of the field-name if you want it to be descending. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -</xs:attributeGroup> >> <xs:element name="filter-list-by-and" >> substitutionGroup="EntityFindOperations"> >> <xs:annotation> >> <xs:documentation> >> @@ -2975,38 +2972,41 @@ under the License. >> <xs:element name="make-value" substitutionGroup="EntityValueOperations"> >> <xs:annotation> >> <xs:documentation> >> - The make-value tag uses the delegator to construct >> an entity value. >> - The resulting value will not necessarily exist in >> the database, but will simply be assembled using the entity-name and >> fields map. >> - The resulting GenericValue object will be placed in >> the method environment using the specified value-field. >> + Creates a new entity value. >> + The new entity value exists only in memory - it is >> not persisted in the database until it is stored. >> </xs:documentation> >> </xs:annotation> >> <xs:complexType> >> -<xs:attributeGroup ref="attlist.make-value"/> >> +<xs:attribute type="xs:string" name="entity-name" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The entity name. >> +<br/><br/> >> + Required. Attribute type: constant, >> ${expression}. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute type="xs:string" name="value-field" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the field that will contain the >> entity value. >> +<br/><br/> >> + Required. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute type="xs:string" name="map"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the field that contains a map >> that is used to initialize the entity value fields. >> + Map values whose key matches one of the >> entity value fields will be copied to the entity value. >> +<br/><br/> >> + Optional. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> </xs:complexType> >> </xs:element> >> -<xs:attributeGroup name="attlist.make-value"> >> -<xs:attribute type="xs:string" name="value-field" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - The name of the method environment field that >> contains the GenericValue object. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="entity-name" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - The name of the entity to construct an instance of. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="map"> >> -<xs:annotation> >> -<xs:documentation> >> - The name of a map in the method environment that >> will be used for the entity fields. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -</xs:attributeGroup> >> <xs:element name="clone-value" >> substitutionGroup="EntityValueOperations"> >> <xs:annotation> >> <xs:documentation> >> @@ -3017,7 +3017,7 @@ under the License. >> <xs:attribute type="xs:string" name="value-field" use="required"> >> <xs:annotation> >> <xs:documentation> >> - The name of the field that contains the >> GenericValue object. >> + The name of the field that contains the >> entity value. >> <br/><br/> >> Required. Attribute type: expression. >> </xs:documentation> >> @@ -3119,172 +3119,158 @@ under the License. >> <xs:element name="refresh-value" >> substitutionGroup="EntityValueOperations"> >> <xs:annotation> >> <xs:documentation> >> - Refresh from database the value given in value-field. >> + Refresh an entity value from the database. >> </xs:documentation> >> </xs:annotation> >> <xs:complexType> >> -<xs:attributeGroup ref="attlist.refresh-value"/> >> +<xs:attribute type="xs:string" name="value-field" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the field that contains the >> entity value. >> +<br/><br/> >> + Required. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute name="do-cache-clear"> >> +<xs:annotation> >> +<xs:documentation> >> + Clear the cache. Defaults to "true". >> +<br/><br/> >> + Optional. Attribute type: constant, >> ${expression}. >> +</xs:documentation> >> +</xs:annotation> >> +<xs:simpleType> >> +<xs:restriction base="xs:token"> >> +<xs:enumeration value="true" /> >> +<xs:enumeration value="false" /> >> +</xs:restriction> >> +</xs:simpleType> >> +</xs:attribute> >> </xs:complexType> >> </xs:element> >> -<xs:attributeGroup name="attlist.refresh-value"> >> -<xs:attribute type="xs:string" name="value-field" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - Name of the value to refresh from database. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute name="do-cache-clear" default="true"> >> -<xs:annotation> >> -<xs:documentation> >> - Clear the cache, defaults to true. >> -</xs:documentation> >> -</xs:annotation> >> -<xs:simpleType> >> -<xs:restriction base="xs:token"> >> -<xs:enumeration value="true"/> >> -<xs:enumeration value="false"/> >> -</xs:restriction> >> -</xs:simpleType> >> -</xs:attribute> >> -</xs:attributeGroup> >> <xs:element name="remove-value" >> substitutionGroup="EntityValueOperations"> >> <xs:annotation> >> <xs:documentation> >> - The remove-value tag removes the specified >> GenericValue object by removing the instance of the entity in the >> datasource. >> - An error will result if an instance of the entity >> does not exist in the datasource with the same primary key. >> + Removes an entity value from the database. >> </xs:documentation> >> </xs:annotation> >> <xs:complexType> >> -<xs:attributeGroup ref="attlist.remove-value"/> >> +<xs:attribute name="value-field" type="xs:string" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the field containing the entity >> value. >> +<br/><br/> >> + Required. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute name="do-cache-clear"> >> +<xs:annotation> >> +<xs:documentation> >> + Clear the cache. Defaults to "true". >> +<br/><br/> >> + Optional. Attribute type: constant, >> ${expression}. >> +</xs:documentation> >> +</xs:annotation> >> +<xs:simpleType> >> +<xs:restriction base="xs:token"> >> +<xs:enumeration value="true" /> >> +<xs:enumeration value="false" /> >> +</xs:restriction> >> +</xs:simpleType> >> +</xs:attribute> >> </xs:complexType> >> </xs:element> >> -<xs:attributeGroup name="attlist.remove-value"> >> -<xs:attribute type="xs:string" name="value-field" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - The name of the method environment field that >> contains the GenericValue object. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute name="do-cache-clear" default="true"> >> -<xs:annotation> >> -<xs:documentation> >> - Clear the cache, defaults to true >> -</xs:documentation> >> -</xs:annotation> >> -<xs:simpleType> >> -<xs:restriction base="xs:token"> >> -<xs:enumeration value="true"/> >> -<xs:enumeration value="false"/> >> -</xs:restriction> >> -</xs:simpleType> >> -</xs:attribute> >> -</xs:attributeGroup> >> <xs:element name="remove-related" >> substitutionGroup="EntityValueOperations"> >> <xs:annotation> >> <xs:documentation> >> - Given a value name and a relationship name, >> - follows the relationship and remove all related >> - records, whether they be a type one or type many >> - relationship. >> - >> - For a type one relationship it will remove a >> - single record if it exists, and for a type many >> relationship >> - it will remove all the records that are related to it. >> - >> - This of course can be dangerous, for example if you >> - have a product-type entity and you do a remove-related >> - with a certain product type value object here, and the >> - relation name product here, it will remove all products >> - of that type. This is of more value when you're doing >> - something like removing an order or removing a product, >> - and you want to remove all related elements before >> - removing the product to resolve foreign key issues. >> - >> - Usually the best practice for that, for removing a >> product >> - for example, is to do a remove-related on certain >> - types of information related to the product, and >> then try >> - to remove the product but not remove all related >> tables. >> - >> - In many cases, if the product has been ordered for >> example, >> - then you do not want to remove the product, >> - and so you can do all these remove-relateds. >> + Removes entity values from the database that are >> related to an existing entity value. >> + For a one-to-one relationship it will remove a >> single entity value if it exists, >> + and for a one-to-many relationship it will remove >> all related entity values. >> </xs:documentation> >> </xs:annotation> >> <xs:complexType> >> -<xs:attributeGroup ref="attlist.remove-related"/> >> +<xs:attribute name="value-field" type="xs:string" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the field containing the entity >> value. >> +<br/><br/> >> + Required. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute name="relation-name" type="xs:string" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the entity value relation to use. >> +<br/><br/> >> + Required. Attribute type: constant, >> ${expression}. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute name="do-cache-clear"> >> +<xs:annotation> >> +<xs:documentation> >> + Clear the cache. Defaults to "true". >> +<br/><br/> >> + Optional. Attribute type: constant, >> ${expression}. >> +</xs:documentation> >> +</xs:annotation> >> +<xs:simpleType> >> +<xs:restriction base="xs:token"> >> +<xs:enumeration value="true" /> >> +<xs:enumeration value="false" /> >> +</xs:restriction> >> +</xs:simpleType> >> +</xs:attribute> >> </xs:complexType> >> </xs:element> >> -<xs:attributeGroup name="attlist.remove-related"> >> -<xs:attribute type="xs:string" name="value-field" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - Name of a generic value to remove all related >> records. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="relation-name" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - Name of a relation to use to remove related >> records. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute name="do-cache-clear" default="true"> >> -<xs:annotation> >> -<xs:documentation> >> - Clear the cache, defaults to true >> -</xs:documentation> >> -</xs:annotation> >> -<xs:simpleType> >> -<xs:restriction base="xs:token"> >> -<xs:enumeration value="true"/> >> -<xs:enumeration value="false"/> >> -</xs:restriction> >> -</xs:simpleType> >> -</xs:attribute> >> -</xs:attributeGroup> >> <xs:element name="remove-by-and" >> substitutionGroup="EntityValueOperations"> >> <xs:annotation> >> <xs:documentation> >> - The remove-by-and tag uses the delegator to remove >> entity values from the datasource and is constrained by anding the >> fields passed in the map. >> - Make sure the map contains something, or all values >> will be removed. >> + Removes entity values from the datasource. >> + Uses a map of name/value pairs that will be combined >> using a boolean AND to constrain the removal. >> </xs:documentation> >> </xs:annotation> >> <xs:complexType> >> -<xs:attributeGroup ref="attlist.remove-by-and"/> >> +<xs:attribute type="xs:string" name="entity-name" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the entity. >> +<br/><br/> >> + Required. Attribute type: constant, >> ${expression}. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute type="xs:string" name="map" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the field containing a map that >> will be used for the constraint. >> + The map name/value pairs will be combined >> using a boolean AND. >> + If the map is missing or empty, then all >> entity values will be removed. >> +<br/><br/> >> + Required. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute name="do-cache-clear"> >> +<xs:annotation> >> +<xs:documentation> >> + Clear the cache. Defaults to "true". >> +<br/><br/> >> + Optional. Attribute type: constant, >> ${expression}. >> +</xs:documentation> >> +</xs:annotation> >> +<xs:simpleType> >> +<xs:restriction base="xs:token"> >> +<xs:enumeration value="true" /> >> +<xs:enumeration value="false" /> >> +</xs:restriction> >> +</xs:simpleType> >> +</xs:attribute> >> </xs:complexType> >> </xs:element> >> -<xs:attributeGroup name="attlist.remove-by-and"> >> -<xs:attribute type="xs:string" name="entity-name" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - The name of the entity to remove instances of. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute type="xs:string" name="map" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - The name of a map in the method environment that >> will be used for the entity fields. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute name="do-cache-clear" default="true"> >> -<xs:annotation> >> -<xs:documentation> >> - Clear the cache, defaults to true >> -</xs:documentation> >> -</xs:annotation> >> -<xs:simpleType> >> -<xs:restriction base="xs:token"> >> -<xs:enumeration value="true"/> >> -<xs:enumeration value="false"/> >> -</xs:restriction> >> -</xs:simpleType> >> -</xs:attribute> >> -</xs:attributeGroup> >> <xs:element name="clear-cache-line" >> substitutionGroup="EntityValueOperations"> >> <xs:annotation> >> <xs:documentation> >> @@ -3441,36 +3427,38 @@ under the License. >> <xs:element name="remove-list" substitutionGroup="EntityListOperations"> >> <xs:annotation> >> <xs:documentation> >> - The remove-list tag uses the delegator to remove all >> entity values in the list. >> - For each value in the list if it is a primary key >> just that entity instance will be removed, but if it is not a full >> primary key all entity instances will be removed from the datasource >> that match the constraint of the field map. >> + Removes from the database all entity values in a list. >> + If an entity value in the list is a complete primary >> key, then just that entity value will be removed from the database. >> + If an entity value in the list is not a complete >> primary key, then all matching entity values will be removed from the >> database. >> </xs:documentation> >> </xs:annotation> >> <xs:complexType> >> -<xs:attributeGroup ref="attlist.remove-list"/> >> +<xs:attribute type="xs:string" name="list" use="required"> >> +<xs:annotation> >> +<xs:documentation> >> + The name of the field that contains the list >> of entity values. >> +<br/><br/> >> + Required. Attribute type: expression. >> +</xs:documentation> >> +</xs:annotation> >> +</xs:attribute> >> +<xs:attribute name="do-cache-clear"> >> +<xs:annotation> >> +<xs:documentation> >> + Clear the cache. Defaults to "true". >> +<br/><br/> >> + Optional. Attribute type: constant, >> ${expression}. >> +</xs:documentation> >> +</xs:annotation> >> +<xs:simpleType> >> +<xs:restriction base="xs:token"> >> +<xs:enumeration value="true" /> >> +<xs:enumeration value="false" /> >> +</xs:restriction> >> +</xs:simpleType> >> +</xs:attribute> >> </xs:complexType> >> </xs:element> >> -<xs:attributeGroup name="attlist.remove-list"> >> -<xs:attribute type="xs:string" name="list" use="required"> >> -<xs:annotation> >> -<xs:documentation> >> - The name of the method environment field that >> contains the list of GenericValue objects. >> -</xs:documentation> >> -</xs:annotation> >> -</xs:attribute> >> -<xs:attribute name="do-cache-clear" default="true"> >> -<xs:annotation> >> -<xs:documentation> >> - Clear the cache, defaults to true >> -</xs:documentation> >> -</xs:annotation> >> -<xs:simpleType> >> -<xs:restriction base="xs:token"> >> -<xs:enumeration value="true"/> >> -<xs:enumeration value="false"/> >> -</xs:restriction> >> -</xs:simpleType> >> -</xs:attribute> >> -</xs:attributeGroup> >> >> <!-- =================== CONTROL OPERATIONS =================== --> >> <xs:element name="iterate" substitutionGroup="ControlOperations"> >> >> Modified: >> ofbiz/trunk/framework/minilang/src/META-INF/services/org.ofbiz.minilang.method.MethodOperation$Factory >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/META-INF/services/org.ofbiz.minilang.method.MethodOperation%24Factory?rev=1345652&r1=1345651&r2=1345652&view=diff >> ============================================================================== >> >> --- >> ofbiz/trunk/framework/minilang/src/META-INF/services/org.ofbiz.minilang.method.MethodOperation$Factory >> (original) >> +++ >> ofbiz/trunk/framework/minilang/src/META-INF/services/org.ofbiz.minilang.method.MethodOperation$Factory >> Sun Jun 3 11:13:32 2012 >> @@ -49,15 +49,12 @@ org.ofbiz.minilang.method.entityops.GetR >> org.ofbiz.minilang.method.entityops.GetRelatedOne$GetRelatedOneFactory >> org.ofbiz.minilang.method.entityops.MakeNextSeqId$MakeNextSeqIdFactory >> org.ofbiz.minilang.method.entityops.MakeValue$MakeValueFactory >> -org.ofbiz.minilang.method.entityops.NowDateToEnv$NowDateToEnvFactory >> -org.ofbiz.minilang.method.entityops.NowTimestampToEnv$NowTimestampFactory >> >> >> org.ofbiz.minilang.method.entityops.OrderValueList$OrderValueListFactory >> org.ofbiz.minilang.method.entityops.RefreshValue$RefreshValueFactory >> org.ofbiz.minilang.method.entityops.RemoveByAnd$RemoveByAndFactory >> org.ofbiz.minilang.method.entityops.RemoveList$RemoveListFactory >> org.ofbiz.minilang.method.entityops.RemoveRelated$RemoveRelatedFactory >> org.ofbiz.minilang.method.entityops.RemoveValue$RemoveValueFactory >> -org.ofbiz.minilang.method.entityops.SequencedIdToEnv$SequencedIdToEnvFactory >> >> >> org.ofbiz.minilang.method.entityops.SequencedIdToEnv$SequencedIdFactory >> >> org.ofbiz.minilang.method.entityops.SetCurrentUserLogin$SetCurrentUserLoginFactory >> >> org.ofbiz.minilang.method.entityops.SetNonpkFields$SetNonpkFieldsFactory >> @@ -83,6 +80,8 @@ org.ofbiz.minilang.method.envops.ListToL >> org.ofbiz.minilang.method.envops.Loop$LoopFactory >> org.ofbiz.minilang.method.envops.MapToMap$MapToMapFactory >> org.ofbiz.minilang.method.envops.Now$NowFactory >> +org.ofbiz.minilang.method.envops.Now$NowDateToEnvFactory >> +org.ofbiz.minilang.method.envops.Now$NowTimestampFactory >> org.ofbiz.minilang.method.envops.OrderMapList$OrderMapListFactory >> org.ofbiz.minilang.method.envops.SetCalendar$SetCalendarFactory >> org.ofbiz.minilang.method.envops.SetOperation$SetOperationFactory >> >> 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=1345652&r1=1345651&r2=1345652&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 >> Sun Jun 3 11:13:32 2012 >> @@ -21,75 +21,85 @@ package org.ofbiz.minilang.method.entity >> import java.util.Collection; >> import java.util.Map; >> >> -import org.ofbiz.minilang.artifact.ArtifactInfoContext; >> import org.ofbiz.base.util.Debug; >> import org.ofbiz.base.util.UtilMisc; >> -import org.ofbiz.base.util.UtilValidate; >> +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; >> import org.ofbiz.minilang.MiniLangException; >> +import org.ofbiz.minilang.MiniLangRuntimeException; >> +import org.ofbiz.minilang.MiniLangValidate; >> import org.ofbiz.minilang.SimpleMethod; >> -import org.ofbiz.minilang.method.ContextAccessor; >> +import org.ofbiz.minilang.artifact.ArtifactInfoContext; >> import org.ofbiz.minilang.method.MethodContext; >> import org.ofbiz.minilang.method.MethodOperation; >> import org.w3c.dom.Element; >> >> /** >> - * Uses the delegator to find an entity value by its primary key >> + * Implements the<find-by-primary-key> element. >> */ >> -public class FindByPrimaryKey extends MethodOperation { >> +public final class FindByPrimaryKey extends MethodOperation { >> >> public static final String module = >> FindByPrimaryKey.class.getName(); >> >> - String delegatorName; >> - String entityName; >> - ContextAccessor<Collection<String>> fieldsToSelectListAcsr; >> - ContextAccessor<Map<String, ? extends Object>> mapAcsr; >> - String useCacheStr; >> - ContextAccessor<GenericValue> valueAcsr; >> + private final FlexibleStringExpander delegatorNameFse; >> + private final FlexibleStringExpander entityNameFse; >> + private final FlexibleMapAccessor<Collection<String>> >> fieldsToSelectListFma; >> + private final FlexibleMapAccessor<Map<String, ? extends >> Object>> mapFma; >> + private final FlexibleStringExpander useCacheFse; >> + private final FlexibleMapAccessor<GenericValue> valueFma; >> >> public FindByPrimaryKey(Element element, SimpleMethod >> simpleMethod) throws MiniLangException { >> super(element, simpleMethod); >> - valueAcsr = new >> ContextAccessor<GenericValue>(element.getAttribute("value-field"), >> element.getAttribute("value-name")); >> - entityName = element.getAttribute("entity-name"); >> - mapAcsr = new ContextAccessor<Map<String, ? extends >> Object>>(element.getAttribute("map"), element.getAttribute("map-name")); >> - fieldsToSelectListAcsr = new >> ContextAccessor<Collection<String>>(element.getAttribute("fields-to-select-list")); >> - delegatorName = element.getAttribute("delegator-name"); >> - useCacheStr = element.getAttribute("use-cache"); >> + 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.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")); >> } >> >> @Override >> public boolean exec(MethodContext methodContext) throws >> MiniLangException { >> - String entityName = >> methodContext.expandString(this.entityName); >> - String delegatorName = >> methodContext.expandString(this.delegatorName); >> - String useCacheStr = >> methodContext.expandString(this.useCacheStr); >> - boolean useCache = "true".equals(useCacheStr); >> + String entityName = >> entityNameFse.expandString(methodContext.getEnvMap()); >> + boolean useCache = >> "true".equals(useCacheFse.expandString(methodContext.getEnvMap())); >> Delegator delegator = methodContext.getDelegator(); >> - if (UtilValidate.isNotEmpty(delegatorName)) { >> + String delegatorName = >> delegatorNameFse.expandString(methodContext.getEnvMap()); >> + if (!delegatorName.isEmpty()) { >> delegator = DelegatorFactory.getDelegator(delegatorName); >> } >> - Map<String, ? extends Object> inMap = >> mapAcsr.get(methodContext); >> - if (UtilValidate.isEmpty(entityName)&& inMap instanceof >> GenericEntity) { >> + Map<String, ? extends Object> inMap = >> mapFma.get(methodContext.getEnvMap()); >> + if (inMap == null) { >> + throw new MiniLangRuntimeException("Primary key map \"" >> + mapFma + "\" not found", this); >> + } >> + if (entityName.isEmpty()&& inMap instanceof GenericEntity) { >> GenericEntity inEntity = (GenericEntity) inMap; >> entityName = inEntity.getEntityName(); >> } >> - Collection<String> fieldsToSelectList = null; >> - if (!fieldsToSelectListAcsr.isEmpty()) { >> - fieldsToSelectList = >> fieldsToSelectListAcsr.get(methodContext); >> + if (entityName.isEmpty()) { >> + throw new MiniLangRuntimeException("Entity name not >> found", this); >> } >> + Collection<String> fieldsToSelectList = >> fieldsToSelectListFma.get(methodContext.getEnvMap()); >> try { >> if (fieldsToSelectList != null) { >> - valueAcsr.put(methodContext, >> delegator.findByPrimaryKeyPartial(delegator.makePK(entityName, >> inMap), UtilMisc.makeSetWritable(fieldsToSelectList))); >> + valueFma.put(methodContext.getEnvMap(), >> delegator.findByPrimaryKeyPartial(delegator.makePK(entityName, >> inMap), UtilMisc.makeSetWritable(fieldsToSelectList))); >> } else { >> - valueAcsr.put(methodContext, >> delegator.findOne(entityName, inMap, useCache)); >> + valueFma.put(methodContext.getEnvMap(), >> delegator.findOne(entityName, inMap, useCache)); >> } >> } catch (GenericEntityException e) { >> - Debug.logError(e, module); >> - String errMsg = "ERROR: Could not complete the " + >> simpleMethod.getShortDescription() + " process [problem finding the " >> + entityName + " entity: " + e.getMessage() + "]"; >> - methodContext.setErrorReturn(errMsg, simpleMethod); >> + String errMsg = "Exception thrown while performing >> entity find: " + e.getMessage(); >> + Debug.logWarning(e, errMsg, module); >> + simpleMethod.addErrorMessage(methodContext, errMsg); >> return false; >> } >> return true; >> @@ -97,26 +107,48 @@ public class FindByPrimaryKey extends Me >> >> @Override >> public String expandedString(MethodContext methodContext) { >> - // TODO: something more than a stub/dummy >> - return this.rawString(); >> + return FlexibleStringExpander.expandString(toString(), >> methodContext.getEnvMap()); >> } >> >> @Override >> public void gatherArtifactInfo(ArtifactInfoContext aic) { >> - aic.addEntityName(entityName); >> + aic.addEntityName(entityNameFse.toString()); >> } >> >> @Override >> public String rawString() { >> - // TODO: something more than the empty tag >> - return "<find-by-primary-key/>"; >> + return toString(); >> } >> >> + @Override >> + public String toString() { >> + StringBuilder sb = new StringBuilder("<find-by-primary-key "); >> + >> sb.append("entity-name=\"").append(this.entityNameFse).append("\" "); >> + sb.append("value-field=\"").append(this.valueFma).append("\" >> "); >> + sb.append("map=\"").append(this.mapFma).append("\" "); >> + if (!fieldsToSelectListFma.isEmpty()) { >> + >> sb.append("fields-to-select-list=\"").append(this.fieldsToSelectListFma).append("\" >> "); >> + } >> + 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(); >> + } >> + >> + /** >> + * A factory for the<find-by-primary-key> element. >> + */ >> public static final class FindByPrimaryKeyFactory implements >> Factory<FindByPrimaryKey> { >> + @Override >> public FindByPrimaryKey createMethodOperation(Element >> element, SimpleMethod simpleMethod) throws MiniLangException { >> return new FindByPrimaryKey(element, simpleMethod); >> } >> >> + @Override >> public String getName() { >> return "find-by-primary-key"; >> } >> >> Modified: >> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelated.java >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelated.java?rev=1345652&r1=1345651&r2=1345652&view=diff >> ============================================================================== >> >> --- >> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelated.java >> (original) >> +++ >> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelated.java >> Sun Jun 3 11:13:32 2012 >> @@ -21,65 +21,66 @@ package org.ofbiz.minilang.method.entity >> import java.util.List; >> import java.util.Map; >> >> -import org.ofbiz.minilang.artifact.ArtifactInfoContext; >> import org.ofbiz.base.util.Debug; >> +import org.ofbiz.base.util.collections.FlexibleMapAccessor; >> +import org.ofbiz.base.util.string.FlexibleStringExpander; >> import org.ofbiz.entity.GenericEntityException; >> import org.ofbiz.entity.GenericValue; >> import org.ofbiz.minilang.MiniLangException; >> +import org.ofbiz.minilang.MiniLangRuntimeException; >> +import org.ofbiz.minilang.MiniLangValidate; >> import org.ofbiz.minilang.SimpleMethod; >> -import org.ofbiz.minilang.method.ContextAccessor; >> +import org.ofbiz.minilang.artifact.ArtifactInfoContext; >> import org.ofbiz.minilang.method.MethodContext; >> import org.ofbiz.minilang.method.MethodOperation; >> import org.w3c.dom.Element; >> >> /** >> - * Gets a list of related entity instance according to the specified >> relation-name >> + * Implements the<get-related> element. >> */ >> -public class GetRelated extends MethodOperation { >> +public final class GetRelated extends MethodOperation { >> >> public static final String module = GetRelated.class.getName(); >> >> - ContextAccessor<List<GenericValue>> listAcsr; >> - ContextAccessor<Map<String, ? extends Object>> mapAcsr; >> - ContextAccessor<List<String>> orderByListAcsr; >> - String relationName; >> - String useCacheStr; >> - ContextAccessor<GenericValue> valueAcsr; >> + private final FlexibleMapAccessor<Object> listFma; >> + private final FlexibleMapAccessor<Map<String, ? extends >> Object>> mapFma; >> + private final FlexibleMapAccessor<List<String>> orderByListFma; >> + private final FlexibleStringExpander relationNameFse; >> + private final FlexibleStringExpander useCacheFse; >> + private final FlexibleMapAccessor<GenericValue> valueFma; >> >> public GetRelated(Element element, SimpleMethod simpleMethod) >> throws MiniLangException { >> super(element, simpleMethod); >> - valueAcsr = new >> ContextAccessor<GenericValue>(element.getAttribute("value-field"), >> element.getAttribute("value-name")); >> - relationName = element.getAttribute("relation-name"); >> - listAcsr = new >> ContextAccessor<List<GenericValue>>(element.getAttribute("list"), >> element.getAttribute("list-name")); >> - mapAcsr = new ContextAccessor<Map<String, ? extends >> Object>>(element.getAttribute("map"), element.getAttribute("map-name")); >> - orderByListAcsr = new >> ContextAccessor<List<String>>(element.getAttribute("order-by-list"), >> element.getAttribute("order-by-list-name")); >> - useCacheStr = element.getAttribute("use-cache"); >> + if (MiniLangValidate.validationOn()) { >> + MiniLangValidate.attributeNames(simpleMethod, element, >> "value-field", "relation-name", "list", "map", "order-by-list", >> "use-cache"); >> + MiniLangValidate.requiredAttributes(simpleMethod, >> element, "value-field", "relation-name", "list"); >> + MiniLangValidate.expressionAttributes(simpleMethod, >> element, "value-field", "list", "map", "order-by-list"); >> + MiniLangValidate.noChildElements(simpleMethod, element); >> + } >> + valueFma = >> FlexibleMapAccessor.getInstance(element.getAttribute("value-field")); >> + relationNameFse = >> FlexibleStringExpander.getInstance(element.getAttribute("relation-name")); >> + listFma = >> FlexibleMapAccessor.getInstance(element.getAttribute("list")); >> + mapFma = >> FlexibleMapAccessor.getInstance(element.getAttribute("map")); >> + orderByListFma = >> FlexibleMapAccessor.getInstance(element.getAttribute("order-by-list")); >> + useCacheFse = >> FlexibleStringExpander.getInstance(element.getAttribute("use-cache")); >> } >> >> @Override >> public boolean exec(MethodContext methodContext) throws >> MiniLangException { >> - String relationName = >> methodContext.expandString(this.relationName); >> - String useCacheStr = >> methodContext.expandString(this.useCacheStr); >> - boolean useCache = "true".equals(useCacheStr); >> - List<String> orderByNames = null; >> - if (!orderByListAcsr.isEmpty()) { >> - orderByNames = orderByListAcsr.get(methodContext); >> - } >> - Map<String, ? extends Object> constraintMap = null; >> - if (!mapAcsr.isEmpty()) { >> - constraintMap = mapAcsr.get(methodContext); >> - } >> - GenericValue value = valueAcsr.get(methodContext); >> + GenericValue value = valueFma.get(methodContext.getEnvMap()); >> if (value == null) { >> - Debug.logWarning("Value not found with name: " + >> valueAcsr + ", not getting related...", module); >> - return true; >> + throw new MiniLangRuntimeException("Entity value not >> found with name: " + valueFma, this); >> } >> + String relationName = >> relationNameFse.expandString(methodContext.getEnvMap()); >> + boolean useCache = >> "true".equals(useCacheFse.expandString(methodContext.getEnvMap())); >> + List<String> orderByNames = >> orderByListFma.get(methodContext.getEnvMap()); >> + Map<String, ? extends Object> constraintMap = >> mapFma.get(methodContext.getEnvMap()); >> try { >> - listAcsr.put(methodContext, >> value.getRelated(relationName, constraintMap, orderByNames, useCache)); >> + listFma.put(methodContext.getEnvMap(), >> value.getRelated(relationName, constraintMap, orderByNames, useCache)); >> } catch (GenericEntityException e) { >> - String errMsg = "ERROR: Could not complete the " + >> simpleMethod.getShortDescription() + " process [problem getting >> related from entity with name " + value.getEntityName() + " for the >> relation-name: " + relationName + ": " + e.getMessage() + "]"; >> - Debug.logError(e, errMsg, module); >> - methodContext.setErrorReturn(errMsg, simpleMethod); >> + String errMsg = "Exception thrown while finding related >> values: " + e.getMessage(); >> + Debug.logWarning(e, errMsg, module); >> + simpleMethod.addErrorMessage(methodContext, errMsg); >> return false; >> } >> return true; >> @@ -87,26 +88,48 @@ public class GetRelated extends MethodOp >> >> @Override >> public String expandedString(MethodContext methodContext) { >> - // TODO: something more than a stub/dummy >> - return this.rawString(); >> + return FlexibleStringExpander.expandString(toString(), >> methodContext.getEnvMap()); >> } >> >> @Override >> public void gatherArtifactInfo(ArtifactInfoContext aic) { >> - aic.addEntityName(relationName); >> + aic.addEntityName(relationNameFse.toString()); >> } >> >> @Override >> public String rawString() { >> - // TODO: something more than the empty tag >> - return "<get-related/>"; >> + return toString(); >> } >> >> + @Override >> + public String toString() { >> + StringBuilder sb = new StringBuilder("<get-related "); >> + sb.append("value-field=\"").append(this.valueFma).append("\" >> "); >> + >> sb.append("relation-name=\"").append(this.relationNameFse).append("\" >> "); >> + sb.append("list=\"").append(this.listFma).append("\" "); >> + if (!mapFma.isEmpty()) { >> + sb.append("map=\"").append(this.mapFma).append("\" "); >> + } >> + if (!orderByListFma.isEmpty()) { >> + >> sb.append("order-by-list=\"").append(this.orderByListFma).append("\" "); >> + } >> + if (!useCacheFse.isEmpty()) { >> + >> sb.append("use-cache=\"").append(this.useCacheFse).append("\" "); >> + } >> + sb.append("/>"); >> + return sb.toString(); >> + } >> + >> + /** >> + * A factory for the<get-related> element. >> + */ >> public static final class GetRelatedFactory implements >> Factory<GetRelated> { >> + @Override >> public GetRelated createMethodOperation(Element element, >> SimpleMethod simpleMethod) throws MiniLangException { >> return new GetRelated(element, simpleMethod); >> } >> >> + @Override >> public String getName() { >> return "get-related"; >> } >> >> Modified: >> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelatedOne.java >> URL: >> http://svn.apache.org/viewvc/ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelatedOne.java?rev=1345652&r1=1345651&r2=1345652&view=diff >> ============================================================================== >> >> --- >> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelatedOne.java >> (original) >> +++ >> ofbiz/trunk/framework/minilang/src/org/ofbiz/minilang/method/entityops/GetRelatedOne.java >> Sun Jun 3 11:13:32 2012 >> @@ -18,60 +18,60 @@ >> >> *******************************************************************************/ >> package org.ofbiz.minilang.method.entityops; >> >> -import org.ofbiz.minilang.artifact.ArtifactInfoContext; >> import org.ofbiz.base.util.Debug; >> +import org.ofbiz.base.util.collections.FlexibleMapAccessor; >> +import org.ofbiz.base.util.string.FlexibleStringExpander; >> import org.ofbiz.entity.GenericEntityException; >> import org.ofbiz.entity.GenericValue; >> import org.ofbiz.minilang.MiniLangException; >> +import org.ofbiz.minilang.MiniLangRuntimeException; >> +import org.ofbiz.minilang.MiniLangValidate; >> import org.ofbiz.minilang.SimpleMethod; >> -import org.ofbiz.minilang.method.ContextAccessor; >> +import org.ofbiz.minilang.artifact.ArtifactInfoContext; >> import org.ofbiz.minilang.method.MethodContext; >> import org.ofbiz.minilang.method.MethodOperation; >> import org.w3c.dom.Element; >> >> /** >> - * Gets a list of related entity instance according to the specified >> relation-name >> + * Implements the<get-related-one> element. >> */ >> -public class GetRelatedOne extends MethodOperation { >> +public final class GetRelatedOne extends MethodOperation { >> >> public static final String module = GetRelatedOne.class.getName(); >> >> - String relationName; >> - ContextAccessor<GenericValue> toValueAcsr; >> - String useCacheStr; >> - ContextAccessor<Object> valueAcsr; >> + private final FlexibleStringExpander relationNameFse; >> + private final FlexibleMapAccessor<GenericValue> toValueFma; >> + private final FlexibleStringExpander useCacheFse; >> + private final FlexibleMapAccessor<GenericValue> valueFma; >> >> public GetRelatedOne(Element element, SimpleMethod >> simpleMethod) throws MiniLangException { >> super(element, simpleMethod); >> - valueAcsr = new >> ContextAccessor<Object>(element.getAttribute("value-field"), >> element.getAttribute("value-name")); >> - toValueAcsr = new >> ContextAccessor<GenericValue>(element.getAttribute("to-value-field"), >> element.getAttribute("to-value-name")); >> - relationName = element.getAttribute("relation-name"); >> - useCacheStr = element.getAttribute("use-cache"); >> + if (MiniLangValidate.validationOn()) { >> + MiniLangValidate.attributeNames(simpleMethod, element, >> "value-field", "relation-name", "to-value-field", "use-cache"); >> + MiniLangValidate.requiredAttributes(simpleMethod, >> element, "value-field", "relation-name", "to-value-field"); >> + MiniLangValidate.expressionAttributes(simpleMethod, >> element, "value-field", "to-value-field"); >> + MiniLangValidate.noChildElements(simpleMethod, element); >> + } >> + valueFma = >> FlexibleMapAccessor.getInstance(element.getAttribute("value-field")); >> + relationNameFse = >> FlexibleStringExpander.getInstance(element.getAttribute("relation-name")); >> + toValueFma = >> FlexibleMapAccessor.getInstance(element.getAttribute("to-value-field")); >> + useCacheFse = >> FlexibleStringExpander.getInstance(element.getAttribute("use-cache")); >> } >> >> @Override >> public boolean exec(MethodContext methodContext) throws >> MiniLangException { >> - String relationName = >> methodContext.expandString(this.relationName); >> - String useCacheStr = >> methodContext.expandString(this.useCacheStr); >> - boolean useCache = "true".equals(useCacheStr); >> - Object valueObject = valueAcsr.get(methodContext); >> - if (!(valueObject instanceof GenericValue)) { >> - String errMsg = "ERROR: Could not complete the " + >> simpleMethod.getShortDescription() + " process [env variable for >> value-name " + valueAcsr.toString() + " is not a GenericValue object; >> for the relation-name: " + relationName + "]"; >> - Debug.logError(errMsg, module); >> - methodContext.setErrorReturn(errMsg, simpleMethod); >> - return false; >> - } >> - GenericValue value = (GenericValue) valueObject; >> + GenericValue value = valueFma.get(methodContext.getEnvMap()); >> if (value == null) { >> - Debug.logWarning("Value not found with name: " + >> valueAcsr + ", not getting related...", module); >> - return true; >> + throw new MiniLangRuntimeException("Entity value not >> found with name: " + valueFma, this); >> } >> + String relationName = >> relationNameFse.expandString(methodContext.getEnvMap()); >> + boolean useCache = >> "true".equals(useCacheFse.expandString(methodContext.getEnvMap())); >> try { >> - toValueAcsr.put(methodContext, >> value.getRelatedOne(relationName, useCache)); >> + toValueFma.put(methodContext.getEnvMap(), >> value.getRelatedOne(relationName, useCache)); >> } catch (GenericEntityException e) { >> - String errMsg = "ERROR: Could not complete the " + >> simpleMethod.getShortDescription() + " process [problem getting >> related one from entity with name " + value.getEntityName() + " for >> the relation-name: " + relationName + ": " + e.getMessage() + "]"; >> - Debug.logError(e, errMsg, module); >> - methodContext.setErrorReturn(errMsg, simpleMethod); >> + String errMsg = "Exception thrown while finding related >> value: " + e.getMessage(); >> + Debug.logWarning(e, errMsg, module); >> + simpleMethod.addErrorMessage(methodContext, errMsg); >> return false; >> } >> return true; >> @@ -79,26 +79,42 @@ public class GetRelatedOne extends Metho >> >> @Override >> public String expandedString(MethodContext methodContext) { >> - // TODO: something more than a stub/dummy >> - return this.rawString(); >> + return FlexibleStringExpander.expandString(toString(), >> methodContext.getEnvMap()); >> } >> >> @Override >> public void gatherArtifactInfo(ArtifactInfoContext aic) { >> - aic.addEntityName(relationName); >> + aic.addEntityName(relationNameFse.toString()); >> } >> >> @Override >> public String rawString() { >> - // TODO: something more than the empty tag >> - return "<get-related-one/>"; >> + return toString(); >> + } >> + >> + @Override >> + public String toString() { >> + StringBuilder sb = new StringBuilder("<get-related-one "); >> + sb.append("value-field=\"").append(this.valueFma).append("\" >> "); >> + >> sb.append("relation-name=\"").append(this.relationNameFse).append("\" >> "); >> + >> sb.append("to-value-field=\"").append(this.toValueFma).append("\" "); >> + if (!useCacheFse.isEmpty()) { >> + >> sb.append("use-cache=\"").append(this.useCacheFse).append("\" "); >> + } >> + sb.append("/>"); >> + return sb.toString(); >> } >> >> + /** >> + * A factory for the<get-related-one> element. >> + */ >> public static final class GetRelatedOneFactory implements >> Factory<GetRelatedOne> { >> + @Override >> public GetRelatedOne createMethodOperation(Element element, >> SimpleMethod simpleMethod) throws MiniLangException { >> return new GetRelatedOne(element, simpleMethod); >> } >> >> + @Override >> public String getName() { >> return "get-related-one"; >> } >> >> > |
|
On 06/03/2012 04:51 PM, Adrian Crum wrote:
> This commit is one of many similar commits that have been made over the > last three months. There was a Mini-language overhaul discussion on the > dev mailing list. Sure, I know there was a discussion. But 2 years from now, when someone is looking at svn history, how will they know that? There is no mailing list url(which is *not* what should be done, as list aggregators come and go; a message-id tho is fine, as it doesn't matter which aggregator is used), no issue#(sometimes those come and go, so a full url is also not recommended). You can reference nearby commits in the history, without using an exact revision number, but it's generally not that great to mention far-away commits, except by number. Even then, using revision numbers is also not the best thing, as sometimes the repo format can switch(think cvs->svn that ofbiz did, or even changing repo hosters(svn.ofbiz.org->svn.apache.org)). And there could even be a switch to git or something else in the future. So, really, no matter what external discussion occurred, in an issue system, on a mailing list, or by the water cooler, the commit itself should be described when it is done. |
| Free forum by Nabble | Edit this page |
