Пример #1
0
 private static void FillCustomLocationDescriptionFields(AttributeHolder attributeHolder, string field, string filter)
 {
     try {
         DataSetUtil.FillBlank(attributeHolder, field);
         var location = attributeHolder.GetAttribute("location_.description");
         if (DataSetUtil.IsValid(location, typeof(String)))
         {
             var l = location.ToString();
             if (l.Contains(filter))
             {
                 var attributeAux = Regex.Split(l, filter);
                 if (attributeAux.Count() > 1)
                 {
                     var attribute = Regex.Split(attributeAux[1], "/");
                     if (attribute.Count() > 1)
                     {
                         attributeHolder.Attributes[field] = attribute[0];
                     }
                 }
             }
         }
     } catch {
         DataSetUtil.FillBlank(attributeHolder, field);
     }
 }
Пример #2
0
 /// <summary>
 /// Gets or sets a value in the collection by name.
 /// </summary>
 /// <param name="name">
 /// The key name of the value in the collection.
 /// </param>
 /// <returns>
 /// The value in the collection with the specified name.
 /// </returns>
 object ISessionStateItemCollection.this[string name]
 {
     get
     {
         AcquireReadLock();
         try
         {
             AttributeHolder attr = (AttributeHolder)BaseGet(name);
             return(attr == null ? null : attr.Value);
         }
         finally
         {
             ReleaseReadLock();
         }
     }
     set
     {
         AcquireWriteLock();
         try
         {
             AttributeHolder attr = (AttributeHolder)BaseGet(name);
             if (attr == null)
             {
                 attr = AddAttribute(name);
             }
             attr.Value = value;
         }
         finally
         {
             ReleaseWriteLock();
         }
     }
 }
Пример #3
0
 public BasePreFilterParameters(SearchRequestDto baseDto,
                                TRelationhipmetadata relationship, AttributeHolder originalEntity)
 {
     _baseDto        = baseDto;
     _originalEntity = originalEntity;
     _relationship   = relationship;
 }
Пример #4
0
        public static object CloneFromEntity(object target, AttributeHolder attributes)
        {
            PropertyDescriptorCollection targetProperties = TypeDescriptor.GetProperties(target);

            foreach (PropertyDescriptor prop in targetProperties)
            {
                var value = attributes.GetAttribute(prop.Name.ToLower());
                if (value == null)
                {
                    continue;
                }
                if (prop.PropertyType.IsPrimitive)
                {
                    prop.SetValue(target, value);
                }
                else if (!prop.PropertyType.IsPrimitive)
                {
                    object o = prop.GetValue(target);
                    if (o == null)
                    {
                        object newInstance = ReflectionUtil.InstanceFromType(prop.PropertyType);
                        prop.SetValue(target, newInstance);
                        o = newInstance;
                    }
                    r.SetProperty(o, new { Value = value });
                }
            }
            return(target);
        }
        public Object ProvideInjection(CompositeInstance instance, AbstractInjectableModel model, Type targetType)
        {
            InvocationInfo invocationInfo = instance.InvocationInfo;
            Object         result;

            if (Object.Equals(typeof(MethodInfo), targetType))
            {
                result = invocationInfo.CompositeMethod;
            }
            else if (Object.Equals(typeof(CompositeMethodModel), targetType))
            {
                result = invocationInfo.FragmentMethodModel.CompositeMethod;
            }
            else if (typeof(AbstractFragmentMethodModel).IsAssignableFrom(targetType))
            {
                result = invocationInfo.FragmentMethodModel;
            }
            else
            {
                AttributeHolder holder = instance.ModelInfo.CompositeMethodAttributeHolders[invocationInfo.FragmentMethodModel.CompositeMethod.MethodIndex];
                if (typeof(Attribute).IsAssignableFrom(targetType))
                {
                    ListQuery <Attribute> list;
                    holder.AllAttributes.TryFindInTypeDictionarySearchBottommostType(targetType, out list);
                    result = list.FirstOrDefault();
                }
                else // target type must be attribute holder
                {
                    result = holder;
                }
            }

            return(result);
        }
Пример #6
0
 /// <summary>
 /// Gets or sets a value in the collection by numerical index.
 /// </summary>
 /// <param name="index">
 /// The numerical index of the value in the collection.
 /// </param>
 /// <returns>
 /// The value in the collection stored at the specified index.
 /// </returns>
 object ISessionStateItemCollection.this[int index]
 {
     get
     {
         AcquireReadLock();
         try
         {
             AttributeHolder attr = (AttributeHolder)BaseGet(index);
             return(attr.Value);
         }
         finally
         {
             ReleaseReadLock();
         }
     }
     set
     {
         AcquireWriteLock();
         try
         {
             AttributeHolder attr = (AttributeHolder)BaseGet(index);
             attr.Value = value;
         }
         finally
         {
             ReleaseWriteLock();
         }
     }
 }
Пример #7
0
        private bool HandleCustomerApprovers(InMemoryUser user, AttributeHolder result, string approvalGroup, IEnumerable <Dictionary <string, object> > worklogs, IDictionary <string, object> approval,
                                             IEnumerable <Dictionary <string, object> > wostatus)
        {
            //https://controltechnologysolutions.atlassian.net/browse/HAP-976
            //https://controltechnologysolutions.atlassian.net/browse/HAP-1113 --> changing the way it filters the status
            worklogs = FilterWorkLogsOlderThanLatestAuth(worklogs, wostatus);

            var wlEnumerable = worklogs as Dictionary <string, object>[] ?? worklogs.ToArray();

            var apprDescription = c.GetWorkLogDescriptions(approvalGroup, true);
            var rejDescription  = c.GetWorkLogDescriptions(approvalGroup, false);


            var apprWl = wlEnumerable.FirstOrDefault(w =>
                                                     apprDescription.EqualsIc(w["description"] as string) &&
                                                     c.WlApprLogType.EqualsIc(w["logtype"] as string) &&
                                                     w["recordkey"].Equals(result.GetAttribute("wonum"))
                                                     );

            var rejWl = wlEnumerable.FirstOrDefault(w =>
                                                    rejDescription.EqualsIc(w["description"] as string) &&
                                                    c.WlRejLogType.EqualsIc(w["logtype"] as string) &&
                                                    w["recordkey"].Equals(result.GetAttribute("wonum"))
                                                    );

            var anyrejWl = wlEnumerable.FirstOrDefault(w =>
                                                       (w["description"] != null && w["description"].ToString().StartsWith(c.RejectedWorklogDescription, StringComparison.CurrentCultureIgnoreCase)) &&
                                                       w["logtype"].ToString().Equals(c.WlRejLogType) &&
                                                       w["recordkey"].Equals(result.GetAttribute("wonum"))
                                                       );

            //approval["#shouldshowaction"] = LevelMatches(result, approval) && user.HasPersonGroup(approvalGroup); ;
            //removed due to thomas comments, on HAP-976
            approval["#shouldshowaction"] = user.HasPersonGroup(approvalGroup);
            ;

            if (apprWl != null || rejWl != null)
            {
                Log.DebugFormat("Specific approval or rejected worklog found");

                approval[c.ChangeByColumn]    = apprWl != null ? apprWl[c.CreateByColumn] : rejWl[c.CreateByColumn];
                approval[c.ChangeDateColumn]  = apprWl != null ? apprWl[c.CreateDate] : rejWl[c.CreateDate];
                approval[c.StatusColumn]      = apprWl != null ? c.ApprovedStatus : c.RejectedStatus;
                approval["#shouldshowaction"] = false;
            }
            else if (anyrejWl != null)
            {
                Log.DebugFormat("At least one rejected worklog found scenario");
                //if there´s a rejected worklog on the level, then all groups should be rejected, except the ones that might have approved it already...
                approval[c.StatusColumn] = c.RejectedStatus;
                //HAP-993 if any of the groups rejected it, we should no longer display the actions
                approval["#shouldshowaction"] = false;
            }
            Log.DebugFormat("customer approval handled " + string.Join(", ", approval.Select(m => m.Key + ":" + m.Value).ToArray()));
            //if this group has not yet been approved or rejectd, it will still require some action (maybe not by this user)
            return(!approval.ContainsKey(c.StatusColumn) || !approval[c.StatusColumn].EqualsAny(c.ApprovedStatus, c.RejectedStatus));
        }
Пример #8
0
        protected bool FullSatisfied(IDependableField dependableField, AttributeHolder originalEntity)
        {
            var dependantFields = dependableField.DependantFields;

            if (dependantFields.Count == 0)
            {
                return(true);
            }
            return(dependantFields.All(depField => originalEntity.GetAttribute(depField) != null));
        }
Пример #9
0
        private string BuildComplexLabel(AttributeHolder attributeHolder, ApplicationAssociationDefinition association)
        {
            var fmt = new object[association.LabelFields.Count];

            for (var i = 0; i < association.LabelFields.Count; i++)
            {
                fmt[i] = attributeHolder.GetAttribute(association.LabelFields[i], true);
            }
            return(String.Format(association.LabelPattern, fmt));
        }
Пример #10
0
        public IEnumerable <IAssociationOption> ResolveOptions(ApplicationMetadata applicationMetadata,
                                                               AttributeHolder originalEntity, ApplicationAssociationDefinition association, SearchRequestDto associationFilter)
        {
            if (!FullSatisfied(association, originalEntity))
            {
                return(null);
            }

            // Set dependante lookup atributes
            var lookupAttributes = association.LookupAttributes();

            foreach (var lookupAttribute in lookupAttributes)
            {
                var searchValue = SearchUtils.GetSearchValue(lookupAttribute, originalEntity);
                if (!String.IsNullOrEmpty(searchValue))
                {
                    associationFilter.AppendSearchParam(lookupAttribute.To);
                    associationFilter.AppendSearchValue(searchValue);
                }
                else if (lookupAttribute.Query != null)
                {
                    associationFilter.AppendWhereClause(lookupAttribute.GetQueryReplacingMarkers(association.EntityAssociation.To));
                }
            }

            // Set projections and pre filter functions
            var numberOfLabels        = BuildProjections(associationFilter, association);
            var prefilterFunctionName = association.Schema.DataProvider.PreFilterFunctionName;

            if (prefilterFunctionName != null)
            {
                var preFilterParam = new AssociationPreFilterFunctionParameters(applicationMetadata, associationFilter, association, originalEntity);
                associationFilter = PrefilterInvoker.ApplyPreFilterFunction(DataSetProvider.GetInstance().LookupDataSet(applicationMetadata.Name), preFilterParam, prefilterFunctionName);
            }

            var entityMetadata = MetadataProvider.Entity(association.EntityAssociation.To);

            associationFilter.QueryAlias = association.AssociationKey;
            var queryResponse = EntityRepository.Get(entityMetadata, associationFilter);

            if (associationFilter is PaginatedSearchRequestDto)
            {
                var paginatedFilter = (PaginatedSearchRequestDto)associationFilter;
                if (paginatedFilter.NeedsCountUpdate)
                {
                    paginatedFilter.TotalCount = EntityRepository.Count(entityMetadata, associationFilter);
                }
            }

            var    options            = BuildOptions(queryResponse, association, numberOfLabels);
            string filterFunctionName = association.Schema.DataProvider.PostFilterFunctionName;

            return(filterFunctionName != null?ApplyFilters(applicationMetadata.Name, originalEntity, filterFunctionName, options, association) : options);
        }
Пример #11
0
        private static PersonGroup GeneratePersonGroup(AttributeHolder personGroup)
        {
            var description = (string)personGroup.GetAttribute("description");
            var pg          = new PersonGroup {
                Name        = (string)personGroup.GetAttribute(PersonGroupColumn),
                Description = description,
                Rowstamp    = (long)personGroup.GetAttribute("rowstamp")
            };

            pg.SuperGroup = HlagLocationUtil.IsSuperGroup(pg);
            return(pg);
        }
Пример #12
0
        /// <summary>
        /// Gets the data in the field as a string. Handles edge cases (numbers, #, etc).
        /// </summary>
        /// <param name="holder"></param>
        /// <param name="field"></param>
        /// <returns></returns>
        private string GetValueAsString(AttributeHolder holder, IDefaultValueApplicationDisplayable field)
        {
            var    attributes = holder.Attributes;
            object dataAux;

            attributes.TryGetValue(field.Attribute, out dataAux);
            if (dataAux == null && field.Attribute.StartsWith("#") && char.IsNumber(field.Attribute[1]))
            {
                attributes.TryGetValue(field.Attribute.Substring(2), out dataAux);
            }
            return(dataAux == null ? string.Empty : dataAux.ToString());
        }
Пример #13
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);
            }
Пример #14
0
 public static void FillField(AttributeHolder attributeHolder, string field, string attribute)
 {
     try {
         FillBlank(attributeHolder, field);
         var value = attributeHolder.GetAttribute(attribute);
         if (IsValid(value, typeof(String)))
         {
             attributeHolder.Attributes[field] = value.ToString();
         }
     } catch {
         FillBlank(attributeHolder, field);
     }
 }
Пример #15
0
        public static void search()
        {
            CertificateManagement cm   = new CertificateManagement();
            X509Certificate2      cert = cm.GetTrustedSystemPrivateCert(certPath, certPassword);

            //build the attributes
            AttributeHolder attr = new AttributeHolder();

            attr.Id                 = "123";
            attr.IssueInstant       = DateTime.Now.ToUniversalTime();
            attr.ElectronicEntityId = "https://mise.agencyone.gov/";
            attr.FullName           = "John Doe";
            attr.CitizenCodes       = new List <string>()
            {
                "USA"
            };
            attr.LEI = true;
            attr.PPI = true;
            attr.COI = true;

            ServiceHandler sh = new ServiceHandler();

            //send the saml login - the cookie represents the session
            CookieContainer session = sh.SendSamlRequest(cert, attr);

            ServiceEndPointManager sepm = new ServiceEndPointManager();
            //set up a base search URL
            Uri url = new Uri(sepm.BuildServiceEndPoint("Search", "IAN", ""));

            //Assemble the query arguments - e.g. lat/lng, etc
            Dictionary <string, string> qd = new Dictionary <string, string>();

            qd.Add("ulat", "10");
            qd.Add("ulng", "-10");
            qd.Add("llat", "-10");
            qd.Add("llng", "10");
            TimeSpan tStart = new TimeSpan(365, 0, 0, 0); //search the past years data
            TimeSpan tEnd   = new TimeSpan(0, 0, 30);     //cover search up to 30 seconds ago (data refresh rate determination)
            string   start  = DateTime.Now.Subtract(tStart).ToUniversalTime().ToString("o");
            string   end    = DateTime.Now.Subtract(tEnd).ToUniversalTime().ToString("o");

            qd.Add("start", start);
            qd.Add("end", end);

            url = HttpExtensions.AddQuery(url, qd);

            XDocument result = sh.SendQueryRequest(cert, session, url.ToString(), "application/xml");

            Console.WriteLine(result.ToString());
        }
Пример #16
0
        private static void HandleClosedDate(AttributeHolder resultObject)
        {
            var status     = resultObject.GetAttribute("status");
            var statusDate = resultObject.GetAttribute("statusdate");

            if ("CLOSED".Equals(status))
            {
                resultObject.Attributes["#closeddate"] = statusDate;
            }
            else
            {
                resultObject.Attributes["#closeddate"] = "";
            }
        }
Пример #17
0
        private string NewLocationDelegate(AttributeHolder holder, ApplicationFieldDefinition field, string originalData)
        {
            if (!field.Attribute.EqualsIc("#rI102newlocation"))
            {
                return(originalData);
            }
            var country       = holder.GetAttribute("location_pluspservaddr_.country");
            var loccode       = holder.GetAttribute("hlagpluspcustomer");
            var streetaddress = holder.GetAttribute("location_pluspservaddr_.streetaddress");
            var floor         = holder.GetAttribute("location_.floor") as string;
            var room          = holder.GetAttribute("location_.room") as string;

            if (string.IsNullOrEmpty(floor) || string.IsNullOrEmpty(room))
            {
                return(country + "/" + loccode + "/" + streetaddress);
            }
            return(country + "/" + loccode + "/" + streetaddress + "/" + floor + "/" + room);
        }
Пример #18
0
        public static void retrieve()
        {
            CertificateManagement cm   = new CertificateManagement();
            X509Certificate2      cert = cm.GetTrustedSystemPrivateCert(certPath, certPassword);

            //build the attributes
            AttributeHolder attr = new AttributeHolder();

            attr.Id                 = "123";
            attr.IssueInstant       = DateTime.Now.ToUniversalTime();
            attr.ElectronicEntityId = "https://mise.agencyone.gov/";
            attr.FullName           = "John Doe";
            attr.CitizenCodes       = new List <string>()
            {
                "USA"
            };
            attr.LEI = true;
            attr.PPI = true;
            attr.COI = true;

            ServiceHandler sh = new ServiceHandler();

            //send the saml login - the cookie represents the session
            CookieContainer session = sh.SendSamlRequest(cert, attr);

            ServiceEndPointManager sepm = new ServiceEndPointManager();
            //set up a base retrieve URL
            Uri url = new Uri(sepm.BuildServiceEndPoint("Retrieve", "IAN", ""));

            Dictionary <string, string> qd = new Dictionary <string, string>();

            qd.Add("entityid", "https://mise.agencyone.gov/");
            qd.Add("recordid", "123456789");

            url = HttpExtensions.AddQuery(url, qd);

            XDocument xd = sh.SendQueryRequest(cert, session, url.ToString(), "application/xml");

            Console.WriteLine(xd.ToString());
        }
Пример #19
0
 public Dictionary <string, EntityRepository.SearchEntityResult> ResolveCollections(SlicedEntityMetadata entityMetadata, IDictionary <string, ApplicationCompositionSchema> compositionSchemas,
                                                                                    AttributeHolder mainEntity, PaginatedSearchRequestDto paginatedSearch = null)
 {
     return(ResolveCollections(entityMetadata, compositionSchemas, new List <AttributeHolder> {
         mainEntity
     }, paginatedSearch));
 }
Пример #20
0
 public static void FillBlank(AttributeHolder attributeHolder, string field)
 {
     attributeHolder.Attributes[field] = string.Empty;
 }
Пример #21
0
 internal void AppendEntry(CollectionMatchingResultKey key, AttributeHolder value)
 {
     _matchingDict[key] = value;
 }
Пример #22
0
 public override void ProcessHolder(AttributeHolder holder)
 {
     switch (WrapType)
     {
         case WrapTypes.NativePtrValueType:
         case WrapTypes.ValueType:
             if (!holder.HasAttribute<ValueTypeAttribute>())
                 holder.Attributes.Add(new ValueTypeAttribute());
             break;
         case WrapTypes.Overridable:
             DefClass type = (DefClass)holder;
             AddAttributeToInheritanceChain(type, new BaseForSubclassingAttribute());
             break;
     }
 }
Пример #23
0
 public AssociationPreFilterFunctionParameters(ApplicationMetadata metadata, SearchRequestDto baseDto,
                                               ApplicationAssociationDefinition association, AttributeHolder originalEntity)
     : base(baseDto, association, originalEntity)
 {
     _metadata = metadata;
 }
Пример #24
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        // DrawDefaultInspector();



        AttributeHolder myScript = (AttributeHolder)target;

        if (myScript.getNote() == null)
        {
            return;
        }


        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Tap"))
        {
            foreach (Object cur in targets)
            {
                myScript = (AttributeHolder)cur;
                myScript.setNoteType(noteType.Tap);
            }
        }

        if (GUILayout.Button("Hold"))
        {
            foreach (Object cur in targets)
            {
                myScript = (AttributeHolder)cur;
                myScript.setNoteType(noteType.Hold);
            }
        }

        if (GUILayout.Button("Item"))
        {
            foreach (Object cur in targets)
            {
                myScript = (AttributeHolder)cur;
                myScript.setNoteType(noteType.Item);
            }
        }

        if (myScript.getNote().myNoteType == noteType.Hold)
        {
            float curPos = myScript.getNote().holdTimer;
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Hold Time: ");
            curPos = GUILayout.HorizontalSlider(curPos, 0.0f, 5.0f);

            GUILayout.EndHorizontal();

            {
                foreach (Object cur in targets)
                {
                    myScript = (AttributeHolder)cur;
                    myScript.getNote().holdTimer = curPos;
                }
            }
        }
        else
        {
            GUILayout.EndHorizontal();
        }


        if (myScript.getNote().myNoteType == noteType.Item)
        {
            string curItem = myScript.getNote().itemSpawn;
            GUILayout.BeginHorizontal();
            GUILayout.Label("Item Name: ");
            myScript.getNote().itemSpawn = GUILayout.TextField(curItem);
            GUILayout.EndHorizontal();
        }
    }
Пример #25
0
        public override void ProcessHolder(AttributeHolder holder)
        {
            DefClass type = (DefClass)holder;

            foreach (string[] names in _interfaceNames)
            {
                List<DefClass> ifaces = new List<DefClass>();
                foreach (string ifacename in names)
                {
                    ifaces.Add(type.FindType<DefClass>(ifacename));
                }
                Interfaces.Add(ifaces.ToArray());
            }
        }
Пример #26
0
 private void AddAttributeInHolder(AttributeHolder holder, AutoWrapAttribute attr)
 {
     holder.Attributes.Add(attr);
     _holders.Add(new KeyValuePair<AttributeHolder, AutoWrapAttribute>(holder, attr));
 }
Пример #27
0
 public virtual void ProcessHolder(AttributeHolder holder)
 {
 }
Пример #28
0
        public IEnumerable <IAssociationOption> ResolveOptions(ApplicationMetadata application, OptionField optionField, AttributeHolder dataMap)
        {
            if (!FullSatisfied(optionField, dataMap))
            {
                return(null);
            }
            if (optionField.ShowExpression == "false")
            {
                return(null);
            }

            var attribute = optionField.ProviderAttribute;

            attribute = attribute.Replace("#", "");
            attribute = attribute.Replace("_", "");


            var methodName = GetMethodName(attribute);
            var dataSet    = FindDataSet(application.Name, methodName);
            var mi         = dataSet.GetType().GetMethod(methodName);

            if (mi == null)
            {
                throw new InvalidOperationException(String.Format(MethodNotFound, methodName, dataSet.GetType().Name));
            }
            if (mi.GetParameters().Count() != 1 || mi.GetParameters()[0].ParameterType != typeof(OptionFieldProviderParameters))
            {
                throw new InvalidOperationException(String.Format(WrongMethod, methodName, dataSet.GetType().Name));
            }
            var associationOptions = (IEnumerable <IAssociationOption>)mi.Invoke(dataSet, new object[] { new OptionFieldProviderParameters {
                                                                                                             OriginalEntity = dataMap, ApplicationMetadata = application, OptionField = optionField
                                                                                                         } });

            if (optionField.Sort)
            {
                associationOptions = associationOptions.OrderBy(f => f.Label);
            }
            return(associationOptions);
        }
Пример #29
0
        private static PaginatedSearchRequestDto BuildSearchDTO(AssociationUpdateRequest request, ApplicationAssociationDefinition association, AttributeHolder cruddata)
        {
            var searchRequest = new PaginatedSearchRequestDto(100, PaginatedSearchRequestDto.DefaultPaginationOptions);

            if (request.SearchDTO == null)
            {
                request.SearchDTO = PaginatedSearchRequestDto.DefaultInstance(null);
            }
            searchRequest.PageNumber = request.SearchDTO.PageNumber;
            searchRequest.PageSize   = request.SearchDTO.PageSize;
            //avoids pagination unless the association renderer defines so (lookup)
            searchRequest.ShouldPaginate   = association.IsPaginated();
            searchRequest.NeedsCountUpdate = association.IsPaginated();
            var valueSearchString = request.ValueSearchString;

            if (association.IsLazyLoaded() && !request.HasClientSearch())
            {
                if ((cruddata == null || cruddata.GetAttribute(association.Target) == null))
                {
                    //we should not update lazy dependant associations except in one case:
                    //there´s a default value in place already for the dependent association
                    // in that case, we would need to return a 1-value list to show on screen
                    return(null);
                }
                //this will force that the search would be made only on that specific value
                //ex: autocomplete server, lookups that depend upon another association
                valueSearchString = cruddata.GetAttribute(association.Target) as string;
            }

            if (request.AssociationKey != null)
            {
                // If association has a schema key defined, the searchDTO will be filled on client, so just copy it from request
                searchRequest.SearchParams = request.SearchDTO.SearchParams;
                searchRequest.SearchValues = request.SearchDTO.SearchValues;
            }
            else
            {
                if (!String.IsNullOrWhiteSpace(valueSearchString))
                {
                    searchRequest.AppendSearchParam(association.EntityAssociation.PrimaryAttribute().To);
                    searchRequest.AppendSearchValue("%" + valueSearchString + "%");
                }
                if (!String.IsNullOrWhiteSpace(request.LabelSearchString))
                {
                    AppendSearchLabelString(request, association, searchRequest);
                }
            }
            return(searchRequest);
        }
Пример #30
0
        private IEnumerable <IAssociationOption> ApplyFilters(string applicationName, AttributeHolder originalEntity, string filterFunctionName, ISet <IAssociationOption> options, ApplicationAssociationDefinition association)
        {
            var dataSet = FindDataSet(applicationName, filterFunctionName);
            var mi      = dataSet.GetType().GetMethod(filterFunctionName);

            if (mi == null)
            {
                throw new InvalidOperationException(String.Format(MethodNotFound, filterFunctionName, dataSet.GetType().Name));
            }
            if (mi.GetParameters().Count() != 1)
            {
                throw new InvalidOperationException(String.Format(WrongPostFilterMethod, filterFunctionName, dataSet.GetType().Name));
            }
            var postFilterParam = new AssociationPostFilterFunctionParameters()
            {
                Options        = options,
                OriginalEntity = originalEntity,
                Association    = association
            };

            return((IEnumerable <IAssociationOption>)mi.Invoke(dataSet, new object[] { postFilterParam }));
        }
Пример #31
0
 private static void LocationDescriptionHandler(AttributeHolder attributeHolder)
 {
     FillCustomLocationDescriptionFields(attributeHolder, "#floor", "FL:");
     FillCustomLocationDescriptionFields(attributeHolder, "#room", "RO:");
 }
Пример #32
0
 public IEnumerable <IAssociationOption> ResolveOptions(ApplicationMetadata applicationMetadata,
                                                        AttributeHolder originalEntity, ApplicationAssociationDefinition association)
 {
     return(ResolveOptions(applicationMetadata, originalEntity, association, new SearchRequestDto()));
 }
Пример #33
0
 public override void ProcessHolder(AttributeHolder holder)
 {
     DefClass type = (DefClass)holder;
     AddAttributeToInheritanceChain(type, new BaseForSubclassingAttribute());
 }
Пример #34
0
        protected virtual IDictionary <string, BaseAssociationUpdateResult> DoUpdateAssociation(ApplicationMetadata application, AssociationUpdateRequest request,
                                                                                                AttributeHolder cruddata)
        {
            var before = LoggingUtil.StartMeasuring(Log, "starting update association options fetching for application {0} schema {1}", application.Name, application.Schema.Name);
            IDictionary <string, BaseAssociationUpdateResult> resultObject =
                new Dictionary <string, BaseAssociationUpdateResult>();
            ISet <string> associationsToUpdate = null;

            // Check if 'self' (for lazy load) or 'dependant' (for dependant combos) association update
            if (!String.IsNullOrWhiteSpace(request.AssociationFieldName))
            {
                associationsToUpdate = new HashSet <String> {
                    request.AssociationFieldName
                };
            }
            else if (!String.IsNullOrWhiteSpace(request.TriggerFieldName))
            {
                var triggerFieldName = request.TriggerFieldName;
                if (!application.Schema.DependantFields.TryGetValue(triggerFieldName, out associationsToUpdate))
                {
                    throw new InvalidOperationException();
                }
            }

            if (associationsToUpdate == null)
            {
                return(resultObject);
            }

            var tasks = new List <Task>();
            var ctx   = ContextLookuper.LookupContext();

            //there might be some associations/optionfields to be updated after the first value is selected
            foreach (var associationToUpdate in associationsToUpdate)
            {
                var association = application.Schema.Associations.FirstOrDefault(f => (
                                                                                     EntityUtil.IsRelationshipNameEquals(f.AssociationKey, associationToUpdate)));
                if (association == null)
                {
                    var optionField = application.Schema.OptionFields.First(f => f.AssociationKey == associationToUpdate);
                    tasks.Add(Task.Factory.NewThread(c => {
                        Quartz.Util.LogicalThreadContext.SetData("context", c);
                        var data = _dynamicOptionFieldResolver.ResolveOptions(application, optionField, cruddata);
                        resultObject.Add(optionField.AssociationKey, new LookupAssociationUpdateResult(data, 100, PaginatedSearchRequestDto.DefaultPaginationOptions));
                    }, ctx));
                }
                else
                {
                    var associationApplicationMetadata =
                        ApplicationAssociationResolver.GetAssociationApplicationMetadata(association);

                    var searchRequest = BuildSearchDTO(request, association, cruddata);

                    if (searchRequest == null)
                    {
                        //this would only happen if association is lazy and there´s no default value
                        //(cause we´d need to fetch one-value list for displaying)
                        continue;
                    }
                    var threadSafeContext = new ContextHolderWithSearchDto(ctx, searchRequest);
                    tasks.Add(Task.Factory.NewThread(c => {
                        Quartz.Util.LogicalThreadContext.SetData("context", threadSafeContext.Context);
                        var options = _associationOptionResolver.ResolveOptions(application, cruddata, association,
                                                                                threadSafeContext.Dto);

                        resultObject.Add(association.AssociationKey,
                                         new LookupAssociationUpdateResult(searchRequest.TotalCount, searchRequest.PageNumber,
                                                                           searchRequest.PageSize, options, associationApplicationMetadata, PaginatedSearchRequestDto.DefaultPaginationOptions));
                    }, threadSafeContext));
                }
            }

            Task.WaitAll(tasks.ToArray());

            if (Log.IsDebugEnabled)
            {
                var keys = String.Join(",", resultObject.Keys.Where(k => resultObject[k].AssociationData != null));
                Log.Debug(LoggingUtil.BaseDurationMessageFormat(before,
                                                                "Finished execution of options fetching. Resolved collections: {0}", keys));
            }
            return(resultObject);
        }
Пример #35
0
 /// <summary>
 /// Add existing attribute to underlying name-value collection.
 /// </summary>
 /// <param name="attr">Attribute holder to add.</param>
 /// <returns>Added attribute holder.</returns>
 protected virtual AttributeHolder AddAttribute(AttributeHolder attr)
 {
     BaseAdd(attr.Name, attr);
     return(attr);
 }