public void HarvestChildren([NotNull] ObjectDataset dataset) { // TODO harvest some attribute roles selectively (mainly ObjectID, based on heuristics for what might be a suitable OID in case of non-SDE-geodatabases) if (HarvestAttributes) { AttributeHarvestingUtils.HarvestAttributes(dataset); } if (HarvestObjectTypes) { ObjectTypeHarvestingUtils.HarvestObjectTypes(dataset); } }
public void CanTranslateSql() { IFeatureClass fc; ITable table; IRelationshipClass rc; CreateTestWorkspace( "CanTranslateSql_master", "fc", "table", "rc", out fc, out table, out rc); IFeatureClass fc_child; ITable table_child; IRelationshipClass rc_child; IFeatureWorkspace childWorkspace = CreateTestWorkspace( "CanTranslateSql_child", "fc_child", "table_child", "rc_child", out fc_child, out table_child, out rc_child); IRow t = table_child.CreateRow(); t.Value[table_child.FindField("TEXT")] = "table"; // same as table name int pk = t.OID; t.Store(); IFeature f = fc_child.CreateFeature(); f.Value[fc_child.FindField("FKEY")] = pk; f.Shape = GeometryFactory.CreatePoint(100, 200); f.Store(); var model = new SimpleModel("model", fc); ModelVectorDataset vectorDataset = model.AddDataset( new ModelVectorDataset(DatasetUtils.GetName(fc))); ModelTableDataset tableDataset = model.AddDataset( new ModelTableDataset(DatasetUtils.GetName(table))); AttributeHarvestingUtils.HarvestAttributes( vectorDataset, ModelElementUtils.GetMasterDatabaseWorkspaceContext(vectorDataset)); AttributeHarvestingUtils.HarvestAttributes( tableDataset, ModelElementUtils.GetMasterDatabaseWorkspaceContext(tableDataset)); ObjectAttribute fkAttribute = vectorDataset.GetAttribute("FKEY"); ObjectAttribute pkAttribute = tableDataset.GetAttribute(table.OIDFieldName); Assert.NotNull(fkAttribute); Assert.NotNull(pkAttribute); Association association = model.AddAssociation(new ForeignKeyAssociation(DatasetUtils.GetName(rc), AssociationCardinality.OneToMany, fkAttribute, pkAttribute)); var childWorkspaceContext = new SimpleWorkspaceContext( model, childWorkspace, new[] { new WorkspaceDataset("fc_child", null, vectorDataset), new WorkspaceDataset("table_child", null, tableDataset), }, new[] { new WorkspaceAssociation("rc_child", null, association) }); var clsDesc = new ClassDescriptor(typeof(QaRelConstraint)); var tstDesc = new TestDescriptor("RelConstraint", clsDesc); QualityCondition condition = new QualityCondition("fc_table_constraints", tstDesc); QualityConditionParameterUtils.AddParameterValue(condition, "relationTables", vectorDataset); QualityConditionParameterUtils.AddParameterValue(condition, "relationTables", tableDataset); QualityConditionParameterUtils.AddParameterValue(condition, "relation", "rc"); QualityConditionParameterUtils.AddParameterValue(condition, "join", JoinType.InnerJoin); QualityConditionParameterUtils.AddParameterValue(condition, "constraint", "(fc.OBJECTID = 1 AND table.OBJECTID = 1) AND (table.TEXT = 'table')"); var factory = new QaRelConstraint { Condition = condition }; ITest test = factory.CreateTests(new SimpleDatasetOpener(childWorkspaceContext))[0]; var runner = new QaContainerTestRunner(1000, test); runner.Execute(GeometryFactory.CreateEnvelope(0, 0, 1000, 1000)); AssertUtils.NoError(runner); }