• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pkiraly / metadata-qa-marc / #1527

22 Aug 2025 02:21PM UTC coverage: 90.345%. Remained the same
#1527

push

pkiraly
Improve timeline handling

5191 of 6416 new or added lines in 219 files covered. (80.91%)

886 existing lines in 78 files now uncovered.

36717 of 40641 relevant lines covered (90.34%)

0.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.86
/src/main/java/de/gwdg/metadataqa/marc/utils/keygenerator/MixedDataFieldKeyGenerator.java
1
package de.gwdg.metadataqa.marc.utils.keygenerator;
2

3
import de.gwdg.metadataqa.marc.definition.bibliographic.SchemaType;
4
import de.gwdg.metadataqa.marc.definition.structure.DataFieldDefinition;
5
import de.gwdg.metadataqa.marc.definition.structure.SubfieldDefinition;
6

7
public class MixedDataFieldKeyGenerator extends DataFieldKeyGenerator {
8

9
  public MixedDataFieldKeyGenerator(DataFieldDefinition definition) {
10
    super(definition);
1✔
11
  }
1✔
12

13
  public MixedDataFieldKeyGenerator(DataFieldDefinition definition,
14
                                    String tag,
15
                                    SchemaType schemaType) {
16
    super(definition, tag, schemaType);
1✔
17
  }
1✔
18

19
  @Override
20
  public String forInd1() {
21
    if (definition == null) {
1✔
NEW
22
      return String.format("%sind1", tag);
×
23
    }
24

25
    return String.format("%sind1_%s_%s", tag, indexTag, definition.getInd1().getIndexTag());
1✔
26
  }
27

28
  @Override
29
  public String forInd2() {
30
    if (definition == null) {
1✔
NEW
31
      return String.format("%sind2", tag);
×
32
    }
33

34
    return String.format("%sind2_%s_%s", tag, indexTag, definition.getInd2().getIndexTag());
1✔
35
  }
36

37
  @Override
38
  public String getKeyForSubfield(String code, String codeForIndex) {
39
    // Make sure that the field tag does not contain any invalid characters
40
    String safeTag = nonValidSubfieldCode.matcher(tag).find() ? escape(tag) : tag;
1✔
41

42
    // Also make sure that the subfield code does not contain any invalid characters
43
    if (nonValidSubfieldCode.matcher(code).matches()) {
1✔
44
      code = String.format("x%x", (int) code.charAt(0));
1✔
45
    }
46

47
    if (schemaType != null && schemaType.equals(SchemaType.PICA)) {
1✔
48
      return String.format("%s%s", safeTag, code);
1✔
49
    }
50
    if (!tag.equals(indexTag) && !codeForIndex.equals(code) && !codeForIndex.isEmpty()) {
1✔
51
      return String.format("%s%s_%s_%s", safeTag, code, indexTag, codeForIndex);
1✔
52
    }
53
    if (!tag.equals(indexTag)) {
1✔
54
      return String.format("%s%s_%s", safeTag, code, indexTag);
1✔
55
    }
56
    return String.format("%s%s", safeTag, code);
1✔
57
  }
58

59
  @Override
60
  public String forFullField() {
61
    String safeTag = nonValidSubfieldCode.matcher(tag).find() ? escape(tag) : tag;
1✔
62
    if (definition != null && !tag.equals(indexTag)) {
1✔
63
      String key = String.format("%s_%s", safeTag, indexTag);
1✔
64
      return key + "_full";
1✔
65
    }
66
    return safeTag + "_full";
1✔
67
  }
68

69
  @Override
70
  protected String addVersionSpecifier(SubfieldDefinition versionSpecificDefinition, String key) {
71
    if (versionSpecificDefinition != null && versionSpecificDefinition.getMarcVersion() != null) {
1✔
72
      key += "_" + versionSpecificDefinition.getMarcVersion().getCode();
1✔
73
    }
74
    return key;
1✔
75
  }
76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc