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
f84980b6
Commit
f84980b6
authored
10 years ago
by
Jérôme Euzenat
Browse files
Options
Downloads
Patches
Plain Diff
- Reengineered LOVAlignmentService
parent
7ddef04b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/fr/inrialpes/exmo/align/service/AlignmentService.java
+3
-3
3 additions, 3 deletions
src/fr/inrialpes/exmo/align/service/AlignmentService.java
src/fr/inrialpes/exmo/align/service/LOVAlignmentService.java
+120
-115
120 additions, 115 deletions
src/fr/inrialpes/exmo/align/service/LOVAlignmentService.java
with
123 additions
and
118 deletions
src/fr/inrialpes/exmo/align/service/AlignmentService.java
+
3
−
3
View file @
f84980b6
...
...
@@ -92,7 +92,7 @@ public class AlignmentService extends CommonCLI {
private
Hashtable
<
String
,
Directory
>
directories
=
null
;
private
HTTPTransport
transport
=
null
;
pr
ivate
AServProtocolManager
manager
;
pr
otected
AServProtocolManager
manager
;
private
DBService
connection
;
public
AlignmentService
()
{
...
...
@@ -120,12 +120,12 @@ public class AlignmentService extends CommonCLI {
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
try
{
new
AlignmentService
().
run
(
args
);
}
catch
(
Exception
ex
)
{
logger
.
error
(
"FATAL error"
,
ex
);
};
}
public
void
run
(
String
[]
args
)
throws
Exception
{
public
void
run
(
String
[]
args
)
throws
Exception
{
services
=
new
Vector
<
AlignmentServiceProfile
>();
directories
=
new
Hashtable
<
String
,
Directory
>();
...
...
This diff is collapsed.
Click to expand it.
src/fr/inrialpes/exmo/align/service/LOVAlignmentService.java
+
120
−
115
View file @
f84980b6
/*
* $Id$
*
* Copyright (C) INRIA, 2006-2009, 2010, 2013-2014
*
* 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.service
;
import
java.io.IOException
;
...
...
@@ -10,6 +30,7 @@ import java.net.URL;
import
java.util.Collection
;
import
java.util.Iterator
;
import
java.util.Set
;
import
java.util.Properties
;
import
org.semanticweb.owl.align.AlignmentException
;
import
org.semanticweb.owl.align.OntologyNetwork
;
...
...
@@ -21,131 +42,115 @@ import com.google.gson.JsonParser;
import
fr.inrialpes.exmo.align.impl.BasicOntologyNetwork
;
public
class
LOVAlignmentService
extends
AlignmentService
{
public
class
LOVAlignmentService
extends
AlignmentService
{
private
AServProtocolManager
manager
;
public
LOVAlignmentService
(
AServProtocolManager
manager
)
{
this
.
manager
=
manager
;
public
static
void
main
(
String
[]
args
)
{
try
{
new
LOVAlignmentService
().
run
(
args
);
}
catch
(
Exception
ex
)
{
logger
.
error
(
"FATAL error"
,
ex
);
};
}
protected
void
init
(
Properties
parameters
)
{
logger
.
info
(
"LOVAlignment server running"
);
// Here should everything be done!
// If no ontologynetwork for LOV
// create it
BasicOntologyNetwork
nolov
;
try
{
nolov
=
readLOV
(
"http://lov.okfn.org/dataset/lov/api/v1/vocabs"
);
String
id
=
manager
.
alignmentCache
.
recordNewNetwork
(
nolov
,
true
);
logger
.
trace
(
"Nolov loaded as {}"
,
id
);
// JE: it should also be matched
// JE: it should also be stored
}
catch
(
AlignmentException
e
)
{
logger
.
debug
(
"IGNORED: cannot record LOV network of ontology"
);
}
public
static
JsonObject
getJsonObject
(
String
uri
)
throws
IOException
{
URL
url
=
new
URL
(
uri
);
HttpURLConnection
request
=
(
HttpURLConnection
)
url
.
openConnection
();
request
.
connect
();
// Convert to a JSON object to print data
JsonParser
jp
=
new
JsonParser
();
//convert the input stream to a json element
JsonElement
root
=
jp
.
parse
(
new
InputStreamReader
((
InputStream
)
request
.
getContent
()));
JsonObject
jsonobject
=
root
.
getAsJsonObject
();
return
jsonobject
;
}
// Otherwise
// update it (check each filename)
}
public
static
BasicOntologyNetwork
readLOV
(
String
uri
)
throws
AlignmentException
{
JsonObject
jsonobject
;
try
{
jsonobject
=
getJsonObject
(
uri
);
}
catch
(
IOException
e
)
{
throw
new
AlignmentException
(
"Ontology Network error: unable to create Json Object from ("
+
uri
+
")"
);
}
/*
* URI is LOV uri
*/
public
static
BasicOntologyNetwork
readLOV
(
String
uri
)
throws
AlignmentException
{
JsonObject
jsonobject
;
try
{
URL
url
=
new
URL
(
uri
);
HttpURLConnection
request
=
(
HttpURLConnection
)
url
.
openConnection
();
request
.
connect
();
// Convert to a JSON object to print data
JsonParser
jp
=
new
JsonParser
();
//convert the input stream to a json element
JsonElement
root
=
jp
.
parse
(
new
InputStreamReader
((
InputStream
)
request
.
getContent
()));
jsonobject
=
root
.
getAsJsonObject
();
}
catch
(
IOException
e
)
{
throw
new
AlignmentException
(
"Ontology Network error: unable to create Json Object from ("
+
uri
+
")"
);
}
/*
* lov Structure at May 27th, 2014
* using api: http://lov.okfn.org/dataset/lov/api/v1/vocabs
* "vocabularies": [
* {
* "uri", "namespace", "prefix",
* "titles": [ {"value", "language", "dataType"} ],
* "descriptions": [ {"value", "language", "dataType"} ],
* "lastVersionReviewed": {"date", "versionDecimal", "label", "link"}
* }
* ]
* We are getting the ontologies' uri
*/
/*
* lov Structure at May 27th, 2014
* using api: http://lov.okfn.org/dataset/lov/api/v1/vocabs
* "vocabularies": [
* {
* "uri", "namespace", "prefix",
* "titles": [ {"value", "language", "dataType"} ],
* "descriptions": [ {"value", "language", "dataType"} ],
* "lastVersionReviewed": {"date", "versionDecimal", "label", "link"}
* }
* ]
* We are getting the ontologies' uri
*/
BasicOntologyNetwork
on
=
null
;
//fetching the ontologies in the network
JsonElement
ontologynetwork
=
jsonobject
.
get
(
"vocabularies"
);
JsonArray
array
=
ontologynetwork
.
getAsJsonArray
();
Iterator
<
JsonElement
>
itr
=
array
.
iterator
();
on
=
new
BasicOntologyNetwork
();
while
(
itr
.
hasNext
())
{
JsonElement
element
=
itr
.
next
();
JsonObject
data
=
element
.
getAsJsonObject
();
// main data
String
ontouri
=
data
.
get
(
"uri"
).
isJsonNull
()
?
null
:
data
.
get
(
"uri"
).
getAsString
();
try
{
on
.
addOntology
(
new
URI
(
ontouri
)
);
}
catch
(
URISyntaxException
e
)
{
throw
new
AlignmentException
(
"Ontologies must be identified by URIs"
);
}
/* if other information is needed:
String namespace = data.get("namespace").isJsonNull() ? null : data.get("namespace").getAsString();
String prefix = data.get("prefix").isJsonNull() ? null : data.get("prefix").getAsString();
// titles
JsonArray array_titles = data.get("titles").getAsJsonArray();
Iterator<JsonElement> itr_titles = array_titles.iterator();
while(itr_titles.hasNext()) {
JsonElement titles = itr_titles.next();
JsonObject data_titles = titles.getAsJsonObject();
String title_value = data_titles.get("value").isJsonNull() ? null : data_titles.get("value").getAsString();
String title_language = data_titles.get("language").isJsonNull() ? null : data_titles.get("language").getAsString();
String title_dataType = data_titles.get("dataType").isJsonNull() ? null : data_titles.get("dataType").getAsString();
}
// descriptions
JsonArray array_descriptions = data.get("descriptions").getAsJsonArray();
Iterator<JsonElement> itr_descriptions = array_descriptions.iterator();
while(itr_descriptions.hasNext()) {
JsonElement descriptions = itr_descriptions.next();
JsonObject data_descriptions = descriptions.getAsJsonObject();
String descriptions_value = data_descriptions.get("value").isJsonNull() ? null : data_descriptions.get("value").getAsString();
String descriptions_language = data_descriptions.get("language").isJsonNull() ? null : data_descriptions.get("language").getAsString();
String descriptions_dataType = data_descriptions.get("dataType").isJsonNull() ? null : data_descriptions.get("dataType").getAsString();
}
BasicOntologyNetwork
on
=
new
BasicOntologyNetwork
();
//fetching the ontologies in the network
for
(
JsonElement
element
:
jsonobject
.
get
(
"vocabularies"
).
getAsJsonArray
()
)
{
JsonObject
data
=
element
.
getAsJsonObject
();
// main data
String
ontouri
=
data
.
get
(
"uri"
).
isJsonNull
()
?
null
:
data
.
get
(
"uri"
).
getAsString
();
try
{
// JE2014:
// I want more than that! I want to create an ontology object
// with the ontology locator
on
.
addOntology
(
new
URI
(
ontouri
)
);
}
catch
(
URISyntaxException
e
)
{
logger
.
debug
(
"IGNORED: Malformed URI in LOV data : {}"
,
ontouri
);
}
/* if other information is needed:
String namespace = data.get("namespace").isJsonNull() ? null : data.get("namespace").getAsString();
String prefix = data.get("prefix").isJsonNull() ? null : data.get("prefix").getAsString();
// titles
JsonArray array_titles = data.get("titles").getAsJsonArray();
Iterator<JsonElement> itr_titles = array_titles.iterator();
while(itr_titles.hasNext()) {
JsonElement titles = itr_titles.next();
JsonObject data_titles = titles.getAsJsonObject();
String title_value = data_titles.get("value").isJsonNull() ? null : data_titles.get("value").getAsString();
String title_language = data_titles.get("language").isJsonNull() ? null : data_titles.get("language").getAsString();
String title_dataType = data_titles.get("dataType").isJsonNull() ? null : data_titles.get("dataType").getAsString();
}
// descriptions
JsonArray array_descriptions = data.get("descriptions").getAsJsonArray();
Iterator<JsonElement> itr_descriptions = array_descriptions.iterator();
while(itr_descriptions.hasNext()) {
JsonElement descriptions = itr_descriptions.next();
JsonObject data_descriptions = descriptions.getAsJsonObject();
String descriptions_value = data_descriptions.get("value").isJsonNull() ? null : data_descriptions.get("value").getAsString();
String descriptions_language = data_descriptions.get("language").isJsonNull() ? null : data_descriptions.get("language").getAsString();
String descriptions_dataType = data_descriptions.get("dataType").isJsonNull() ? null : data_descriptions.get("dataType").getAsString();
}
// descriptions
if (!data.get("lastVersionReviewed").isJsonNull()) {
// descriptions
if (!data.get("lastVersionReviewed").isJsonNull()) {
JsonObject lastVersionReviewed = data.get("lastVersionReviewed").getAsJsonObject();
String lastVersionReviewed_date = lastVersionReviewed.get("date").isJsonNull() ? null : lastVersionReviewed.get("date").getAsString();
String lastVersionReviewed_versionDecimal = lastVersionReviewed.get("versionDecimal").isJsonNull() ? null : lastVersionReviewed.get("versionDecimal").getAsString();
String lastVersionReviewed_label = lastVersionReviewed.get("label").isJsonNull() ? null : lastVersionReviewed.get("label").getAsString();
String lastVersionReviewed_link = lastVersionReviewed.get("link").isJsonNull() ? null : lastVersionReviewed.get("link").getAsString();
}
*/
}
return
on
;
}
public
void
lovServer
(
)
{
logger
.
info
(
"LOVAlignment server running"
);
BasicOntologyNetwork
noo1
=
new
BasicOntologyNetwork
();
BasicOntologyNetwork
noo2
=
new
BasicOntologyNetwork
();
String
uri
=
"http://lov.okfn.org/dataset/lov/api/v1/vocabs"
;
Collection
<
OntologyNetwork
>
allOntologyNetworks
=
manager
.
ontologyNetworks
();
for
(
OntologyNetwork
oNetwork
:
allOntologyNetworks
)
{
noo1
=
(
BasicOntologyNetwork
)
oNetwork
;
}
try
{
noo2
=
readLOV
(
uri
);
String
id
=
manager
.
alignmentCache
.
recordNewNetwork
(
noo2
,
true
);
logger
.
info
(
"Loading network of ontology (lov) {}"
,
uri
);
}
catch
(
AlignmentException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
Set
<
URI
>
networkOntology1
=
noo1
.
getOntologies
();
Set
<
URI
>
networkOntology2
=
noo2
.
getOntologies
();
if
(
!(
networkOntology1
.
containsAll
(
networkOntology2
)
&&
networkOntology2
.
containsAll
(
networkOntology1
)))
{
//update differences
logger
.
info
(
"lov Network has changed {}"
,
uri
);
}
}
*/
}
return
on
;
}
}
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