// Creates a config file similar to the previous one, but with an extra spatial // context and feature schema. void FdoImportExportTest::CreateConfig2( FdoIoStream* stream ) { stream->Reset(); FdoXmlWriterP writer = FdoXmlWriter::Create(stream); AddSC( writer, L"Default", L"default context", L"Non-Earth (Meter)", GetWKT(L"Non-Earth (Meter)"), 2000 ); AddSchema( writer, 1 ); AddSC( writer, L"Manhole1", L"diagram", L"Non-Earth (Meter)", GetWKT(L"Non-Earth (Meter)"), 3 ); AddSchema( writer, 2 ); AddSC( writer, L"Manhole2", L"diagram", L"Non-Earth (Meter)", GetWKT(L"Non-Earth (Meter)"), 2 ); AddSchema( writer, 3 ); writer = NULL; UnitTestUtil::Stream2File( stream, UnitTestUtil::GetOutputFileName( L"impexp_config2.xml" ) ); }
///<summary>Executes the ApplySchema command that creates metadata and physical ///storage for the schema. An exception is thrown if the schema already ///exists or if a schema already exists and the feature provider only ///supports a single schema. If schema changes include deletion of classes ///or the schema itself, then those classes (or the schema, if it is marked ///as deleted) must not contain any instance data. If they do, an exception ///will be thrown.</summary> /// <returns>Returns nothing</returns> void SuperMapApplySchemaCommand::Execute () { TRACE(_T("调用 SuperMapApplySchemaCommand::Execute() 。\n")); FdoSchemaElementState state; FdoPtr<SuperMapLpFeatureSchemaCollection> lp_schemas; FdoPtr<SuperMapLpFeatureSchema> schema; if((m_Schema == NULL) || (NULL == m_Schema->GetName()) || 0 == wcslen(m_Schema->GetName())) { throw FdoException::Create(NlsMsgGet(SUPERMAP_SCHEMA_NOT_SPECIFIED, "No schema specified for the apply schema command")); } state = m_Schema->GetElementState(); // 根据状态忽略标志不同作不同处理 if(GetIgnoreStates()) { lp_schemas = mConnection->GetLpSchemas(); schema = lp_schemas->FindItem(m_Schema->GetName()); if(schema == NULL) state = FdoSchemaElementState_Added; else state = FdoSchemaElementState_Modified; } switch(state) { case FdoSchemaElementState_Added: AddSchema(); break; case FdoSchemaElementState_Deleted: DeleteSchema(); break; case FdoSchemaElementState_Detached: break; case FdoSchemaElementState_Modified: ModifySchema(); break; case FdoSchemaElementState_Unchanged: break; default: throw FdoException::Create(NlsMsgGet(SUPERMAP_SCHEMA_UNSUPPORTED_ELEMENT_STATE, "Schema element state '%l$d' is not supported.", (int)m_Schema->GetElementState())); } m_Schema->AcceptChanges(); }