// this test depend on insert_WithIdent which creates the valid schema: // Always run insert_WithIdent before this test. void FdoAssociationInsertTest::insert_ManyWithIdent() { FdoStringP name1 = L"FirstName"; FdoStringP name2 = L"LastName"; FdoPtr<FdoIConnection> connection = UnitTestUtil::GetConnection(DB_SUFFIX); FdoPtr<FdoITransaction> featureTransaction = connection->BeginTransaction(); FdoPtr<FdoIInsert>insertCommand = (FdoIInsert *) connection->CreateCommand(FdoCommandType_Insert); // Add instances of the TestClass FdoPtr<FdoPropertyValueCollection> propertyValues; FdoPtr<FdoDataValue>dataValue; FdoPtr<FdoPropertyValue>propertyValue; FdoPtr<FdoIFeatureReader> reader; for(int i=90; i<100; i++ ) { char id[4]; sprintf(id,"%d",i); FdoStringP idx(id); FdoStringP val1 = name1 + idx; FdoStringP val2 = name2 + idx; insertCommand->SetFeatureClassName(L"TestClass"); propertyValues = insertCommand->GetPropertyValues(); dataValue = FdoDataValue::Create( i ); propertyValue = AddNewProperty( propertyValues, L"Id"); propertyValue->SetValue(dataValue); // Add the name one property dataValue = FdoDataValue::Create( (FdoString*)val1 ); propertyValue = AddNewProperty( propertyValues, L"Name One"); propertyValue->SetValue(dataValue); // Add the name two property dataValue = FdoDataValue::Create( (FdoString*)val2 ); propertyValue = AddNewProperty( propertyValues, L"Name Two"); propertyValue->SetValue(dataValue); reader = insertCommand->Execute(); // Add an instance of the TestFeatureClass insertCommand->SetFeatureClassName(L"TestFeatureClass"); propertyValues = insertCommand->GetPropertyValues(); propertyValues->Clear(); dataValue = FdoDataValue::Create( (FdoString*)val1 ); propertyValue = AddNewProperty( propertyValues, L"Association Prop1.Name One"); propertyValue->SetValue(dataValue); // Add the name two property dataValue = FdoDataValue::Create( (FdoString*)val2 ); propertyValue = AddNewProperty( propertyValues, L"Association Prop1.Name Two"); propertyValue->SetValue(dataValue); reader = insertCommand->Execute(); } featureTransaction->Commit(); }
void FdoImportExportTest::AddFeature( FdoIInsert* insertCommand, FdoInt32 idx ) { FdoPtr<FdoPropertyValueCollection> propertyValues = insertCommand->GetPropertyValues(); FdoPtr<FdoDataValue> dataValue; FdoPtr<FdoPropertyValue> propertyValue; FdoPtr<FdoIConnection> connection = insertCommand->GetConnection(); bool supportsZ = (FdoPtr<FdoIGeometryCapabilities>(connection->GetGeometryCapabilities())->GetDimensionalities() & FdoDimensionality_Z); dataValue = FdoDataValue::Create((FdoInt64) idx); propertyValue = AddNewProperty( propertyValues, L"Prop1"); propertyValue->SetValue(dataValue); dataValue = FdoDataValue::Create((FdoString*)FdoStringP::Format(L"Prop2_Val%d",idx)); propertyValue = AddNewProperty( propertyValues, L"Prop2"); propertyValue->SetValue(dataValue); dataValue = FdoDataValue::Create((FdoString*)FdoStringP::Format(L"SubProp1_Val%d",idx)); propertyValue = AddNewProperty( propertyValues, L"SubProp1"); propertyValue->SetValue(dataValue); double coordsBuffer[3]; int segCount = 1; coordsBuffer[0] = 5 * idx; coordsBuffer[1] = 10 * idx; coordsBuffer[2] = 0; propertyValue = AddNewProperty( propertyValues, L"Geometry"); FdoPtr<FdoFgfGeometryFactory> gf = FdoFgfGeometryFactory::GetInstance(); FdoPtr<FdoIPoint> point1; if ( supportsZ ) point1 = gf->CreatePoint(FdoDimensionality_XY|FdoDimensionality_Z, coordsBuffer); else point1 = gf->CreatePoint(FdoDimensionality_XY, coordsBuffer); FdoPtr<FdoByteArray> byteArray = gf->GetFgf(point1); FdoPtr<FdoGeometryValue> geometryValue = FdoGeometryValue::Create(byteArray); propertyValue->SetValue(geometryValue); FdoPtr<FdoIFeatureReader> reader = insertCommand->Execute(); }
void QmitkAddNewPropertyDialog::Initialize() { m_Controls.setupUi(this); QStringList types; types << "bool" << "double" << "float" << "int" << "string"; m_Controls.typeComboBox->addItems(types); connect(m_Controls.typeComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(ShowAdequateValueWidget(const QString&))); connect(m_Controls.addButton, SIGNAL(clicked()), this, SLOT(AddNewProperty())); connect(m_Controls.cancelButton, SIGNAL(clicked()), this, SLOT(reject())); this->ShowAdequateValueWidget(types[0]); }
QmitkAddNewPropertyDialog::QmitkAddNewPropertyDialog(mitk::DataNode::Pointer dataNode, mitk::BaseRenderer::Pointer renderer, QWidget* parent) : QDialog(parent), m_DataNode(dataNode), m_Renderer(renderer) { m_Controls.setupUi(this); QStringList types; types << "bool" << "double" << "float" << "int" << "string"; m_Controls.typeComboBox->addItems(types); connect(m_Controls.typeComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(ShowAdequateValueWidget(const QString&))); connect(m_Controls.addButton, SIGNAL(clicked()), this, SLOT(AddNewProperty())); connect(m_Controls.cancelButton, SIGNAL(clicked()), this, SLOT(reject())); this->ShowAdequateValueWidget(types[0]); }
void MySqlFdoInsertTest::insertBoundaryUnsigned() { StaticConnection* conn = new MySqlStaticConnection(); try { UnitTestUtil::SetProvider( conn->GetServiceName() ); conn->connect(); FdoSchemaManagerP mgr = conn->CreateSchemaManager(); FdoSmPhMgrP phMgr = mgr->GetPhysicalSchema(); FdoStringP datastore = phMgr->GetDcOwnerName( UnitTestUtil::GetEnviron("datastore", UNSIGNED_SUFFIX) ); FdoSmPhDatabaseP database = phMgr->GetDatabase(); FdoSmPhOwnerP owner = phMgr->FindOwner( datastore, L"", false ); if ( owner ) { owner->SetElementState( FdoSchemaElementState_Deleted ); owner->Commit(); } owner = database->CreateOwner( datastore, false ); owner->SetPassword( L"test" ); FdoStringP tableName = L"unsigned_test"; FdoSmPhTableP table = owner->CreateTable( tableName ); table->SetPkeyName( tableName + L"_key" ); FdoSmPhColumnP column = table->CreateColumnInt32( L"id", false ); table->AddPkeyCol( column->GetName() ); column = table->CreateColumnUnknown( L"uint_column", L"int unsigned", false, 0, 0 ); owner->Commit(); phMgr = NULL; mgr = NULL; conn->disconnect(); delete conn; conn = NULL; FdoPtr<FdoIConnection> connection = UnitTestUtil::GetConnection(UNSIGNED_SUFFIX, false); FdoPtr<FdoITransaction> featureTransaction = connection->BeginTransaction(); FdoPtr<FdoIInsert> insertCommand = (FdoIInsert *) connection->CreateCommand(FdoCommandType_Insert); insertCommand->SetFeatureClassName(tableName); FdoPtr<FdoPropertyValueCollection> propertyValues = insertCommand->GetPropertyValues(); FdoPtr<FdoDataValue> dataValue; dataValue = FdoDataValue::Create(L"1"); FdoPtr<FdoPropertyValue> propertyValue = AddNewProperty( propertyValues, L"id"); propertyValue->SetValue(dataValue); dataValue = FdoDataValue::Create(L"0"); propertyValue = AddNewProperty( propertyValues, L"uint_column"); propertyValue->SetValue(dataValue); FdoPtr<FdoIFeatureReader> reader = insertCommand->Execute(); dataValue = FdoDataValue::Create(L"2"); propertyValue = AddNewProperty( propertyValues, L"id"); propertyValue->SetValue(dataValue); dataValue = FdoDataValue::Create(L"4294967295"); propertyValue = AddNewProperty( propertyValues, L"uint_column"); propertyValue->SetValue(dataValue); reader = insertCommand->Execute(); featureTransaction->Commit(); // check FdoPtr<FdoISelect> selectCmd = (FdoISelect *) connection->CreateCommand(FdoCommandType_Select); selectCmd->SetFeatureClassName(tableName); FdoPtr<FdoIFeatureReader> featureReader = selectCmd->Execute(); FdoInt32 rowCount = 0; while ( featureReader->ReadNext() ) { rowCount++; switch ( featureReader->GetInt32(L"id") ) { case 1: CPPUNIT_ASSERT ( featureReader->GetInt64(L"uint_column") == 0 ); break; case 2: CPPUNIT_ASSERT ( featureReader->GetInt64(L"uint_column") == 4294967295LL); break; } } CPPUNIT_ASSERT( rowCount == 2 ); } catch (FdoCommandException *ex) { if (conn) { conn->disconnect(); delete conn; } UnitTestUtil::FailOnException(ex); } catch (FdoException *ex) { if (conn) { conn->disconnect(); delete conn; } UnitTestUtil::FailOnException(ex); } }
void FdoAssociationInsertTest::masterTestNoObj( FdoAssociationInsertType type, const wchar_t* name1, const wchar_t* name2, int id, bool assocIsFeat, bool ownerIsFeat, int circularType ) { try { // Setup the schema if( assocIsFeat && ownerIsFeat ) { if ( circularType > 0 ) mSchemaUtil->TestCreate_NoIdentAssocFeatClassCirc (circularType); else mSchemaUtil->TestCreate_NoIdentAssocFeatClass (); } else if( !ownerIsFeat ) { if ( circularType > 0 ) mSchemaUtil->TestCreate_WithIdentNoFeatClassCirc (circularType); else mSchemaUtil->TestCreate_WithIdentNoFeatClass(); } else { if( type == Insert_NoIdentity ) { if ( circularType > 0 ) mSchemaUtil->TestCreate_NoIdentCirc (circularType); else mSchemaUtil->TestCreate_NoIdent(); } else { if ( circularType > 0 ) mSchemaUtil->TestCreate_WithIdentCirc (circularType); else mSchemaUtil->TestCreate_WithIdent(); } } // Get a connection object FdoPtr<FdoIConnection> connection = UnitTestUtil::GetConnection(DB_SUFFIX); FdoPtr<FdoITransaction> featureTransaction = connection->BeginTransaction(); FdoPtr<FdoIInsert>insertCommand = (FdoIInsert *) connection->CreateCommand(FdoCommandType_Insert); // Add an instance of the TestClass insertCommand->SetFeatureClassName(L"TestClass"); FdoPtr<FdoPropertyValueCollection> propertyValues = insertCommand->GetPropertyValues(); // Add the id property FdoPtr<FdoDataValue>dataValue; FdoPtr<FdoPropertyValue>propertyValue; if( ! assocIsFeat ) { dataValue = FdoDataValue::Create( id ); propertyValue = AddNewProperty( propertyValues, L"Id"); propertyValue->SetValue(dataValue); } // Add the name one property dataValue = FdoDataValue::Create( name1 ); propertyValue = AddNewProperty( propertyValues, L"Name One"); propertyValue->SetValue(dataValue); // Add the name two property dataValue = FdoDataValue::Create( name2 ); propertyValue = AddNewProperty( propertyValues, L"Name Two"); propertyValue->SetValue(dataValue); FdoPtr<FdoIFeatureReader> reader = insertCommand->Execute(); if( assocIsFeat && ownerIsFeat && reader->ReadNext() ) { id = (long)reader->GetInt64(L"FeatId"); } // Add an instance of the TestFeatureClass insertCommand->SetFeatureClassName(L"TestFeatureClass"); propertyValues = insertCommand->GetPropertyValues(); propertyValues->Clear(); // Initialize the association property if( !ownerIsFeat ) { dataValue = FdoDataValue::Create(19); propertyValue = AddNewProperty( propertyValues, L"Id"); propertyValue->SetValue(dataValue); } if( type == Insert_NoIdentity ) { // Initialize the association property dataValue = FdoDataValue::Create( id ); if( assocIsFeat ) propertyValue = AddNewProperty( propertyValues, L"Association Prop1.FeatId"); else propertyValue = AddNewProperty( propertyValues, L"Association Prop1.Id"); propertyValue->SetValue(dataValue); // Initialize the second association if ( circularType == 0 ) { if( assocIsFeat ) propertyValue = AddNewProperty( propertyValues, L"Association Prop2.FeatId"); else propertyValue = AddNewProperty( propertyValues, L"Association Prop2.Id"); propertyValue->SetValue(dataValue); } } if( type == Insert_WithIdentityParent || type == Insert_WithIdentityBothSet || type == Insert_NoIdentity || type == Insert_WithIdentityError ) { dataValue = FdoDataValue::Create( name1 ); propertyValue = AddNewProperty( propertyValues, L"First Name"); propertyValue->SetValue(dataValue); // Add the name two property dataValue = FdoDataValue::Create( name2 ); propertyValue = AddNewProperty( propertyValues, L"Last Name"); propertyValue->SetValue(dataValue); } if( type == Insert_WithIdentityAssociated || type == Insert_WithIdentityBothSet || type == Insert_WithIdentityError ) { // Add the name one property if( type == Insert_WithIdentityError ) dataValue = FdoDataValue::Create( L"BOGUS" ); else dataValue = FdoDataValue::Create( name1 ); propertyValue = AddNewProperty( propertyValues, L"Association Prop1.Name One"); propertyValue->SetValue(dataValue); // Add the name two property dataValue = FdoDataValue::Create( name2 ); propertyValue = AddNewProperty( propertyValues, L"Association Prop1.Name Two"); propertyValue->SetValue(dataValue); } reader = insertCommand->Execute(); featureTransaction->Commit(); } catch(FdoException *exp ) { if( type != Insert_WithIdentityError ) { printf("Insert Master Test(NO OBJ) Error: %ls\n", exp->GetExceptionMessage() ); UnitTestUtil::PrintException(exp, UnitTestUtil::GetOutputFileName( L"TestSchema.txt" ) ); exp->Release(); CPPUNIT_FAIL ( "Insert Master Test(NO OBJ) exception" ); } else { printf("Insert Master Test(NO OBJ) Expected Error: %ls\n", exp->GetExceptionMessage() ); exp->Release(); return; } } if( type == Insert_WithIdentityError ) { printf("Insert Master Test(NO OBJ) SHOULD Fail"); CPPUNIT_FAIL ( "Insert Master Test(NO OBJ) SHOULD Fail" ); } }
void FdoAssociationInsertTest::masterTestWithObj(FdoAssociationInsertType type, const wchar_t* name1, const wchar_t* name2, int id ) { try { // Get a connection object FdoPtr<FdoIConnection> connection = UnitTestUtil::GetConnection(DB_SUFFIX); FdoPtr<FdoITransaction> featureTransaction = connection->BeginTransaction(); FdoPtr<FdoIInsert>insertCommand = (FdoIInsert *) connection->CreateCommand(FdoCommandType_Insert); // Add an instance of the TestClass insertCommand->SetFeatureClassName(L"TestClass"); FdoPtr<FdoPropertyValueCollection> propertyValues = insertCommand->GetPropertyValues(); // Add the id property FdoPtr<FdoDataValue>dataValue = FdoDataValue::Create( 11 ); FdoPtr<FdoPropertyValue>propertyValue = AddNewProperty( propertyValues, L"Id"); propertyValue->SetValue(dataValue); // Add the name one property dataValue = FdoDataValue::Create( name1 ); propertyValue = AddNewProperty( propertyValues, L"Name One"); propertyValue->SetValue(dataValue); // Add the name two property dataValue = FdoDataValue::Create( name2 ); propertyValue = AddNewProperty( propertyValues, L"Name Two"); propertyValue->SetValue(dataValue); FdoPtr<FdoIFeatureReader> reader = insertCommand->Execute(); // Add an instance of the TestFeatureClass insertCommand->SetFeatureClassName(L"TestSubFeatureClass"); propertyValues = insertCommand->GetPropertyValues(); propertyValues->Clear(); // Add the id property dataValue = FdoDataValue::Create( name1 ); propertyValue = AddNewProperty( propertyValues, L"First Name"); propertyValue->SetValue(dataValue); // Add the name two property dataValue = FdoDataValue::Create( name2 ); propertyValue = AddNewProperty( propertyValues, L"Last Name"); propertyValue->SetValue(dataValue); dataValue = FdoDataValue::Create( 10 ); propertyValue = AddNewProperty( propertyValues, L"Id"); propertyValue->SetValue(dataValue); // Add the id property dataValue = FdoDataValue::Create( name1 ); propertyValue = AddNewProperty( propertyValues, L"Object.First Name"); propertyValue->SetValue(dataValue); // Add the name two property dataValue = FdoDataValue::Create( name2 ); propertyValue = AddNewProperty( propertyValues, L"Object.Last Name"); propertyValue->SetValue(dataValue); dataValue = FdoDataValue::Create( 10 ); propertyValue = AddNewProperty( propertyValues, L"Object.Id"); propertyValue->SetValue(dataValue); if( type == Insert_NoIdentity ) { dataValue = FdoDataValue::Create( 11 ); propertyValue = AddNewProperty( propertyValues, L"Object.Association Prop1.Id"); propertyValue->SetValue(dataValue); } else if( type == Insert_NoIdentityObjNested ) { dataValue = FdoDataValue::Create( name1 ); propertyValue = AddNewProperty( propertyValues, L"Object.LeafObject.First Name"); propertyValue->SetValue(dataValue); // Add the name two property dataValue = FdoDataValue::Create( name2 ); propertyValue = AddNewProperty( propertyValues, L"Object.LeafObject.Last Name"); propertyValue->SetValue(dataValue); dataValue = FdoDataValue::Create( 10 ); propertyValue = AddNewProperty( propertyValues, L"Object.LeafObject.Id"); propertyValue->SetValue(dataValue); dataValue = FdoDataValue::Create( 11 ); propertyValue = AddNewProperty( propertyValues, L"Object.LeafObject.Association Prop1.Id"); propertyValue->SetValue(dataValue); } reader = insertCommand->Execute(); featureTransaction->Commit(); } catch(FdoException *exp ) { printf("Insert Master Test Error: %ls\n", exp->GetExceptionMessage() ); UnitTestUtil::PrintException(exp, UnitTestUtil::GetOutputFileName( L"TestSchema.txt" ) ); exp->Release(); CPPUNIT_FAIL ( "Insert Master Test(WITH OBJ) exception" ); } }