Commit 3ded4560 authored by Oliver Kellogg's avatar Oliver Kellogg
Browse files

Followup to commit c0d58b3b for loading UML2/XMI2 files

umbrello/object_factory.cpp function makeObjectFromXMI() :
- Map UML2 PrimitiveType to UMLClassifier with base type ot_Datatype.

umbrello/attribute.cpp function load() :
- Replace direct accesses to QDomElement::attribute("xmi.id") by
  Model_Utils::getXmiId()
- If no xmi.id attribute is found in tempElement then check for attribute
  "href". If href is found then look for a hashmark (#) in its value. If
  found then extract the substring following the hashmark and seek this
  name in the Datatypes folder. If found then set m_pSecondary to the
  datatype object found; else create a new datatype with this name, and
  set m_pSecondary to the new datatype object.

CCBUG:56184
parent c0d58b3b
......@@ -18,6 +18,7 @@
#include "umlobject.h"
#include "umldoc.h"
#include "uml.h"
#include "folder.h"
#include "umlattributedialog.h"
#include "object_factory.h"
......@@ -295,20 +296,37 @@ bool UMLAttribute::load(QDomElement & element)
node = node.nextSibling();
continue;
}
m_SecondaryId = tempElement.attribute("xmi.id", "");
m_SecondaryId = Model_Utils::getXmiId(tempElement);
if (m_SecondaryId.isEmpty())
m_SecondaryId = tempElement.attribute("xmi.idref", "");
if (m_SecondaryId.isEmpty()) {
QDomNode inner = node.firstChild();
QDomElement tmpElem = inner.toElement();
m_SecondaryId = tmpElem.attribute("xmi.id", "");
if (m_SecondaryId.isEmpty())
m_SecondaryId = tmpElem.attribute("xmi.idref", "");
QString href = tempElement.attribute("href", "");
if (href.isEmpty()) {
QDomNode inner = node.firstChild();
QDomElement tmpElem = inner.toElement();
m_SecondaryId = Model_Utils::getXmiId(tmpElem);
if (m_SecondaryId.isEmpty())
m_SecondaryId = tmpElem.attribute("xmi.idref", "");
} else {
int hashpos = href.lastIndexOf(QChar('#'));
if (hashpos < 0) {
uDebug() << name() << ": cannot find type " << href;
} else {
QString typeName = href.mid(hashpos + 1);
UMLFolder *dtFolder = UMLApp::app()->document()->datatypeFolder();
m_pSecondary = Model_Utils::findUMLObject(dtFolder->containedObjects(),
typeName, UMLObject::ot_Datatype);
if (!m_pSecondary) {
m_pSecondary = Object_Factory::createUMLObject(UMLObject::ot_Datatype,
typeName, dtFolder);
}
}
}
}
break;
}
if (m_SecondaryId.isEmpty()) {
uDebug() << name() << ": " << "cannot find type.";
uDebug() << name() << ": cannot find type.";
}
}
m_InitialValue = element.attribute("initialValue", "");
......
......@@ -351,8 +351,10 @@ UMLObject* makeObjectFromXMI(const QString& xmiTag,
UMLClassifier *c = new UMLClassifier();
c->setBaseType(UMLObject::ot_Interface);
pObject = c;
} else if (UMLDoc::tagEq(xmiTag, "DataType") || UMLDoc::tagEq(xmiTag, "Primitive")
|| UMLDoc::tagEq(xmiTag, "Datatype")) { // for bkwd compat.
} else if (UMLDoc::tagEq(xmiTag, "DataType")
|| UMLDoc::tagEq(xmiTag, "Datatype") // for bkwd compat.
|| UMLDoc::tagEq(xmiTag, "Primitive")
|| UMLDoc::tagEq(xmiTag, "PrimitiveType")) {
UMLClassifier *c = new UMLClassifier();
c->setBaseType(UMLObject::ot_Datatype);
pObject = c;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment