private static IEnumerable <IFeature> GetDerivedTableGeometryFeatures( [NotNull] IObject obj, [NotNull] IDatasetLookup datasetLookup, [NotNull] IModelContext modelContext) { Assert.ArgumentNotNull(obj, nameof(obj)); Assert.ArgumentNotNull(datasetLookup, nameof(datasetLookup)); ObjectDataset dataset = datasetLookup.GetDataset(obj); if (dataset == null) { yield break; } foreach (IFeature feature in GetDerivedTableGeometryFeatures( obj, dataset, modelContext)) { yield return(feature); } }
public void CanGetAttributes() { const string dsName = "TOPGIS.TLM_DATASET"; DdxModel m = CreateModel(); ObjectDataset ds = m.AddDataset(CreateObjectDataset(dsName)); ObjectAttribute oa1 = ds.AddAttribute( new ObjectAttribute("field1", FieldType.Text)); ObjectAttribute oa2 = ds.AddAttribute( new ObjectAttribute("field2", FieldType.Text)); oa1.ReadOnlyOverride = false; oa2.ReadOnlyOverride = true; CreateSchema(m); UnitOfWork.NewTransaction( delegate { AssertUnitOfWorkHasNoChanges(); IList <Dataset> list = Repository.Get(dsName); Assert.AreEqual(1, list.Count); var result = list[0] as VectorDataset; Assert.IsNotNull(result); Assert.AreEqual(dsName, result.Name); Assert.AreEqual(2, ds.Attributes.Count); Assert.AreEqual(2, (new List <ObjectAttribute>(ds.GetAttributes())).Count); ObjectAttribute field1 = ds.GetAttribute("field1"); ObjectAttribute field2 = ds.GetAttribute("field2"); Assert.IsNotNull(field1, "field1"); Assert.IsNotNull(field2, "field2"); Assert.IsFalse(field1.ReadOnly); Assert.IsTrue(field2.ReadOnly); }); }
private static void AddOrUpdateAttribute([NotNull] ObjectDataset objectDataset, [NotNull] IField field, int fieldIndex) { Assert.ArgumentNotNull(field, nameof(field)); ObjectAttribute attribute = objectDataset.Attributes.FirstOrDefault( att => string.Equals(att.Name, field.Name, StringComparison .OrdinalIgnoreCase)); if (attribute == null) { attribute = objectDataset.CreateObjectAttribute(field.Name, (FieldType)field.Type); attribute.FieldLength = field.Length; _msg.InfoFormat("Adding attribute {0}", attribute.Name); objectDataset.AddAttribute(attribute); } else { if (attribute.Deleted) { _msg.WarnFormat( "Attribute {0} was registered as deleted, but exists now. " + "Resurrecting it...", attribute.Name); attribute.RegisterExisting(); } attribute.FieldType = (FieldType)field.Type; attribute.FieldLength = field.Length; } // configure the attribute, no matter if it existed or was new attribute.SortOrder = fieldIndex; }
public DatasetConstraintConfigurator([NotNull] ObjectDataset dataset, [NotNull] IList <ConstraintNode> constraints) { Dataset = dataset; Constraints = constraints; }
GetRelationshipClassChainsToVerifiedFeatureClassesCore( [NotNull] IObjectDataset objectDataset, [NotNull] ICollection <IRelationshipClass> precedingRelationshipClasses, [NotNull] IWorkspaceContextLookup workspaceContextLookup, [CanBeNull] Predicate <VectorDataset> isRelevantVectorDataset, out bool hasAnyAssociationsToFeatureClasses) { var result = new List <IList <IRelationshipClass> >(); var relClassesToFeatureClasses = new List <IRelationshipClass>(); var associationEndsToTables = new List <AssociationEnd>(); IWorkspaceContext workspaceContext = null; hasAnyAssociationsToFeatureClasses = false; foreach (AssociationEnd associationEnd in objectDataset.GetAssociationEnds()) { ObjectDataset oppositeDataset = associationEnd.OppositeDataset; var oppositeVectorDataset = oppositeDataset as VectorDataset; if (oppositeVectorDataset != null) { if (associationEnd.Association.NotUsedForDerivedTableGeometry) { continue; } hasAnyAssociationsToFeatureClasses = true; if (isRelevantVectorDataset != null && !isRelevantVectorDataset(oppositeVectorDataset)) { continue; } if (workspaceContext == null) { workspaceContext = workspaceContextLookup.GetWorkspaceContext(objectDataset); Assert.NotNull(workspaceContext, "Unable to determine workspace context for dataset {0}", objectDataset); } IRelationshipClass relationshipClass = workspaceContext.OpenRelationshipClass(associationEnd.Association); if (relationshipClass != null) { relClassesToFeatureClasses.Add(relationshipClass); } } else if (oppositeDataset is TableDataset) { associationEndsToTables.Add(associationEnd); } } if (relClassesToFeatureClasses.Count > 0) { foreach (IRelationshipClass relClass in relClassesToFeatureClasses) { result.Add(new List <IRelationshipClass>(precedingRelationshipClasses) { relClass }); } } else { foreach (AssociationEnd associationEndToTable in associationEndsToTables) { if (workspaceContext == null) { workspaceContext = workspaceContextLookup.GetWorkspaceContext(objectDataset); Assert.NotNull(workspaceContext, "Unable to determine workspace context for dataset {0}", objectDataset); } IRelationshipClass relClassToTable = workspaceContext.OpenRelationshipClass(associationEndToTable.Association); if (relClassToTable == null) { continue; } if (precedingRelationshipClasses.Contains(relClassToTable)) { continue; } var relClassChainToTable = new List <IRelationshipClass>(precedingRelationshipClasses) { relClassToTable }; bool hasAnyIndirectAssociationsToFeatureClasses; ICollection <IList <IRelationshipClass> > indirectRelClassChains = GetRelationshipClassChainsToVerifiedFeatureClassesCore( associationEndToTable.OppositeDataset, relClassChainToTable, workspaceContextLookup, isRelevantVectorDataset, out hasAnyIndirectAssociationsToFeatureClasses); if (hasAnyIndirectAssociationsToFeatureClasses) { hasAnyAssociationsToFeatureClasses = true; } result.AddRange(indirectRelClassChains); // TODO REVISE: use only the first association end to a table which leads to a verified feature class if (indirectRelClassChains.Count > 0) { break; } } } return(result); }