Example #1
0
            internal IDictionary <string, object> FetchEntity(CollectionMatchingResultKey key)
            {
                AttributeHolder result;

                if (!_matchingDict.TryGetValue(key, out result))
                {
                    return(null);
                }
                return(result.Attributes);
            }
Example #2
0
            internal CollectionMatchingResultKey FetchKey(AttributeHolder entity)
            {
                CollectionMatchingResultKey key;

                if (!_inverseDict.TryGetValue(entity, out key))
                {
                    key = new CollectionMatchingResultKey();
                    _matchingDict[key]   = entity;
                    _inverseDict[entity] = key;
                }
                return(key);
            }
Example #3
0
        private void MatchResults(EntityRepository.SearchEntityResult resultCollections, CollectionMatchingResultWrapper matchingResultWrapper, string targetCollectionAttribute)
        {
            foreach (var resultCollection in resultCollections.ResultList)
            {
                var resultkey = new CollectionMatchingResultKey();
                foreach (var key in matchingResultWrapper.Keys)
                {
                    object result;
                    if (!resultCollection.TryGetValue(key, out result))
                    {
                        throw new Exception("key {0} was not present on the dictionary".Fmt(key));
                    }
                    if (result != null)
                    {
                        resultkey.AppendEntry(key, result.ToString());
                    }
                }

                IDictionary <string, object> attributes;

                if (targetCollectionAttribute == "worklog_" && resultCollection.ContainsKey("relatedrecordkey") && resultCollection["relatedrecordkey"] != null)
                {
                    //let´s see if this was provenient from a related record, workaround for //HAP-968
                    // see also HapagBaseApplicationDataSet#AppendRelatedRecordWCToWorklog
                    resultkey = new CollectionMatchingResultKey();
                    resultkey.AppendEntry("recordkey", resultCollection["relatedrecordkey"] as string);
                    attributes = matchingResultWrapper.FetchEntity(resultkey);
                    if (attributes == null)
                    {
                        throw new Exception("could not locate entry");
                    }
                }
                else
                {
                    attributes = matchingResultWrapper.FetchEntity(resultkey);
                }



                if (!attributes.ContainsKey(targetCollectionAttribute))
                {
                    attributes.Add(targetCollectionAttribute, new List <IDictionary <string, object> >());
                }
                var collection = (List <IDictionary <string, object> >)attributes[targetCollectionAttribute];
                collection.Add(resultCollection);
            }
        }
Example #4
0
 protected bool Equals(CollectionMatchingResultKey other)
 {
     return(other._pairs.OrderBy(r => r.Key).SequenceEqual(_pairs.OrderBy(r => r.Key)));
 }
Example #5
0
 internal void AppendEntry(CollectionMatchingResultKey key, AttributeHolder value)
 {
     _matchingDict[key] = value;
 }