Project

General

Profile

1
package eu.dnetlib.data.transform.xml2;
2

    
3
import java.util.Map;
4

    
5
import com.google.common.collect.Maps;
6

    
7
import static eu.dnetlib.data.transform.xml2.Utils.*;
8
import static eu.dnetlib.data.transform.xml2.VtdUtilityParser.xpath;
9

    
10
public class PublicationToProto extends AbstractResultDom4jParser {
11

    
12
    public PublicationToProto() {
13
        super(getFields());
14
    }
15

    
16
    public PublicationToProto(final boolean invisible, final String provenance, final String trust) {
17
        super(invisible, provenance, trust, getFields());
18
    }
19

    
20
    @Override
21
    protected String getResulttype(final String cobjcategory) {
22
        switch (cobjcategory) {
23
        case "0029":
24
            return "software";
25
        default:
26
            return "publication";
27
        }
28
    }
29

    
30
    protected static Map<String, String> getFields() {
31
        final Map<String, String> fields = Maps.newHashMap();
32

    
33
        fields.put("originalId", xpath("record", "header", "recordIdentifier"));
34
        fields.put("dateofcollection", xpath("record", "header", "dateOfCollection"));
35
        fields.put("dateoftransformation", xpath("record", "header", "dateOfTransformation"));
36
        fields.put("collectedfrom", metadataXpath("collectedFrom"));
37
        fields.put("pid", metadataXpath("identifier"));
38
        fields.put("license", metadataXpath("license"));
39
        fields.put("accessright", metadataXpath("accessrights"));
40
        fields.put("instancetype", metadataXpath("CobjCategory"));
41
        fields.put("hostedby", metadataXpath("hostedBy"));
42
        fields.put("url", metadataXpath("identifier"));
43
        fields.put("title", metadataXpath("title"));
44
        fields.put("description", metadataXpath("description"));
45
        fields.put("dateofacceptance", metadataXpath("dateAccepted"));
46
        fields.put("embargoenddate", metadataXpath("embargoenddate"));
47
        fields.put("storagedate", metadataXpath("storagedate"));
48
        fields.put("author", metadataXpath("creator"));
49
        fields.put("contributor", metadataXpath("contributor"));
50
        fields.put("subject", metadataXpath("subject"));
51
        fields.put("format", metadataXpath("format"));
52
        fields.put("source", metadataXpath("source"));
53
        fields.put("publisher", metadataXpath("publisher"));
54
        fields.put("language", metadataXpath("language"));
55
        fields.put("resulttype", metadataXpath("CobjCategory"));
56
        fields.put("concept", metadataXpath("concept"));
57
        fields.put("externalReference", metadataXpath("reference"));
58

    
59
        fields.put("cachedRel", String.format("%s | %s | %s",
60
                metadataXpath("projectid"),
61
                metadataXpath("relatedDataSet"),
62
                xpath("record", "metadata") + "//*[local-name()='relatedIdentifier']"));
63

    
64
        return fields;
65
    }
66

    
67
}
(6-6/11)