Skip to content

Commit f8ef044

Browse files
committed
Fix #256: Support sameEntity in none and all
Add support for the `sameEntity` attribute to `none` and `all` statements. The attribute does not make sense in `any` statements.
1 parent ee9ef99 commit f8ef044

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

src/main/resources/schemata/metamorph.xsd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@
230230
<attribute name="flushWith" type="string" use="optional" />
231231
<attribute name="reset" type="boolean" use="optional"
232232
default="false" />
233+
<attribute name="sameEntity" type="boolean" use="optional" default="false" />
233234
</complexType>
234235
</element>
235236

@@ -268,6 +269,7 @@
268269
default="record" />
269270
<attribute name="reset" type="boolean" use="optional"
270271
default="false" />
272+
<attribute name="sameEntity" type="boolean" use="optional" default="false" />
271273
</complexType>
272274
</element>
273275

src/test/java/org/culturegraph/mf/morph/collectors/AllTest.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,41 @@
189189
</result>
190190
</test-case>
191191

192+
<test-case name="should reset when entity changes if sameEntity">
193+
<input type="text/x-cg+xml">
194+
<cgxml:cgxml version="1.0">
195+
<cgxml:records>
196+
<cgxml:record id="1">
197+
<cgxml:entity name="entity">
198+
<cgxml:literal name="data2" value="A" />
199+
</cgxml:entity>
200+
<cgxml:entity name="entity">
201+
<cgxml:literal name="data1" value="A" />
202+
</cgxml:entity>
203+
</cgxml:record>
204+
</cgxml:records>
205+
</cgxml:cgxml>
206+
</input>
207+
208+
<transformation type="text/x-metamorph+xml">
209+
<mm:metamorph version="1">
210+
<mm:rules>
211+
<mm:all sameEntity="true">
212+
<mm:data source="entity.data2" />
213+
<mm:data source="entity.data1" />
214+
</mm:all>
215+
</mm:rules>
216+
</mm:metamorph>
217+
</transformation>
218+
219+
<result type="text/x-cg+xml">
220+
<cgxml:cgxml version="1.0">
221+
<cgxml:records>
222+
<cgxml:record id="1">
223+
</cgxml:record>
224+
</cgxml:records>
225+
</cgxml:cgxml>
226+
</result>
227+
</test-case>
228+
192229
</metamorph-test>

src/test/java/org/culturegraph/mf/morph/collectors/NoneTest.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,41 @@
154154
</result>
155155
</test-case>
156156

157+
<test-case name="should reset when entity changes if sameEntity">
158+
<input type="text/x-cg+xml">
159+
<cgxml:cgxml version="1.0">
160+
<cgxml:records>
161+
<cgxml:record id="1">
162+
<cgxml:entity name="entity">
163+
<cgxml:literal name="data2" value="A" />
164+
</cgxml:entity>
165+
<cgxml:entity name="entity">
166+
<cgxml:literal name="data1" value="A" />
167+
</cgxml:entity>
168+
</cgxml:record>
169+
</cgxml:records>
170+
</cgxml:cgxml>
171+
</input>
172+
173+
<transformation type="text/x-metamorph+xml">
174+
<mm:metamorph version="1">
175+
<mm:rules>
176+
<mm:none sameEntity="true">
177+
<mm:data source="entity.data2" />
178+
</mm:none>
179+
</mm:rules>
180+
</mm:metamorph>
181+
</transformation>
182+
183+
<result type="text/x-cg+xml">
184+
<cgxml:cgxml version="1.0">
185+
<cgxml:records>
186+
<cgxml:record id="1">
187+
<cgxml:literal name="" value="true" />
188+
</cgxml:record>
189+
</cgxml:records>
190+
</cgxml:cgxml>
191+
</result>
192+
</test-case>
193+
157194
</metamorph-test>

0 commit comments

Comments
 (0)