void FdoSchemaRollbackTest::ModAcadSchema( FdoIConnection* connection ) { /* Test modifying an existing schema */ FdoPtr<FdoIDescribeSchema> pDescCmd = (FdoIDescribeSchema*) connection->CreateCommand(FdoCommandType_DescribeSchema); pDescCmd->SetSchemaName( L"Electric'l" ); FdoFeatureSchemasP pSchemas = pDescCmd->Execute(); FdoPtr<FdoIApplySchema> pCmd = (FdoIApplySchema*) connection->CreateCommand(FdoCommandType_ApplySchema); FdoPtr<FdoFeatureSchema> pSchema = pSchemas->GetItem( L"Acad" ); FdoPtr<FdoFeatureClass> pClass = (FdoFeatureClass*) (FdoClassesP(pSchema->GetClasses())->GetItem(L"AcDbEntity")); FdoPtr<FdoClass> pRefClass = (FdoClass*) (FdoClassesP(pSchema->GetClasses())->GetItem(L"Entity")); // Test delete of property FdoPtr<FdoDataPropertyDefinition> pProp = (FdoDataPropertyDefinition*) (FdoPropertiesP(pClass->GetProperties())->GetItem(L"ColourIndex")); pProp->Delete(); pProp = (FdoDataPropertyDefinition*) (FdoPropertiesP(pRefClass->GetProperties())->GetItem(L"ColourIndex")); pProp->Delete(); // Test adding data property to existing class. pProp = FdoDataPropertyDefinition::Create( L"Plot Style", L"" ); pProp->SetDataType( FdoDataType_String ); pProp->SetLength(20); pProp->SetNullable(!mCanAddNotNullCol); FdoPropertiesP(pClass->GetProperties())->Add( pProp ); pProp = FdoDataPropertyDefinition::Create( L"Plot Style", L"" ); pProp->SetDataType( FdoDataType_String ); pProp->SetLength(20); pProp->SetNullable(!mCanAddNotNullCol); FdoPropertiesP(pRefClass->GetProperties())->Add( pProp ); pClass = (FdoFeatureClass*) (FdoClassesP(pSchema->GetClasses())->GetItem(L"AcDbHatch")); FdoPtr<FdoObjectPropertyDefinition> pObjProp = (FdoObjectPropertyDefinition*) FdoPropertiesP(pClass->GetProperties())->GetItem(L"edges"); pObjProp->Delete(); pRefClass = (FdoClass*) (FdoClassesP(pSchema->GetClasses())->GetItem(L"AcDbVertexData")); pObjProp = (FdoObjectPropertyDefinition*) FdoPropertiesP(pRefClass->GetProperties())->GetItem(L"point"); pObjProp->Delete(); pCmd->SetFeatureSchema( pSchema ); pCmd->Execute(); }
EGwsStatus GwsCommonFdoUtils::DescribeClassSC ( FdoIConnection * conn, const GWSQualifiedName & classname, GwsSpatialContextDescription & desc ) { FdoPtr<FdoFeatureSchema> schema; FdoPtr<FdoClassDefinition> classDef; GwsCommonFdoUtils::GetClassDefinition (conn, classname, schema.p, classDef.p); for (; classDef != NULL ; classDef = classDef->GetBaseClass ()) { FdoPtr<FdoPropertyDefinitionCollection> propdsc = classDef->GetProperties (); // discover geometric property name. Use the first one if there are many. for (int idx = 0; idx < propdsc->GetCount(); idx ++) { FdoPtr<FdoPropertyDefinition> prop; prop = propdsc->GetItem (idx); if (prop->GetPropertyType () == FdoPropertyType_GeometricProperty) { FdoGeometricPropertyDefinition* geomProp = static_cast<FdoGeometricPropertyDefinition*>(prop.p); FdoString* pSC = geomProp->GetSpatialContextAssociation(); if(pSC != NULL) { return GwsCommonFdoUtils::DescribeSC (conn, pSC, desc); } } } } return eGwsSCNotFound; }
FdoPropertyDefinition * GwsCommonFdoUtils::GetPropertyDefinition ( FdoClassDefinition * pClassDef, FdoString * PropertyName ) { pClassDef->AddRef (); FdoPtr<FdoClassDefinition> classDef = pClassDef; FdoPropertyDefinition * propDef = NULL; for (; propDef == NULL && classDef != NULL ; classDef = classDef->GetBaseClass ()) { FdoPtr<FdoPropertyDefinitionCollection> propdsc = classDef->GetProperties (); propDef = propdsc->FindItem (PropertyName); } return propDef; }
bool GwsCommonFdoUtils::GetGeometryName (FdoClassDefinition *pClassDef, std::wstring &name) { if(pClassDef == NULL) return false; if(pClassDef->GetClassType() == FdoClassType_FeatureClass) { FdoFeatureClass* pFeatClass = dynamic_cast<FdoFeatureClass*>(pClassDef); if(!pFeatClass) { assert(false); return false; } FdoPtr<FdoGeometricPropertyDefinition> pgDef = pFeatClass->GetGeometryProperty(); if (pgDef != NULL) { name = pgDef->GetName(); return true; } } FdoInt32 idx; FdoPtr<FdoClassDefinition> classDef = pClassDef; FDO_SAFE_ADDREF(pClassDef); for (; classDef != NULL ; classDef = classDef->GetBaseClass ()) { FdoPtr<FdoPropertyDefinitionCollection> propdsc = classDef->GetProperties (); // discover geometric property name. Use the first one if there are many. for (idx = 0; idx < propdsc->GetCount(); idx ++) { FdoPtr<FdoPropertyDefinition> prop; prop = propdsc->GetItem(idx); if (prop->GetPropertyType () == FdoPropertyType_GeometricProperty) { name = prop->GetName (); return true; } } } return false; }
void SuperMapLpPropertyDefinition::ConvertPhysicalToLogical(UGC::UGFieldInfo* fieldInfo) { if(m_fieldInfo == NULL) { m_fieldInfo = fieldInfo; } VALIDATE_POINTER(m_fieldInfo); // 逻辑的FDO属性名及为物理数据集的字段名 //FdoStringP pLogicalPropertyName = fieldInfo->m_strName; FdoStringP pLogicalPropertyName = SuperMapUtil::StringToWString(fieldInfo->m_strName.Cstr()).c_str(); //modified by majun, 支持汉字字段 FdoString* logicalPropertyName = (FdoString*)pLogicalPropertyName; FdoString* logicalPropertyDescription = L""; // 创建逻辑属性 m_logicalProperty = FdoDataPropertyDefinition::Create(logicalPropertyName, logicalPropertyDescription); // 属性字段物理属性转换 FdoDataType data_type ; FdoInt32 nType = fieldInfo->m_nType; // ugc的字段类型 //TRACE(_T("SuperMapLpPropertyDefinition::ConvertPhysicalToLogical..[%ls]...[%d]\n"), logicalPropertyName, nType); switch(nType) { case UGC::UGFieldInfo::Boolean: data_type = FdoDataType_Boolean; break; case UGC::UGFieldInfo::Byte: case UGC::UGFieldInfo::Char: data_type = FdoDataType_Byte; break; case UGC::UGFieldInfo::Integer: data_type = FdoDataType_Int16; break; case UGC::UGFieldInfo::Long: data_type = FdoDataType_Int32; break; case UGC::UGFieldInfo::Single: case UGC::UGFieldInfo::Float: data_type = FdoDataType_Single; break; case UGC::UGFieldInfo::Double: data_type = FdoDataType_Double; break; case UGC::UGFieldInfo::Date: case UGC::UGFieldInfo::Time: data_type = FdoDataType_DateTime; break; case UGC::UGFieldInfo::Decimal: data_type = FdoDataType_Decimal; break; case UGC::UGFieldInfo::Binary: case UGC::UGFieldInfo::LongBinary: case UGC::UGFieldInfo::VarBinary: case UGC::UGFieldInfo::TimeStamp: data_type = FdoDataType_BLOB; break; case UGC::UGFieldInfo::Text: case UGC::UGFieldInfo::Memo: case UGC::UGFieldInfo::NVarChar: //data_type = FdoDataType_CLOB; data_type = FdoDataType_String; break; default: return; //其他可能类型字段暂不转换 } m_logicalProperty->SetDataType(data_type); // 如果是字符串类型设置长度 if (data_type == FdoDataType_String) { if(fieldInfo->m_nType == UGC::UGFieldInfo::NVarChar) m_logicalProperty->SetLength(fieldInfo->m_nSize * 2); else m_logicalProperty->SetLength(fieldInfo->m_nSize); } // 如果是十进制类型设置位数和精度 if (data_type == FdoDataType_Decimal) { m_logicalProperty->SetPrecision(fieldInfo->m_nPrecision); m_logicalProperty->SetScale(fieldInfo->m_nScale); } FdoPtr<FdoClassDefinition> logicalClass = m_parentLpClass->GetLogicalClass(); //各种逻辑属性要加入此类中 FdoPtr<FdoPropertyDefinitionCollection> logicalProperties = logicalClass->GetProperties(); // 如果有重复字段名返回 if (logicalProperties->Contains (m_logicalProperty->GetName ())) return; // modified by zhouxu 2007-12-18 // 对Sm开头的字段除了SmUserId以外都设为只读。/ 并且加为逻辑类的标识属性 if((0 == wcscmp (L"SmGeometry", pLogicalPropertyName)) || (0 == wcscmp(L"SMGEOMETRY",pLogicalPropertyName))) //modified by zhouxu 2007-12-7 //added by majun ,要素类中去掉SmGeometry字段 { return; } else if((0 == wcscmp(L"SmUserID", pLogicalPropertyName)) || (0 == wcscmp(L"SMUSERID", pLogicalPropertyName))) { m_logicalProperty->SetReadOnly(false); m_logicalProperty->SetIsAutoGenerated(false); m_logicalProperty->SetNullable(false); logicalProperties->Add(m_logicalProperty); } else if((0 == wcscmp(L"Sm", pLogicalPropertyName.Mid(0,2))) || (0 == wcscmp(L"SM", pLogicalPropertyName.Mid(0,2)))) { m_logicalProperty->SetReadOnly(true);//m_logicalProperty->SetReadOnly(true); m_logicalProperty->SetIsAutoGenerated(true); m_logicalProperty->SetNullable(false); //// 作为一个标识属性 //FdoPtr<FdoDataPropertyDefinitionCollection> pIdentityProperties = logicalClass->GetIdentityProperties(); //VALIDATE_POINTER(pIdentityProperties); logicalProperties->Add(m_logicalProperty); //pIdentityProperties->Add(m_logicalProperty); } else { m_logicalProperty->SetReadOnly(false); m_logicalProperty->SetIsAutoGenerated(false); m_logicalProperty->SetNullable(true); logicalProperties->Add(m_logicalProperty); } }
void FdoSchemaRollbackTest::ModElectricSchema( FdoIConnection* connection ) { /* Test modifying an existing schema */ FdoPtr<FdoIDescribeSchema> pDescCmd = (FdoIDescribeSchema*) connection->CreateCommand(FdoCommandType_DescribeSchema); pDescCmd->SetSchemaName( L"Electric'l" ); FdoFeatureSchemasP pSchemas = pDescCmd->Execute(); FdoPtr<FdoIApplySchema> pCmd = (FdoIApplySchema*) connection->CreateCommand(FdoCommandType_ApplySchema); FdoPtr<FdoFeatureSchema> pSchema = pSchemas->GetItem( L"Electric'l" ); FdoPtr<FdoFeatureClass> pClass = (FdoFeatureClass*) (FdoClassesP(pSchema->GetClasses())->GetItem(L"Transformer")); pClass->Delete(); // Add a new non-inherited class that will later be removed. pClass = FdoFeatureClass::Create( L"Pole", L"" ); pClass->SetIsAbstract(false); FdoPtr<FdoDataPropertyDefinition> pProp = FdoDataPropertyDefinition::Create( L"FeatureId", L"" ); pProp->SetDataType( FdoDataType_Int64 ); pProp->SetIsAutoGenerated(true); pProp->SetNullable(false); FdoPropertiesP(pClass->GetProperties())->Add( pProp ); FdoDataPropertiesP(pClass->GetIdentityProperties())->Add( pProp ); pProp = FdoDataPropertyDefinition::Create( L"Height", L"" ); pProp->SetDataType( FdoDataType_Double ); pProp->SetNullable(false); FdoPropertiesP(pClass->GetProperties())->Add( pProp ); FdoClassesP(pSchema->GetClasses())->Add( pClass ); /* The following 3 classes tests adding nested object properties to an FdoClass, * instead of an FdoFeatureClass. */ // class for nested object property FdoPtr<FdoClass> pStClass = FdoClass::Create( L"Street", L"" ); pStClass->SetIsAbstract(false); pProp = FdoDataPropertyDefinition::Create( L"Name", L"" ); pProp->SetDataType( FdoDataType_String ); pProp->SetLength( 30 ); pProp->SetNullable(false); FdoPropertiesP(pStClass->GetProperties())->Add( pProp ); pProp = FdoDataPropertyDefinition::Create( L"Type", L"" ); pProp->SetDataType( FdoDataType_String ); pProp->SetLength( 30 ); pProp->SetNullable(false); FdoPropertiesP(pStClass->GetProperties())->Add( pProp ); FdoClassesP(pSchema->GetClasses())->Add( pStClass ); // Class for top object property ( includes nested property ) FdoPtr<FdoClass> pAddrClass = FdoClass::Create( L"'Address", L"" ); pAddrClass->SetIsAbstract(false); pProp = FdoDataPropertyDefinition::Create( L"Number", L"" ); pProp->SetDataType( FdoDataType_Int32 ); pProp->SetNullable(false); FdoPropertiesP(pAddrClass->GetProperties())->Add( pProp ); FdoPtr<FdoObjectPropertyDefinition> pObjProp = FdoObjectPropertyDefinition::Create( L"street", L"" ); pObjProp->SetClass( pStClass ); pObjProp->SetObjectType( FdoObjectType_Value ); FdoPropertiesP(pAddrClass->GetProperties())->Add( pObjProp ); FdoClassesP(pSchema->GetClasses())->Add( pAddrClass ); // Class that contains top object property FdoPtr<FdoClass> pEmpClass = FdoClass::Create( L"Employee", L"" ); pEmpClass->SetIsAbstract(false); pProp = FdoDataPropertyDefinition::Create( L"First Name", L"" ); pProp->SetDataType( FdoDataType_String ); pProp->SetLength( 30 ); pProp->SetNullable(false); FdoPropertiesP(pEmpClass->GetProperties())->Add( pProp ); FdoDataPropertiesP(pEmpClass->GetIdentityProperties())->Add( pProp ); pProp = FdoDataPropertyDefinition::Create( L"Last Name", L"" ); pProp->SetDataType( FdoDataType_String ); pProp->SetLength( 30 ); pProp->SetNullable(false); FdoPropertiesP(pEmpClass->GetProperties())->Add( pProp ); FdoDataPropertiesP(pEmpClass->GetIdentityProperties())->Add( pProp ); pObjProp = FdoObjectPropertyDefinition::Create( L"home' address", L"" ); pObjProp->SetClass( pAddrClass ); pObjProp->SetObjectType( FdoObjectType_Value ); FdoPropertiesP(pEmpClass->GetProperties())->Add( pObjProp ); FdoClassesP(pSchema->GetClasses())->Add( pEmpClass ); pCmd->SetFeatureSchema( pSchema ); pCmd->Execute(); }
void FdoSchemaRollbackTest::CreateElectricSchema( FdoIConnection* connection ) { FdoPtr<FdoIDescribeSchema> pDescCmd = (FdoIDescribeSchema*) connection->CreateCommand(FdoCommandType_DescribeSchema); pDescCmd->SetSchemaName( L"Acad" ); FdoPtr<FdoFeatureSchemaCollection> pAcadSchema = pDescCmd->Execute(); FdoPtr<FdoClassDefinition> pEntClass = FdoClassesP(FdoFeatureSchemaP(pAcadSchema->GetItem( L"Acad" ))->GetClasses())->GetItem( L"Entity" ); FdoPtr<FdoIApplySchema> pCmd = (FdoIApplySchema*) connection->CreateCommand(FdoCommandType_ApplySchema); /* A schema with dictionary */ FdoPtr<FdoFeatureSchema> pSchema = FdoFeatureSchema::Create( L"Electric'l", L"Electrical '' schema'" ); pAcadSchema->Add( pSchema ); FdoSADP(pSchema->GetAttributes())->Add( L"'Author", L"Thomas O'Edison" ); /* An abstract base class */ FdoPtr<FdoFeatureClass> pDevClass = FdoFeatureClass::Create( L"ElectricDevice", L"electic base class" ); pDevClass->SetIsAbstract(true); FdoPtr<FdoDataPropertyDefinition> pProp = FdoDataPropertyDefinition::Create( L"FeatId", L"id" ); pProp->SetDataType( FdoDataType_Int64 ); pProp->SetNullable(false); pProp->SetIsAutoGenerated(true); FdoPropertiesP(pDevClass->GetProperties())->Add( pProp ); FdoDataPropertiesP(pDevClass->GetIdentityProperties())->Add( pProp ); // Test nested object properties (ElectricDevice.graphic.xdata) where graphic's class has an id. FdoPtr<FdoObjectPropertyDefinition> pObjProp = FdoObjectPropertyDefinition::Create( L"graphic", L"Acad entity" ); pObjProp->SetObjectType( FdoObjectType_Value ); pObjProp->SetClass( pEntClass ); FdoPropertiesP(pDevClass->GetProperties())->Add( pObjProp ); // Test geometry property FdoPtr<FdoGeometricPropertyDefinition> pGeomProp = FdoGeometricPropertyDefinition::Create( L"Geometry", L"location and shape" ); pGeomProp->SetGeometryTypes( FdoGeometricType_Point | FdoGeometricType_Curve ); FdoPropertiesP(pDevClass->GetProperties())->Add( pGeomProp ); pDevClass->SetGeometryProperty( pGeomProp ); FdoClassesP(pSchema->GetClasses())->Add( pDevClass ); /* Subclass with dictionary */ FdoPtr<FdoFeatureClass> pClass = FdoFeatureClass::Create( L"Transformer", L"" ); pClass->SetIsAbstract(false); pClass->SetBaseClass( pDevClass ); FdoSADP(pClass->GetAttributes())->Add( L"Rules' DLL", L"transformer.dll" ); FdoSADP(pClass->GetAttributes())->Add( L"Entrypoint", L"start_transformer" ); // Add data properties of various types pProp = FdoDataPropertyDefinition::Create( L"Voltage", L"voltage" ); FdoSADP(pProp->GetAttributes())->Add( L"Calculable", L"yes" ); pProp->SetDataType( FdoDataType_Decimal ); pProp->SetPrecision(10); pProp->SetScale(2); pProp->SetNullable(false); FdoPropertiesP(pClass->GetProperties())->Add( pProp ); pProp = FdoDataPropertyDefinition::Create( L"Phase", L"A, B or C" ); pProp->SetDataType( FdoDataType_String ); pProp->SetLength(1); pProp->SetNullable(false); FdoPropertiesP(pClass->GetProperties())->Add( pProp ); pProp = FdoDataPropertyDefinition::Create( L"InstallDate", L"" ); pProp->SetDataType( FdoDataType_DateTime ); pProp->SetNullable(true); FdoPropertiesP(pClass->GetProperties())->Add( pProp ); pProp = FdoDataPropertyDefinition::Create( L"LastInspectDate", L"" ); pProp->SetDataType( FdoDataType_DateTime ); pProp->SetNullable(true); FdoPropertiesP(pClass->GetProperties())->Add( pProp ); pProp = FdoDataPropertyDefinition::Create( L"LastRepairDate", L"" ); pProp->SetDataType( FdoDataType_DateTime ); pProp->SetNullable(true); FdoPropertiesP(pClass->GetProperties())->Add( pProp ); pProp = FdoDataPropertyDefinition::Create( L"PartNum", L"" ); pProp->SetDataType( FdoDataType_Int16 ); pProp->SetNullable(true); FdoPropertiesP(pClass->GetProperties())->Add( pProp ); pProp = FdoDataPropertyDefinition::Create( L"Volume", L"" ); pProp->SetDataType( FdoDataType_Single ); pProp->SetNullable(false); FdoPropertiesP(pClass->GetProperties())->Add( pProp ); FdoClassesP(pSchema->GetClasses())->Add( pClass ); pClass = FdoFeatureClass::Create( L"Conductor", L"" ); pClass->SetIsAbstract(false); pClass->SetBaseClass( pDevClass ); pProp = FdoDataPropertyDefinition::Create( L"underground", L"" ); pProp->SetDataType( FdoDataType_Boolean ); pProp->SetNullable(false); FdoPropertiesP(pClass->GetProperties())->Add( pProp ); FdoClassesP(pSchema->GetClasses())->Add( pClass ); pCmd->SetFeatureSchema( pSchema ); pCmd->Execute(); }
void FdoSchemaRollbackTest::CreateAcadSchema( FdoIConnection* connection ) { FdoPtr<FdoIApplySchema> pCmd = (FdoIApplySchema*) connection->CreateCommand(FdoCommandType_ApplySchema); FdoFeatureSchemasP pSchemas = FdoFeatureSchemaCollection::Create(NULL); FdoPtr<FdoFeatureSchema> pSchema = FdoFeatureSchema::Create( L"Acad", L"AutoCAD schema" ); pSchemas->Add( pSchema ); // Id'less class for Object Properties only FdoPtr<FdoClass> pXData = FdoClass::Create( L"AcXData", L"Xdata" ); pXData->SetIsAbstract(false); FdoPtr<FdoDataPropertyDefinition> pXDataSeq = FdoDataPropertyDefinition::Create( L"Seq", L"seq" ); pXDataSeq->SetDataType( FdoDataType_Int32 ); pXDataSeq->SetNullable(false); FdoPropertiesP(pXData->GetProperties())->Add( pXDataSeq ); FdoPtr<FdoDataPropertyDefinition> pProp = FdoDataPropertyDefinition::Create( L"Datavalue", L"datavalue" ); pProp->SetDataType( FdoDataType_String ); pProp->SetLength(4000); pProp->SetNullable(false); FdoPropertiesP(pXData->GetProperties())->Add( pProp ); FdoClassesP(pSchema->GetClasses())->Add( pXData ); // More Id'less classes used to test unique table name generation FdoPtr<FdoClass> pCoordVal = FdoClass::Create( L"AcDbVertexCoordinateValue", L"" ); pCoordVal->SetIsAbstract(false); FdoPtr<FdoDataPropertyDefinition> pCoordValSeq = FdoDataPropertyDefinition::Create( L"Seq", L"seq" ); pCoordValSeq->SetDataType( FdoDataType_Int32 ); pCoordValSeq->SetNullable(false); FdoPropertiesP(pCoordVal->GetProperties())->Add( pCoordValSeq ); pProp = FdoDataPropertyDefinition::Create( L"Value", L"" ); pProp->SetDataType( FdoDataType_Double ); pProp->SetNullable(false); FdoPropertiesP(pCoordVal->GetProperties())->Add( pProp ); FdoClassesP(pSchema->GetClasses())->Add( pCoordVal ); FdoPtr<FdoClass> pVertex = FdoClass::Create( L"AcDbVertexData", L"" ); pVertex->SetIsAbstract(false); FdoPtr<FdoDataPropertyDefinition> pVertexSeq = FdoDataPropertyDefinition::Create( L"Seq", L"seq" ); pVertexSeq->SetDataType( FdoDataType_Int32 ); pVertexSeq->SetNullable(false); FdoPropertiesP(pVertex->GetProperties())->Add( pVertexSeq ); FdoPtr<FdoObjectPropertyDefinition> pObjProp = FdoObjectPropertyDefinition::Create( L"point", L"" ); pObjProp->SetClass( pCoordVal ); pObjProp->SetIdentityProperty( pCoordValSeq ); pObjProp->SetObjectType( FdoObjectType_Collection ); FdoPropertiesP(pVertex->GetProperties())->Add( pObjProp ); FdoClassesP(pSchema->GetClasses())->Add( pVertex ); // A non-abstract base class FdoPtr<FdoFeatureClass> pEntClass = FdoFeatureClass::Create( L"AcDbEntity", L"AutoCAD entity base class" ); pEntClass->SetIsAbstract(false); pProp = FdoDataPropertyDefinition::Create( L"FeatId", L"id" ); pProp->SetDataType( FdoDataType_Int64 ); pProp->SetNullable(false); pProp->SetIsAutoGenerated(true); FdoPropertiesP(pEntClass->GetProperties())->Add( pProp ); FdoDataPropertiesP(pEntClass->GetIdentityProperties())->Add( pProp ); pProp = FdoDataPropertyDefinition::Create( L"Layer", L"Acad layer" ); pProp->SetDataType( FdoDataType_String ); pProp->SetLength(10); pProp->SetNullable(true); FdoPropertiesP(pEntClass->GetProperties())->Add( pProp ); pProp = FdoDataPropertyDefinition::Create( L"ColourIndex", L"Acad Colour" ); pProp->SetDataType( FdoDataType_Byte ); pProp->SetNullable(false); FdoPropertiesP(pEntClass->GetProperties())->Add( pProp ); pObjProp = FdoObjectPropertyDefinition::Create( L"xdata", L"xdata" ); pObjProp->SetClass( pXData ); pObjProp->SetIdentityProperty( pXDataSeq ); pObjProp->SetObjectType( FdoObjectType_OrderedCollection ); pObjProp->SetOrderType( FdoOrderType_Ascending ); FdoPropertiesP(pEntClass->GetProperties())->Add( pObjProp ); FdoClassesP(pSchema->GetClasses())->Add( pEntClass ); FdoPtr<FdoClass> pEntRefClass = FdoClass::Create( L"Entity", L"Embedded entity base class" ); pEntRefClass->SetIsAbstract(false); pProp = FdoDataPropertyDefinition::Create( L"FeatId", L"id" ); pProp->SetDataType( FdoDataType_Int64 ); pProp->SetNullable(false); FdoPropertiesP(pEntRefClass->GetProperties())->Add( pProp ); FdoDataPropertiesP(pEntRefClass->GetIdentityProperties())->Add( pProp ); pProp = FdoDataPropertyDefinition::Create( L"Layer", L"Acad layer" ); pProp->SetDataType( FdoDataType_String ); pProp->SetLength(10); pProp->SetNullable(true); FdoPropertiesP(pEntRefClass->GetProperties())->Add( pProp ); pProp = FdoDataPropertyDefinition::Create( L"ColourIndex", L"Acad Colour" ); pProp->SetDataType( FdoDataType_Byte ); pProp->SetNullable(true); FdoPropertiesP(pEntRefClass->GetProperties())->Add( pProp ); pObjProp = FdoObjectPropertyDefinition::Create( L"xdata", L"xdata" ); pObjProp->SetClass( pXData ); pObjProp->SetIdentityProperty( pXDataSeq ); pObjProp->SetObjectType( FdoObjectType_OrderedCollection ); pObjProp->SetOrderType( FdoOrderType_Ascending ); FdoPropertiesP(pEntRefClass->GetProperties())->Add( pObjProp ); FdoClassesP(pSchema->GetClasses())->Add( pEntRefClass ); // A sub-class to test Object and Data property inheritance. FdoPtr<FdoFeatureClass> pPlineClass = FdoFeatureClass::Create( L"AcDb3dPolyline", L"AutoCAD 3d polyline" ); pPlineClass->SetIsAbstract(false); pPlineClass->SetBaseClass( pEntClass ); FdoClassesP(pSchema->GetClasses())->Add( pPlineClass ); pProp = FdoDataPropertyDefinition::Create( L"Width", L"line width" ); pProp->SetDataType( FdoDataType_Double ); pProp->SetPrecision(10); pProp->SetScale(5); pProp->SetNullable(false); FdoPropertiesP(pPlineClass->GetProperties())->Add( pProp ); pCmd->SetFeatureSchema( pSchema ); pCmd->Execute(); pProp = FdoDataPropertyDefinition::Create( L"Closed", L"is first and last points the same" ); pProp->SetDataType( FdoDataType_Boolean ); pProp->SetNullable(!mCanAddNotNullCol); FdoPropertiesP(pPlineClass->GetProperties())->Add( pProp ); pObjProp = FdoObjectPropertyDefinition::Create( L"vertices", L"" ); pObjProp->SetClass( pVertex ); pObjProp->SetIdentityProperty( pVertexSeq ); pObjProp->SetObjectType( FdoObjectType_Collection ); FdoPropertiesP(pPlineClass->GetProperties())->Add( pObjProp ); FdoPtr<FdoClass> pPlineRefClass = FdoClass::Create( L"Polyline", L"Embedded 3d polyline" ); pPlineRefClass->SetIsAbstract(false); pPlineRefClass->SetBaseClass( pEntRefClass ); FdoClassesP(pSchema->GetClasses())->Add( pPlineRefClass ); pProp = FdoDataPropertyDefinition::Create( L"Width", L"line width" ); pProp->SetDataType( FdoDataType_Double ); pProp->SetPrecision(10); pProp->SetScale(5); pProp->SetNullable(false); FdoPropertiesP(pPlineRefClass->GetProperties())->Add( pProp ); pProp = FdoDataPropertyDefinition::Create( L"Closed", L"is first and last points the same" ); pProp->SetDataType( FdoDataType_Boolean ); pProp->SetNullable(false); FdoPropertiesP(pPlineRefClass->GetProperties())->Add( pProp ); pObjProp = FdoObjectPropertyDefinition::Create( L"vertices", L"" ); pObjProp->SetClass( pVertex ); pObjProp->SetIdentityProperty( pVertexSeq ); pObjProp->SetObjectType( FdoObjectType_Collection ); FdoPropertiesP(pPlineRefClass->GetProperties())->Add( pObjProp ); // The following tests object property nesting to 3 levels. FdoPtr<FdoFeatureClass> pHatchClass = FdoFeatureClass::Create( L"AcDbHatch", L"AutoCAD hatched polygon" ); pHatchClass->SetIsAbstract(false); pHatchClass->SetBaseClass( pEntClass ); pObjProp = FdoObjectPropertyDefinition::Create( L"edges", L"" ); pObjProp->SetClass( pPlineRefClass ); pObjProp->SetObjectType( FdoObjectType_Collection ); FdoPropertiesP(pHatchClass->GetProperties())->Add( pObjProp ); FdoClassesP(pSchema->GetClasses())->Add( pHatchClass ); pCmd->SetFeatureSchema( pSchema ); pCmd->Execute(); }
void FdoSpatialContextTest::CreateSchema( FdoIConnection* connection, bool hasMetaSchema ) { FdoPtr<FdoFeatureSchema> schema; if ( hasMetaSchema ) { /* A schema with dictionary */ schema = FdoFeatureSchema::Create( L"ScTest", L"" ); } else { FdoPtr<FdoIDescribeSchema> cmd = (FdoIDescribeSchema*) connection->CreateCommand(FdoCommandType_DescribeSchema); FdoFeatureSchemasP schemas = cmd->Execute(); CPPUNIT_ASSERT( schemas->GetCount() > 0 ); schema = schemas->FindItem(L"dbo"); if ( !schema ) schema = schemas->GetItem(0); } FdoPtr<FdoIApplySchema> pCmd = (FdoIApplySchema*) connection->CreateCommand(FdoCommandType_ApplySchema); /* An abstract base class */ FdoPtr<FdoFeatureClass> pClass = FdoFeatureClass::Create( L"ClassB1", L"" ); FdoClassesP(schema->GetClasses())->Add( pClass ); FdoPtr<FdoDataPropertyDefinition> pProp = FdoDataPropertyDefinition::Create( L"Prop1", L"" ); pProp->SetDataType( FdoDataType_Int64 ); pProp->SetNullable(false); pProp->SetIsAutoGenerated(true); FdoPropertiesP(pClass->GetProperties())->Add( pProp ); FdoDataPropertiesP(pClass->GetIdentityProperties())->Add( pProp ); // Test geometry property FdoPtr<FdoGeometricPropertyDefinition> pGeomProp = FdoGeometricPropertyDefinition::Create( L"Geometry1", L"" ); pGeomProp->SetGeometryTypes( FdoGeometricType_Point | FdoGeometricType_Curve ); pGeomProp->SetSpatialContextAssociation(L"Bermuda"); FdoPropertiesP(pClass->GetProperties())->Add( pGeomProp ); pClass->SetGeometryProperty( pGeomProp ); pGeomProp = FdoGeometricPropertyDefinition::Create( L"Geometry2", L"" ); pGeomProp->SetGeometryTypes( FdoGeometricType_Point | FdoGeometricType_Curve ); pGeomProp->SetSpatialContextAssociation(L"Rectangular"); FdoPropertiesP(pClass->GetProperties())->Add( pGeomProp ); pGeomProp = FdoGeometricPropertyDefinition::Create( L"Geometry3", L"" ); pGeomProp->SetGeometryTypes( FdoGeometricType_Point | FdoGeometricType_Curve ); pGeomProp->SetSpatialContextAssociation(L"South"); FdoPropertiesP(pClass->GetProperties())->Add( pGeomProp ); pGeomProp = FdoGeometricPropertyDefinition::Create( L"Geometry4", L"" ); pGeomProp->SetGeometryTypes( FdoGeometricType_Point | FdoGeometricType_Curve ); pGeomProp->SetSpatialContextAssociation(L"Bermuda Duplicate"); FdoPropertiesP(pClass->GetProperties())->Add( pGeomProp ); pGeomProp = FdoGeometricPropertyDefinition::Create( L"Geometry5", L"" ); pGeomProp->SetGeometryTypes( FdoGeometricType_Point | FdoGeometricType_Curve ); pGeomProp->SetSpatialContextAssociation(L"sc_1"); FdoPropertiesP(pClass->GetProperties())->Add( pGeomProp ); pCmd->SetFeatureSchema( schema ); pCmd->Execute(); }