comparison src/main/java/org/mpi/openmind/repository/utils/OM4StreamWriter.java @ 31:7d8ebe8ac8a2

create reader and check script for XML dumps.
author casties
date Wed, 24 Aug 2016 19:12:24 +0200
parents 5786aa6caeb3
children e0be7c0030f5
comparison
equal deleted inserted replaced
30:2f19cdf8e60b 31:7d8ebe8ac8a2
17 import org.mpi.openmind.repository.bo.Entity; 17 import org.mpi.openmind.repository.bo.Entity;
18 import org.mpi.openmind.repository.bo.Node; 18 import org.mpi.openmind.repository.bo.Node;
19 import org.mpi.openmind.repository.bo.Relation; 19 import org.mpi.openmind.repository.bo.Relation;
20 import org.mpi.openmind.repository.services.PersistenceService; 20 import org.mpi.openmind.repository.services.PersistenceService;
21 21
22 /**
23 * Export all entities and relations and definitions to XML.
24 *
25 * Saves (real) entities and relations (i.e. assertions) and definitions
26 * (i.e. definition entities and relations) in separate files.
27 *
28 * @author jurzua, casties
29 *
30 */
22 public class OM4StreamWriter { 31 public class OM4StreamWriter {
23 32
24 private static Logger logger = Logger.getLogger(OM4StreamWriter.class); 33 private static Logger logger = Logger.getLogger(OM4StreamWriter.class);
25 34
26 private static int itemsPerPage = 500; 35 private static int itemsPerPage = 500;
29 * Return the object's string representation or "null" if its null. 38 * Return the object's string representation or "null" if its null.
30 * 39 *
31 * @param s 40 * @param s
32 * @return 41 * @return
33 */ 42 */
34 public static String defaultString(Object s) { 43 private static String defaultString(Object s) {
35 if (s == null) { 44 if (s == null) {
36 return "null"; 45 return "null";
37 } else { 46 } else {
38 return s.toString(); 47 return s.toString();
39 } 48 }
67 76
68 writer.writeStartDocument("UTF-8", "1.0"); 77 writer.writeStartDocument("UTF-8", "1.0");
69 78
70 if (type.equals(Node.TYPE_ABOX)) { 79 if (type.equals(Node.TYPE_ABOX)) {
71 writer.writeStartElement(XMLUtil.OPENMIND_DATA); 80 writer.writeStartElement(XMLUtil.OPENMIND_DATA);
72 writer.writeAttribute("version", "3.0"); 81 writer.writeAttribute("version", "4.3");
73 entitiesCount = ps.getEntityCount(null).intValue(); 82 entitiesCount = ps.getEntityCount(null).intValue();
74 } else { 83 } else {
75 writer.writeStartElement(XMLUtil.META_DATA); 84 writer.writeStartElement(XMLUtil.META_DATA);
76 writer.writeAttribute("version", "3.0"); 85 writer.writeAttribute("version", "4.3");
77 entitiesCount = ps.getEntityCount(Node.TYPE_TBOX).intValue(); 86 entitiesCount = ps.getEntityCount(Node.TYPE_TBOX).intValue();
78 } 87 }
79 88
80 int numberOfPages = entitiesCount / itemsPerPage; 89 int numberOfPages = entitiesCount / itemsPerPage;
81 // debug: int numberOfPages = 1; 90 // debug: int numberOfPages = 1;