changeset 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 5380bdeb7457
children c418851eeb86
files src/main/java/org/mpi/openmind/repository/utils/OM4StreamWriter.java
diffstat 1 files changed, 21 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/org/mpi/openmind/repository/utils/OM4StreamWriter.java	Tue Oct 30 18:29:24 2018 +0100
+++ b/src/main/java/org/mpi/openmind/repository/utils/OM4StreamWriter.java	Wed Oct 31 15:44:12 2018 +0100
@@ -32,7 +32,7 @@
  */
 public class OM4StreamWriter {
 
-    protected static final String FORMAT_VERSION = "4.7";
+    protected static final String FORMAT_VERSION = "4.8";
 
     private static Logger logger = Logger.getLogger(OM4StreamWriter.class);
 
@@ -218,7 +218,10 @@
         writer.writeStartElement(XMLUtil.RELATION);
 
         // update stats
-        Map<String, Long> attStats = updateNodeStats(rel, relStats);
+		Map<String, Long> attStats = null;
+    	if (relStats != null) {
+    		attStats = updateNodeStats(rel, relStats);
+    	}
 
         /*
          * write XML-attributes
@@ -248,8 +251,10 @@
         if (rel.getAttributes().size() > 0) {
             writer.writeStartElement(XMLUtil.ATTRIBUTES);
 			for (Attribute att : rel.getAttributes()) {
-				// update stats
-				updateAttStats(att, attStats);
+				if (attStats != null) {
+					// update stats
+					updateAttStats(att, attStats);
+				}
 				// write xml
 				writeAttribute(att, writer, includeNorm);
 			}
@@ -322,6 +327,18 @@
         }
 
         /*
+         * write outgoing relations of this entity as XML tags
+         */
+        if (entity.getSourceRelations().size() > 0) {
+            writer.writeStartElement(XMLUtil.RELATIONS);
+            for (Relation rel : entity.getSourceRelations()) {
+            	// write xml (without stats)
+            	writeRelation(rel, writer, includeNorm, null);
+            }
+            writer.writeEndElement();
+        }
+
+        /*
          * write own value
          */
         String ov = entity.getOwnValue();