[Uml-devel] kdesdk/umbrello/umbrello/codegenerators
Sebastian Stein
seb.kde at hpfsc.de
Thu Jul 29 08:45:13 UTC 2004
CVS commit by sstein:
fix remaining issues of bug 73632 and bug 77377:
- correct comma (,) adding, even if the attributes have different scopes (public, private, protected)
- removed the comment with the foreign key constraint, because it doesn't make any sense
- fixed foreign key constraint handling; only the role names and the aggregation names are interpreted; multiplicity is ignored, because you can not add a multiplicity in a foreign key constraint statement
modified functions:
void SQLWriter::writeClass(UMLClassifier *c)
void SQLWriter::printAttributes(QTextStream& sql, UMLAttributeList attributeList, bool first)
void SQLWriter::writeAttributes(UMLClass *c, QTextStream &sql)
M +31 -11 sqlwriter.cpp 1.14
M +5 -1 sqlwriter.h 1.10
--- kdesdk/umbrello/umbrello/codegenerators/sqlwriter.h #1.9:1.10
@@ -73,6 +73,10 @@ private:
/**
* Prints out attributes as columns in the table
+ *
+ * @param sql the stream we should print to
+ * @param attributeList the attributes to be printed
+ * @param first if the attributes are the first one
*/
- void printAttributes(QTextStream& sql, UMLAttributeList attributeList);
+ void printAttributes(QTextStream& sql, UMLAttributeList attributeList, bool first);
};
--- kdesdk/umbrello/umbrello/codegenerators/sqlwriter.cpp #1.13:1.14
@@ -90,10 +90,10 @@ void SQLWriter::writeClass(UMLClassifier
if( forceSections() || !aggregations.isEmpty() ) {
for(UMLAssociation* a = aggregations.first(); a; a = aggregations.next()) {
- if( a->getObject(A)->getID()==c->getID() ) {
- sql << m_newLineEndingChars << "-- CONSTRAINT " << a->getName() << " FOREIGN KEY (" << a->getMulti(B) <<
- ") REFERENCES " << a->getObject(A)->getName() << "(" << a->getMulti(A) << ")";
- } else {
- sql << "," << m_newLineEndingChars << m_indentation << "CONSTRAINT " << a->getName() << " FOREIGN KEY (" << a->getMulti(B) <<
- ") REFERENCES " << a->getObject(A)->getName() << "(" << a->getMulti(A) << ")";
+ if( a->getObject(A)->getID() != c->getID() ) {
+
+ sql << m_indentation << "," << m_newLineEndingChars << m_indentation
+ << "CONSTRAINT " << a->getName() << " FOREIGN KEY ("
+ << a->getRoleName(B) << ") REFERENCES "
+ << a->getObject(A)->getName() << " (" << a->getRoleName(A) << ")";
}
}
@@ -130,11 +130,31 @@ void SQLWriter::writeAttributes(UMLClass
}
- printAttributes(sql, atpub);
- printAttributes(sql, atprot);
- printAttributes(sql, atpriv);
+ // now print the attributes; they are sorted by there scope
+ // in front of the first attribute shouldn't be a , -> so we need to find
+ // out, when the first attribute was added
+ bool first = true;
+
+ if (atpub.count() > 0)
+ {
+ printAttributes(sql, atpub, first);
+ first = false;
+ }
+
+ if (atprot.count() > 0)
+ {
+ printAttributes(sql, atprot, first);
+ first = false;
+ }
+
+ if (atpriv.count() > 0)
+ {
+ printAttributes(sql, atpriv, first);
+ first = false;
+ }
+
+ return;
}
-void SQLWriter::printAttributes(QTextStream& sql, UMLAttributeList attributeList) {
- bool first = true;
+void SQLWriter::printAttributes(QTextStream& sql, UMLAttributeList attributeList, bool first) {
QString attrDoc = "";
UMLAttribute* at;
More information about the umbrello-devel
mailing list