Revision 44949
Added by Sandro La Bruzzo over 7 years ago
OdfToHbaseXsltFunctions.java | ||
---|---|---|
6 | 6 |
import com.google.common.collect.Lists; |
7 | 7 |
import com.google.common.collect.Maps; |
8 | 8 |
import eu.dnetlib.data.mapreduce.util.DNGFRowKeyDecoder; |
9 |
import eu.dnetlib.data.proto.DNGFProtos; |
|
9 | 10 |
import eu.dnetlib.data.proto.DNGFProtos.DNGF; |
10 | 11 |
import eu.dnetlib.data.proto.DNGFProtos.DNGFEntity; |
12 |
import eu.dnetlib.data.proto.DatasetProtos; |
|
11 | 13 |
import eu.dnetlib.data.proto.DatasetProtos.Dataset; |
12 | 14 |
import eu.dnetlib.data.proto.FieldTypeProtos.Instance; |
13 | 15 |
import eu.dnetlib.data.proto.FieldTypeProtos.StructuredProperty; |
... | ... | |
79 | 81 |
} |
80 | 82 |
|
81 | 83 |
// title |
82 |
for (int i = 0; i < titles.getLength(); i++) { |
|
83 |
Node currentNode = titles.item(i); |
|
84 |
NodeList childNodes = currentNode.getChildNodes(); |
|
85 |
if (childNodes.getLength() > 0) { |
|
86 |
String titleValue = childNodes.item(0).getNodeValue(); |
|
87 |
String classname = "main title"; |
|
88 |
String classid = "main title"; |
|
89 |
if (currentNode.hasAttributes()) { |
|
90 |
NamedNodeMap attributes = currentNode.getAttributes(); |
|
91 |
Node titleType = attributes.getNamedItem("titleType"); |
|
84 |
manageTitle(titles, metadataProto); |
|
92 | 85 |
|
93 |
if (titleType != null && titleType.getNodeValue().equals("AlternativeTitle")) { |
|
94 |
classname = "alternative title"; |
|
95 |
classid = "alternative title"; |
|
96 |
} |
|
97 |
if (titleType != null && titleType.getNodeValue().equals("Subtitle")) { |
|
98 |
classname = "subtitle"; |
|
99 |
classid = "subtitle"; |
|
100 |
} |
|
101 |
if (titleType != null && titleType.getNodeValue().equals("TranslatedTitle")) { |
|
102 |
classname = "translated title"; |
|
103 |
classid = "translated title"; |
|
104 |
} |
|
105 |
} |
|
106 |
addField(metadataProto, Dataset.Metadata.getDescriptor().findFieldByName("title"), |
|
107 |
getStructuredProperty(titleValue, classname, classid, "dnet:dataCite_title", "dnet:dataCite_title")); |
|
108 |
} |
|
109 |
} |
|
110 |
|
|
111 | 86 |
// description |
112 | 87 |
for (int i = 0; i < descriptions.getLength(); i++) { |
113 | 88 |
Node currentNode = descriptions.item(i); |
... | ... | |
130 | 105 |
addField(metadataProto, Dataset.Metadata.getDescriptor().findFieldByName("publisher"), getFirstItem(publisher)); |
131 | 106 |
|
132 | 107 |
// dates |
133 |
for (int i = 0; i < dates.getLength(); i++) { |
|
134 |
Node currentNode = dates.item(i); |
|
135 |
if (currentNode != null && currentNode.hasAttributes() && currentNode.hasChildNodes()) { |
|
136 |
String dateAttribute = currentNode.getAttributes().getNamedItem("dateType").getNodeValue(); |
|
137 |
String dateValue = currentNode.getChildNodes().item(0).getNodeValue(); |
|
138 |
String protoAttribute = "relevantdate"; |
|
139 |
if ("Accepted".equals(dateAttribute)) { |
|
140 |
protoAttribute = "dateofacceptance"; |
|
141 |
} else if ("Issued".equals(dateAttribute)) { |
|
142 |
protoAttribute = "storagedate"; |
|
143 |
} else if ("Updated".equals(dateAttribute)) { |
|
144 |
protoAttribute = "lastmetadataupdate"; |
|
145 |
} else if ("Available".equals(dateAttribute)) { |
|
146 |
protoAttribute = "embargoenddate"; |
|
147 |
} |
|
148 |
if (protoAttribute.equals("relevantdate") == false) { |
|
149 |
addField(metadataProto, Dataset.Metadata.getDescriptor().findFieldByName(protoAttribute), dateValue); |
|
150 |
} else { |
|
151 |
addField(metadataProto, Dataset.Metadata.getDescriptor().findFieldByName(protoAttribute), |
|
152 |
getStructuredProperty(dateValue, "UNKNOWN", "UNKNOWN", "dnet:dataCite_date", "dnet:dataCite_date")); |
|
153 |
} |
|
154 |
} |
|
155 |
} |
|
108 |
manageDate(dates, metadataProto); |
|
156 | 109 |
|
110 |
|
|
157 | 111 |
// dateofacceptance |
158 | 112 |
addField(metadataProto, Dataset.Metadata.getDescriptor().findFieldByName("dateofacceptance"), getFirstItem(dateaccepted)); |
159 | 113 |
|
... | ... | |
226 | 180 |
return entity; |
227 | 181 |
} |
228 | 182 |
|
229 |
public static String odfDataset( |
|
183 |
|
|
184 |
public static String odfDataset( |
|
230 | 185 |
final String resultId, |
231 | 186 |
final NodeList about, |
232 | 187 |
final NodeList metadata, |
... | ... | |
283 | 238 |
return out; |
284 | 239 |
} |
285 | 240 |
|
241 |
|
|
242 |
//personDataset_Authorship($personId, $datasetId, $position, 'isAuthorOf', $provenance, $trust, $about) |
|
243 |
|
|
244 |
|
|
245 |
public static String personDataset_Authorship( |
|
246 |
final String personIdentifier, |
|
247 |
final String datasetIdentifier, |
|
248 |
final int position, |
|
249 |
final String relation, |
|
250 |
final String provenance, |
|
251 |
final String trust, |
|
252 |
final NodeList about) { |
|
253 |
|
|
254 |
return authorship(personIdentifier, "person", |
|
255 |
datasetIdentifier, "dataset", position, |
|
256 |
relation, provenance, trust, about); |
|
257 |
|
|
258 |
|
|
259 |
} |
|
260 |
|
|
261 |
|
|
262 |
|
|
263 |
|
|
286 | 264 |
} |
Also available in: Unified diff
fixed test