|
a/src/net/timbusproject/context/converter/OWLExport.java |
|
b/src/net/timbusproject/context/converter/OWLExport.java |
|
... |
|
... |
146 |
public static final FolderType[] FOLDER_TYPES = { FolderType.BUSINESS, FolderType.APPLICATION,
|
146 |
public static final FolderType[] FOLDER_TYPES = { FolderType.BUSINESS, FolderType.APPLICATION,
|
147 |
FolderType.TECHNOLOGY, FolderType.MOTIVATION, FolderType.IMPLEMENTATION_MIGRATION, FolderType.CONNECTORS,
|
147 |
FolderType.TECHNOLOGY, FolderType.MOTIVATION, FolderType.IMPLEMENTATION_MIGRATION, FolderType.CONNECTORS,
|
148 |
FolderType.RELATIONS };
|
148 |
FolderType.RELATIONS };
|
149 |
|
149 |
|
150 |
public static void exportToOwl(IArchimateModel model, File file) throws IOException {
|
150 |
public static void exportToOwl(IArchimateModel model, File file) throws IOException {
|
|
|
151 |
exportToOwl(model, file, getDefaultIRI(file));
|
|
|
152 |
}
|
151 |
|
153 |
|
|
|
154 |
public static void exportToOwl(IArchimateModel model, File file, String iriThisOntology) throws IOException {
|
|
|
155 |
if (iriThisOntology == null || iriThisOntology.trim().length() == 0) {
|
|
|
156 |
iriThisOntology = getDefaultIRI(file);
|
|
|
157 |
}
|
152 |
// create Ontology manager
|
158 |
// create Ontology manager
|
153 |
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
|
159 |
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
|
154 |
OWLDataFactory df = OWLManager.getOWLDataFactory();
|
160 |
OWLDataFactory df = OWLManager.getOWLDataFactory();
|
155 |
|
161 |
|
156 |
String iriThisOntology = getDefaultIRI(file);
|
|
|
157 |
OWLOntology ontology;
|
162 |
OWLOntology ontology;
|
158 |
try {
|
163 |
try {
|
159 |
ontology = manager.createOntology(IRI.create(iriThisOntology));
|
164 |
ontology = manager.createOntology(IRI.create(iriThisOntology));
|
160 |
} catch (OWLOntologyCreationException e) {
|
165 |
} catch (OWLOntologyCreationException e) {
|
161 |
e.printStackTrace();
|
166 |
e.printStackTrace();
|
|
... |
|
... |
254 |
try {
|
259 |
try {
|
255 |
manager.saveOntology(ontology, new OWLXMLOntologyFormat(), fileTarget);
|
260 |
manager.saveOntology(ontology, new OWLXMLOntologyFormat(), fileTarget);
|
256 |
} catch (OWLOntologyStorageException e) {
|
261 |
} catch (OWLOntologyStorageException e) {
|
257 |
e.printStackTrace();
|
262 |
e.printStackTrace();
|
258 |
}
|
263 |
}
|
259 |
|
|
|
260 |
}
|
264 |
}
|
261 |
|
265 |
|
262 |
/**
|
266 |
/**
|
263 |
* Returns a valid IRI fragment - according to
|
267 |
* Returns a valid IRI fragment - according to
|
264 |
* http://sourceforge.net/p/owlapi/mailman/owlapi-developer/thread/CAHYxBS
|
268 |
* http://sourceforge.net/p/owlapi/mailman/owlapi-developer/thread/CAHYxBS
|
|
... |
|
... |
289 |
}
|
293 |
}
|
290 |
if (view == null) {
|
294 |
if (view == null) {
|
291 |
System.out.print("Trying to find layered view... ");
|
295 |
System.out.print("Trying to find layered view... ");
|
292 |
view = getLayeredView(model);
|
296 |
view = getLayeredView(model);
|
293 |
System.out.println(view != null ? "found" : "not found");
|
297 |
System.out.println(view != null ? "found" : "not found");
|
|
|
298 |
}
|
|
|
299 |
if (view == null) {
|
|
|
300 |
System.out.print("Checking if there is only one view... ");
|
|
|
301 |
|
|
|
302 |
EList<EObject> elements = model.getFolder(FolderType.DIAGRAMS).getElements();
|
|
|
303 |
if (elements.size() == 1) {
|
|
|
304 |
view = (ArchimateDiagramModel) elements.get(0);
|
|
|
305 |
System.out.println("succes, using view " + view.getName());
|
|
|
306 |
} else if (elements.size() == 0) {
|
|
|
307 |
System.out.println("no views found at all!");
|
|
|
308 |
} else {
|
|
|
309 |
ArrayList<String> viewNames = new ArrayList<String>();
|
|
|
310 |
for (EObject eObject : elements) {
|
|
|
311 |
viewNames.add(((ArchimateDiagramModel) eObject).getName());
|
|
|
312 |
}
|
|
|
313 |
System.out.println("found " + elements.size() + " views, please specifiy one of " + viewNames);
|
|
|
314 |
}
|
294 |
}
|
315 |
}
|
295 |
|
316 |
|
296 |
return exportLayout(layoutFile, defaultIRI, view);
|
317 |
return exportLayout(layoutFile, defaultIRI, view);
|
297 |
}
|
318 |
}
|
298 |
|
319 |
|