[Uml-devel] branches/KDE/3.5/kdesdk/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Thu Nov 30 18:50:09 UTC 2006
SVN commit 609424 by okellogg:
Apply attachment 18732 from Alexey Parshin with slight modification.
writeClass(): Add an auxiliary variable, constraintMap, to avoid excessive
code for duplicated associations. (Those duplicated associations should
not be there in the first place though.)
writeAttributes(): Generate code for implementation-level attributes.
BUG:138139
M +1 -0 ChangeLog
M +24 -11 umbrello/codegenerators/sqlwriter.cpp
--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #609423:609424
@@ -11,6 +11,7 @@
http://www.geeksoc.org/~jr/umbrello/uml-devel/9863.html
* Bugs/wishes from http://bugs.kde.org:
* Artifacts of a component diagram are wrongly placed in Deployment View folder (137564)
+* Incorrect export to SQL (138139)
Version 1.5.52
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/sqlwriter.cpp #609423:609424
@@ -83,6 +83,9 @@
if (isClass)
writeAttributes(c, sql);
+ sql << m_endl << ");" << m_endl;
+
+ QMap<UMLAssociation*,UMLAssociation*> constraintMap; // so we don't repeat constraint
UMLAssociationList aggregations = c->getAggregations();
if( forceSections() || !aggregations.isEmpty() ) {
for(UMLAssociation* a = aggregations.first(); a; a = aggregations.next()) {
@@ -90,18 +93,20 @@
UMLObject *objB = a->getObject(Uml::B);
if (objA->getID() == c->getID() && objB->getID() != c->getID())
continue;
- QString roleNameA = a->getRoleName(Uml::A);
- QString roleNameB = a->getRoleName(Uml::B);
- if (roleNameA.isEmpty() || roleNameB.isEmpty())
- continue;
- sql << m_indentation << "," << m_endl;
- sql << m_indentation << "CONSTRAINT " << a->getName()
- << " FOREIGN KEY (" << roleNameB << ") REFERENCES "
- << objA->getName() << " (" << roleNameA << ")";
+ constraintMap[a] = a;
}
}
+
+ QMap<UMLAssociation*,UMLAssociation*>::Iterator itor = constraintMap.begin();
+ for (;itor != constraintMap.end();itor++) {
+ UMLAssociation* a = itor.data();
+ sql << "ALTER TABLE "<< classname
+ << " ADD CONSTRAINT " << a->getName() << " FOREIGN KEY ("
+ << a->getRoleName(Uml::B) << ") REFERENCES "
+ << a->getObject(Uml::A)->getName()
+ << " (" << a->getRoleName(Uml::A) << ");" << m_endl;
+ }
- sql << m_endl << ");" << m_endl;
file.close();
emit codeGenerated(c, true);
@@ -109,10 +114,11 @@
void SQLWriter::writeAttributes(UMLClassifier *c, QTextStream &sql) {
- UMLAttributeList atpub, atprot, atpriv;
+ UMLAttributeList atpub, atprot, atpriv, atimp;
atpub.setAutoDelete(false);
atprot.setAutoDelete(false);
atpriv.setAutoDelete(false);
+ atimp.setAutoDelete(false);
//sort attributes by scope and see if they have a default value
UMLAttributeList atl = c->getAttributeList();
@@ -127,7 +133,8 @@
case Uml::Visibility::Private:
atpriv.append(at);
break;
- default:
+ case Uml::Visibility::Implementation:
+ atimp.append(at);
break;
}
}
@@ -155,6 +162,12 @@
first = false;
}
+ if (atimp.count() > 0)
+ {
+ printAttributes(sql, atimp, first);
+ first = false;
+ }
+
return;
}
More information about the umbrello-devel
mailing list