Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-graphical IRIs in the project #288

Merged
merged 8 commits into from
Nov 20, 2024
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
Loading