Skip to content

Commit f220f9e

Browse files
committed
Removing CGEntity and CGText and refactoring test cases to make it
possible
1 parent 5227f19 commit f220f9e

16 files changed

+329
-361
lines changed

src/main/java/org/culturegraph/mf/stream/converter/CGTextEncoder.java

Lines changed: 0 additions & 102 deletions
This file was deleted.

src/main/java/org/culturegraph/mf/stream/pipe/IdChangePipe.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ public final class IdChangePipe extends DefaultStreamPipe<StreamReceiver> {
3737
private String idName = StreamConstants.ID;
3838
private final StreamBuffer streamBuffer = new StreamBuffer();
3939
private String currentIdentifier;
40+
private String originalIdentifier;
4041
private int depth;
41-
private boolean keepIdless;
42+
private boolean keepIdless = true;
4243

4344
public IdChangePipe() {
4445
super();
@@ -61,20 +62,23 @@ public void setKeepIdless(final boolean keepIdless) {
6162
public void startRecord(final String identifier) {
6263
assert !isClosed();
6364
currentIdentifier = null;
65+
originalIdentifier = identifier;
6466
depth = 0;
6567
}
6668

6769
@Override
6870
public void endRecord() {
6971
assert !isClosed();
70-
if (null != currentIdentifier || keepIdless) {
71-
getReceiver().startRecord(currentIdentifier);
72+
if (currentIdentifier != null || keepIdless) {
73+
if (currentIdentifier == null) {
74+
getReceiver().startRecord(originalIdentifier);
75+
} else {
76+
getReceiver().startRecord(currentIdentifier);
77+
}
7278
streamBuffer.replay();
73-
streamBuffer.clear();
7479
getReceiver().endRecord();
75-
}else{
76-
streamBuffer.clear();
7780
}
81+
streamBuffer.clear();
7882
}
7983

8084
@Override

src/main/java/org/culturegraph/mf/stream/pipe/StreamMerger.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@
3434
public final class StreamMerger
3535
extends DefaultStreamPipe<StreamReceiver> {
3636

37-
private boolean firstRecord = true;
37+
private boolean hasRecordsReceived;
3838
private String currentId = "";
3939

4040
@Override
4141
public void startRecord(final String identifier) {
4242
assert !isClosed();
4343
if (!currentId.equals(identifier)) {
44-
if (!firstRecord) {
44+
if (hasRecordsReceived) {
4545
getReceiver().endRecord();
4646
}
4747
getReceiver().startRecord(identifier);
4848
currentId = identifier;
4949
}
5050

51-
firstRecord = false;
51+
hasRecordsReceived = true;
5252
}
5353

5454
@Override
@@ -71,13 +71,13 @@ public void literal(final String name, final String value) {
7171

7272
@Override
7373
protected void onResetStream() {
74-
firstRecord = true;
74+
hasRecordsReceived = false;
7575
currentId = "";
7676
}
7777

7878
@Override
7979
protected void onCloseStream() {
80-
if (!firstRecord) {
80+
if (hasRecordsReceived) {
8181
getReceiver().endRecord();
8282
}
8383
onResetStream();

src/test/java/org/culturegraph/mf/stream/converter/CGTextDecoderTest.java

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/test/java/org/culturegraph/mf/stream/converter/CGTextEncoderTest.java

Lines changed: 0 additions & 72 deletions
This file was deleted.

src/test/java/org/culturegraph/mf/stream/converter/JsonEncoderTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public final class JsonEncoderTest {
5757
@Before
5858
public void setup() {
5959
MockitoAnnotations.initMocks(this);
60-
6160
encoder = new JsonEncoder();
6261
encoder.setReceiver(receiver);
6362
}

0 commit comments

Comments
 (0)