Project

General

Profile

1 43783 sandro.lab
package eu.dnetlib.resolver.model;
2 34591 sandro.lab
3 39927 sandro.lab
import java.util.List;
4 37758 sandro.lab
5 43618 sandro.lab
import eu.dnetlib.dli.DLIUtils;
6
import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
7
import org.apache.commons.lang3.StringEscapeUtils;
8 34591 sandro.lab
9
/**
10
 * The Class DLIRelation.
11
 */
12 43783 sandro.lab
public class ObjectRelation {
13 34591 sandro.lab
14 43618 sandro.lab
	/**
15
	 * The source doi.
16
	 */
17
	private String sourceRecordId;
18 38162 sandro.lab
19 43618 sandro.lab
	/**
20
	 * The source doi.
21
	 */
22
	private String sourcePid;
23 34591 sandro.lab
24 43618 sandro.lab
	/**
25
	 * The target type.
26
	 */
27 43783 sandro.lab
	private ObjectType targetType;
28 35546 sandro.lab
29 43618 sandro.lab
	/**
30
	 * The target pid.
31
	 */
32 43783 sandro.lab
	private PID targetPID;
33 34591 sandro.lab
34 43618 sandro.lab
	/**
35
	 * The target title.
36
	 */
37
	private String targetTitle;
38 34591 sandro.lab
39 43618 sandro.lab
	/**
40
	 * The authors.
41
	 */
42
	private List<String> authors;
43 34591 sandro.lab
44 43618 sandro.lab
	/**
45
	 * The relation semantics.
46
	 */
47
	private String relationSemantics;
48 37725 sandro.lab
49 43618 sandro.lab
	/**
50
	 * The relation provenance.
51
	 */
52 43783 sandro.lab
	private List<ObjectProvenance> relationProvenance;
53 34591 sandro.lab
54 43618 sandro.lab
	/**
55
	 * The status.
56
	 */
57
	private String completionStatus = "incomplete";
58 34591 sandro.lab
59 43783 sandro.lab
	private ResolvedObject extraInfo;
60 35546 sandro.lab
61 43618 sandro.lab
	/**
62 43783 sandro.lab
	 * Gets the source do
63 43618 sandro.lab
	 *
64
	 * @return the source doi
65
	 */
66
	public String getSourceRecordId() {
67
		return sourceRecordId;
68
	}
69 34591 sandro.lab
70 43618 sandro.lab
	/**
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 34591 sandro.lab
81 43618 sandro.lab
	/**
82
	 * Gets the escaped xmldoi.
83
	 *
84
	 * @return the escaped xmldoi
85
	 */
86
	public String getEscapedXMLDOI() {
87
		return StringEscapeUtils.escapeXml(sourceRecordId);
88
	}
89 34591 sandro.lab
90 43618 sandro.lab
	/**
91
	 * Gets the target type.
92
	 *
93
	 * @return the target type
94
	 */
95 43783 sandro.lab
	public ObjectType getTargetType() {
96 43618 sandro.lab
		return targetType;
97
	}
98 34591 sandro.lab
99 43618 sandro.lab
	/**
100
	 * Sets the target type.
101
	 *
102
	 * @param targetType the new target type
103
	 */
104 43783 sandro.lab
	public void setTargetType(final ObjectType targetType) {
105 43618 sandro.lab
		this.targetType = targetType;
106
	}
107 34591 sandro.lab
108 43618 sandro.lab
	/**
109
	 * Gets the ID relation.
110
	 *
111
	 * @return the ID relation
112
	 */
113
	public String getIDRelation() {
114 35546 sandro.lab
115 43618 sandro.lab
		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 34591 sandro.lab
120 43618 sandro.lab
	public String getIDRecord() {
121
		return (DnetXsltFunctions.md5(String.format("%s::%s", this.getTargetPID().getId(), this.getTargetPID().getType())));
122
	}
123 38162 sandro.lab
124 43618 sandro.lab
	/**
125
	 * Gets the target pid.
126
	 *
127
	 * @return the target pid
128
	 */
129 43783 sandro.lab
	public PID getTargetPID() {
130 43618 sandro.lab
		return targetPID;
131
	}
132 38162 sandro.lab
133 43618 sandro.lab
	/**
134
	 * Sets the target pid.
135
	 *
136
	 * @param targetPID the new target pid
137
	 */
138 43783 sandro.lab
	public void setTargetPID(final PID targetPID) {
139 34591 sandro.lab
140 43618 sandro.lab
		if (targetPID.getType() != null && "doi".equals(targetPID.getType().trim().toLowerCase()))
141
			targetPID.setId(DLIUtils.fixPID(targetPID.getId()));
142
		this.targetPID = targetPID;
143
	}
144 34591 sandro.lab
145 43618 sandro.lab
	/**
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("&", "&amp;");
154
		bf = bf.replaceAll("\"", "&quot;");
155
		bf = bf.replaceAll("'", "&apos;");
156
		bf = bf.replaceAll("<", "&lt;");
157
		bf = bf.replaceAll(">", "&gt;");
158
		return bf;
159
	}
160 34591 sandro.lab
161 43618 sandro.lab
	/**
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 34591 sandro.lab
170 43618 sandro.lab
	/**
171
	 * Gets the relation semantics.
172
	 *
173
	 * @return the relation semantics
174
	 */
175
	public String getRelationSemantics() {
176
		return relationSemantics;
177
	}
178 34591 sandro.lab
179 43618 sandro.lab
	/**
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 34591 sandro.lab
188 43618 sandro.lab
	/**
189
	 * Gets the relation provenance.
190
	 *
191
	 * @return the relationProvenance
192
	 */
193 43783 sandro.lab
	public List<ObjectProvenance> getRelationProvenance() {
194 43618 sandro.lab
		return relationProvenance;
195
	}
196 34591 sandro.lab
197 43618 sandro.lab
	/**
198
	 * Sets the relation provenance.
199
	 *
200
	 * @param relationProvenance the relationProvenance to set
201
	 */
202 43783 sandro.lab
	public void setRelationProvenance(final List<ObjectProvenance> relationProvenance) {
203 43618 sandro.lab
		this.relationProvenance = relationProvenance;
204
	}
205 34591 sandro.lab
206 43618 sandro.lab
	/**
207
	 * Gets the completion status.
208
	 *
209
	 * @return the completion status
210
	 */
211
	public String getCompletionStatus() {
212
		return this.completionStatus;
213
	}
214 35546 sandro.lab
215 43618 sandro.lab
	/**
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 35546 sandro.lab
224 43618 sandro.lab
	/**
225
	 * Gets the source pid.
226
	 *
227
	 * @return the source pid
228
	 */
229
	public String getSourcePid() {
230
		return sourcePid;
231
	}
232 35546 sandro.lab
233 43618 sandro.lab
	/**
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 35546 sandro.lab
242 43618 sandro.lab
	/**
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 43939 sandro.lab
				this.getRelationProvenance());
254 43618 sandro.lab
	}
255 35785 sandro.lab
256 43618 sandro.lab
	/**
257
	 * Gets the authors.
258
	 *
259
	 * @return the authors
260
	 */
261
	public List<String> getAuthors() {
262
		return authors;
263
	}
264 37725 sandro.lab
265 43618 sandro.lab
	/**
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 37725 sandro.lab
274 43618 sandro.lab
	/**
275
	 * Gets the escaped xml authors.
276
	 *
277
	 * @return the escaped xml authors
278
	 */
279 43783 sandro.lab
	public List<String> getEscapedXMLAuthors() {
280 43618 sandro.lab
		if (authors != null)
281 43783 sandro.lab
			return ResolvedObject.escapedArray(authors);
282 43618 sandro.lab
		return null;
283
	}
284 37758 sandro.lab
285 43783 sandro.lab
	public ResolvedObject getExtraInfo() {
286 43618 sandro.lab
		return extraInfo;
287
	}
288 37758 sandro.lab
289 43783 sandro.lab
	public void setExtraInfo(final ResolvedObject extraInfo) {
290 43618 sandro.lab
		this.extraInfo = extraInfo;
291
	}
292 34591 sandro.lab
}