public HtmlDataModel([NotNull] DdxModel model) { Assert.ArgumentNotNull(model, nameof(model)); Assert.ArgumentNotNullOrEmpty(model.Name, "model name is not defined"); _model = model; }
private static nodetype CreateModelNode([NotNull] ModelNode modelNode) { DdxModel model = modelNode.Model; var data = new List <datatype> { CreateData(_keyNodeLabel, model.Name), CreateData(_keyModelName, model.Name) }; var mlgraph = new graphtype { edgedefault = graphedgedefaulttype.directed, Items = modelNode.DatasetNodes.Select(node => CreateDatasetNode(node, useQualifiedLabel : false)) .Cast <object>() .ToArray() }; var items = new List <object>(); items.AddRange(data.Cast <object>()); items.Add(mlgraph); return(new nodetype { id = modelNode.NodeId, Items = items.ToArray() }); }
private static IEnumerable <HtmlDataModel> GetInvolvedDataModels( [NotNull] IEnumerable <HtmlQualitySpecificationElement> htmlElements) { var models = new Dictionary <DdxModel, HtmlDataModel>(); foreach (HtmlQualitySpecificationElement element in htmlElements) { foreach (HtmlTestParameterValue parameterValue in element.QualityCondition.ParameterValues) { if (!parameterValue.IsDatasetParameter) { continue; } Dataset dataset = Assert.NotNull(parameterValue.DatasetValue); DdxModel model = dataset.Model; HtmlDataModel htmlDataModel; if (!models.TryGetValue(model, out htmlDataModel)) { htmlDataModel = new HtmlDataModel(model); models.Add(model, htmlDataModel); } HtmlDataset htmlDataset = htmlDataModel.GetHtmlDataset(dataset); htmlDataset.AddReference(new HtmlDatasetReference(element, parameterValue)); } } return(models.Values.OrderBy(m => m.Name)); }
public void CanGetByName() { const string dsName1 = "TOPGIS.TLM_DATASET1"; const string dsName2 = "TOPGIS.TLM_DATASET2"; const string dsName3 = "TOPGIS.TLM_DATASET3"; DdxModel m = CreateModel(); m.AddDataset(CreateObjectDataset(dsName1)); m.AddDataset(CreateObjectDataset(dsName2)); m.AddDataset(CreateObjectDataset(dsName3)); CreateSchema(m); UnitOfWork.NewTransaction( delegate { Assert.IsFalse(UnitOfWork.HasChanges); IList <Dataset> list = Repository.Get(dsName2); Assert.AreEqual(1, list.Count); var result = list[0] as VectorDataset; Assert.IsNotNull(result); Assert.AreEqual(dsName2, result.Name); }); }
public Dataset GetDataset(string gdbDatasetName, IWorkspaceName workspaceName) { DdxModel model = GetModel(workspaceName); Dataset result = model.GetDatasetByModelName(gdbDatasetName); return(result); }
private static IWorkspaceContext GetWorkspaceContext( DdxModel model, GdbWorkspace gdbWorkspace) { return(new SimpleWorkspaceContext( model, gdbWorkspace, GetWorkspaceDatasets(model, gdbWorkspace), new List <WorkspaceAssociation>())); }
public static string TranslateToMasterDatabaseDatasetName( [NotNull] string modelElementName, DdxModel ddxModel) { return(ModelElementNameUtils.IsQualifiedName(modelElementName) ? modelElementName : ModelElementNameUtils.GetQualifiedName(ddxModel.DefaultDatabaseName, ddxModel.DefaultDatabaseSchemaOwner, modelElementName)); }
private GdbWorkspace GetWorkspace([NotNull] DdxModel model) { // TODO: In case it is needed before InitializeSchema() is called, allow creation of // a 'lazy' workspace that is just an empty container that gets initialized // with datasets from remote only when necessary. GdbWorkspace workspace = _virtualWorkspaces?.FirstOrDefault(w => w.WorkspaceHandle == model.Id); return(workspace); }
public IList <T> Get <T>(DdxModel model) where T : Dataset { using (ISession session = OpenSession(true)) { AssertInTransaction(session); return(session.CreateCriteria(typeof(T)) .Add(Restrictions.Eq("Model", model)) .List <T>()); } }
private static IEnumerable <WorkspaceDataset> GetWorkspaceDatasets( DdxModel model, GdbWorkspace primaryWorkspace) { foreach (IDataset gdbDataset in primaryWorkspace.GetDatasets()) { Dataset modelDataset = model.GetDatasetByModelName(gdbDataset.Name); if (modelDataset != null) { yield return(new WorkspaceDataset(gdbDataset.Name, null, modelDataset)); } } }
public void CanGetByUnknownName() { DdxModel m = CreateModel(); CreateSchema(m); UnitOfWork.NewTransaction( delegate { AssertUnitOfWorkHasNoChanges(); IList <Dataset> list = Repository.Get("UKNOWN.DATASET.NAME"); Assert.AreEqual(0, list.Count); }); }
public IEnumerable<QualityVerification> Get(DdxModel model) { Assert.ArgumentNotNull(model, nameof(model)); if (! model.IsPersistent) { return new List<QualityVerification>(); } using (ISession session = OpenSession(true)) { IList<int> datasetIds = GetEntityIds(model.Datasets); if (datasetIds.Count == 0) { return new List<QualityVerification>(); } const int maxSublistLength = 1000; if (datasetIds.Count <= maxSublistLength) { return GetQualityVerifications(session, datasetIds); } // more than 1000 datasets; split the lists var distinctVerifications = new HashSet<QualityVerification>(); var first = true; foreach (IList<int> datasetIdSublist in CollectionUtils.Split(datasetIds, maxSublistLength)) { foreach (QualityVerification verification in GetQualityVerifications(session, datasetIdSublist)) { // avoid the cost of unnecessary Contains() call for first sub list // (verification should be unique *within* each sub list) if (first || ! distinctVerifications.Contains(verification)) { distinctVerifications.Add(verification); } } first = false; } return distinctVerifications; } }
public void CanGetByUnknownName() { DdxModel m = CreateModel(); CreateSchema(m); UnitOfWork.NewTransaction( delegate { AssertUnitOfWorkHasNoChanges(); IList <Association> result = Repository.Get("UKNOWN.ASSOCIATION.NAME"); Assert.AreEqual(0, result.Count); }); }
public Dataset GetByAbbreviation(DdxModel model, string abbreviation) { Assert.ArgumentNotNull(model, nameof(model)); Assert.ArgumentNotNull(abbreviation, nameof(abbreviation)); using (ISession session = OpenSession(true)) { return(session.CreateQuery( "from Dataset ds " + "where ds.Model = :model " + " and upper(ds.Abbreviation) = :abbreviation") .SetEntity("model", model) .SetString("abbreviation", abbreviation.ToUpper()) .UniqueResult <Dataset>()); } }
public SimpleWorkspaceContext( [NotNull] DdxModel model, [NotNull] IFeatureWorkspace featureWorkspace, [NotNull] IEnumerable <WorkspaceDataset> workspaceDatasets, [NotNull] IEnumerable <WorkspaceAssociation> workspaceAssociations) : base(featureWorkspace) { Assert.ArgumentNotNull(model, nameof(model)); Assert.ArgumentNotNull(featureWorkspace, nameof(featureWorkspace)); Assert.ArgumentNotNull(workspaceDatasets, nameof(workspaceDatasets)); Assert.ArgumentNotNull(workspaceAssociations, nameof(workspaceAssociations)); _model = model; UpdateContent(workspaceDatasets, workspaceAssociations); }
public void CanGetByName() { const string dsName1 = "ds1"; const string dsName2 = "ds2"; DdxModel m = CreateModel(); VectorDataset ds1 = m.AddDataset(CreateVectorDataset(dsName1)); VectorDataset ds2 = m.AddDataset(CreateVectorDataset(dsName2)); var uuidType = new ObjectAttributeType("uuid", AttributeRole.UUID); ObjectAttribute pk1 = ds1.AddAttribute(new ObjectAttribute("pk1", FieldType.Text, uuidType)); ObjectAttribute pk2 = ds2.AddAttribute(new ObjectAttribute("pk2", FieldType.Text, uuidType)); const string asoName = "aso1"; const string fk1Name = "fk1"; const string fk2Name = "fk2"; m.AddAssociation( new AttributedAssociation( asoName, AssociationCardinality.ManyToMany, fk1Name, FieldType.Text, pk1, fk2Name, FieldType.Text, pk2)); CreateSchema(uuidType, m); UnitOfWork.NewTransaction( delegate { AssertUnitOfWorkHasNoChanges(); IList <Association> list = Repository.Get(asoName); Assert.AreEqual(1, list.Count); Association result = list[0] as AttributedAssociation; Assert.IsNotNull(result); Assert.AreEqual(asoName, result.Name); Assert.AreEqual(fk1Name, result.End1.ForeignKey.Name); Assert.AreEqual(fk2Name, result.End2.ForeignKey.Name); Assert.AreEqual(dsName1, result.End1.ObjectDataset.Name); Assert.AreEqual(dsName2, result.End2.ObjectDataset.Name); }); }
public static ProcessDatasetName TryCreate([NotNull] DdxModel model, [NotNull] string spec, out string message) { Assert.ArgumentNotNull(model, nameof(model)); Assert.ArgumentNotNullOrEmpty(spec, nameof(spec)); int whereIndex = spec.IndexOf(';'); string datasetSpec = whereIndex < 0 ? spec.Trim() : spec.Substring(0, whereIndex).Trim(); string whereClause = whereIndex < 0 ? null : spec.Substring(whereIndex + 1).Trim(); return(TryCreate(model, datasetSpec, whereClause, out message)); }
public void CanGetAssociationEnds() { const string associationName = "relClass"; const string dsName1 = "ds1"; const string dsName2 = "ds2"; DdxModel m = CreateModel(); ObjectDataset ds1 = m.AddDataset(CreateObjectDataset(dsName1)); ObjectDataset ds2 = m.AddDataset(CreateObjectDataset(dsName2)); ObjectAttribute fk = ds1.AddAttribute( new ObjectAttribute("fk", FieldType.Text)); ObjectAttribute pk = ds2.AddAttribute( new ObjectAttribute("pk", FieldType.Text)); m.AddAssociation(new ForeignKeyAssociation(associationName, AssociationCardinality.OneToMany, fk, pk)); CreateSchema(m); UnitOfWork.NewTransaction( delegate { AssertUnitOfWorkHasNoChanges(); IList <Dataset> list = Repository.Get(dsName1); Assert.AreEqual(1, list.Count); var result = list[0] as VectorDataset; Assert.IsNotNull(result); Assert.AreEqual(1, result.AssociationEnds.Count); Assert.AreEqual( 1, (new List <AssociationEnd>(result.GetAssociationEnds())).Count); AssociationEnd associationEnd = result.AssociationEnds[0]; Assert.AreEqual(ds1, associationEnd.ObjectDataset); Assert.IsNotNull(associationEnd.Association); Assert.AreEqual(associationName, associationEnd.Association.Name); Assert.AreEqual(ds2, result.AssociationEnds[0].OppositeEnd.ObjectDataset); }); }
public static ProcessDatasetName TryCreate([NotNull] DdxModel model, [NotNull] string datasetSpec, [CanBeNull] string whereClause, out string message) { Assert.ArgumentNotNull(model, nameof(model)); Assert.ArgumentNotNullOrEmpty(datasetSpec, nameof(datasetSpec)); int colonIndex = datasetSpec.IndexOf(':'); string datasetName = colonIndex < 0 ? datasetSpec.Trim() : datasetSpec.Substring(0, colonIndex).Trim(); string repClassName = colonIndex < 0 ? null : datasetSpec.Substring(colonIndex + 1).Trim(); return(TryCreate(model, datasetName, repClassName, whereClause, out message)); }
private static Dataset GetDataset([NotNull] DdxModel model, string datasetName) { Dataset dataset = model.GetDatasetByModelName(datasetName); if (dataset != null) { return(dataset); } // Search all datasets, ignoring qualification foreach (Dataset candidate in model.GetDatasets()) { if (CompareUnqualifiedName(datasetName, candidate.Name) == 0) { return(candidate); } } return(null); // not found }
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); }); }
public IList <QualityCondition> Get(DdxModel model) { Assert.ArgumentNotNull(model, nameof(model)); if (!model.IsPersistent) { return(new List <QualityCondition>()); } using (ISession session = OpenSession(true)) { return(session.CreateQuery( "select distinct qcon " + " from QualityCondition qcon " + " join qcon.ParameterValues paramVal " + " where paramVal.Id in (select paramVal.Id " + " from DatasetTestParameterValue paramVal " + " where paramVal.DatasetValue.Model = :model)") .SetEntity("model", model) .List <QualityCondition>()); } }
public DatasetDependencyGraph([NotNull] IEnumerable <Dataset> datasets, [CanBeNull] string description = null) { Assert.ArgumentNotNull(datasets, nameof(datasets)); Description = description; _datasetNodes = datasets.ToDictionary( ds => ds, ds => new DatasetNode(ds)); foreach (DatasetNode datasetNode in _datasetNodes.Values) { DdxModel model = datasetNode.Dataset.Model; ModelNode modelNode; if (!_modelNodes.TryGetValue(model, out modelNode)) { modelNode = new ModelNode(model); _modelNodes.Add(model, modelNode); } modelNode.AddDatasetNode(datasetNode); } }
public static ProcessDatasetName TryCreate([NotNull] DdxModel model, string datasetName, string repClassName, string whereClause, out string message) { Dataset dataset = GetDataset(model, datasetName); if (dataset == null) { message = $"Dataset '{datasetName}' not found in model '{model.Name}'"; return(null); } var vectorDataset = dataset as VectorDataset; if (vectorDataset == null) { message = $"Dataset '{datasetName}' in model '{model.Name}' is not a vector dataset"; return(null); } message = string.Empty; return(new ProcessDatasetName(vectorDataset, whereClause, repClassName)); }
private DdxModel GetModel(IWorkspaceName workspaceName) { IWorkspace workspace = (IWorkspace)((IName)workspaceName).Open(); if (!(workspace is GdbWorkspace gdbWorkspace)) { throw new ArgumentException( "The workspace name does not reference a virtual gdb workspace"); } int?modelId = gdbWorkspace.WorkspaceHandle; Assert.NotNull(modelId, "Workspace handle is null"); DdxModel model = _knownModels.FirstOrDefault(m => m.Id == modelId.Value); if (model == null) { model = Assert.NotNull(_modelRepository.Get(modelId.Value)); _knownModels.Add(model); } return(model); }
public ModelNode([NotNull] DdxModel model) { _model = model; NodeId = model.Name; }
private bool TryGetArgumentValue( [NotNull] TestParameter parameter, [NotNull] IOpenDataset datasetContext, [CanBeNull] ICollection <TableConstraint> tableConstraints, [CanBeNull] out object value) { if (Condition == null) { value = null; return(false); } var valuesForParameter = new List <object>(); var parameterValueList = new List <DatasetTestParameterValue>(); foreach (TestParameterValue parameterValue in Condition.ParameterValues) { if (!Equals(parameterValue.TestParameterName, parameter.Name)) { continue; } object valueForParameter = GetValue(parameterValue, parameter, datasetContext); valuesForParameter.Add(valueForParameter); // add value to list anyway, // correct type is checked at the end of parameterIndex Loop parameterValueList.Add(parameterValue as DatasetTestParameterValue); } if (valuesForParameter.Count == 0 && !parameter.IsConstructorParameter) { value = null; return(false); } value = GetArgumentValue(parameter, valuesForParameter); // if correct type, add to dataSetList if (tableConstraints != null && valuesForParameter.Count > 0 && valuesForParameter[0] is ITable) { foreach (DatasetTestParameterValue datasetParameterValue in parameterValueList) { Dataset dataset = Assert.NotNull(datasetParameterValue.DatasetValue, "dataset is null"); var table = (ITable)datasetContext.OpenDataset( dataset, Assert.NotNull(datasetParameterValue.DataType)); Assert.NotNull(table, "Dataset not found in current context: {0}", dataset.Name); DdxModel dataModel = dataset.Model; bool useCaseSensitiveSql = dataModel != null && ModelElementUtils.UseCaseSensitiveSql( table, dataModel.SqlCaseSensitivity); tableConstraints.Add(new TableConstraint( table, datasetParameterValue.FilterExpression, useCaseSensitiveSql)); } } return(true); }
public Association GetAssociation(string relationshipClass, IWorkspaceName workspaceName) { DdxModel model = GetModel(workspaceName); return(model.GetAssociationByModelName(relationshipClass)); }