jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sal...@apache.org
Subject svn commit: r1363992 - in /jena/trunk/jena-core: ReleaseNotes.txt src/main/java/jena/schemagen.java
Date Fri, 20 Jul 2012 22:31:04 GMT
Author: sallen
Date: Fri Jul 20 22:31:04 2012
New Revision: 1363992

URL: http://svn.apache.org/viewvc?rev=1363992&view=rev
Log:
Schemagen: added ontology's owl:versionInfo if it exists.

Modified:
    jena/trunk/jena-core/ReleaseNotes.txt
    jena/trunk/jena-core/src/main/java/jena/schemagen.java

Modified: jena/trunk/jena-core/ReleaseNotes.txt
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/ReleaseNotes.txt?rev=1363992&r1=1363991&r2=1363992&view=diff
==============================================================================
--- jena/trunk/jena-core/ReleaseNotes.txt (original)
+++ jena/trunk/jena-core/ReleaseNotes.txt Fri Jul 20 22:31:04 2012
@@ -3,7 +3,8 @@ Release Notes 
 
 ==== Jena 2.7.3
 
-+ Remnove unused: GramMemSmal, MixedGraphMem and GraphMem (in-memory is GraphMemFaster).
  
++ Remove unused: GraphMemSmall, MixedGraphMem and GraphMem (in-memory is GraphMemFaster).
++ Schemagen: added ontology's owl:versionInfo if it exists.
 
 ==== Jena 2.7.2
 

Modified: jena/trunk/jena-core/src/main/java/jena/schemagen.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/jena/schemagen.java?rev=1363992&r1=1363991&r2=1363992&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/jena/schemagen.java (original)
+++ jena/trunk/jena-core/src/main/java/jena/schemagen.java Fri Jul 20 22:31:04 2012
@@ -596,6 +596,7 @@ public class schemagen {
         writeModelDeclaration();
         writeSource();
         writeNamespace();
+        writeOntologyVersionInfo();
 
         if (m_options.hasDeclarationsOption()) {
             writeln( 0, m_options.getDeclarationsOption() );
@@ -666,6 +667,17 @@ public class schemagen {
     private String protectQuotes( String s ) {
         return s.replaceAll( "\\\\", "\\\\\\\\" ).replaceAll( "\"", "\\\\\"" );
     }
+    
+    /** Write owl:versionInfo string if it exists **/
+    protected void writeOntologyVersionInfo() {
+        String versionInfo = getOntologyElementVersionInfo();
+        
+        if (null != versionInfo) {
+            writeln( 1, "/** <p>The ontology's owl:versionInfo as a string</p>
*/" );
+            writeln( 1, "public static final String VERSION_INFO = \"" + protectQuotes(versionInfo)
+ "\";" );
+            writeln( 1 );
+        }
+    }
 
     /** Write the string and resource that represent the namespace */
     protected void writeNamespace() {
@@ -724,6 +736,42 @@ public class schemagen {
 
         return defaultNS;
     }
+    
+    /** Document has an owl:Ontology or daml:Ontology element */
+    protected String getOntologyElementVersionInfo() {
+        String versionInfo = null;
+        
+        StmtIterator i = m_source.getBaseModel().listStatements( null, RDF.type, m_source.getProfile().ONTOLOGY()
);
+        if (i.hasNext()) {
+            Resource ont = i.nextStatement().getSubject();
+            StmtIterator j = m_source.getBaseModel().listStatements( ont, OWL.versionInfo,
(RDFNode)null );
+            if (j.hasNext()) {
+                versionInfo = j.nextStatement().getObject().asLiteral().getLexicalForm();
+                
+                // check for ambiguous answers
+                if (j.hasNext()) {
+                    System.err.println( "Warning: ambiguous owl:versionInfo - there is more
than one owl:Ontology element." );
+                    System.err.println( "Picking first choice: " + versionInfo  + ". Other
choices are:" );
+                    while (j.hasNext()) {
+                        System.err.print( " " );
+                        System.err.print( j.nextStatement().getString() );
+                    }
+                }
+            }
+            
+            // check for ambiguous answers
+            if (i.hasNext()) {
+                System.err.println( "Warning: ambiguous owl:versionInfo - there is more than
one owl:Ontology element." );
+                System.err.println( "Picking first choice: " + ont.getURI()  + ". Other choices
are:" );
+                while (i.hasNext()) {
+                    System.err.print( " " );
+                    System.err.print( i.nextStatement().getString() );
+                }
+            }
+        }
+        
+        return versionInfo;
+    }
 
     /** Document has an owl:Ontology or daml:Ontology element */
     protected String getOntologyElementNamespace() {



Mime
View raw message