1
|
package eu.dnetlib.resolver.model;
|
2
|
|
3
|
import java.util.List;
|
4
|
|
5
|
import eu.dnetlib.dli.DLIUtils;
|
6
|
import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
|
7
|
import org.apache.commons.lang3.StringEscapeUtils;
|
8
|
|
9
|
/**
|
10
|
* The Class DLIRelation.
|
11
|
*/
|
12
|
public class ObjectRelation {
|
13
|
|
14
|
/**
|
15
|
* The source doi.
|
16
|
*/
|
17
|
private String sourceRecordId;
|
18
|
|
19
|
/**
|
20
|
* The source doi.
|
21
|
*/
|
22
|
private String sourcePid;
|
23
|
|
24
|
/**
|
25
|
* The target type.
|
26
|
*/
|
27
|
private ObjectType targetType;
|
28
|
|
29
|
/**
|
30
|
* The target pid.
|
31
|
*/
|
32
|
private PID targetPID;
|
33
|
|
34
|
/**
|
35
|
* The target title.
|
36
|
*/
|
37
|
private String targetTitle;
|
38
|
|
39
|
/**
|
40
|
* The authors.
|
41
|
*/
|
42
|
private List<String> authors;
|
43
|
|
44
|
/**
|
45
|
* The relation semantics.
|
46
|
*/
|
47
|
private String relationSemantics;
|
48
|
|
49
|
/**
|
50
|
* The relation provenance.
|
51
|
*/
|
52
|
private List<ObjectProvenance> relationProvenance;
|
53
|
|
54
|
/**
|
55
|
* The status.
|
56
|
*/
|
57
|
private String completionStatus = "incomplete";
|
58
|
|
59
|
private ResolvedObject extraInfo;
|
60
|
|
61
|
/**
|
62
|
* Gets the source do
|
63
|
*
|
64
|
* @return the source doi
|
65
|
*/
|
66
|
public String getSourceRecordId() {
|
67
|
return sourceRecordId;
|
68
|
}
|
69
|
|
70
|
/**
|
71
|
* Sets the source doi.
|
72
|
*
|
73
|
* @param sourceRecordId the new source record id
|
74
|
*/
|
75
|
public void setSourceRecordId(final String sourceRecordId) {
|
76
|
if (sourceRecordId != null) {
|
77
|
this.sourceRecordId = sourceRecordId;
|
78
|
}
|
79
|
}
|
80
|
|
81
|
/**
|
82
|
* Gets the escaped xmldoi.
|
83
|
*
|
84
|
* @return the escaped xmldoi
|
85
|
*/
|
86
|
public String getEscapedXMLDOI() {
|
87
|
return StringEscapeUtils.escapeXml(sourceRecordId);
|
88
|
}
|
89
|
|
90
|
/**
|
91
|
* Gets the target type.
|
92
|
*
|
93
|
* @return the target type
|
94
|
*/
|
95
|
public ObjectType getTargetType() {
|
96
|
return targetType;
|
97
|
}
|
98
|
|
99
|
/**
|
100
|
* Sets the target type.
|
101
|
*
|
102
|
* @param targetType the new target type
|
103
|
*/
|
104
|
public void setTargetType(final ObjectType targetType) {
|
105
|
this.targetType = targetType;
|
106
|
}
|
107
|
|
108
|
/**
|
109
|
* Gets the ID relation.
|
110
|
*
|
111
|
* @return the ID relation
|
112
|
*/
|
113
|
public String getIDRelation() {
|
114
|
|
115
|
if ((this.getSourceRecordId() == null) || (this.getTargetPID() == null) || (this.getTargetPID().getId() == null))
|
116
|
return null;
|
117
|
return String.format("%s::%s", this.getSourceRecordId(), DnetXsltFunctions.md5(getTargetPID().getId().toLowerCase().trim()));
|
118
|
}
|
119
|
|
120
|
public String getIDRecord() {
|
121
|
return (DnetXsltFunctions.md5(String.format("%s::%s", this.getTargetPID().getId(), this.getTargetPID().getType())));
|
122
|
}
|
123
|
|
124
|
/**
|
125
|
* Gets the target pid.
|
126
|
*
|
127
|
* @return the target pid
|
128
|
*/
|
129
|
public PID getTargetPID() {
|
130
|
return targetPID;
|
131
|
}
|
132
|
|
133
|
/**
|
134
|
* Sets the target pid.
|
135
|
*
|
136
|
* @param targetPID the new target pid
|
137
|
*/
|
138
|
public void setTargetPID(final PID targetPID) {
|
139
|
|
140
|
if (targetPID.getType() != null && "doi".equals(targetPID.getType().trim().toLowerCase()))
|
141
|
targetPID.setId(DLIUtils.fixPID(targetPID.getId()));
|
142
|
this.targetPID = targetPID;
|
143
|
}
|
144
|
|
145
|
/**
|
146
|
* Gets the target title.
|
147
|
*
|
148
|
* @return the target title
|
149
|
*/
|
150
|
public String getTargetTitle() {
|
151
|
if (targetTitle == null) return null;
|
152
|
String bf = targetTitle;
|
153
|
bf = bf.replaceAll("&", "&");
|
154
|
bf = bf.replaceAll("\"", """);
|
155
|
bf = bf.replaceAll("'", "'");
|
156
|
bf = bf.replaceAll("<", "<");
|
157
|
bf = bf.replaceAll(">", ">");
|
158
|
return bf;
|
159
|
}
|
160
|
|
161
|
/**
|
162
|
* Sets the target title.
|
163
|
*
|
164
|
* @param targetTitle the new target title
|
165
|
*/
|
166
|
public void setTargetTitle(final String targetTitle) {
|
167
|
this.targetTitle = targetTitle;
|
168
|
}
|
169
|
|
170
|
/**
|
171
|
* Gets the relation semantics.
|
172
|
*
|
173
|
* @return the relation semantics
|
174
|
*/
|
175
|
public String getRelationSemantics() {
|
176
|
return relationSemantics;
|
177
|
}
|
178
|
|
179
|
/**
|
180
|
* Sets the relation semantics.
|
181
|
*
|
182
|
* @param relationSemantics the new relation semantics
|
183
|
*/
|
184
|
public void setRelationSemantics(final String relationSemantics) {
|
185
|
this.relationSemantics = relationSemantics;
|
186
|
}
|
187
|
|
188
|
/**
|
189
|
* Gets the relation provenance.
|
190
|
*
|
191
|
* @return the relationProvenance
|
192
|
*/
|
193
|
public List<ObjectProvenance> getRelationProvenance() {
|
194
|
return relationProvenance;
|
195
|
}
|
196
|
|
197
|
/**
|
198
|
* Sets the relation provenance.
|
199
|
*
|
200
|
* @param relationProvenance the relationProvenance to set
|
201
|
*/
|
202
|
public void setRelationProvenance(final List<ObjectProvenance> relationProvenance) {
|
203
|
this.relationProvenance = relationProvenance;
|
204
|
}
|
205
|
|
206
|
/**
|
207
|
* Gets the completion status.
|
208
|
*
|
209
|
* @return the completion status
|
210
|
*/
|
211
|
public String getCompletionStatus() {
|
212
|
return this.completionStatus;
|
213
|
}
|
214
|
|
215
|
/**
|
216
|
* Sets the completion status.
|
217
|
*
|
218
|
* @param completionStatus the new completion status
|
219
|
*/
|
220
|
public void setCompletionStatus(final String completionStatus) {
|
221
|
this.completionStatus = completionStatus;
|
222
|
}
|
223
|
|
224
|
/**
|
225
|
* Gets the source pid.
|
226
|
*
|
227
|
* @return the source pid
|
228
|
*/
|
229
|
public String getSourcePid() {
|
230
|
return sourcePid;
|
231
|
}
|
232
|
|
233
|
/**
|
234
|
* Sets the source pid.
|
235
|
*
|
236
|
* @param sourcePid the new source pid
|
237
|
*/
|
238
|
public void setSourcePid(final String sourcePid) {
|
239
|
this.sourcePid = sourcePid;
|
240
|
}
|
241
|
|
242
|
/**
|
243
|
* {@inheritDoc}
|
244
|
*
|
245
|
* @see Object#toString()
|
246
|
*/
|
247
|
@Override
|
248
|
public String toString() {
|
249
|
String format =
|
250
|
"Relation: \n\tId:%s \n\tSourcePid%s \n\tTargetPid:%s \n\tTargetPidType:%s \n\ttitle:%s \n\tCompletionStatus:%s \n\t Relation Semantic:%s \n\tProvenances:%s";
|
251
|
return String.format(format, this.getIDRelation(), this.getSourcePid(), this.getTargetPID() == null ? "" : this.getTargetPID(),
|
252
|
this.getTargetType(), this.getTargetTitle(), this.getCompletionStatus(), this.getRelationSemantics(),
|
253
|
this.getRelationProvenance());
|
254
|
}
|
255
|
|
256
|
/**
|
257
|
* Gets the authors.
|
258
|
*
|
259
|
* @return the authors
|
260
|
*/
|
261
|
public List<String> getAuthors() {
|
262
|
return authors;
|
263
|
}
|
264
|
|
265
|
/**
|
266
|
* Sets the authors.
|
267
|
*
|
268
|
* @param authors the new authors
|
269
|
*/
|
270
|
public void setAuthors(final List<String> authors) {
|
271
|
this.authors = authors;
|
272
|
}
|
273
|
|
274
|
/**
|
275
|
* Gets the escaped xml authors.
|
276
|
*
|
277
|
* @return the escaped xml authors
|
278
|
*/
|
279
|
public List<String> getEscapedXMLAuthors() {
|
280
|
if (authors != null)
|
281
|
return ResolvedObject.escapedArray(authors);
|
282
|
return null;
|
283
|
}
|
284
|
|
285
|
public ResolvedObject getExtraInfo() {
|
286
|
return extraInfo;
|
287
|
}
|
288
|
|
289
|
public void setExtraInfo(final ResolvedObject extraInfo) {
|
290
|
this.extraInfo = extraInfo;
|
291
|
}
|
292
|
}
|