Project

General

Profile

1
package eu.dnetlib.wds.resolver;
2

    
3
import eu.dnetlib.miscutils.collections.Pair;
4
import eu.dnetlib.pid.resolver.model.*;
5
import org.apache.commons.lang3.StringEscapeUtils;
6

    
7
import java.util.ArrayList;
8
import java.util.HashMap;
9
import java.util.List;
10
import java.util.Map;
11
import java.util.stream.Collectors;
12

    
13

    
14
public class WDSResolvedObject extends AbstractResolvedObject {
15

    
16

    
17
    private List<PID> pids;
18
    private List<String> titles;
19
    private List<String> authors;
20
    private ObjectType type;
21
    private List<Project> projects;
22
    private List<Pair<String, String>> descriptions;
23
    private List<SubjectType> subjects;
24
    private Map<String, String> dates;
25
    private String publisher;
26
    private String license;
27
    private List<ObjectRelation> relations;
28

    
29

    
30
    public Map<String, String> getDates() {
31
        return dates;
32
    }
33

    
34
    public WDSResolvedObject setDates(Map<String, String> dates) {
35
        this.dates = dates;
36
        return this;
37
    }
38

    
39
    public WDSResolvedObject addProject(final Project project) {
40
        if (this.projects == null)
41
            this.projects = new ArrayList<>();
42
        projects.add(project);
43
        return this;
44
    }
45

    
46
    public String getLicense() {
47
        return license;
48
    }
49

    
50
    public WDSResolvedObject setLicense(String license) {
51
        this.license = license;
52
        return this;
53
    }
54

    
55
    public WDSResolvedObject addPid(final PID pid) {
56
        if (this.pids == null) {
57
            this.pids = new ArrayList<>();
58
            this.setPid(pid.getId()).setPidType(pid.getType());
59
        }
60
        pids.add(pid);
61
        return this;
62
    }
63

    
64
    public WDSResolvedObject addDate(final String dateType, final String dateValue) {
65
        if (dates == null)
66
            dates = new HashMap<>();
67
        dates.put(dateType, dateValue);
68
        return this;
69
    }
70

    
71
    public WDSResolvedObject addTitle(final String title) {
72
        if (this.titles == null)
73
            this.titles = new ArrayList<>();
74
        titles.add(title);
75
        return this;
76
    }
77

    
78
    public WDSResolvedObject addDescription(final Pair<String, String> description) {
79
        if (this.descriptions == null)
80
            this.descriptions = new ArrayList<>();
81
        descriptions.add(description);
82
        return this;
83
    }
84

    
85
    public WDSResolvedObject addSubject(final SubjectType subject) {
86
        if (this.subjects == null)
87
            this.subjects = new ArrayList<>();
88
        subjects.add(subject);
89
        return this;
90
    }
91

    
92
    public WDSResolvedObject addAuthor(final String author) {
93
        if (this.authors == null)
94
            this.authors = new ArrayList<>();
95
        authors.add(author);
96
        return this;
97
    }
98

    
99

    
100
    public List<PID> getPids() {
101
        return pids;
102
    }
103

    
104
    public WDSResolvedObject setPids(List<PID> pids) {
105
        this.pids = pids;
106
        return this;
107
    }
108

    
109
    public List<String> getTitles() {
110
        return titles;
111
    }
112

    
113
    public WDSResolvedObject setTitles(List<String> titles) {
114
        this.titles = titles;
115
        return this;
116
    }
117

    
118
    public ObjectType getType() {
119
        return type;
120
    }
121

    
122
    public WDSResolvedObject setType(ObjectType type) {
123
        this.type = type;
124
        return this;
125
    }
126

    
127
    @Override
128
    public List<ObjectRelation> getRelations() {
129
        return this.relations;
130
    }
131

    
132

    
133
    public WDSResolvedObject setRelations(List<ObjectRelation> relations) {
134
        this.relations = relations;
135
        return this;
136
    }
137

    
138
    public WDSResolvedObject addRelation(ObjectRelation relation) {
139
        if (this.relations == null) {
140
            this.relations = new ArrayList<>();
141
        }
142
        this.relations.add(relation);
143
        return this;
144
    }
145

    
146
    public List<Project> getProjects() {
147
        return projects;
148
    }
149

    
150
    public WDSResolvedObject setProjects(List<Project> projects) {
151
        this.projects = projects;
152
        return this;
153
    }
154

    
155
    public List<Pair<String, String>> getDescriptions() {
156
        return descriptions;
157
    }
158

    
159
    public WDSResolvedObject setDescriptions(List<Pair<String, String>> descriptions) {
160
        this.descriptions = descriptions;
161
        return this;
162
    }
163

    
164
    public List<String> getAuthors() {
165
        return authors;
166
    }
167

    
168
    public WDSResolvedObject setAuthors(List<String> authors) {
169
        this.authors = authors;
170
        return this;
171
    }
172

    
173
    public List<SubjectType> getSubjects() {
174
        return subjects;
175
    }
176

    
177
    public WDSResolvedObject setSubjects(List<SubjectType> subjects) {
178
        this.subjects = subjects;
179
        return this;
180
    }
181

    
182
    public String getPublisher() {
183
        return publisher;
184
    }
185

    
186

    
187
    public String getEscapedPublisher() {
188
        return StringEscapeUtils.escapeXml11(publisher);
189
    }
190

    
191
    public WDSResolvedObject setPublisher(final String publisher) {
192
        this.publisher = publisher;
193
        return this;
194
    }
195

    
196

    
197
    public List<String> getEscapedXMLAuthors() {
198
        if (authors == null)
199
            return authors;
200
        return authors.stream().map(StringEscapeUtils::escapeXml11).collect(Collectors.toList());
201
    }
202

    
203
    public List<String> getEscapedXMLTitles() {
204
        if (titles == null)
205
            return titles;
206
        return titles.stream().map(StringEscapeUtils::escapeXml11).collect(Collectors.toList());
207

    
208
    }
209

    
210
    public List<String> getEscapedDescriptions() {
211
        if (descriptions == null)
212
            return null;
213
        return descriptions.stream().map(Pair::getValue).map(StringEscapeUtils::escapeXml11).collect(Collectors.toList());
214
    }
215

    
216

    
217
    @Override
218
    public String toString() {
219
        return toJsonString();
220
    }
221

    
222

    
223
}
(5-5/6)