1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package eu.ehri.project.importers.ead;
23
24 import eu.ehri.project.importers.base.ItemImporter;
25 import eu.ehri.project.importers.properties.XmlImportProperties;
26 import eu.ehri.project.importers.util.ImportHelpers;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30 import java.util.List;
31 import java.util.Map;
32
33
34
35
36
37 public class UshmmHandler extends EadHandler {
38
39 private static final Logger logger = LoggerFactory.getLogger(UshmmHandler.class);
40
41 private int count;
42
43 public UshmmHandler(ItemImporter<Map<String, Object>, ?> importer) {
44 super(importer, new XmlImportProperties("ushmm.properties"));
45
46 }
47
48 @Override
49 protected void extractIdentifier(Map<String, Object> currentGraph) {
50
51 if (currentGraph.containsKey(ImportHelpers.OBJECT_IDENTIFIER)) {
52 if (currentGraph.get(ImportHelpers.OBJECT_IDENTIFIER) instanceof List) {
53 logger.debug("class of identifier: " + currentGraph.get(ImportHelpers.OBJECT_IDENTIFIER).getClass());
54 List<String> identifiers = (List<String>) currentGraph.get(ImportHelpers.OBJECT_IDENTIFIER);
55 List<String> identifierType = (List<String>) currentGraph.get("objectIdentifierType");
56 for (int i = 0; i < identifiers.size(); i++) {
57 if (identifierType.get(i).equals("irn")) {
58 logger.debug("found official id: " + identifiers.get(i));
59 currentGraph.put(ImportHelpers.OBJECT_IDENTIFIER, identifiers.get(i));
60 } else {
61 logger.debug("found other form of identifier: " + identifiers.get(i));
62 addOtherIdentifier(currentGraph, identifiers.get(i));
63
64 }
65 }
66 currentGraph.remove("objectIdentifierType");
67 }
68 } else {
69 logger.error("no unitid found, setting {}", ++count);
70 currentGraph.put(ImportHelpers.OBJECT_IDENTIFIER, "ushmmID" + count);
71 }
72 }
73 }