Mercurial > hg > openmind
comparison src/main/java/org/mpi/openmind/repository/utils/OM4StreamWriter.java @ 100:734c0d8c7369
add relations-tag with source relations for each entity to XML dump format 4.8.
author | Robert Casties <casties@mpiwg-berlin.mpg.de> |
---|---|
date | Wed, 31 Oct 2018 15:44:12 +0100 |
parents | 8005f7011975 |
children | 1149eb948036 |
comparison
equal
deleted
inserted
replaced
99:5380bdeb7457 | 100:734c0d8c7369 |
---|---|
30 * @author jurzua, casties | 30 * @author jurzua, casties |
31 * | 31 * |
32 */ | 32 */ |
33 public class OM4StreamWriter { | 33 public class OM4StreamWriter { |
34 | 34 |
35 protected static final String FORMAT_VERSION = "4.7"; | 35 protected static final String FORMAT_VERSION = "4.8"; |
36 | 36 |
37 private static Logger logger = Logger.getLogger(OM4StreamWriter.class); | 37 private static Logger logger = Logger.getLogger(OM4StreamWriter.class); |
38 | 38 |
39 private static final int itemsPerPage = 500; | 39 private static final int itemsPerPage = 500; |
40 | 40 |
216 private static void writeRelation(Relation rel, XMLStreamWriter writer, boolean includeNorm, | 216 private static void writeRelation(Relation rel, XMLStreamWriter writer, boolean includeNorm, |
217 Map<String, Map<String, Long>> relStats) throws XMLStreamException { | 217 Map<String, Map<String, Long>> relStats) throws XMLStreamException { |
218 writer.writeStartElement(XMLUtil.RELATION); | 218 writer.writeStartElement(XMLUtil.RELATION); |
219 | 219 |
220 // update stats | 220 // update stats |
221 Map<String, Long> attStats = updateNodeStats(rel, relStats); | 221 Map<String, Long> attStats = null; |
222 if (relStats != null) { | |
223 attStats = updateNodeStats(rel, relStats); | |
224 } | |
222 | 225 |
223 /* | 226 /* |
224 * write XML-attributes | 227 * write XML-attributes |
225 */ | 228 */ |
226 writer.writeAttribute(XMLUtil.OBJECT_CLASS, defaultString(rel.getObjectClass())); | 229 writer.writeAttribute(XMLUtil.OBJECT_CLASS, defaultString(rel.getObjectClass())); |
246 * write OpenMind attributes of this relation as XML tags | 249 * write OpenMind attributes of this relation as XML tags |
247 */ | 250 */ |
248 if (rel.getAttributes().size() > 0) { | 251 if (rel.getAttributes().size() > 0) { |
249 writer.writeStartElement(XMLUtil.ATTRIBUTES); | 252 writer.writeStartElement(XMLUtil.ATTRIBUTES); |
250 for (Attribute att : rel.getAttributes()) { | 253 for (Attribute att : rel.getAttributes()) { |
251 // update stats | 254 if (attStats != null) { |
252 updateAttStats(att, attStats); | 255 // update stats |
256 updateAttStats(att, attStats); | |
257 } | |
253 // write xml | 258 // write xml |
254 writeAttribute(att, writer, includeNorm); | 259 writeAttribute(att, writer, includeNorm); |
255 } | 260 } |
256 writer.writeEndElement(); | 261 writer.writeEndElement(); |
257 } | 262 } |
315 for (Attribute att : entity.getAttributes()) { | 320 for (Attribute att : entity.getAttributes()) { |
316 // update stats | 321 // update stats |
317 updateAttStats(att, attStats); | 322 updateAttStats(att, attStats); |
318 // write xml | 323 // write xml |
319 writeAttribute(att, writer, includeNorm); | 324 writeAttribute(att, writer, includeNorm); |
325 } | |
326 writer.writeEndElement(); | |
327 } | |
328 | |
329 /* | |
330 * write outgoing relations of this entity as XML tags | |
331 */ | |
332 if (entity.getSourceRelations().size() > 0) { | |
333 writer.writeStartElement(XMLUtil.RELATIONS); | |
334 for (Relation rel : entity.getSourceRelations()) { | |
335 // write xml (without stats) | |
336 writeRelation(rel, writer, includeNorm, null); | |
320 } | 337 } |
321 writer.writeEndElement(); | 338 writer.writeEndElement(); |
322 } | 339 } |
323 | 340 |
324 /* | 341 /* |