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));
}
示例#2
0
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;
}
示例#3
0
 Livraison::Livraison( QString code, QDate date, QObject *parent ) :
         QDjangoModel( parent ),
         m_code( code ),
         m_date( date)
 {
     setForeignKey( "commande", new Commande( this ) );
 }
示例#4
0
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;
}
示例#5
0
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;
}
示例#6
0
void Owner::setItem2(Item *item2)
{
    setForeignKey("item2", item2);
}
示例#7
0
 void RProduitStock::setProduit( Produit* produit )
 {
     setForeignKey( "produit", produit );
 }
示例#8
0
void Owner::setItem1(Item *item1)
{
    setForeignKey("item1", item1);
}
示例#9
0
 RProduitStock::RProduitStock( QObject *parent ) : QDjangoModel( parent )
 {
     setForeignKey( "stock", new Stock( this ) );
     setForeignKey( "produit", new Produit( this ) );
 }
示例#10
0
 void RProduitStock::setStock( Stock* stock )
 {
     setForeignKey( "stock", stock );
 }
示例#11
0
ArchiveMessage::ArchiveMessage()
{
    setForeignKey("chat", new ArchiveChat(this));
}
示例#12
0
void RequirementElement::setComponent(ArchitectElement *component)
{
     setForeignKey("component", component);
}
示例#13
0
Message::Message(QObject *parent)
    : QDjangoModel(parent)
{
    setForeignKey("user", new User(this));
}
示例#14
0
void tst_FkConstraint::setNoConstraint(User *user)
{
    setForeignKey("noConstraint", user);
}
示例#15
0
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;
}
示例#16
0
void UserGroups::setUser(User *user)
{
    setForeignKey("user", user);
}
示例#17
0
void Computer::user(const User* _user) {
  setForeignKey("user", const_cast<User*>(_user));
}
示例#18
0
void tst_FkConstraint::setCascadeConstraint(User *user)
{
    setForeignKey("cascadeConstraint", user);
}
示例#19
0
void ArchiveMessage::setChat(ArchiveChat *chat)
{
    setForeignKey("chat", chat);
}
示例#20
0
Owner::Owner(QObject *parent)
    : QDjangoModel(parent)
{
    setForeignKey("item1", new Item(this));
    setForeignKey("item2", new Item(this));
}
示例#21
0
RequirementElement::RequirementElement(QObject *parent)
    : QDjangoModel(parent)
{
    setForeignKey("component", new ArchitectElement(this));
}
示例#22
0
UserGroups::UserGroups(QObject *parent)
    : QDjangoModel(parent)
{
    setForeignKey("user", new User(this));
    setForeignKey("group", new Group(this));
}
示例#23
0
void tst_FkConstraint::setRestrictConstraint(User *user)
{
    setForeignKey("restrictConstraint", user);
}
示例#24
0
void UserGroups::setGroup(Group *group)
{
    setForeignKey("group", group);
}
示例#25
0
 Livraison::Livraison( QObject *parent ) : QDjangoModel( parent )
 {
     setForeignKey( "commande", new Commande( this ) );
 }
示例#26
0
void Message::setUser(User *user)
{
    setForeignKey("user", user);
}
示例#27
0
 void Livraison::setCommande( Commande* commande )
 {
     setForeignKey( "commande", commande);
 }