示例#1
0
/**
 * Jump to the next group, KateSyntaxContextData::currentGroup will point to the next group
 */
bool KateSyntaxDocument::nextGroup( KateSyntaxContextData* data)
{
  if(!data)
    return false;

  // No group yet so go to first child
  if (data->currentGroup.isNull())
  {
    // Skip over non-elements. So far non-elements are just comments
    QDomNode node = data->parent.firstChild();
    while (node.isComment())
      node = node.nextSibling();

    data->currentGroup = node.toElement();
  }
  else
  {
    // common case, iterate over siblings, skipping comments as we go
    QDomNode node = data->currentGroup.nextSibling();
    while (node.isComment())
      node = node.nextSibling();

    data->currentGroup = node.toElement();
  }

  return !data->currentGroup.isNull();
}
示例#2
0
bool Journal::loadXML( const QDomDocument& document )
{
  QDomElement top = document.documentElement();

  if ( top.tagName() != "journal" ) {
    qWarning( "XML error: Top tag was %s instead of the expected Journal",
              top.tagName().ascii() );
    return false;
  }

  for ( QDomNode n = top.firstChild(); !n.isNull(); n = n.nextSibling() ) {
    if ( n.isComment() )
      continue;
    if ( n.isElement() ) {
      QDomElement e = n.toElement();
      if ( !loadAttribute( e ) ) {
        // Unhandled tag - save for later storage
        //qDebug( "Unhandled tag: %s", e.toCString().data() );
      }
    } else
      qDebug( "Node is not a comment or an element???" );
  }

  return true;
}
示例#3
0
SWBuildCommand::SWBuildCommand( QDomNode& swBuildNode ):
fileType_(),
command_(),
flags_(),
replaceDefault_(false) {

	for (int i = 0; i < swBuildNode.childNodes().count(); ++i) {
		QDomNode node = swBuildNode.childNodes().at(i);

		if (node.isComment()) {
			continue;
		}
		else if (node.nodeName() == QString("kactus2:fileType")) {
			fileType_ = node.childNodes().at(0).nodeValue();
		}
		else if (node.nodeName() == QString("spirit:command")) {
			command_ = node.childNodes().at(0).nodeValue();
		}
		else if (node.nodeName() == QString("spirit:flags")) {
			flags_ = node.childNodes().at(0).nodeValue();
		}
		else if (node.nodeName() == QString("spirit:replaceDefaultFlags")) {
			const QString value = node.childNodes().at(0).nodeValue();
			replaceDefault_ = General::str2Bool(value, false);
		}
	}
}
示例#4
0
bool Task::loadXML( const QDomDocument& document )
{
  mKolabPriorityFromDom = -1;
  mKCalPriorityFromDom = -1;

  QDomElement top = document.documentElement();

  if ( top.tagName() != "task" ) {
    qWarning( "XML error: Top tag was %s instead of the expected task",
              top.tagName().toAscii().data() );
    return false;
  }
  setHasStartDate( false ); // todo's don't necessarily have one

  for ( QDomNode n = top.firstChild(); !n.isNull(); n = n.nextSibling() ) {
    if ( n.isComment() )
      continue;
    if ( n.isElement() ) {
      QDomElement e = n.toElement();
      if ( !loadAttribute( e ) )
        // TODO: Unhandled tag - save for later storage
        kDebug() <<"Warning: Unhandled tag" << e.tagName();
    } else
      kDebug() <<"Node is not a comment or an element???";
  }

  loadAttachments();
  decideAndSetPriority();
  return true;
}
bool XmlRelationCheckerCoreImpl::SearchGivenNodeFrom(QDomNode nodeToCheck, const QString& key, XmlRelation* xmlRelation) const
{
    if(!nodeToCheck.isNull())
    {
        if(nodeToCheck.isElement() && !nodeToCheck.isComment())
        {
            //For debug
            //const QString& nodeName = nodeToCheck.nodeName();

            //Controll if the node is a node to key
            QList<QString>* keyList = CheckIsNodeFrom(nodeToCheck, xmlRelation);

            bool found = false;

            for(int i=0; i < keyList->size() && !found; ++i)
            {
                if(key.compare(keyList->at(i), Qt::CaseInsensitive) == 0)
                {
                    found = true;
                }
            }

            delete keyList;

            //Check this is the wanted node to
            if(found || SearchGivenNodeFrom(nodeToCheck.firstChildElement(), key, xmlRelation))
            {
                return true;
            }
        }
        //Recursive call
        return SearchGivenNodeFrom(nodeToCheck.nextSiblingElement(), key, xmlRelation);
    }
    return false;
}
示例#6
0
//-----------------------------------------------------------------------------
// Function: ApiInterface::ApiInterface()
//-----------------------------------------------------------------------------
ApiInterface::ApiInterface(QDomNode& node)
    : nameGroup_(node),
      apiType_(),
      dependencyDir_(DEPENDENCY_PROVIDER),
      defaultPos_()
{
    for (int i = 0; i < node.childNodes().count(); ++i)
    {
        QDomNode childNode = node.childNodes().at(i);

        if (childNode.isComment())
        {
            continue;
        }

        if (childNode.nodeName() == "kactus2:apiType")
        {
            apiType_ = VLNV::createVLNV(childNode, VLNV::APIDEFINITION);
        }
        else if (childNode.nodeName() == "kactus2:dependencyDirection")
        {
            dependencyDir_ = str2DependencyDirection(childNode.childNodes().at(0).nodeValue(), DEPENDENCY_PROVIDER);
        }
        else if (childNode.nodeName() == "kactus2:position")
        {
            defaultPos_.setX(childNode.attributes().namedItem("x").nodeValue().toInt());
            defaultPos_.setY(childNode.attributes().namedItem("y").nodeValue().toInt());
        }
    }
}
示例#7
0
BSPBuildCommand::BSPBuildCommand( QDomNode& bspNode ):
fileType_(),
command_(),
arguments_(),
cpuName_() {

	for (int i = 0; i < bspNode.childNodes().count(); ++i) {
		QDomNode node = bspNode.childNodes().at(i);

		if (node.isComment()) {
			continue;
		}
		else if (node.nodeName() == QString("kactus2:fileType")) {
			fileType_ = node.childNodes().at(0).nodeValue();
		}
		else if (node.nodeName() == QString("spirit:command")) {
			command_ = node.childNodes().at(0).nodeValue();
		}
		else if (node.nodeName() == QString("kactus2:arguments")) {
			arguments_ = node.childNodes().at(0).nodeValue();
		}
		else if (node.nodeName() == QString("kactus2:cpuName")) {
			cpuName_ = node.childNodes().at(0).nodeValue();
		}
	}
}
示例#8
0
bool QDomNodeProto:: isComment() const
{
  QDomNode *item = qscriptvalue_cast<QDomNode*>(thisObject());
  if (item)
    return item->isComment();
  return false;
}
示例#9
0
/**
 * Jump to the next item, KateSyntaxContextData::item will point to the next item
 */
bool KateSyntaxDocument::nextItem( KateSyntaxContextData* data)
{
  if(!data)
    return false;

  if (data->item.isNull())
  {
    QDomNode node = data->currentGroup.firstChild();
    while (node.isComment())
      node = node.nextSibling();

    data->item = node.toElement();
  }
  else
  {
    QDomNode node = data->item.nextSibling();
    while (node.isComment())
      node = node.nextSibling();

    data->item = node.toElement();
  }

  return !data->item.isNull();
}
示例#10
0
	void XmlVendorParser::parseRootNode( const QDomElement &node )
	{
		for ( QDomNode child = node.firstChild(); !child.isNull(); child = child.nextSibling() )
		{
			if ( child.toElement().tagName() == "Vendor" )
			{
				parseVendorNode( child.toElement() );
			}
			else if ( !child.isComment() )
			{
				qWarning() << "Warning: bad element: "
					   << child.toElement().tagName()
					   << ", Ignored.";
			}
		}
	}
示例#11
0
bool UMLAttribute::load( QDomElement & element ) {
    m_SecondaryId = element.attribute( "type", "" );
    // We use the m_SecondaryId as a temporary store for the xmi.id
    // of the attribute type model object.
    // It is resolved later on, when all classes have been loaded.
    // This deferred resolution is required because the xmi.id may
    // be a forward reference, i.e. it may identify a model object
    // that has not yet been loaded.
    if (m_SecondaryId.isEmpty()) {
        // Perhaps the type is stored in a child node:
        QDomNode node = element.firstChild();
        while (!node.isNull()) {
            if (node.isComment()) {
                node = node.nextSibling();
                continue;
            }
            QDomElement tempElement = node.toElement();
            QString tag = tempElement.tagName();
            if (!Uml::tagEq(tag, "type")) {
                node = node.nextSibling();
                continue;
            }
            m_SecondaryId = tempElement.attribute( "xmi.id", "" );
            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", "" );
            }
            break;
        }
        if (m_SecondaryId.isEmpty()) {
            kDebug() << "UMLAttribute::load(" << m_Name << "): "
            << "cannot find type." << endl;
        }
    }
    m_InitialValue = element.attribute( "initialValue", "" );
    if (m_InitialValue.isEmpty()) {
        // for backward compatibility
        m_InitialValue = element.attribute( "value", "" );
    }
    return true;
}
QString XmlRelationCheckerCoreImpl::SearchGivenNodeTo(QDomNode nodeToCheck, const QString& key, XmlRelation* xmlRelation,
                                                   const QString& parentNumberBase, int number) const
{
    if(!nodeToCheck.isNull())
    {
        if(nodeToCheck.isElement() && !nodeToCheck.isComment())
        {
            //Initialize the identifiersNumber string with the base number
            QString identifierNumber = parentNumberBase;

            //If it's not empty is because it's the first node and it needn't the dot seprator
            if(!parentNumberBase.isEmpty())
            {
                identifierNumber.append('.');
            }

            //Attach the number
            identifierNumber.append(QString::number(number));

            //Controll if the node is a node to key
            const QString& nodeToKey = CheckIsNodeTo(nodeToCheck, xmlRelation);

            //Check this is the wanted node to
            if(key.compare(nodeToKey, Qt::CaseInsensitive) == 0)
            {
                return identifierNumber;
            }
            //Check the son
            else
            {
                const QString& sonIdentifier = SearchGivenNodeTo(nodeToCheck.firstChildElement(), key, xmlRelation, identifierNumber, 1);

                //If the son is the node searched
                if( ! sonIdentifier.isEmpty())
                {
                    //return the child identifier number
                    return sonIdentifier;
                }
            }
        }
        //Recursive call on the sibling
        return SearchGivenNodeTo(nodeToCheck.nextSiblingElement(), key, xmlRelation, parentNumberBase, number+1);
    }
    return "";
}
示例#13
0
bool Incidence::loadAttendeeAttribute(QDomElement &element,
                                      Attendee &attendee)
{
    for(QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling())
    {
        if(n.isComment())
            continue;
        if(n.isElement())
        {
            QDomElement e = n.toElement();
            QString tagName = e.tagName();

            if(tagName == "display-name")
                attendee.displayName = e.text();
            else if(tagName == "smtp-address")
                attendee.smtpAddress = e.text();
            else if(tagName == "status")
                attendee.status = e.text();
            else if(tagName == "request-response")
                // This sets reqResp to false, if the text is "false". Otherwise it
                // sets it to true. This means the default setting is true.
                attendee.requestResponse = (e.text().lower() != "false");
            else if(tagName == "invitation-sent")
                // Like above, only this defaults to false
                attendee.invitationSent = (e.text().lower() != "true");
            else if(tagName == "role")
                attendee.role = e.text();
            else if(tagName == "delegated-to")
                attendee.delegate = e.text();
            else if(tagName == "delegated-from")
                attendee.delegator = e.text();
            else
                // TODO: Unhandled tag - save for later storage
                kdDebug() << "Warning: Unhandled tag " << e.tagName() << endl;
        }
        else
            kdDebug() << "Node is not a comment or an element???" << endl;
    }

    return true;
}
示例#14
0
void Incidence::loadRecurrence(const QDomElement &element)
{
    mRecurrence.interval = 0;
    mRecurrence.cycle = element.attribute("cycle");
    mRecurrence.type = element.attribute("type");
    for(QDomNode n = element.firstChild(); !n.isNull(); n = n.nextSibling())
    {
        if(n.isComment())
            continue;
        if(n.isElement())
        {
            QDomElement e = n.toElement();
            QString tagName = e.tagName();

            if(tagName == "interval")
                mRecurrence.interval = e.text().toInt();
            else if(tagName == "day")    // can be present multiple times
                mRecurrence.days.append(e.text());
            else if(tagName == "daynumber")
                mRecurrence.dayNumber = e.text();
            else if(tagName == "month")
                mRecurrence.month = e.text();
            else if(tagName == "range")
            {
                mRecurrence.rangeType = e.attribute("type");
                mRecurrence.range = e.text();
            }
            else if(tagName == "exclusion")
            {
                mRecurrence.exclusions.append(stringToDate(e.text()));
            }
            else
                // TODO: Unhandled tag - save for later storage
                kdDebug() << "Warning: Unhandled tag " << e.tagName() << endl;
        }
    }
}
示例#15
0
/**
 * This method loads the generic parts of the XMI common to most model
 * classes.  It is not usually reimplemented by child classes.
 * Instead, it invokes the load() method which implements the loading
 * of the specifics of each child class.
 *
 * @param element   The QDomElement from which to load.
 */
bool UMLObject::loadFromXMI(QDomElement & element)
{
    UMLDoc* umldoc = UMLApp::app()->document();
    if (umldoc == 0) {
        uError() << "umldoc is NULL";
        return false;
    }
    // Read the name first so that if we encounter a problem, the error
    // message can say the name.
    m_name = element.attribute(QLatin1String("name"));
    QString id = Model_Utils::getXmiId(element);
    if (id.isEmpty() || id == QLatin1String("-1")) {
        // Before version 1.4, Umbrello did not save the xmi.id of UMLRole objects.
        // Some tools (such as Embarcadero's) do not have an xmi.id on all attributes.
        m_nId = UniqueID::gen();
        uWarning() << m_name << ": xmi.id not present, generating a new one";
    } else {
        Uml::ID::Type nId = Uml::ID::fromString(id);
        if (m_BaseType == ot_Role) {
            // Some older Umbrello versions had a problem with xmi.id's
            // of other objects being reused for the UMLRole, see e.g.
            // attachment 21179 at http://bugs.kde.org/147988 .
            // If the xmi.id is already being used then we generate a new one.
            UMLObject *o = umldoc->findObjectById(nId);
            if (o) {
                uError() << "loadFromXMI(UMLRole): id " << id
                         << " is already in use!!! Please fix your XMI file.";
            }
        }
        m_nId = nId;
    }

    if (element.hasAttribute(QLatin1String("documentation")))  // for bkwd compat.
        m_Doc = element.attribute(QLatin1String("documentation"));
    else
        m_Doc = element.attribute(QLatin1String("comment"));    //CHECK: need a UML:Comment?

    m_visibility = Uml::Visibility::Public;
    if (element.hasAttribute(QLatin1String("scope"))) {        // for bkwd compat.
        QString scope = element.attribute(QLatin1String("scope"));
        if (scope == QLatin1String("instance_level"))         // nsuml compat.
            m_bStatic = false;
        else if (scope == QLatin1String("classifier_level"))  // nsuml compat.
            m_bStatic = true;
        else {
            int nScope = scope.toInt();
            switch (nScope) {
            case 200:
                m_visibility = Uml::Visibility::Public;
                break;
            case 201:
                m_visibility = Uml::Visibility::Private;
                break;
            case 202:
                m_visibility = Uml::Visibility::Protected;
                break;
            default:
                uError() << m_name << ": illegal scope " << nScope;
            }
        }
    } else {
        QString visibility = element.attribute(QLatin1String("visibility"), QLatin1String("public"));
        if (visibility == QLatin1String("private")
                || visibility == QLatin1String("private_vis"))    // for compatibility with other programs
            m_visibility = Uml::Visibility::Private;
        else if (visibility == QLatin1String("protected")
                 || visibility == QLatin1String("protected_vis"))  // for compatibility with other programs
            m_visibility = Uml::Visibility::Protected;
        else if (visibility == QLatin1String("implementation"))
            m_visibility = Uml::Visibility::Implementation;
    }

    QString stereo = element.attribute(QLatin1String("stereotype"));
    if (!stereo.isEmpty()) {
        Uml::ID::Type stereoID = Uml::ID::fromString(stereo);
        m_pStereotype = umldoc->findStereotypeById(stereoID);
        if (m_pStereotype) {
            m_pStereotype->incrRefCount();
        } else {
            uDebug() << m_name << ": UMLStereotype " << Uml::ID::toString(stereoID)
                     << " not found, creating now.";
            setStereotypeCmd(stereo);
        }
    }

    if (element.hasAttribute(QLatin1String("abstract"))) {      // for bkwd compat.
        QString abstract = element.attribute(QLatin1String("abstract"), QLatin1String("0"));
        m_bAbstract = (bool)abstract.toInt();
    } else {
        QString isAbstract = element.attribute(QLatin1String("isAbstract"), QLatin1String("false"));
        m_bAbstract = (isAbstract == QLatin1String("true"));
    }

    if (element.hasAttribute(QLatin1String("static"))) {        // for bkwd compat.
        QString staticScope = element.attribute(QLatin1String("static"), QLatin1String("0"));
        m_bStatic = (bool)staticScope.toInt();
    } else {
        QString ownerScope = element.attribute(QLatin1String("ownerScope"), QLatin1String("instance"));
        m_bStatic = (ownerScope == QLatin1String("classifier"));
    }

    // If the node has child nodes, check whether attributes can be
    // extracted from them.
    if (element.hasChildNodes()) {
        QDomNode node = element.firstChild();
        if (node.isComment())
            node = node.nextSibling();
        QDomElement elem = node.toElement();
        while (!elem.isNull()) {
            QString tag = elem.tagName();
            if (UMLDoc::tagEq(tag, QLatin1String("name"))) {
                m_name = elem.attribute(QLatin1String("xmi.value"));
                if (m_name.isEmpty())
                    m_name = elem.text();
            } else if (UMLDoc::tagEq(tag, QLatin1String("visibility"))) {
                QString vis = elem.attribute(QLatin1String("xmi.value"));
                if (vis.isEmpty())
                    vis = elem.text();
                if (vis == QLatin1String("private") || vis == QLatin1String("private_vis"))
                    m_visibility = Uml::Visibility::Private;
                else if (vis == QLatin1String("protected") || vis == QLatin1String("protected_vis"))
                    m_visibility = Uml::Visibility::Protected;
                else if (vis == QLatin1String("implementation"))
                    m_visibility = Uml::Visibility::Implementation;
            } else if (UMLDoc::tagEq(tag, QLatin1String("isAbstract"))) {
                QString isAbstract = elem.attribute(QLatin1String("xmi.value"));
                if (isAbstract.isEmpty())
                    isAbstract = elem.text();
                m_bAbstract = (isAbstract == QLatin1String("true"));
            } else if (UMLDoc::tagEq(tag, QLatin1String("ownerScope"))) {
                QString ownerScope = elem.attribute(QLatin1String("xmi.value"));
                if (ownerScope.isEmpty())
                    ownerScope = elem.text();
                m_bStatic = (ownerScope == QLatin1String("classifier"));
            } else {
                loadStereotype(elem);
            }
            node = node.nextSibling();
            if (node.isComment())
                node = node.nextSibling();
            elem = node.toElement();
        }
    }

    // Operations, attributes, enum literals, templates, stereotypes,
    // and association role objects get added and signaled elsewhere.
    if (m_BaseType != ot_Operation && m_BaseType != ot_Attribute &&
        m_BaseType != ot_EnumLiteral && m_BaseType != ot_EntityAttribute &&
        m_BaseType != ot_Template && m_BaseType != ot_Stereotype &&
        m_BaseType != ot_Role && m_BaseType != ot_UniqueConstraint &&
        m_BaseType != ot_ForeignKeyConstraint && m_BaseType != ot_CheckConstraint) {
        if (m_pUMLPackage) {
            m_pUMLPackage->addObject(this);
        } else if (umldoc->rootFolderType(this) == Uml::ModelType::N_MODELTYPES) {
            // m_pUMLPackage is not set on the root folders.
            uDebug() << m_name << ": m_pUMLPackage is not set";
        }
    }
    return load(element);
}
示例#16
0
void MainWindow::buildTree(QDomNode doc, QStandardItemModel* model, QStandardItem *item, QList<int> *nbChildren, int childNumber, QList<int> *currentChild, int currentLevel)
{
    //check if doc is not empty
    if(!doc.isNull())
    {
        QStandardItem *itemUpdated = item;
        int nbAttributes = 0;
        nbAttributesMax(doc, &nbAttributes);
        //append root to model
        if(currentLevel == -1)
        {
            QList<QStandardItem*> list;
            list.append(item);
            for(int i = 0; i < nbAttributes; i++)
            {
                QStandardItem *newItem = new QStandardItem("");
                newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
                list.append(newItem);
            }
            model->appendRow(list);
        }
        //append everything but root to model
        else
        {
            if(!doc.isComment())
            {
                //get the parent to the node we want to add to the model
                QList<QStandardItem*> list;
                for(int i = 0; i < currentLevel; i++)
                {
                    itemUpdated = itemUpdated->child(currentChild->at(i));
                }
                addColumnModel(model, doc);
                getTagAttributes(&list, doc);

                //append the list
                itemUpdated->appendRow(list);
            }
            else
            {
                for(int i = 0; i < currentLevel; i++)
                {
                    itemUpdated = itemUpdated->child(currentChild->at(i));
                }
                QStandardItem *newItem = new QStandardItem("(Comment) " + doc.nodeValue());
                newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
                itemUpdated->appendRow(newItem);
            }
        }
        //if the node has at least one child get all the children and add them to the model
        if(!doc.childNodes().isEmpty() && (doc.firstChild().toElement().tagName() != "" || doc.firstChild().isComment()))
        {
            //get the children
            QDomNodeList nodeList = doc.childNodes();
            //update the level and store the number of children
            currentLevel++;
            (*nbChildren)[currentLevel] = nodeList.length();

            //for each child add the child and its children to the model
            for(int i = 0; i < (*nbChildren)[currentLevel]; i++)
            {
                (*currentChild)[currentLevel] = i;
                buildTree(nodeList.at(i), model, item, nbChildren, i, currentChild, currentLevel);
            }
        }
        //if the current node doesn't have any children the previous level need to be updated
        else
        {
            //the level which must be updated is the first one which is not equal to the
            //number of children of its level (if we start by the last level scanned)
            int ii = 1;
            if(currentLevel >= 1 && childNumber == (*nbChildren)[currentLevel] - 1)
            {
                while((*currentChild)[currentLevel-ii] == (*nbChildren)[currentLevel-ii] && ii <= currentLevel)
                {
                    ii++;
                }
                //if currentLevel-ii is < 0, it means that all the children of the previous levels have been scanned
                if(ii <= currentLevel)
                {
                    (*currentChild)[currentLevel-ii] += 1;
                }
            }
        }
    }
}
示例#17
0
/**
 * Creates the <UML:Generalization> or <UML:Association> XMI element
 * including its role objects.
 */
bool UMLAssociation::load( QDomElement & element )
{
    if (id() == Uml::id_None)
        return false; // old style XMI file. No real info in this association.

    UMLDoc * doc = UMLApp::app()->document();
    UMLObject * obj[2] = { NULL, NULL };
    if (m_AssocType == Uml::AssociationType::Generalization ||
        m_AssocType == Uml::AssociationType::Realization    ||
        m_AssocType == Uml::AssociationType::Dependency     ||
        m_AssocType == Uml::AssociationType::Child2Category ||
        m_AssocType == Uml::AssociationType::Category2Parent
        ) {
        for (unsigned r = Uml::A; r <= Uml::B; ++r) {
            const QString fetch = (m_AssocType == Uml::AssociationType::Generalization ?
                                   r == Uml::A ? "child" : "parent"
                       : r == Uml::A ? "client" : "supplier");
            QString roleIdStr = element.attribute(fetch, "");
            if (roleIdStr.isEmpty()) {
                // Might be given as a child node instead - see below.
                continue;
            }

            // set umlobject of role if possible (else defer resolution)
            obj[r] = doc->findObjectById(STR2ID(roleIdStr));
            Uml::Role_Type role = (Uml::Role_Type)r;
            if (obj[r] == NULL) {
                m_pRole[role]->setSecondaryId(roleIdStr);  // defer to resolveRef()
            } else {
                m_pRole[role]->setObject(obj[r]);
                if (m_pUMLPackage == NULL) {
                    Uml::ModelType mt = Model_Utils::convert_OT_MT(obj[r]->baseType());
                    m_pUMLPackage = doc->rootFolder(mt);
                    uDebug() << "assoctype " << m_AssocType
                        << ": setting model type " << mt;
                }
            }
        }
        if (obj[A] == NULL || obj[B] == NULL) {
            for (QDomNode node = element.firstChild(); !node.isNull();
                    node = node.nextSibling()) {
                if (node.isComment())
                    continue;
                QDomElement tempElement = node.toElement();
                QString tag = tempElement.tagName();
                if (Model_Utils::isCommonXMIAttribute(tag))
                    continue;
                // Permitted tag names:
                //  roleA: "child" "subtype" "client"
                //  roleB: "parent" "supertype" "supplier"
                QString idStr = tempElement.attribute( "xmi.id", "" );
                if (idStr.isEmpty())
                    idStr = tempElement.attribute( "xmi.idref", "" );
                if (idStr.isEmpty()) {
                    QDomNode inner = node.firstChild();
                    QDomElement tmpElem = inner.toElement();
                    idStr = tmpElem.attribute( "xmi.id", "" );
                    if (idStr.isEmpty())
                        idStr = tmpElem.attribute( "xmi.idref", "" );
                }
                if (idStr.isEmpty()) {
                    uError() << "type " << m_AssocType
                        << ", id " << ID2STR(id()) << ": "
                        << "xmi id not given for " << tag;
                    continue;
                }
                // Since we know for sure that we're dealing with a non
                // umbrello file, use deferred resolution unconditionally.
                if (UMLDoc::tagEq(tag, "child") || UMLDoc::tagEq(tag, "subtype") || UMLDoc::tagEq(tag, "client")) {
                    getUMLRole(A)->setSecondaryId(idStr);
                } else {
                    getUMLRole(B)->setSecondaryId(idStr);
                }
            }
        }

        // it is a realization if either endpoint is an interface
        if (isRealization(obj[A], obj[B])) {
            m_AssocType = Uml::AssociationType::Realization;
        }
        return true;
    }

    for (QDomNode node = element.firstChild(); !node.isNull();
            node = node.nextSibling()) {
        // uml13.dtd compliant format (new style)
        if (node.isComment())
            continue;
        QDomElement tempElement = node.toElement();
        QString tag = tempElement.tagName();
        if (Model_Utils::isCommonXMIAttribute(tag))
            continue;
        if (!UMLDoc::tagEq(tag, "Association.connection") &&
                !UMLDoc::tagEq(tag, "Namespace.ownedElement") &&
                !UMLDoc::tagEq(tag, "Namespace.contents")) {
            uWarning() << "unknown child node " << tag;
            continue;
        }
        // Load role A.
        node = tempElement.firstChild();
        while (node.isComment())
            node = node.nextSibling();
        tempElement = node.toElement();
        if (tempElement.isNull()) {
            uWarning() << "UML:Association : element (A) is Null";
            return false;
        }
        tag = tempElement.tagName();
        if (!UMLDoc::tagEq(tag, "AssociationEndRole") &&
                !UMLDoc::tagEq(tag, "AssociationEnd")) {
            uWarning() << "unknown child (A) tag " << tag;
            return false;
        }
        if (! getUMLRole(A)->loadFromXMI(tempElement))
            return false;
        // Load role B.
        node = node.nextSibling();
        while (node.isComment())
            node = node.nextSibling();
        tempElement = node.toElement();
        if (tempElement.isNull()) {
            uWarning() << "UML:Association : element (B) is Null";
            return false;
        }
        tag = tempElement.tagName();
        if (!UMLDoc::tagEq(tag, "AssociationEndRole") &&
                !UMLDoc::tagEq(tag, "AssociationEnd")) {
            uWarning() << "unknown child (B) tag " << tag;
            return false;
        }
        if (! getUMLRole(B)->loadFromXMI(tempElement))
            return false;

        if (m_pUMLPackage == NULL) {
            Uml::ModelType mt = Model_Utils::convert_OT_MT(getObject(B)->baseType());
            m_pUMLPackage = doc->rootFolder(mt);
            uDebug() << "setting model type " << mt;
        }

        // setting the association type:
        //
        // In the old days, we could just record this on the association,
        // and be done with it. But thats not how the UML13.dtd does things.
        // As a result, we are checking roleA for information about the
        // parent association (!) which by this point in the parse, should
        // be set. However, the information that the roles are allowed to have
        // is not complete, so we need to finish the analysis here.

        // find self-associations
        if (m_AssocType == Uml::AssociationType::Association && getObjectId(A) == getObjectId(B))
            m_AssocType = Uml::AssociationType::Association_Self;

        // fall-back default type
        if (m_AssocType == Uml::AssociationType::Unknown) {
            m_AssocType = Uml::AssociationType::Association;
        }

        return true;
    }

    // From here on it's old-style stuff.
    QString assocTypeStr = element.attribute( "assoctype", "-1" );
    Uml::AssociationType assocType = Uml::AssociationType::Unknown;
    if (assocTypeStr[0] >= 'a' && assocTypeStr[0] <= 'z') {
        // In an earlier version, the natural assoctype names were saved.
        const QString assocTypeString[] = {
                    "generalization",   // Uml::AssociationType::Generalization
                    "aggregation",      // Uml::AssociationType::Aggregation
                    "dependency",       // Uml::AssociationType::Dependency
                    "association",      // Uml::AssociationType::Association
                    "associationself",  // Uml::AssociationType::Association_Self
                    "collmessage",      // Uml::AssociationType::Coll_Message
                    "seqmessage",       // Uml::AssociationType::Seq_Message
                    "collmessageself",  // Uml::AssociationType::Coll_Message_Self
                    "seqmessageself",   // Uml::AssociationType::Seq_Message_Self
                    "implementation",   // Uml::AssociationType::Implementation
                    "composition",      // Uml::AssociationType::Composition
                    "realization",      // Uml::AssociationType::Realization
                    "uniassociation",   // Uml::AssociationType::UniAssociation
                    "anchor",           // Uml::AssociationType::Anchor
                    "state",            // Uml::AssociationType::State
                    "activity",         // Uml::AssociationType::Activity
                    "exception",        // Uml::AssociationType::Exception
                    "category2parent"   // Uml::AssociationType::Category2Parent
                    "child2category"    // Uml::AssociationType::Child2Category
                    "relationship"      // Uml::AssociationType::Relationship
        };
        const int arraySize = sizeof(assocTypeString)/sizeof(QString);
        uDebug() << "AssociationType string array size = " << arraySize;

        int index;
        for (index = 0; index < arraySize; ++index)
            if (assocTypeStr == assocTypeString[index])
                break;
        if (index < arraySize)
            assocType = Uml::AssociationType::Value(index);
    } else {
        int assocTypeNum = assocTypeStr.toInt();
        if (assocTypeNum < (int)Uml::AssociationType::Generalization ||   // first enum
            assocTypeNum > (int)Uml::AssociationType::Relationship) {     // last enum
            uWarning() << "bad assoctype of UML:AssociationType " << ID2STR(id());
            return false;
        }
        assocType = Uml::AssociationType::Value(assocTypeNum);
    }
    setAssociationType( assocType );

    Uml::IDType roleAObjID = STR2ID(element.attribute( "rolea", "-1" ));
    Uml::IDType roleBObjID = STR2ID(element.attribute( "roleb", "-1" ));
    if (assocType == Uml::AssociationType::Aggregation ||
        assocType == Uml::AssociationType::Composition) {
        // Flip roles to compensate for changed diamond logic in AssociationLine.
        // For further explanations see AssociationWidget::loadFromXMI.
        Uml::IDType tmp = roleAObjID;
        roleAObjID = roleBObjID;
        roleBObjID = tmp;
    }

    UMLObject * objA = doc->findObjectById(roleAObjID);
    UMLObject * objB = doc->findObjectById(roleBObjID);

    if(objA)
        getUMLRole(A)->setObject(objA);
    else
        return false;

    if(objB)
        getUMLRole(B)->setObject(objB);
    else
        return false;

    setMulti(element.attribute( "multia", "" ), A);
    setMulti(element.attribute( "multib", "" ), B);

    setRoleName(element.attribute( "namea", "" ), A);
    setRoleName(element.attribute( "nameb", "" ), B);

    setRoleDoc(element.attribute( "doca", "" ), A);
    setRoleDoc(element.attribute( "docb", "" ), B);

    // Visibility defaults to Public if it cant set it here..
    QString visibilityA = element.attribute( "visibilitya", "0");
    QString visibilityB = element.attribute( "visibilityb", "0");
    int vis = visibilityA.toInt();
    if (vis >= 200)  // bkwd compat.
        vis -= 200;
    setVisibility((Uml::Visibility::Value)vis, A);
    vis = visibilityB.toInt();
    if (vis >= 200)  // bkwd compat.
        vis -= 200;
    setVisibility((Uml::Visibility::Value)vis, B);

    // Changeability defaults to Changeable if it cant set it here..
    QString changeabilityA = element.attribute( "changeabilitya", "0");
    QString changeabilityB = element.attribute( "changeabilityb", "0");
    if (changeabilityA.toInt() > 0)
        setChangeability(Uml::Changeability(Uml::Changeability::Value(changeabilityA.toInt())), A);
    if (changeabilityB.toInt() > 0)
        setChangeability(Uml::Changeability(Uml::Changeability::Value(changeabilityB.toInt())), B);

    return true;
}
示例#18
0
bool ToolScript::load(const QString& file) {
  reset();

  QDomDocument document;

  { // load the source file into the DOM document
    QFile scriptFile(file);
    if (!scriptFile.open(QFile::ReadOnly)) {
      return setLastError(kFileNotFound);
    }

    document.setContent(&scriptFile);
    scriptFile.close();
  }

  // pull out each of the tools from the element
  QDomElement root = document.documentElement();
  if (root.tagName() != "toolScript") {
    qDebug() << "No toolScript element " << file;
    return setLastError(kInvalidRootElement);
  }

  name_ = root.attributes().namedItem("name").nodeValue();
  description_ = root.attributes().namedItem("description").nodeValue();
  printer_name_ = root.attributes().namedItem("printer").nodeValue();

  {
    QDomNodeList print_nodes = root.elementsByTagName("printScript");
    if (print_nodes.size() != 1) {
      qDebug() << "No printScript node in " << file;
      return setLastError(kInvalidPrintScriptNode);
    }
    print_nodes = print_nodes.at(0).childNodes();
    if (print_nodes.size() != 1 || !print_nodes.at(0).isCDATASection()) {
      qDebug() << "Invalid printScript node in " << file;
      return setLastError(kInvalidPrintScriptNode);
    }
    print_script_ = print_nodes.at(0).nodeValue();
  }

  QDomNodeList settingsNodes = root.elementsByTagName("settings");
  for (unsigned int i = 0; i < settingsNodes.length(); ++i) {
    QDomNode node = settingsNodes.at(i);
    QDomNode parent = node.parentNode();
    if (parent.nodeName() == "tool") {
      QString tool_name = parent.attributes().namedItem("name").nodeValue();
      QString material_name = parent.attributes().namedItem("material").nodeValue();
      todo("kwg8", "check these names for validity; else, toolscript is not valid");
      QString script_variable = parent.attributes().namedItem("scriptVariable").nodeValue();
      bool is_support_material = false;
      { // Determine if this tool is flagged as support material
        QString is_support_material_s = parent.attributes().namedItem("isSupportMaterial").nodeValue();
        bool ok = false;
        is_support_material = 0 != is_support_material_s.toInt(&ok, 10);
        if (!ok) {
          if (is_support_material_s.isEmpty()) {
            is_support_material = false;
          } else {
            char first = is_support_material_s.toAscii().at(0);
            is_support_material = first == 'T' || first == 't';
          }
        }
      }
      ToolScriptTool* tool = new ToolScriptTool(tool_name, material_name, is_support_material, script_variable);
      QDomNodeList settingNodes = node.childNodes();
      for (int j = 0; j < settingNodes.size(); ++j) {
        QDomNode settingNode = settingNodes.at(j);
        if (settingNode.isComment()) continue; // discard all the weird stuff
        tool->addSetting(new ToolScriptSetting(settingNode));
      }
      tools_.append(tool);
    } else if (parent.nodeName() == "toolScript") {
      // contains custom non-tool-specific setting
      QDomNodeList settingNodes = node.childNodes();
      for (int j = 0; j < settingNodes.size(); ++j) {
        QDomNode settingNode = settingNodes.at(j);
        if (settingNodes.at(j).isComment()) continue;
        settings_.append(new ToolScriptSetting(settingNode));
      }
    } else {
      // there is a problem with the tool-script, but it can be ignored
    }
  }

  return setLastError(kNoError);
}
void XmlRelationCheckerCoreImpl::CheckAllRelation(QDomNode nodeToCheck, QList<XmlRelationError*>* errorCollection,
                                                  const QString& absoluteFileName, const QString& parentNumberBase, int number) const
{
    if(!nodeToCheck.isNull())
    {
        if(nodeToCheck.isElement() && !nodeToCheck.isComment())
        {

            //Calcolate the hierarchical number
            QString completeIdentifiersNumber = parentNumberBase;
            //If it's not empty is because it's the first node and it needn't the dot seprator
            if(!parentNumberBase.isEmpty())
            {
                completeIdentifiersNumber.append('.');
            }
            //Attach the number
            completeIdentifiersNumber.append(QString::number(number));

            //For debug
            //const QString& nodeName = nodeToCheck.nodeName();

            //For every xml relations
            for(int i=0; i < m_pXmlRelationCollection->Size(); ++i)
            {
                //Current analized xml relation
                XmlRelation* xmlRelation = new XmlRelation(*m_pXmlRelationCollection->GetRelationAt(i));

                //If the relation is a SUB_TAG relation
                if(xmlRelation->GetRelationType() == SUB_TAG)
                {

                    //It would be better if it's mantained a list of the finded tag to in order to avoid the research of
                    //the tag from of this tag
                    //It's not inplemented because even without thid optimization it's fast enough

                    //If the current tag is a node from for the current relation then check for the existence of the node to
                    //The current tag is a nofe from is the list of the key contained is at least 1
                    QList<QString>* keyFound = CheckIsNodeFrom(nodeToCheck, xmlRelation);
                    if(keyFound->size() > 0)
                    {
                        //For each key
                        for(int k=0; k < keyFound->size(); ++k)
                        {
                            bool referenceFound = false;

                            //Search in all the files the referenced node to
                            for(int j=0; j < m_xmlDocumentsList->size() && !referenceFound; ++j)
                            {
                                const QDomNode& rootNode = m_xmlDocumentsList->at(j)->GetQDomDocument()->firstChildElement();

                                //Search if this reference is valid
                                referenceFound = referenceFound || ! SearchGivenNodeTo(rootNode, keyFound->at(k), xmlRelation, "", 1).isEmpty();
                            }

                            //If the reference not exist add an error
                            if(!referenceFound)
                            {
                                XmlRelationError* xmlRelationError = new XmlRelationError(absoluteFileName, xmlRelation, completeIdentifiersNumber,
                                                                              keyFound->at(k), XML_RELATION_ERROR_TYPE_REFERENCED_NOT_FOUND);

                                //Add the error in the list
                                errorCollection->append(xmlRelationError);
                            }
                        }
                    }
                    delete keyFound;
                    //If the current tag is a node to for the current relation then check for the existence of the node to
                    const QString& tagToKey = CheckIsNodeTo(nodeToCheck, xmlRelation);
                    if(tagToKey != "") //then is a node to
                    {
                        bool referenceFound = false;

                        //Search in all the files the referencer node from
                        for(int j=0; j < m_xmlDocumentsList->size()  && !referenceFound; ++j)
                        {
                            const QDomNode& rootNode = m_xmlDocumentsList->at(j)->GetQDomDocument()->firstChildElement();

                            //Search if this reference is valid
                            referenceFound = referenceFound || SearchGivenNodeFrom(rootNode, tagToKey, xmlRelation);
                        }

                        //If the reference not exist add an error
                        if(!referenceFound)
                        {
                            XmlRelationError* xmlRelationError = new XmlRelationError(absoluteFileName, xmlRelation, completeIdentifiersNumber,
                                                                          tagToKey, XML_RELATION_ERROR_TYPE_REFERENCED_NEVER_REFERENCED);

                            //Add the error in the list
                            errorCollection->append(xmlRelationError);
                        }
                    }
                }
            }
            //Recursive call that ensure to explore all the document element
            CheckAllRelation(nodeToCheck.firstChildElement(), errorCollection, absoluteFileName, completeIdentifiersNumber, 1);
        }

        //Recursive call that ensure to explore all the document element
        CheckAllRelation(nodeToCheck.nextSiblingElement(), errorCollection, absoluteFileName, parentNumberBase, number+1);
    }
}
void ReadAndWriteXML::parseEntry(const QDomElement &element, QTreeWidgetItem *parent, int parentLevel)
{
 //   item->setText(0, element.attribute("term"));
    QDomNode node = element.firstChild();
    while (!node.isNull()) {
        //qDebug() << "DomParser::parseEntry  node " << node.toElement().tagName();
    //    qDebug() << "DomParser::parseEntry  parsing node " << node.nodeName();
         if (node.isElement()) {
            //qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is element ";
            QTreeWidgetItem *childitem=new QTreeWidgetItem(parent, QStringList(QString("Type: %1").arg(node.nodeName())));
            parseEntry(node.toElement(), childitem,++parentLevel);
            QString _attr="";
            if (node.hasAttributes()) {
               childitem=new QTreeWidgetItem(childitem, QStringList(QString("Attributes node %1").arg(node.nodeName())));
               parseAttribute(node.attributes(), childitem, parentLevel);
            }
            node = node.nextSibling();
            continue;
         }
         if (node.isCDATASection()) {
             //qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is CDATASection --" << node.toText().data() << "--";
             new QTreeWidgetItem(parent, QStringList(QString("Type: %1 Value: %2").arg(node.nodeName(),node.toText().data())));
             node = node.nextSibling();
             continue;
         }
         if (node.isComment()) {
            //qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is comment --" << node.toText().data() << "--";
            new QTreeWidgetItem(parent, QStringList(QString("Type: %1 Value: %2").arg(node.nodeName(),node.toText().data())));
            node = node.nextSibling();
            continue;
         }
         if (node.isText()) {
            //qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " text --" << node.toText().data() << "--";
            new QTreeWidgetItem(parent, QStringList(QString("Type: %1 Value: %2").arg(node.nodeName(),node.toText().data())));
            node = node.nextSibling();
            continue;
         }
         if (node.isDocument()) {
            //qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is document ";
            QTreeWidgetItem *childitem=new QTreeWidgetItem(parent, QStringList(QString("Type: %1").arg(node.nodeName())));
            parseEntry(node.toElement(), childitem,++parentLevel);
            node = node.nextSibling();
            continue;
         }
         if (node.isDocumentType()) {
            qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is  document type";
            QTreeWidgetItem *childitem=new QTreeWidgetItem(parent, QStringList(QString("Type: %1").arg(node.nodeName())));
            parseEntry(node.toElement(), childitem,++parentLevel);
            node = node.nextSibling();
            continue;
         }
         if (node.isDocumentFragment()) {
            qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is  document fragment";
            QTreeWidgetItem *childitem=new QTreeWidgetItem(parent, QStringList(QString("Type: %1").arg(node.nodeName())));
            parseEntry(node.toElement(), childitem,++parentLevel);
            node = node.nextSibling();
            continue;
         }
         if (node.isEntity() || node.isEntityReference () || node.isNotation () || node.isProcessingInstruction ()) {
             qDebug() << "DomParser::parseEntry "<< node.nodeName()<< " is  not supported";
             node = node.nextSibling();
             continue;
         }

        node = node.nextSibling();
    }
}
示例#21
0
文件: umlrole.cpp 项目: KDE/umbrello
/**
 * Loads the <UML:AssociationEnd> XMI element.
 * Auxiliary to UMLObject::loadFromXMI.
 */
bool UMLRole::load(QDomElement & element)
{
    UMLDoc * doc = UMLApp::app()->document();
    QString type = element.attribute(QLatin1String("type"));
    if (!type.isEmpty()) {
        if (!m_SecondaryId.isEmpty())
            uWarning() << "overwriting old m_SecondaryId \"" << m_SecondaryId
                << " with new value \"" << type << "\"";
        m_SecondaryId = type;
    }
    // Inspect child nodes - for multiplicity (and type if not set above.)
    for (QDomNode node = element.firstChild(); !node.isNull(); node = node.nextSibling()) {
        if (node.isComment())
            continue;
        QDomElement tempElement = node.toElement();
        QString tag = tempElement.tagName();
        if (UMLDoc::tagEq(tag, QLatin1String("name"))) {
            m_name = tempElement.text();
        } else if (UMLDoc::tagEq(tag, QLatin1String("AssociationEnd.multiplicity"))) {
            /*
             * There are different ways in which the multiplicity might be given:
             *  - direct value in the <AssociationEnd.multiplicity> tag,
             *  - attributes "lower" and "upper" of a subordinate <MultiplicityRange>,
             *  - direct value in subordinate <MultiplicityRange.lower> and
             *    <MultiplicityRange.upper> tags
             */
            QDomNode n = tempElement.firstChild();
            if (node.isNull() || tempElement.isNull() || n.isNull() ||
                    n.toElement().isNull()) {
                m_Multi = tempElement.text().trimmed();
                continue;
            }
            tempElement = n.toElement();
            tag = tempElement.tagName();
            if (!UMLDoc::tagEq(tag, QLatin1String("Multiplicity"))) {
                m_Multi = tempElement.text().trimmed();
                continue;
            }
            n = tempElement.firstChild();
            tempElement = n.toElement();
            tag = tempElement.tagName();
            if (!UMLDoc::tagEq(tag, QLatin1String("Multiplicity.range"))) {
                m_Multi = tempElement.text().trimmed();
                continue;
            }
            n = tempElement.firstChild();
            tempElement = n.toElement();
            tag = tempElement.tagName();
            if (!UMLDoc::tagEq(tag, QLatin1String("MultiplicityRange"))) {
                m_Multi = tempElement.text().trimmed();
                continue;
            }
            QString multiUpper;
            if (tempElement.hasAttribute(QLatin1String("lower"))) {
                m_Multi = tempElement.attribute(QLatin1String("lower"));
                multiUpper = tempElement.attribute(QLatin1String("upper"));
                if (!multiUpper.isEmpty()) {
                    if (!m_Multi.isEmpty())
                        m_Multi.append(QLatin1String(".."));
                    m_Multi.append(multiUpper);
                }
                continue;
            }
            n = tempElement.firstChild();
            while (!n.isNull()) {
                tempElement = n.toElement();
                tag = tempElement.tagName();
                if (UMLDoc::tagEq(tag, QLatin1String("MultiplicityRange.lower"))) {
                    m_Multi = tempElement.text();
                } else if (UMLDoc::tagEq(tag, QLatin1String("MultiplicityRange.upper"))) {
                    multiUpper = tempElement.text();
                }
                n = n.nextSibling();
            }
            if (!multiUpper.isEmpty()) {
                if (!m_Multi.isEmpty())
                    m_Multi.append(QLatin1String(".."));
                m_Multi.append(multiUpper);
            }
        } else if (m_SecondaryId.isEmpty() &&
                   (UMLDoc::tagEq(tag, QLatin1String("type")) ||
                    UMLDoc::tagEq(tag, QLatin1String("participant")))) {
            m_SecondaryId = tempElement.attribute(QLatin1String("xmi.id"));
            if (m_SecondaryId.isEmpty())
                m_SecondaryId = tempElement.attribute(QLatin1String("xmi.idref"));
            if (m_SecondaryId.isEmpty()) {
                QDomNode inner = tempElement.firstChild();
                QDomElement innerElem = inner.toElement();
                m_SecondaryId = innerElem.attribute(QLatin1String("xmi.id"));
                if (m_SecondaryId.isEmpty())
                    m_SecondaryId = innerElem.attribute(QLatin1String("xmi.idref"));
            }
        }
    }
    if (!m_Multi.isEmpty())
        uDebug() << name() << ": m_Multi is " << m_Multi;
    if (m_SecondaryId.isEmpty()) {
        uError() << name() << ": type not given or illegal";
        return false;
    }
    UMLObject * obj;
    obj = doc->findObjectById(Uml::ID::fromString(m_SecondaryId));
    if (obj) {
        m_pSecondary = obj;
        m_SecondaryId = QString();
    }

    // block signals to prevent needless updating
    blockSignals(true);
    // Here comes the handling of the association type.
    // This is open for discussion - I'm pretty sure there are better ways..

    // Yeah, for one, setting the *parent* object parameters from here is sucky
    // as hell. Why are we using roleA to store what is essentially a parent (association)
    // parameter, eh? The UML13.dtd is pretty silly, but since that is what
    // is driving us to that point, we have to go with it. Some analysis of
    // the component roles/linked items needs to be done in order to get things
    // right. *sigh* -b.t.

    // Setting association type from the role (A)
    // Determination of the "aggregation" attribute used to be done only
    // when (m_role == Uml::RoleType::A) but some XMI writers (e.g. StarUML) place
    // the aggregation attribute at role B.
    // The role end with the aggregation unequal to "none" wins.
    QString aggregation = element.attribute(QLatin1String("aggregation"), QLatin1String("none"));
    if (aggregation == QLatin1String("composite"))
        m_pAssoc->setAssociationType(Uml::AssociationType::Composition);
    else if (aggregation == QLatin1String("shared")       // UML1.3
          || aggregation == QLatin1String("aggregate"))   // UML1.4
        m_pAssoc->setAssociationType(Uml::AssociationType::Aggregation);

    if (!element.hasAttribute(QLatin1String("isNavigable"))) {
        // Backward compatibility mode: In Umbrello version 1.3.x the
        // logic for saving the isNavigable flag was wrong.
        // May happen on loading role A.
        m_pAssoc->setOldLoadMode(true);
    } else if (m_pAssoc->getOldLoadMode() == true) {
        // Here is the original logic:
        // "Role B:
        //  If isNavigable is not given, we make no change to the
        //  association type.
        //  If isNavigable is given, and is "true", then we assume that
        //  the association's other end (role A) is not navigable, and
        //  therefore we change the association type to UniAssociation.
        //  The case that isNavigable is given as "false" is ignored.
        //  Combined with the association type logic for role A, this
        //  allows us to support at_Association and at_UniAssociation."
        if (element.attribute(QLatin1String("isNavigable")) == QLatin1String("true"))
            m_pAssoc->setAssociationType(Uml::AssociationType::UniAssociation);
    } else if (element.attribute(QLatin1String("isNavigable")) == QLatin1String("false")) {
        m_pAssoc->setAssociationType(Uml::AssociationType::UniAssociation);
    }

    //FIXME not standard XMI
    if (element.hasAttribute(QLatin1String("relationship"))) {
        if (element.attribute(QLatin1String("relationship")) == QLatin1String("true")) {
            m_pAssoc->setAssociationType(Uml::AssociationType::Relationship);
        }
    }

    if (m_Multi.isEmpty())
        m_Multi = element.attribute(QLatin1String("multiplicity"));

    // Changeability defaults to Changeable if it cant set it here..
    m_Changeability = Uml::Changeability::Changeable;
    QString changeability = element.attribute(QLatin1String("changeability"));
    if (changeability.isEmpty())
        element.attribute(QLatin1String("changeable"));  // for backward compatibility
    if (changeability == QLatin1String("frozen"))
        m_Changeability = Uml::Changeability::Frozen;
    else if (changeability == QLatin1String("addOnly"))
        m_Changeability = Uml::Changeability::AddOnly;

    // finished config, now unblock
    blockSignals(false);
    return true;
}