Skip to content

Commit ee9ef99

Browse files
committed
Fix #257: Do not reset entity if reset is false
1 parent 9821220 commit ee9ef99

File tree

2 files changed

+81
-4
lines changed

2 files changed

+81
-4
lines changed

src/main/java/org/culturegraph/mf/morph/collectors/Entity.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,11 @@ protected void emit() {
6464

6565
private void write(final StreamReceiver receiver) {
6666
if (!buffer.isEmpty()) {
67-
6867
receiver.startEntity(StringUtil.fallback(currentName, getName()));
6968
buffer.setReceiver(receiver);
7069
buffer.replay();
7170
receiver.endEntity();
72-
73-
buffer.clear();
7471
}
75-
7672
}
7773

7874
@Override

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

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,4 +452,85 @@
452452
</result>
453453
</test-case>
454454

455+
<test-case name="should emit entity contents again if reset is false">
456+
<input type="text/x-cg+xml">
457+
<cgxml:cgxml version="1.0">
458+
<cgxml:records>
459+
<cgxml:record id="1">
460+
<cgxml:literal name="lit1" value="const" />
461+
<cgxml:literal name="lit2" value="1" />
462+
<cgxml:literal name="lit2" value="2" />
463+
</cgxml:record>
464+
</cgxml:records>
465+
</cgxml:cgxml>
466+
</input>
467+
468+
<transformation type="text/x-metamorph+xml">
469+
<mm:metamorph version="1">
470+
<mm:rules>
471+
<mm:entity name="entity">
472+
<mm:data source="lit1" />
473+
<mm:data source="lit2" />
474+
</mm:entity>
475+
</mm:rules>
476+
</mm:metamorph>
477+
</transformation>
478+
479+
<result type="text/x-cg+xml">
480+
<cgxml:cgxml version="1.0">
481+
<cgxml:records>
482+
<cgxml:record id="1">
483+
<cgxml:entity name="entity">
484+
<cgxml:literal name="lit1" value="const" />
485+
<cgxml:literal name="lit2" value="1" />
486+
</cgxml:entity>
487+
<cgxml:entity name="entity">
488+
<cgxml:literal name="lit1" value="const" />
489+
<cgxml:literal name="lit2" value="1" />
490+
<cgxml:literal name="lit2" value="2" />
491+
</cgxml:entity>
492+
</cgxml:record>
493+
</cgxml:records>
494+
</cgxml:cgxml>
495+
</result>
496+
</test-case>
497+
498+
<test-case name="should not emit entity contents again if reset is false">
499+
<input type="text/x-cg+xml">
500+
<cgxml:cgxml version="1.0">
501+
<cgxml:records>
502+
<cgxml:record id="1">
503+
<cgxml:literal name="lit1" value="const" />
504+
<cgxml:literal name="lit2" value="1" />
505+
<cgxml:literal name="lit2" value="2" />
506+
</cgxml:record>
507+
</cgxml:records>
508+
</cgxml:cgxml>
509+
</input>
510+
511+
<transformation type="text/x-metamorph+xml">
512+
<mm:metamorph version="1">
513+
<mm:rules>
514+
<mm:entity name="entity" reset="true">
515+
<mm:data source="lit1" />
516+
<mm:data source="lit2" />
517+
</mm:entity>
518+
</mm:rules>
519+
</mm:metamorph>
520+
</transformation>
521+
522+
<result type="text/x-cg+xml">
523+
<cgxml:cgxml version="1.0">
524+
<cgxml:records>
525+
<cgxml:record id="1">
526+
<cgxml:entity name="entity">
527+
<cgxml:literal name="lit1" value="const" />
528+
<cgxml:literal name="lit2" value="1" />
529+
</cgxml:entity>
530+
</cgxml:record>
531+
</cgxml:records>
532+
</cgxml:cgxml>
533+
</result>
534+
</test-case>
535+
455536
</metamorph-test>

0 commit comments

Comments
 (0)