Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Alignment API
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
moex
Alignment API
Commits
fea8a2ee
Commit
fea8a2ee
authored
19 years ago
by
Jérôme Euzenat
Browse files
Options
Downloads
Patches
Plain Diff
Added new renderer into a SKOS file
parent
eb0bb150
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/fr/inrialpes/exmo/align/impl/renderer/SKOSRendererVisitor.java
+132
-0
132 additions, 0 deletions
...rialpes/exmo/align/impl/renderer/SKOSRendererVisitor.java
with
132 additions
and
0 deletions
src/fr/inrialpes/exmo/align/impl/renderer/SKOSRendererVisitor.java
0 → 100644
+
132
−
0
View file @
fea8a2ee
/*
* $Id$
*
* Copyright (C) INRIA Rhne-Alpes, 2003-2004, 2006
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package
fr.inrialpes.exmo.align.impl.renderer
;
import
java.util.Hashtable
;
import
java.util.Enumeration
;
import
java.io.PrintWriter
;
import
java.io.IOException
;
import
java.lang.reflect.Method
;
import
java.net.URI
;
import
org.xml.sax.ContentHandler
;
import
org.xml.sax.SAXException
;
import
org.semanticweb.owl.model.OWLOntology
;
import
org.semanticweb.owl.model.OWLEntity
;
import
org.semanticweb.owl.model.OWLException
;
import
org.semanticweb.owl.align.Alignment
;
import
org.semanticweb.owl.align.AlignmentVisitor
;
import
org.semanticweb.owl.align.AlignmentException
;
import
org.semanticweb.owl.align.Cell
;
import
org.semanticweb.owl.align.Relation
;
import
fr.inrialpes.exmo.align.impl.rel.*
;
/**
* Renders an alignment as a new ontology merging these.
*
* @author Jrme Euzenat
* @version $$
*/
public
class
SKOSRendererVisitor
implements
AlignmentVisitor
{
PrintWriter
writer
=
null
;
Alignment
alignment
=
null
;
Cell
cell
=
null
;
public
SKOSRendererVisitor
(
PrintWriter
writer
){
this
.
writer
=
writer
;
}
// This must be considered
public
void
visit
(
Alignment
align
)
throws
AlignmentException
{
alignment
=
align
;
writer
.
print
(
"<rdf:RDF\n"
);
writer
.
print
(
" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"
);
writer
.
print
(
" xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\"\n"
);
writer
.
print
(
" xmlns:skos=\"http://www.w3.org/2004/02/skos/core#\">\n\n"
);
for
(
Enumeration
e
=
align
.
getElements
()
;
e
.
hasMoreElements
();
){
Cell
c
=
(
Cell
)
e
.
nextElement
();
c
.
accept
(
this
);
}
//end for
writer
.
print
(
"</rdf:RDF>\n"
);
}
public
void
visit
(
Cell
cell
)
throws
AlignmentException
{
this
.
cell
=
cell
;
try
{
OWLOntology
onto1
=
(
OWLOntology
)
alignment
.
getOntology1
();
URI
entity1URI
=
((
OWLEntity
)
cell
.
getObject1
()).
getURI
();
writer
.
print
(
" <skos:Concept rdf:about=\""
+
entity1URI
.
toString
()+
"\">\n"
);
cell
.
getRelation
().
accept
(
this
);
writer
.
print
(
" </skos:Concept>\n\n"
);
}
catch
(
OWLException
e
)
{
throw
new
AlignmentException
(
"getURI problem"
,
e
);
}
}
public
void
visit
(
EquivRelation
rel
)
throws
AlignmentException
{
try
{
OWLOntology
onto2
=
(
OWLOntology
)
alignment
.
getOntology2
();
URI
entity2URI
=
((
OWLEntity
)
cell
.
getObject2
()).
getURI
();
writer
.
print
(
" <skos:related rdf:resource=\""
+
entity2URI
.
toString
()+
"\"/>\n"
);
}
catch
(
OWLException
e
)
{
throw
new
AlignmentException
(
"getURI problem"
,
e
);
}
}
public
void
visit
(
SubsumeRelation
rel
)
throws
AlignmentException
{
try
{
OWLOntology
onto2
=
(
OWLOntology
)
alignment
.
getOntology2
();
URI
entity2URI
=
((
OWLEntity
)
cell
.
getObject2
()).
getURI
();
writer
.
print
(
" <skos:narrower rdf:resource=\""
+
entity2URI
.
toString
()+
"\"/>\n"
);
}
catch
(
OWLException
e
)
{
throw
new
AlignmentException
(
"getURI problem"
,
e
);
}
}
public
void
visit
(
SubsumedRelation
rel
)
throws
AlignmentException
{
try
{
OWLOntology
onto2
=
(
OWLOntology
)
alignment
.
getOntology2
();
URI
entity2URI
=
((
OWLEntity
)
cell
.
getObject2
()).
getURI
();
writer
.
print
(
" <skos:broader rdf:resource=\""
+
entity2URI
.
toString
()+
"\"/>\n"
);
}
catch
(
OWLException
e
)
{
throw
new
AlignmentException
(
"getURI problem"
,
e
);
}
}
public
void
visit
(
IncompatRelation
rel
)
throws
AlignmentException
{
throw
new
AlignmentException
(
"Cannot translate in SKOS"
+
rel
);
}
public
void
visit
(
Relation
rel
)
throws
AlignmentException
{
// JE: I do not understand why I need this,
// but this seems to be the case...
try
{
Method
mm
=
null
;
if
(
Class
.
forName
(
"fr.inrialpes.exmo.align.impl.rel.EquivRelation"
).
isInstance
(
rel
)
){
mm
=
this
.
getClass
().
getMethod
(
"visit"
,
new
Class
[]
{
Class
.
forName
(
"fr.inrialpes.exmo.align.impl.rel.EquivRelation"
)});
}
else
if
(
Class
.
forName
(
"fr.inrialpes.exmo.align.impl.rel.SubsumeRelation"
).
isInstance
(
rel
)
)
{
mm
=
this
.
getClass
().
getMethod
(
"visit"
,
new
Class
[]
{
Class
.
forName
(
"fr.inrialpes.exmo.align.impl.rel.SubsumeRelation"
)});
}
else
if
(
Class
.
forName
(
"fr.inrialpes.exmo.align.impl.rel.SubsumedRelation"
).
isInstance
(
rel
)
)
{
mm
=
this
.
getClass
().
getMethod
(
"visit"
,
new
Class
[]
{
Class
.
forName
(
"fr.inrialpes.exmo.align.impl.rel.SubsumedRelation"
)});
}
else
if
(
Class
.
forName
(
"fr.inrialpes.exmo.align.impl.rel.IncompatRelation"
).
isInstance
(
rel
)
)
{
mm
=
this
.
getClass
().
getMethod
(
"visit"
,
new
Class
[]
{
Class
.
forName
(
"fr.inrialpes.exmo.align.impl.rel.IncompatRelation"
)});
}
if
(
mm
!=
null
)
mm
.
invoke
(
this
,
new
Object
[]
{
rel
});
}
catch
(
Exception
e
)
{
throw
new
AlignmentException
(
"Dispatching problem "
,
e
);
};
};
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment