public static Ejb3JoinColumn BuildJoinColumn(PrimaryKeyJoinColumnAttribute pkJoinAnn,
									JoinColumnAttribute joinAnn, 
									IKeyValue identifier,
									IDictionary<string, Join> joins, 
									IPropertyHolder propertyHolder, 
									ExtendedMappings mappings)
		{
			throw new NotImplementedException();
		}
Esempio n. 2
0
        public virtual object GetEntity(
            IKeyValue keyValue, EntityLoadInfo entityLoadInfo, bool queryStateManager)
        {
            // hot path
            Debug.Assert(keyValue != null);

            if (queryStateManager)
            {
                var entry = _stateManager.TryGetEntry(keyValue);

                if (entry != null)
                {
                    return entry.Entity;
                }
            }

            object entity;

            WeakReference<object> weakReference;
            if (!_identityMap.TryGetValue(keyValue, out weakReference)
                || !weakReference.TryGetTarget(out entity))
            {
                entity = entityLoadInfo.Materialize();

                if (weakReference != null)
                {
                    weakReference.SetTarget(entity);
                }
                else
                {
                    GarbageCollectIdentityMap();

                    _identityMap.Add(keyValue, new WeakReference<object>(entity));
                }

                _valueBuffers.Add(entity, entityLoadInfo.ValueBuffer);
            }

            return entity;
        }
Esempio n. 3
0
 /// <summary>
 /// Get index of an element.
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public int IndexOf(IKeyValue value)
 {
     return(InnerList.IndexOf(value));
 }
Esempio n. 4
0
 /// <summary>
 /// Add element.
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public int Add(IKeyValue value)
 {
     return(InnerList.Add(value));
 }
Esempio n. 5
0
        /// <summary>
        /// Constructs the NormalizedEntityPerister for the PersistentClass.
        /// </summary>
        /// <param name="persistentClass">The PersistentClass to create the EntityPersister for.</param>
        /// <param name="cache">The configured <see cref="ICacheConcurrencyStrategy" />.</param>
        /// <param name="factory">The SessionFactory that this EntityPersister will be stored in.</param>
        /// <param name="mapping">The mapping used to retrieve type information.</param>
        public JoinedSubclassEntityPersister(PersistentClass persistentClass, ICacheConcurrencyStrategy cache,
                                             ISessionFactoryImplementor factory, IMapping mapping)
            : base(persistentClass, cache, factory)
        {
            #region DISCRIMINATOR

            if (persistentClass.IsPolymorphic)
            {
                try
                {
                    discriminatorValue     = persistentClass.SubclassId;
                    discriminatorSQLString = discriminatorValue.ToString();
                }
                catch (Exception e)
                {
                    throw new MappingException("Could not format discriminator value to SQL string", e);
                }
            }
            else
            {
                discriminatorValue     = null;
                discriminatorSQLString = null;
            }

            if (OptimisticLockMode > Versioning.OptimisticLock.Version)
            {
                throw new MappingException(string.Format("optimistic-lock=all|dirty not supported for joined-subclass mappings [{0}]", EntityName));
            }

            #endregion

            #region MULTITABLES
            int idColumnSpan = IdentifierColumnSpan;

            List <string>           tables         = new List <string>();
            List <string[]>         keyColumns     = new List <string[]>();
            List <bool>             cascadeDeletes = new List <bool>();
            IEnumerator <IKeyValue> kiter          = persistentClass.KeyClosureIterator.GetEnumerator();
            foreach (Table tab in persistentClass.TableClosureIterator)
            {
                kiter.MoveNext();
                IKeyValue key     = kiter.Current;
                string    tabname = tab.GetQualifiedName(factory.Dialect, factory.Settings.DefaultCatalogName, factory.Settings.DefaultSchemaName);
                tables.Add(tabname);

                List <string>        keyCols         = new List <string>(idColumnSpan);
                IEnumerable <Column> enumerableKCols = new SafetyEnumerable <Column>(key.ColumnIterator);
                foreach (Column kcol in enumerableKCols)
                {
                    keyCols.Add(kcol.GetQuotedName(factory.Dialect));
                }

                keyColumns.Add(keyCols.ToArray());
                cascadeDeletes.Add(key.IsCascadeDeleteEnabled && factory.Dialect.SupportsCascadeDelete);
            }
            naturalOrderTableNames           = tables.ToArray();
            naturalOrderTableKeyColumns      = keyColumns.ToArray();
            naturalOrderCascadeDeleteEnabled = cascadeDeletes.ToArray();

            List <string> subtables   = new List <string>();
            List <bool>   isConcretes = new List <bool>();
            keyColumns = new List <string[]>();
            foreach (Table tab in persistentClass.SubclassTableClosureIterator)
            {
                isConcretes.Add(persistentClass.IsClassOrSuperclassTable(tab));
                string tabname = tab.GetQualifiedName(factory.Dialect, factory.Settings.DefaultCatalogName, factory.Settings.DefaultSchemaName);
                subtables.Add(tabname);
                List <string> key = new List <string>(idColumnSpan);
                foreach (Column column in tab.PrimaryKey.ColumnIterator)
                {
                    key.Add(column.GetQuotedName(factory.Dialect));
                }

                keyColumns.Add(key.ToArray());
            }
            subclassTableNameClosure      = subtables.ToArray();
            subclassTableKeyColumnClosure = keyColumns.ToArray();
            isClassOrSuperclassTable      = isConcretes.ToArray();

            constraintOrderedTableNames     = new string[subclassTableNameClosure.Length];
            constraintOrderedKeyColumnNames = new string[subclassTableNameClosure.Length][];
            int currentPosition = 0;
            for (int i = subclassTableNameClosure.Length - 1; i >= 0; i--, currentPosition++)
            {
                constraintOrderedTableNames[currentPosition]     = subclassTableNameClosure[i];
                constraintOrderedKeyColumnNames[currentPosition] = subclassTableKeyColumnClosure[i];
            }

            tableSpan       = naturalOrderTableNames.Length;
            tableNames      = Reverse(naturalOrderTableNames);
            tableKeyColumns = Reverse(naturalOrderTableKeyColumns);
            Reverse(subclassTableNameClosure, tableSpan);
            Reverse(subclassTableKeyColumnClosure, tableSpan);

            spaces = ArrayHelper.Join(tableNames, ArrayHelper.ToStringArray(persistentClass.SynchronizedTables));

            // Custom sql
            customSQLInsert         = new SqlString[tableSpan];
            customSQLUpdate         = new SqlString[tableSpan];
            customSQLDelete         = new SqlString[tableSpan];
            insertCallable          = new bool[tableSpan];
            updateCallable          = new bool[tableSpan];
            deleteCallable          = new bool[tableSpan];
            insertResultCheckStyles = new ExecuteUpdateResultCheckStyle[tableSpan];
            updateResultCheckStyles = new ExecuteUpdateResultCheckStyle[tableSpan];
            deleteResultCheckStyles = new ExecuteUpdateResultCheckStyle[tableSpan];

            PersistentClass pc = persistentClass;
            int             jk = tableSpan - 1;
            while (pc != null)
            {
                customSQLInsert[jk]         = pc.CustomSQLInsert;
                insertCallable[jk]          = customSQLInsert[jk] != null && pc.IsCustomInsertCallable;
                insertResultCheckStyles[jk] = pc.CustomSQLInsertCheckStyle
                                              ??
                                              ExecuteUpdateResultCheckStyle.DetermineDefault(customSQLInsert[jk], insertCallable[jk]);
                customSQLUpdate[jk]         = pc.CustomSQLUpdate;
                updateCallable[jk]          = customSQLUpdate[jk] != null && pc.IsCustomUpdateCallable;
                updateResultCheckStyles[jk] = pc.CustomSQLUpdateCheckStyle
                                              ??
                                              ExecuteUpdateResultCheckStyle.DetermineDefault(customSQLUpdate[jk], updateCallable[jk]);
                customSQLDelete[jk]         = pc.CustomSQLDelete;
                deleteCallable[jk]          = customSQLDelete[jk] != null && pc.IsCustomDeleteCallable;
                deleteResultCheckStyles[jk] = pc.CustomSQLDeleteCheckStyle
                                              ??
                                              ExecuteUpdateResultCheckStyle.DetermineDefault(customSQLDelete[jk], deleteCallable[jk]);
                jk--;
                pc = pc.Superclass;
            }
            if (jk != -1)
            {
                throw new AssertionFailure("Tablespan does not match height of joined-subclass hierarchy.");
            }

            #endregion

            #region PROPERTIES

            int hydrateSpan = PropertySpan;
            naturalOrderPropertyTableNumbers = new int[hydrateSpan];
            propertyTableNumbers             = new int[hydrateSpan];
            int i2 = 0;
            foreach (Property prop in persistentClass.PropertyClosureIterator)
            {
                string tabname = prop.Value.Table.GetQualifiedName(factory.Dialect, factory.Settings.DefaultCatalogName, factory.Settings.DefaultSchemaName);
                propertyTableNumbers[i2]             = GetTableId(tabname, tableNames);
                naturalOrderPropertyTableNumbers[i2] = GetTableId(tabname, naturalOrderTableNames);
                i2++;
            }

            // subclass closure properties
            List <int> columnTableNumbers  = new List <int>();
            List <int> formulaTableNumbers = new List <int>();
            List <int> propTableNumbers    = new List <int>();
            foreach (Property prop in persistentClass.SubclassPropertyClosureIterator)
            {
                Table  tab     = prop.Value.Table;
                string tabname = tab.GetQualifiedName(factory.Dialect, factory.Settings.DefaultCatalogName, factory.Settings.DefaultSchemaName);
                int    tabnum  = GetTableId(tabname, subclassTableNameClosure);
                propTableNumbers.Add(tabnum);

                foreach (ISelectable thing in prop.ColumnIterator)
                {
                    if (thing.IsFormula)
                    {
                        formulaTableNumbers.Add(tabnum);
                    }
                    else
                    {
                        columnTableNumbers.Add(tabnum);
                    }
                }
            }

            subclassColumnTableNumberClosure   = columnTableNumbers.ToArray();
            subclassPropertyTableNumberClosure = propTableNumbers.ToArray();
            subclassFormulaTableNumberClosure  = formulaTableNumbers.ToArray();
            #endregion

            #region SUBCLASSES

            int subclassSpan = persistentClass.SubclassSpan + 1;
            subclassClosure = new string[subclassSpan];
            subclassClosure[subclassSpan - 1] = EntityName;
            if (persistentClass.IsPolymorphic)
            {
                subclassesByDiscriminatorValue[discriminatorValue] = EntityName;
                discriminatorValues = new string[subclassSpan];
                discriminatorValues[subclassSpan - 1] = discriminatorSQLString;
                notNullColumnTableNumbers             = new int[subclassSpan];
                int id =
                    GetTableId(
                        persistentClass.Table.GetQualifiedName(factory.Dialect, factory.Settings.DefaultCatalogName,
                                                               factory.Settings.DefaultSchemaName), subclassTableNameClosure);
                notNullColumnTableNumbers[subclassSpan - 1] = id;
                notNullColumnNames = new string[subclassSpan];
                notNullColumnNames[subclassSpan - 1] = subclassTableKeyColumnClosure[id][0];
                //( (Column) model.getTable().getPrimaryKey().getColumnIterator().next() ).getName();
            }
            else
            {
                discriminatorValues       = null;
                notNullColumnTableNumbers = null;
                notNullColumnNames        = null;
            }

            int k2 = 0;
            foreach (Subclass sc in persistentClass.SubclassIterator)
            {
                subclassClosure[k2] = sc.EntityName;
                try
                {
                    if (persistentClass.IsPolymorphic)
                    {
                        // we now use subclass ids that are consistent across all
                        // persisters for a class hierarchy, so that the use of
                        // "foo.class = Bar" works in HQL
                        int subclassId = sc.SubclassId;                         //new Integer(k+1);
                        subclassesByDiscriminatorValue[subclassId] = sc.EntityName;
                        discriminatorValues[k2] = subclassId.ToString();
                        int id =
                            GetTableId(
                                sc.Table.GetQualifiedName(factory.Dialect, factory.Settings.DefaultCatalogName,
                                                          factory.Settings.DefaultSchemaName), subclassTableNameClosure);
                        notNullColumnTableNumbers[k2] = id;
                        notNullColumnNames[k2]        = subclassTableKeyColumnClosure[id][0];
                        //( (Column) sc.getTable().getPrimaryKey().getColumnIterator().next() ).getName();
                    }
                }
                catch (Exception e)
                {
                    throw new MappingException("Error parsing discriminator value", e);
                }
                k2++;
            }

            #endregion

            InitLockers();

            InitSubclassPropertyAliasesMap(persistentClass);

            PostConstruct(mapping);
        }
Esempio n. 6
0
        /// <summary>
        /// The compare to.
        /// </summary>
        /// <param name="other">
        /// Key value to compare to
        /// </param>
        /// <returns>
        /// The <see cref="int"/> . 
        /// </returns>
        public virtual int CompareTo(IKeyValue other)
        {
            if (this._concept.Equals(other.Concept))
            {
                return string.CompareOrdinal(this._code, other.Code);
            }

            return string.CompareOrdinal(this._concept, other.Concept);
        }
        /// <summary>
        ///     Clears the OBS information.
        /// </summary>
        private void ClearObsInformation()
        {
            // Clear values
            this._attributeValues.Clear();

            // Clear the current Obs information
            this._obsTime = null;
            this._obsValue = null;
            this._attributes = new List<IKeyValue>();
            this._crossSection = null;
        }
Esempio n. 8
0
 public void UpdateDependentMap(InternalEntityEntry entry, IKeyValue oldKeyValue, IForeignKey foreignKey)
 {
     throw new NotImplementedException();
 }
 public IAsyncEnumerable <EntityLoadInfo> GetRelatedValues(IKeyValue keyValue, Func <ValueBuffer, IKeyValue> keyFactory)
 {
     return(_includeCollectionIterator
            .GetRelatedValues(keyValue, keyFactory)
            .Select(vr => new EntityLoadInfo(vr, _materializer)));
 }
Esempio n. 10
0
        public virtual InternalEntityEntry StartTracking(
            IEntityType entityType, IKeyValue keyValue, object entity, ValueBuffer valueBuffer)
        {
            if (keyValue == KeyValue.InvalidKeyValue)
            {
                throw new InvalidOperationException(CoreStrings.InvalidPrimaryKey(entityType.DisplayName()));
            }

            var existingEntry = TryGetEntry(keyValue);
            if (existingEntry != null)
            {
                if (existingEntry.Entity != entity)
                {
                    throw new InvalidOperationException(CoreStrings.IdentityConflict(entityType.DisplayName()));
                }

                return existingEntry;
            }

            var newEntry = _subscriber.SnapshotAndSubscribe(_factory.Create(this, entityType, entity, valueBuffer), valueBuffer);

            AddToIdentityMap(entityType, keyValue, newEntry);

            _entityReferenceMap[entity] = newEntry;
            _detachedEntityReferenceMap.Remove(entity);

            newEntry.SetEntityState(EntityState.Unchanged);

            return newEntry;
        }
Esempio n. 11
0
        public virtual void UpdateDependentMap(InternalEntityEntry entry, IKeyValue oldKeyValue, IForeignKey foreignKey)
        {
            if (entry.EntityState == EntityState.Detached)
            {
                return;
            }

            var newKey = entry.GetDependentKeyValue(foreignKey);

            if (oldKeyValue.Equals(newKey))
            {
                return;
            }

            Dictionary<IKeyValue, HashSet<InternalEntityEntry>> fkMap;
            if (_dependentsMap.TryGetValue(foreignKey, out fkMap))
            {
                HashSet<InternalEntityEntry> dependents;

                if (oldKeyValue != KeyValue.InvalidKeyValue
                    && fkMap.TryGetValue(oldKeyValue, out dependents))
                {
                    dependents.Remove(entry);

                    if (dependents.Count == 0)
                    {
                        fkMap.Remove(oldKeyValue);
                    }
                }

                if (newKey == KeyValue.InvalidKeyValue)
                {
                    if (fkMap.Count == 0)
                    {
                        _dependentsMap.Remove(foreignKey);
                    }
                }
                else
                {
                    if (!fkMap.TryGetValue(newKey, out dependents))
                    {
                        dependents = new HashSet<InternalEntityEntry>();
                        fkMap[newKey] = dependents;
                    }

                    dependents.Add(entry);
                }
            }
        }
Esempio n. 12
0
        public virtual void UpdateIdentityMap(InternalEntityEntry entry, IKeyValue oldKeyValue, IKey principalKey)
        {
            if (entry.EntityState == EntityState.Detached)
            {
                return;
            }

            var newKey = GetKeyValueChecked(principalKey, entry);

            if (oldKeyValue.Equals(newKey))
            {
                return;
            }

            InternalEntityEntry existingEntry;
            if (_identityMap.TryGetValue(newKey, out existingEntry)
                && existingEntry != entry)
            {
                throw new InvalidOperationException(CoreStrings.IdentityConflict(entry.EntityType.Name));
            }

            _identityMap.Remove(oldKeyValue);

            if (newKey != KeyValue.InvalidKeyValue)
            {
                _identityMap[newKey] = entry;
            }
        }
Esempio n. 13
0
 public virtual InternalEntityEntry TryGetEntry(IKeyValue keyValueValue)
 {
     InternalEntityEntry entry;
     _identityMap.TryGetValue(keyValueValue, out entry);
     return entry;
 }
Esempio n. 14
0
        private void AddToIdentityMap(IEntityType entityType, IKeyValue keyValue, InternalEntityEntry newEntry)
        {
            _identityMap.Add(keyValue, newEntry);
            foreach (var key in entityType.GetKeys().Where(k => k != keyValue.Key))
            {
                var principalKeyValue = newEntry.GetPrincipalKeyValue(key);

                if (principalKeyValue != KeyValue.InvalidKeyValue)
                {
                    _identityMap[principalKeyValue] = newEntry;
                }
            }

            foreach (var foreignKey in entityType.GetForeignKeys())
            {
                var dependentKey = newEntry.GetDependentKeyValue(foreignKey);
                if (dependentKey == KeyValue.InvalidKeyValue)
                {
                    continue;
                }

                Dictionary<IKeyValue, HashSet<InternalEntityEntry>> fkMap;
                if (!_dependentsMap.TryGetValue(foreignKey, out fkMap))
                {
                    fkMap = new Dictionary<IKeyValue, HashSet<InternalEntityEntry>>();
                    _dependentsMap[foreignKey] = fkMap;
                }

                HashSet<InternalEntityEntry> dependents;
                if (!fkMap.TryGetValue(dependentKey, out dependents))
                {
                    dependents = new HashSet<InternalEntityEntry>();
                    fkMap[dependentKey] = dependents;
                }

                dependents.Add(newEntry);
            }
        }
Esempio n. 15
0
 /// <summary>
 /// Remove element from list.
 /// </summary>
 /// <param name="value"></param>
 public void Remove(IKeyValue value)
 {
     InnerList.Remove(value);
 }
Esempio n. 16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ObservationImpl"/> class.
        /// </summary>
        /// <param name="obsTime">
        /// The obs time 0. 
        /// </param>
        /// <param name="obsValue">
        /// The obs value 1. 
        /// </param>
        /// <param name="attributes">
        /// The attributes 2. 
        /// </param>
        /// <param name="crossSectionValue">
        /// The cross section value 3. 
        /// </param>
        /// <param name="annotations">
        /// The cross section value 3. 
        /// </param>
        public ObservationImpl(IKeyable seriesKey,
            string obsTime, string obsValue, IList<IKeyValue> attributes, IKeyValue crossSectionValue, 
            params IAnnotation[] annotations)
        {
            this._seriesKey = seriesKey;
            this.obsValue = obsValue;
            this.obsTime = obsTime;

            if (seriesKey == null)
                throw new ArgumentException("Series Key can not be null");

            if (attributes != null)
            {
                this.attributes = new List<IKeyValue>(attributes);

                foreach (IKeyValue currentKv in attributes)
                {
                    this.attributeMap.Add(currentKv.Concept, currentKv);
                }
            }

            if(annotations != null) 
            {
			   foreach(IAnnotation currentAnnotation in annotations)
               {
				  this.annotations.Add(currentAnnotation);
			   }
		    }

            this.crossSectionValue = crossSectionValue;
            this.isCrossSection = crossSectionValue != null;
        }
Esempio n. 17
0
 /**
  * Returns a {@code MessagingAccessPoint} instance from the specified OMS driver url with some preset attributes,
  * which will be passed to MessagingAccessPoint's implementation class as a unique constructor parameter.
  *
  * There are some standard attributes defined by OMS for this method, the same as {@link
  * MessagingAccessPoint#attributes()} ()}
  *
  * @param url the specified OMS driver url
  * @return a {@code MessagingAccessPoint} instance
  * @throws OMSRuntimeException if the factory fails to create a {@code MessagingAccessPoint} due to some driver url
  * some syntax error or internal error.
  */
 public static IMessagingAccessPoint getMessagingAccessPoint(string url, IKeyValue attributes)
 {
     return(MessagingAccessPointAdapter.getMessagingAccessPoint(url, attributes));
 }
        /// <summary>
        /// Processes the key value.
        /// </summary>
        /// <param name="keyValue">The key value.</param>
        /// <param name="conceptMap">The concept map.</param>
        /// <param name="skipConcepts">The skip concepts.</param>
        private static void ProcessKeyValue(IKeyValue keyValue, IDictionary<string, string> conceptMap, ISet<string> skipConcepts)
        {
            string currentConcept = keyValue.Concept;
            if (skipConcepts.Contains(currentConcept))
            {
                return;
            }

            string value;
            if (!conceptMap.TryGetValue(currentConcept, out value))
            {
                conceptMap.Add(currentConcept, keyValue.Code);
            } 
            else if (!value.Equals(keyValue.Code))
            {
                conceptMap.Remove(currentConcept);
                skipConcepts.Add(currentConcept);
            }
        }
Esempio n. 19
0
        private IEntityType IncludeCore(
            object entity,
            INavigation navigation,
            out IKeyValue primaryKeyValue,
            out Func<ValueBuffer, IKeyValue> relatedKeyFactory)
        {
            var keyFactory
                = _keyValueFactorySource
                    .GetKeyFactory(navigation.ForeignKey.PrincipalKey);

            var targetEntityType = navigation.GetTargetType();

            object boxedValueBuffer;
            if (!_valueBuffers.TryGetValue(entity, out boxedValueBuffer))
            {
                var entry = _stateManager.TryGetEntry(entity);

                Debug.Assert(entry != null);

                primaryKeyValue
                    = navigation.IsDependentToPrincipal()
                        ? entry.GetDependentKeyValue(navigation.ForeignKey)
                        : entry.GetPrimaryKeyValue();
            }
            else
            {
                primaryKeyValue
                    = navigation.IsDependentToPrincipal()
                        ? keyFactory
                            .Create(
                                navigation.ForeignKey.Properties,
                                (ValueBuffer)boxedValueBuffer)
                        : keyFactory
                            .Create(
                                navigation.ForeignKey.PrincipalKey.Properties,
                                (ValueBuffer)boxedValueBuffer);
            }

            if (navigation.IsDependentToPrincipal())
            {
                relatedKeyFactory
                    = valueBuffer =>
                        keyFactory
                            .Create(
                                navigation.ForeignKey.PrincipalKey.Properties,
                                valueBuffer);
            }
            else
            {
                relatedKeyFactory
                    = valueBuffer =>
                        keyFactory
                            .Create(
                                navigation.ForeignKey.Properties,
                                valueBuffer);
            }

            return targetEntityType;
        }
Esempio n. 20
0
 public InternalEntityEntry TryGetEntry(IKeyValue keyValueValue)
 {
     throw new NotImplementedException();
 }
 public virtual IAsyncEnumerable <ValueBuffer> GetRelatedValues(
     [NotNull] IKeyValue primaryKeyValue,
     [NotNull] Func <ValueBuffer, IKeyValue> relatedKeyFactory)
 => new RelatedValuesEnumerable(this, primaryKeyValue, relatedKeyFactory);
 /// <summary>
 /// The add key value.
 /// </summary>
 /// <param name="keyvalue">
 /// The keyvalue. 
 /// </param>
 public virtual void AddKeyValue(IKeyValue keyvalue)
 {
     if (keyvalue != null)
     {
         this.keyValues.Add(keyvalue);
     }
 }
            public IEnumerable <EntityLoadInfo> GetRelatedValues(IKeyValue keyValue, Func <ValueBuffer, IKeyValue> keyFactory)
            {
                var valueBuffer = _queryContext.GetIncludeValueBuffer(_queryIndex).WithOffset(_valueBufferOffset);

                yield return(new EntityLoadInfo(valueBuffer, _materializer));
            }
 public bool Equals(IKeyValue other)
 {
     return(Name == other.Name);
 }
Esempio n. 25
0
        /// <summary>
        /// Initializes a new instance containing the specified array 
        /// of IKeyValue objects
        /// </summary>
        /// <param name="value"></param>
        public KeyValueCollection(
			IKeyValue[] value
			)
        {
            AddRange(value);
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="DataKeyObjectCore"/> class.
        /// </summary>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <param name="type">
        /// The type. 
        /// </param>
        public DataKeyObjectCore(IReferenceValue parent, ComponentValueSetType type)
            : base(SdmxStructureType.GetFromEnum(SdmxStructureEnumType.KeyValues), parent)
        {
            this.included = type.include;
            this.keyValue = new KeyValueImpl(type.Value[0].TypedValue, type.id);
        }
Esempio n. 27
0
 /// <summary>
 /// Add element.
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public int Add(IKeyValue value)
 {
     return InnerList.Add(value);
 }
Esempio n. 28
0
 /// <summary>
 /// Indicates whether a specified object is contained in the list.
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public bool Contains(IKeyValue value)
 {
     return(InnerList.Contains(value));
 }
Esempio n. 29
0
 /// <summary>
 /// Add an array of IKeyValue.
 /// </summary>
 /// <param name="items"></param>
 public void AddRange(IKeyValue[] items)
 {
     InnerList.AddRange(items);
 }
Esempio n. 30
0
 /// <summary>
 /// Insert element to list.
 /// </summary>
 /// <param name="index"></param>
 /// <param name="value"></param>
 public void Insert(int index, IKeyValue value)
 {
     InnerList.Insert(index, value);
 }
Esempio n. 31
0
 /// <summary>
 /// Indicates whether a specified object is contained in the list.
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public bool Contains(IKeyValue value)
 {
     return InnerList.Contains(value);
 }
Esempio n. 32
0
 /// <summary>
 /// Sets the Identifier of the Table.
 /// </summary>
 /// <param name="identifierValue">The <see cref="SimpleValue"/> that represents the Identifier.</param>
 public void SetIdentifierValue(SimpleValue identifierValue)
 {
     idValue = identifierValue;
 }
Esempio n. 33
0
        /// <summary>
        /// Copies the collection objects to a one-dimensional Array 
        /// instance beginning at the specified index.
        /// </summary>
        /// <param name="array"></param>
        /// <param name="index"></param>
        public void CopyTo(
			IKeyValue[] array,
			int index
			)
        {
            InnerList.CopyTo(array, index);
        }
Esempio n. 34
0
        /// <summary>
        /// Reads the values of parameter set from the xml file.
        /// </summary>
        /// <returns>parameters set</returns>
        /// <exception cref="InvalidOperationException">Xml path has not been
        /// defined.</exception>
        /// <exception cref="InvalidDataException">The data have not the correct
        /// format.</exception>
        /// <exception cref="IOException">An I/O error is occured.</exception>
        //public IParametersSet ReadValues()
        protected override IParametersSet InternalReadValues()
        {
            // Check source existence
            if ((FilePath == null) || (!File.Exists(FilePath)))
            {
                throw new InvalidOperationException(
                          "Xml file missing or not specified");
            }

            // Read the stream

            /* 8/6/2012 - DFa - refactoring MPE - DCC - begin */
            /* old - begin */
            //IParametersSet ps = DataTypeFactory.NewParametersSet(null, null, null);
            //ISetDescriptor sd = DataTypeFactory.NewSetDescriptor(null, null, null, null, null);
            //ps.Descriptor = sd;
            /* old - end */
            IParametersSet ps;
            ISetDescriptor sd;
            string         descriptorComponent   = null;
            string         descriptorModel       = null;
            string         descriptorKeyType     = null;
            string         descriptorURL         = null;
            string         descriptorDescription = null;
            List <VarInfo> tmpViList             = new List <VarInfo>();
            Dictionary <IKeyValue, Dictionary <VarInfo, List <string> > > temporaryValues = new Dictionary <IKeyValue, Dictionary <VarInfo, List <string> > >();
            /* 8/6/2012 - DFa - refactoring MPE - DCC - end */

            // Create the parser
            // -----------------

            // Create the XmlSchemaSet class
            XmlSchemaSet sc = new XmlSchemaSet();

            // Add the schema to the collection
            string schemaPath = Path.GetDirectoryName(
                System.Reflection.Assembly.GetExecutingAssembly().Location) +
                                Path.DirectorySeparatorChar + SCHEMA_FOLDER +
                                Path.DirectorySeparatorChar + "ValuesXmlSchema.xsd";

            if (!File.Exists(schemaPath))
            {
                schemaPath = Path.GetDirectoryName(
                    System.Reflection.Assembly.GetExecutingAssembly().Location) +
                             Path.DirectorySeparatorChar + "ValuesXmlSchema.xsd";

                if (!File.Exists(schemaPath))
                {
                    throw new IOException("Could not find ValuesXmlSchema.xsd");
                }
            }

            sc.Add("http://CRA.ParameterEditor.org/ValuesXmlSchema.xsd", schemaPath);

            // Set the validation settings
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.ValidationType = ValidationType.Schema;
            settings.Schemas        = sc;

            // Create the XmlReader and XmlDocument objects
            XmlReader   reader = XmlReader.Create(FilePath, settings);
            XmlDocument doc    = new XmlDocument();

            try
            {
                // Map
                // Parameter name - parameter
                Dictionary <string, VarInfo> nameParameterMap =
                    new Dictionary <string, VarInfo>();


                // Read the template
                doc.Load(reader);

                // Fill data structure
                foreach (XmlNode elem in doc.DocumentElement.ChildNodes)
                {
                    if (elem.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }

                    switch (elem.Name)
                    {
                    // Description element
                    case E_DESCRIPTION:
                    {
                        foreach (XmlNode descChild in elem.ChildNodes)
                        {
                            if (descChild.NodeType != XmlNodeType.Element)
                            {
                                continue;
                            }

                            switch (descChild.Name)
                            {
                            /* 8/6/2012 - DFa - refactoring MPE - DCC - begin */
                            /* old - begin */
                            //case E_DESC_E_NAMESPACE:
                            //    sd.Component = descChild.InnerText;
                            //    break;
                            //case E_DESC_E_TYPENAME:
                            //    sd.Model = descChild.InnerText;
                            //    break;
                            //case E_DESC_E_PARAMETER_KEY:
                            //    sd.KeyType = descChild.InnerText;
                            //    break;
                            //case E_DESC_E_URL:
                            //    sd.URL = descChild.InnerText;
                            //    break;
                            //case E_DESC_E_DESCRIPTION:
                            //    sd.Description = descChild.InnerText;
                            //    break;
                            /* old - end */
                            case E_DESC_E_NAMESPACE:
                                descriptorComponent = descChild.InnerText;
                                break;

                            case E_DESC_E_TYPENAME:
                                descriptorModel = descChild.InnerText;
                                break;

                            case E_DESC_E_PARAMETER_KEY:
                                descriptorKeyType = descChild.InnerText;
                                break;

                            case E_DESC_E_URL:
                                descriptorURL = descChild.InnerText;
                                break;

                            case E_DESC_E_DESCRIPTION:
                                descriptorDescription = descChild.InnerText;
                                break;
                                /* 8/6/2012 - DFa - refactoring MPE - DCC - end */
                            }
                        }
                    }
                    break;

                    // Definitions element
                    case E_VARINFO_ATTRIBUTES:
                    {
                        // Temporary variables
                        VarInfo tmpVi = null;
                        /* 8/6/2012 - DFa - refactoring MPE - DCC - begin */
                        /* old - begin */
                        //List<VarInfo> tmpViList = new List<VarInfo>();
                        /* old - end */
                        /* 8/6/2012 - DFa - refactoring MPE - DCC - end */
                        int index = 0;

                        foreach (XmlNode viAttChild in elem.ChildNodes)
                        {
                            if (viAttChild.NodeType != XmlNodeType.Element)
                            {
                                continue;
                            }

                            switch (viAttChild.Name)
                            {
                            case E_VIATT_E_VARINFO:
                            {
                                tmpVi      = new VarInfo();
                                tmpVi.Id   = index++;
                                tmpVi.Name = viAttChild.Attributes[
                                    E_VIATT_E_VARINFO_A_NAME].Value;

                                foreach (XmlNode vInfoChild in viAttChild.ChildNodes)
                                {
                                    if (vInfoChild.NodeType != XmlNodeType.Element)
                                    {
                                        continue;
                                    }

                                    switch (vInfoChild.Name)
                                    {
                                    case E_VIATT_E_DESCRIPTION:
                                        tmpVi.Description = vInfoChild.InnerText;
                                        break;

                                    case E_VIATT_E_MAXVALUE:
                                        tmpVi.MaxValue = double.Parse(vInfoChild.InnerText,
                                                                      NumberFormatInfo.InvariantInfo);
                                        break;

                                    case E_VIATT_E_MINVALUE:
                                        tmpVi.MinValue = double.Parse(vInfoChild.InnerText,
                                                                      NumberFormatInfo.InvariantInfo);
                                        break;

                                    case E_VIATT_E_DEFAULTVALUE:
                                        tmpVi.DefaultValue = double.Parse(vInfoChild.InnerText,
                                                                          NumberFormatInfo.InvariantInfo);
                                        break;

                                    case E_VIATT_E_TYPE:
                                        VarInfo.ParseValueType(vInfoChild.InnerText, tmpVi);
                                        break;

                                    case E_VIATT_E_UNITS:
                                        tmpVi.Units = vInfoChild.InnerText;
                                        break;

                                    case E_VIATT_E_URL:
                                        tmpVi.URL = vInfoChild.InnerText;
                                        break;
                                    }
                                }

                                tmpViList.Add(tmpVi);
                                nameParameterMap.Add(tmpVi.Name, tmpVi);
                            }
                            break;
                            }
                        }
                        /* 8/6/2012 - DFa - refactoring MPE - DCC - begin */
                        /* old - begin */
                        //ps.Parameters = tmpViList.ToArray();
                        /* old - end */
                        /* 8/6/2012 - DFa - refactoring MPE - DCC - end */
                    }
                    break;

                    // Values element
                    case E_VALUES:
                    {
                        // Temporary variables

                        /* 8/6/2012 - DFa - refactoring MPE - DCC - begin */
                        /* old - begin */
                        //ps.Values = new Dictionary<IKeyValue, Dictionary<VarInfo, List<string>>>();
                        /* old - end */
                        /* 8/6/2012 - DFa - refactoring MPE - DCC - end */
                        Dictionary <VarInfo, List <string> > tmpVals = null;
                        IKeyValue     tmpKv         = null;
                        VarInfo       tmpParam      = null;
                        List <string> tmpValuesList = null;
                        int           index         = 0;

                        foreach (XmlNode valsChild in elem.ChildNodes)
                        {
                            if (valsChild.NodeType != XmlNodeType.Element)
                            {
                                continue;
                            }

                            switch (valsChild.Name)
                            {
                            case E_VALS_E_KEYVALUE:
                            {
                                /* 8/6/2012 - DFa - refactoring MPE - DCC - begin */
                                /* old - begin */
                                //tmpKv = DataTypeFactory.NewKeyValue(0, null, null);
                                //tmpKv.Id = index++;
                                //tmpKv.Name = valsChild.Attributes[
                                //    E_VALS_E_KEYVALUE_A_NAME].Value;
                                /* old - end */
                                if (tmpKv != null)
                                {
                                    tmpKv = DataTypeFactory.NewKeyValue(index++, valsChild.Attributes[E_VALS_E_KEYVALUE_A_NAME].Value, tmpKv.Description);
                                }
                                else
                                {
                                    tmpKv = DataTypeFactory.NewKeyValue(index++, valsChild.Attributes[E_VALS_E_KEYVALUE_A_NAME].Value, null);
                                }
                                /* 8/6/2012 - DFa - refactoring MPE - DCC - end */

                                tmpVals = new Dictionary <VarInfo, List <string> >();

                                foreach (XmlNode keyChild in valsChild.ChildNodes)
                                {
                                    if (keyChild.NodeType != XmlNodeType.Element)
                                    {
                                        continue;
                                    }

                                    switch (keyChild.Name)
                                    {
                                    case E_VALS_E_KV_E_DESCRIPTION:
                                        /* 8/6/2012 - DFa - refactoring MPE - DCC - begin */
                                        /* old - begin */
                                        //tmpKv.Description = keyChild.InnerText;
                                        /* old - end */
                                        if (tmpKv != null)
                                        {
                                            tmpKv = DataTypeFactory.NewKeyValue(tmpKv.Id, tmpKv.Name, keyChild.InnerText);
                                        }
                                        else
                                        {
                                            tmpKv = DataTypeFactory.NewKeyValue(0, null, keyChild.InnerText);
                                        }
                                        /* 8/6/2012 - DFa - refactoring MPE - DCC - end */
                                        break;

                                    case E_VALS_E_KV_E_PARAMETER:
                                    {
                                        tmpValuesList = new List <string>();
                                        try
                                        {
                                            tmpParam = nameParameterMap[keyChild.Attributes[E_VALS_E_KV_E_PARAM_A_NAME].Value];
                                        }catch (Exception)
                                        {
                                            throw new Exception("Parameter not found:'" + keyChild.Attributes[E_VALS_E_KV_E_PARAM_A_NAME].Value + "'");
                                        }
                                        foreach (XmlNode paramChild in keyChild.ChildNodes)
                                        {
                                            if (paramChild.NodeType != XmlNodeType.Element)
                                            {
                                                continue;
                                            }

                                            switch (paramChild.Name)
                                            {
                                            case E_VALS_E_KV_E_VALUE:
                                            {
                                                string s = paramChild.InnerText;
                                                if (paramChild.Attributes.GetNamedItem(E_VALS_E_KV_E_KEY) != null)
                                                {
                                                    //  s = s + EditorEngine.E_VALS_E_KV_E_KEY_SEPARATOR + paramChild.Attributes.GetNamedItem(E_VALS_E_KV_E_KEY).Value;
                                                    s =
                                                        VarInfoValueTypes.
                                                        ConcatenateKeyAndValue(
                                                            paramChild.Attributes.
                                                            GetNamedItem(
                                                                E_VALS_E_KV_E_KEY).Value,
                                                            s);
                                                }
                                                tmpValuesList.Add(s);
                                                break;
                                            }
                                            }
                                        }

                                        tmpVals.Add(tmpParam, tmpValuesList);
                                    }
                                    break;
                                    }
                                }
                                /* 8/6/2012 - DFa - refactoring MPE - DCC - begin */
                                /* old - begin */
                                //ps.Values.Add(tmpKv, tmpVals);
                                /* old - end */
                                temporaryValues.Add(tmpKv, tmpVals);
                                /* 8/6/2012 - DFa - refactoring MPE - DCC - end */
                            }
                            break;
                            }
                        }
                    }
                    break;
                    }
                }


                /* 8/6/2012 - DFa - refactoring MPE - DCC - begin */
                sd = DataTypeFactory.NewSetDescriptor(descriptorComponent, descriptorModel, descriptorKeyType, descriptorURL, descriptorDescription);
                ps = DataTypeFactory.NewParametersSet(sd, tmpViList.ToArray(), temporaryValues);
                /* 8/6/2012 - DFa - refactoring MPE - DCC - end */

                return(ps);
            }
            catch (Exception ex)
            {
                throw new InvalidDataException(ex.Message, ex);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
Esempio n. 35
0
 /// <summary>
 /// Get index of an element.
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public int IndexOf(IKeyValue value)
 {
     return InnerList.IndexOf(value);
 }
		public DependantValue(Table table, IKeyValue prototype)
			: base(table)
		{
			wrappedValue = prototype;
		}
Esempio n. 37
0
 /// <summary>
 /// Insert element to list.
 /// </summary>
 /// <param name="index"></param>
 /// <param name="value"></param>
 public void Insert(int index, IKeyValue value)
 {
     InnerList.Insert(index, value);
 }
Esempio n. 38
0
 public void UpdateIdentityMap(InternalEntityEntry entry, IKeyValue oldKeyValue, IKey principalKey)
 {
     throw new NotImplementedException();
 }
Esempio n. 39
0
 /// <summary>
 /// Remove element from list.
 /// </summary>
 /// <param name="value"></param>
 public void Remove(IKeyValue value)
 {
     InnerList.Remove(value);
 }
Esempio n. 40
0
 public InternalEntityEntry StartTracking(IEntityType entityType, IKeyValue keyValue, object entity, ValueBuffer valueBuffer)
 {
     throw new NotImplementedException();
 }
Esempio n. 41
0
 public DependantValue(Table table, IKeyValue prototype)
     : base(table)
 {
     wrappedValue = prototype;
 }
Esempio n. 42
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="table"></param>
		/// <param name="owner"></param>
		public OneToOne(Table table, PersistentClass owner)
			: base(table)
		{
			identifier = owner.Key;
			entityName = owner.EntityName;
		}
Esempio n. 43
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="table"></param>
 /// <param name="owner"></param>
 public OneToOne(Table table, PersistentClass owner)
     : base(table)
 {
     identifier = owner.Key;
     entityName = owner.EntityName;
 }
        /// <summary>
        /// Processes the observation.
        /// </summary>
        /// <param name="parser">
        /// The parser.
        /// </param>
        private void ProcessObservation(XmlReader parser)
        {
            this.ClearObsInformation();

            for (int i = 0; i < parser.AttributeCount; i++)
            {
                parser.MoveToAttribute(i);
                string attributeId = this.GetComponentId(parser.LocalName);
                string attributeValue = parser.Value;
                if (!this.IsTimeSeries && attributeId.Equals(this.CrossSectionConcept))
                {
                    this._crossSection = new KeyValueImpl(attributeValue, attributeId);
                }
                else if (this._observationAttributes.Contains(attributeId))
                {
                    this._attributeValues.Add(attributeId, attributeValue);
                }
                else if (attributeId.Equals(this._primaryMeasureConcept))
                {
                    this._obsValue = attributeValue;
                }
                else if (attributeId.Equals(this._timeConcept))
                {
                    this._obsTime = attributeValue;
                }
            }

            try
            {
                this.ProcessAttributes(this._observationAttributes, this._attributes);
            }
            catch (SdmxSemmanticException e)
            {
                throw new SdmxSemmanticException("Error while processing observation attributes", e);
            }

            // NOTE the current code in Java SdmxSource v1.1.4 possibly needs to be revisit
            try
            {
                if (!this.IsTimeSeries && this._crossSection == null)
                {
                    throw new SdmxSemmanticException(
                        string.Format("Error while processing observation for series '{0}' , missing required concept '{1}'", this.CurrentKeyValue, this.CrossSectionConcept));
                }
            }
            catch (Exception e)
            {
                if (this.CurrentKeyValue != null)
                {
                    throw new SdmxSemmanticException(string.Format("Error while processing observation for key {0}", this.CurrentKeyValue), e);
                }

                throw new SdmxSemmanticException("Error while processing observation", e);
            }

            // clear values
            this._attributeValues.Clear();
        }
 public KeyValueIndex([NotNull] IForeignKey foreignKey, IKeyValue keyValueValue, ValueType valueType)
 {
     ForeignKey = foreignKey;
     KeyValue   = keyValueValue;
     ValueType  = valueType;
 }