Skip to content

Commit

Permalink
Merge pull request #288 from mnamici/nongraphical-iris
Browse files Browse the repository at this point in the history
Non-graphical IRIs in the project
  • Loading branch information
mnamici authored Nov 20, 2024
2 parents 062f236 + 9f28c84 commit 5709b67
Show file tree
Hide file tree
Showing 3 changed files with 538 additions and 525 deletions.
58 changes: 39 additions & 19 deletions eddy/core/exporters/graphol_iri.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
# -*- coding: utf-8 -*-

##########################################################################
# #
# Eddy: a graphical editor for the specification of Graphol ontologies #
# Copyright (C) 2015 Daniele Pantaleone <[email protected]> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 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 General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
# ##################### ##################### #
# #
# Graphol is developed by members of the DASI-lab group of the #
# Dipartimento di Ingegneria Informatica, Automatica e Gestionale #
# A.Ruberti at Sapienza University of Rome: http://www.dis.uniroma1.it #
# #
# - Domenico Lembo <[email protected]> #
# - Valerio Santarelli <[email protected]> #
# - Domenico Fabio Savo <[email protected]> #
# - Daniele Pantaleone <[email protected]> #
# - Marco Console <[email protected]> #
# #
##########################################################################

import os

from PyQt5 import QtXml
Expand All @@ -13,6 +47,7 @@

LOGGER = getLogger()


class GrapholIRIProjectExporter(AbstractProjectExporter):
"""
Extends AbstractProjectExporter with facilities to export the structure of a Graphol project.
Expand Down Expand Up @@ -187,26 +222,11 @@ def getOntologyDomElement(self):

irisEl = self.getDomElement('iris')
ontologyEl.appendChild(irisEl)
if not self.selectedDiagrams:
for iri in sorted(self.project.iris,key=str):
if (self.project.existIriOccurrence(iri) or iri==self.project.ontologyIRI) and not (iri.isTopBottomEntity() or iri in self.project.getDatatypeIRIs() or iri in self.project.constrainingFacets or iri in self.project.getAnnotationPropertyIRIs()):
iriEl = self.getIriDomElement(iri)
irisEl.appendChild(iriEl)
else:
for iri in sorted(self.project.iris,key=str):
if (self.project.existIriOccurrence(iri) or iri == self.project.ontologyIRI) and not (
iri.isTopBottomEntity() or iri in self.project.getDatatypeIRIs() or iri in self.project.constrainingFacets or iri in self.project.getAnnotationPropertyIRIs()):
if self.occursInAtLeastOneSelectedDiagrams(iri):
iriEl = self.getIriDomElement(iri)
irisEl.appendChild(iriEl)
for iri in sorted(self.project.iris, key=str):
iriEl = self.getIriDomElement(iri)
irisEl.appendChild(iriEl)
return ontologyEl

def occursInAtLeastOneSelectedDiagrams(self,iri):
for diagram in self.selectedDiagrams:
if self.project.iriOccurrences(iri=iri,diagram=diagram):
return True
return False

def getOntologyImportDomElement(self, impOnt):
impEl = self.getDomElement('import')
impEl.setAttribute('iri', impOnt.ontologyIRI)
Expand Down Expand Up @@ -742,10 +762,10 @@ def getNodeDomElement(self, node):
element.appendChild(geometry)
return element


#############################################
# INTERFACE
#################################

def createProjectFile(self):
"""
Serialize a previously created QDomDocument to disk.
Expand Down
Loading

0 comments on commit 5709b67

Please sign in to comment.