tst_FkConstraint::tst_FkConstraint(QObject *parent) : QDjangoModel(parent) { setForeignKey("noConstraint", new User(this)); setForeignKey("cascadeConstraint", new User(this)); setForeignKey("restrictConstraint", new User(this)); setForeignKey("nullConstraint", new User(this)); }
string ERModel::getERDiagramTable() { string erDiagramRowString; string erDiagramTableString; string primaryKeyString; string notPrimaryKeyString; vector<Component*> entitySet = searchSpecificTypeComponentSet(PARAMETER_ENTITY, _components); vector<Component*> attributeInEntitySet; setForeignKey(); for(int i = 0; i < entitySet.size(); i++) { erDiagramRowString = TEXT_ONESPACE + entitySet[i]->getText(); // 用空白填滿 while (erDiagramRowString.size() < PARAMETER_FILLUPSIZE) erDiagramRowString += TEXT_ONESPACE; erDiagramRowString += TEXT_LINESPACE; attributeInEntitySet = searchSpecificTypeComponentSet(PARAMETER_ATTRIBUTE, entitySet[i]->getConnections()); erDiagramRowString += getAttributeContents(attributeInEntitySet); for(int j = 0; j < static_cast<NodeEntity*>(entitySet[i])->getForeignKey().size(); j++) { if (static_cast<NodeEntity*>(entitySet[i])->getIsShowForeignKeyinERTable()[j] == PARAMETER_TRUE) erDiagramRowString += searchForeignKey(static_cast<NodeEntity*>(entitySet[i])->getForeignKey()[j]); } erDiagramRowString += TEXT_ENDLINE; erDiagramTableString += erDiagramRowString; } return erDiagramTableString; }
Livraison::Livraison( QString code, QDate date, QObject *parent ) : QDjangoModel( parent ), m_code( code ), m_date( date) { setForeignKey( "commande", new Commande( this ) ); }
Record & Record::setValue( const QString & column, const QVariant & value ) { if( !mImp ) return *this; if( value.userType() == qMetaTypeId<Record>() ) { setForeignKey( column, qvariant_cast<Record>(value) ); return * this; } mImp = mImp->setValue( column, value ); return *this; }
string ERModel::getHTMLERDiagramTable() { string htmlString; // Entity的名字,在方格上面要先寫該Entity是那個 vector<Component*> entitySet = searchSpecificTypeComponentSet(PARAMETER_ENTITY, _components); // 找出與Entity有相連的Attribute vector<Component*> attributeInEntitySet; // 設定FK setForeignKey(); for(int i = 0; i < entitySet.size(); i++) { // 取得Entity名字 htmlString += "<h><b>" + entitySet[i]->getText() + "</b></h>"; htmlString += "<table border=\"1\">"; htmlString += "<tr>"; // 取得此Entity的PK attributeInEntitySet = searchSpecificTypeComponentSet(PARAMETER_ATTRIBUTE, entitySet[i]->getConnections()); for(int j = 0; j < attributeInEntitySet.size(); j++) { if (static_cast<NodeAttribute*>(attributeInEntitySet[j])->getIsPrimaryKey()) htmlString += "<td align=\"center\"><img src=\"./images/pk.png\"></img>" + attributeInEntitySet[j]->getText() + "</td>"; else htmlString += "<td align=\"center\">" + attributeInEntitySet[j]->getText() + "</td>"; } // 取得Entity的FK htmlString += getForeignKeyHtml(entitySet[i]); htmlString += "</tr>"; htmlString += "</table>"; } return htmlString; }
void Owner::setItem2(Item *item2) { setForeignKey("item2", item2); }
void RProduitStock::setProduit( Produit* produit ) { setForeignKey( "produit", produit ); }
void Owner::setItem1(Item *item1) { setForeignKey("item1", item1); }
RProduitStock::RProduitStock( QObject *parent ) : QDjangoModel( parent ) { setForeignKey( "stock", new Stock( this ) ); setForeignKey( "produit", new Produit( this ) ); }
void RProduitStock::setStock( Stock* stock ) { setForeignKey( "stock", stock ); }
ArchiveMessage::ArchiveMessage() { setForeignKey("chat", new ArchiveChat(this)); }
void RequirementElement::setComponent(ArchitectElement *component) { setForeignKey("component", component); }
Message::Message(QObject *parent) : QDjangoModel(parent) { setForeignKey("user", new User(this)); }
void tst_FkConstraint::setNoConstraint(User *user) { setForeignKey("noConstraint", user); }
int readTables (int fd, struct table **tableList){ struct stat st; if(fstat(fd,&st) < 0) return -1; if (st.st_size == 0) return 0; int k = 0, i, readen = 0; while(st.st_size > readen){ int len, r; printf ("\nsize = %d, readen = %d\n", st.st_size, readen); *tableList = (struct table *)realloc(*tableList, (k + 1) * sizeof(struct table)); if((r = read(fd, &len, sizeof(int))) != sizeof(int)){ perror("Reading error: len"); return -1; } readen += r; (*tableList)[k].table_name = (char *)calloc((len+1), sizeof(char)); if((r = read(fd, (*tableList)[k].table_name, len)) != len){ perror("Reading error: table_name"); return -1; } printf("Read table_name = %s\n", (*tableList)[k].table_name); readen += r; if((r = read(fd, &(*tableList)[k].column_count, sizeof(unsigned char))) != sizeof(unsigned char)){ perror("Reading error: qcol"); return -1; } printf("Read qcol = %d\n", (*tableList)[k].column_count); readen += r; (*tableList)[k].columns = (struct column_declare *)calloc((*tableList)[k].column_count, sizeof(struct column_declare)); for(i = 0; i < (*tableList)[k].column_count; i++){ int index; if((r = read(fd, &index, sizeof(int))) != sizeof(int)){ perror("Reading error: index"); return -1; } printf("Read index = %d\n", index); readen += r; int clen; if((r = read(fd, &clen, sizeof(int))) != sizeof(int)){ perror("Reading error: clen"); return -1; } printf("Read clen = %d\n", clen); readen += r; (*tableList)[k].columns[i].column_name = (char *)calloc(clen + 1, sizeof(char)); if((r = read(fd, (*tableList)[k].columns[i].column_name, clen)) != clen){ perror("Reading error: column_name"); return -1; } printf("Read cols: name = %s\n", (*tableList)[k].columns[i].column_name); readen += r; if((r = read(fd, &(*tableList)[k].columns[i].type, sizeof(char))) != sizeof(char)){ perror("Reading error: column_type"); return -1; } printf("Read cols: type = %d\n", (*tableList)[k].columns[i].type); readen += r; if((r = read(fd, &(*tableList)[k].columns[i].constraints, sizeof(char))) != sizeof(char)){ perror("Reading error: column_constraints"); return -1; } printf("Read cols: constr = %d\n", (*tableList)[k].columns[i].constraints); readen += r; if ((*tableList)[k].columns[i].constraints >= 8){ int foreignIndex; if((r = read(fd, &foreignIndex, sizeof(int))) != sizeof(int)){ perror("Reading error: column_foreign_index"); return -1; } printf("Read: foreign key index = %d\n", foreignIndex); readen += r; setForeignKey(foreignIndex, (*tableList), k, i); } } k++; char buf[1]; r = read (fd, buf, 1); readen += r; } return k; }
void UserGroups::setUser(User *user) { setForeignKey("user", user); }
void Computer::user(const User* _user) { setForeignKey("user", const_cast<User*>(_user)); }
void tst_FkConstraint::setCascadeConstraint(User *user) { setForeignKey("cascadeConstraint", user); }
void ArchiveMessage::setChat(ArchiveChat *chat) { setForeignKey("chat", chat); }
Owner::Owner(QObject *parent) : QDjangoModel(parent) { setForeignKey("item1", new Item(this)); setForeignKey("item2", new Item(this)); }
RequirementElement::RequirementElement(QObject *parent) : QDjangoModel(parent) { setForeignKey("component", new ArchitectElement(this)); }
UserGroups::UserGroups(QObject *parent) : QDjangoModel(parent) { setForeignKey("user", new User(this)); setForeignKey("group", new Group(this)); }
void tst_FkConstraint::setRestrictConstraint(User *user) { setForeignKey("restrictConstraint", user); }
void UserGroups::setGroup(Group *group) { setForeignKey("group", group); }
Livraison::Livraison( QObject *parent ) : QDjangoModel( parent ) { setForeignKey( "commande", new Commande( this ) ); }
void Message::setUser(User *user) { setForeignKey("user", user); }
void Livraison::setCommande( Commande* commande ) { setForeignKey( "commande", commande); }