Yes, I think your options are either to use the simple-method "make-
next-seq-id" action or extend the "entity-auto" thingy.
On a side note, to be more consistent with other parts of the data
model, the field being sub-sequenced should have the suffix "SeqId",
like porletSeqId.
Stepping back a little bit... does it even make sense to have the same
portlet on a page more than once? I suppose if they can be
parameterized it does make sense (like two clock portlets for
different time zones).
Another option would be to use fromDate/thruDate where fromDate in the
pk will make it unique, or even just an "addDate" or something.
-David
On Oct 19, 2008, at 5:10 PM, Bruno Busco wrote:
Hi devs,
I am trying to set this service up.
<service name="createPortalPagePortlet"
default-entity-name="PortalPagePortlet" engine="entity-auto"
invoke="create"
auth="true">
<description>Add a registered PortalPortlet to a
PortalPage</description>
<auto-attributes include="pk" mode="IN" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
<override name="sequenceNum" mode="OUT" optional="true"/>
</service>
to create this entity:
<entity entity-name="PortalPagePortlet"
package-name="org.ofbiz.common.portal"
title="Defines Portlets included into Portal Pages">
<field name="portalPageId" type="id-ne"></field>
<field name="portalPortletId" type="id-ne"></field>
<field name="sequenceNum" type="id-
ne"><description>Identify
the portalPortlet instance in case more copy of the same
portalPortlet are
present in the same portalPage</description></field>
<field name="columnNum" type="numeric"></field>
<field name="rowNum" type="numeric"></field>
<prim-key field="portalPageId"/>
<prim-key field="portalPortletId"/>
<prim-key field="sequenceNum"/>
</entity>
It was OK before adding the sequenceNum field as PK and adding the
<override>.
Now what I would like to get is the sequenceNum auto-generation.
But the framework tells me:
Error doing entity-auto operation for entity [PortalPagePortlet] in
service
[createPortalPagePortlet]:
org.ofbiz.service.GenericServiceException: In
Service [createPortalPagePortlet] which uses the entity-auto engine
with the
create invoke option: could not find a valid combination of primary
key
settings to do a known create operation; options include: 1. a
single OUT pk
for primary auto-sequencing, 2. a single INOUT pk for primary
auto-sequencing with optional override, 3. a 2-part pk with one part
IN
(existing primary pk) and one part OUT (the secdonary pk to sub-
sequence, 4.
all pk fields are IN for a manually specified primary key
Digging into the code It seems to me that it is not possible to have
the
sequenceNum auto-generation in the case of a 3-parts PK.
Am I correct?
Any work-around?
Should I switch to engine="simple" and use the code that is
indicated as
comment in EntityAutoEngine.java ?
<make-value entity-name="ExampleItem"
value-name="newEntity"/>
<set-pk-fields map-name="parameters"
value-name="newEntity"/>
<make-next-seq-id value-name="newEntity"
seq-field-name="exampleItemSeqId"/> <!-- this finds the next sub-
sequence ID
-->
<field-to-result field-
name="newEntity.exampleItemSeqId"
result-name="exampleItemSeqId"/>
<set-nonpk-fields map-name="parameters"
value-name="newEntity"/>
<create-value value-name="newEntity"/>
Many thanks,
Bruno