Skip to content

Commit

Permalink
Facet nodes import/export bug solved
Browse files Browse the repository at this point in the history
#79 solved
  • Loading branch information
LL committed Mar 22, 2020
1 parent 8575e65 commit 29b3e89
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 24 deletions.
7 changes: 5 additions & 2 deletions eddy/core/exporters/graphol_iri.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,16 +410,19 @@ def exportFacetNode(self, node):
:rtype: QDomElement
"""
#TODO
nodeEl = self.getNodeDomElement(node)

position = node.mapToScene(node.textPos())
label = self.document.createElement('label')
label.setAttribute('height', node.labelA.height())
label.setAttribute('width', node.labelA.width() + node.labelB.width())
label.setAttribute('x', position.x())
label.setAttribute('y', position.y())
label.appendChild(self.document.createTextNode(node.text()))
nodeEl.appendChild(label)
element = self.getFacetDomElement(node)
element.appendChild(label)
return element
nodeEl.appendChild(element)
return nodeEl

def exportIndividualNode(self, node):
"""
Expand Down
4 changes: 2 additions & 2 deletions eddy/core/items/nodes/common/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,8 +823,8 @@ def doUpdateNodeLabel(self):
self.renderByLabel()
elif rendering == IRIRender.SIMPLE_NAME.value or rendering == IRIRender.SIMPLE_NAME:
self.renderBySimpleName()
self.updateTextPos()
self.updateNode()
#self.updateTextPos()
#self.updateNode()

def renderByFullIRI(self):
self.setText(str(self.iri))
Expand Down
2 changes: 1 addition & 1 deletion eddy/core/items/nodes/facet_iri.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def doUpdateNodeLabel(self):

literal = self.facet.literal
self.labelB.setText(str(literal))
self.updateNode()
#self.updateNode()


#############################################
Expand Down
23 changes: 9 additions & 14 deletions eddy/core/loaders/graphol_iri.py
Original file line number Diff line number Diff line change
Expand Up @@ -1378,20 +1378,14 @@ def importLiteralNode(self, diagram, nodeElement):
return node

def importFacetNode(self, diagram, nodeElement):
labelElement = nodeElement.firstChildElement('label')
labelText = labelElement.text()
firstQuote = labelText.find('"')
secondQuote = labelText.rfind('"')
lexForm = labelText[firstQuote + 1:secondQuote]
literal = Literal(lexForm)
typeIndex = labelText.find('^')
prefixedType = labelText[:typeIndex]
colonIndex = prefixedType.find(':')
prefix = prefixedType[:colonIndex]
ns = prefixedType[colonIndex + 1:]
iriString = '{}{}'.format(self.nproject.getPrefixResolution(prefix), ns)
conFacetIRI = self.nproject.getIRI(iriString)
facet = Facet(conFacetIRI, literal)
facetEl = nodeElement.firstChildElement('facet')
constrFacetEl = facetEl.firstChildElement('constrainingFacet')
constrFacetIRI = self.nproject.getIRI(constrFacetEl.text())
literalEl = facetEl.firstChildElement('literal')
lexForm = literalEl.firstChildElement('lexicalForm').text()
datatypeIRI = self.nproject.getIRI(literalEl.firstChildElement('datatype').text())
literal = Literal(lexForm,datatypeIRI)
facet = Facet(constrFacetIRI, literal)
geometryElement = nodeElement.firstChildElement('geometry')
node = diagram.factory.create(Item.FacetIRINode, **{
'id': nodeElement.attribute('id'),
Expand All @@ -1401,6 +1395,7 @@ def importFacetNode(self, diagram, nodeElement):
})
node.setPos(QtCore.QPointF(int(geometryElement.attribute('x')), int(geometryElement.attribute('y'))))
node.doUpdateNodeLabel()
labelElement = nodeElement.firstChildElement('label')
node.setTextPos(
node.mapFromScene(QtCore.QPointF(int(labelElement.attribute('x')), int(labelElement.attribute('y')))))
return node
Expand Down
2 changes: 1 addition & 1 deletion eddy/core/owl.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def __init__(self, namespace,suffix=None, functional=False, invFuctional=False,
"""
super().__init__(parent)
if not IRI.isValidNamespace(namespace):
raise IllegalNamespaceError(namespace)
raise IllegalNamespaceError('The inserted string "{}" is not a legal namespace'.format(namespace))
self._namespace = str(namespace)
self._suffix = suffix
self._isFunctional = functional
Expand Down
12 changes: 9 additions & 3 deletions eddy/ui/iri.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

from eddy.core.common import HasWidgetSystem

from eddy.core.owl import IRI, IllegalNamespaceError, AnnotationAssertion, Facet, Literal, IllegalLiteralError
from eddy.core.owl import IRI, IllegalNamespaceError, AnnotationAssertion, Facet, Literal, IllegalLiteralError, \
OWL2Datatype

from eddy.core.functions.signals import connect
from eddy.ui.fields import ComboBox, StringField, CheckBox
Expand Down Expand Up @@ -975,8 +976,13 @@ def accept(self):
lexForm = str(self.widget('lexical_form_area').toPlainText())
if not lexForm:
raise RuntimeError('Please insert a constraining value')
currDataType = str(self.widget('datatype_switch').currentText())
literal = Literal(lexForm, self.project.getIRI(currDataType))
currDataTypeStr = str(self.widget('datatype_switch').currentText())
currDataType = None
if currDataTypeStr==self.emptyString:
currDataType = OWL2Datatype.PlainLiteral.value
else:
currDataType = self.project.getIRI(currDataTypeStr)
literal = Literal(lexForm, currDataType)
facet = Facet(self.project.getIRI(currConstrFacet), literal)
if self.facet:
command = CommandChangeFacetOfNode(self.project, self.node, facet, self.facet)
Expand Down
2 changes: 1 addition & 1 deletion eddy/ui/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ def initActions(self):
triggered=self.doOpenIRIPropsBuilder))

self.addAction(QtWidgets.QAction(
QtGui.QIcon(':/icons/24/ic_label_outline_black'),
QtGui.QIcon(':/icons/24/ic_create_black'),
'Annotations',
self, objectName='iri_annotations_refactor',
triggered=self.doOpenIRIPropsAnnotationBuilder))
Expand Down

0 comments on commit 29b3e89

Please sign in to comment.