public IGenericResponseResult Expand(InMemoryUser user, IDictionary <string, ApplicationCompositionSchema> compositionSchemas, CompositionExpanderHelper.CompositionExpansionOptions options) { var resultDict = new Dictionary <string, IEnumerable <IDictionary <string, object> > >(); var result = CompositionExpanderHelper.ParseDictionary(options.CompositionsToExpand); var printMode = _contextLookuper.LookupContext().PrintMode; foreach (var toExpand in result.DetailsToExpand) { var name = toExpand.Key; var compositionSchema = compositionSchemas[name]; var schema = compositionSchema.Schemas.Detail; if (printMode) { schema = compositionSchema.Schemas.Print; } var applicationMetadata = MetadataProvider.Application(EntityUtil.GetApplicationName(name)) .ApplyPolicies(schema.GetSchemaKey(), user, ClientPlatform.Web); var slicedEntityMetadata = MetadataProvider.SlicedEntityMetadata(applicationMetadata); var searchDTO = new SearchRequestDto(); searchDTO.AppendSearchParam(schema.IdFieldName); searchDTO.AppendSearchValue(toExpand.Value); var compositionExpanded = _entityRepository.GetAsRawDictionary(slicedEntityMetadata, searchDTO); resultDict.Add(name, compositionExpanded.ResultList); } return(new GenericResponseResult <Dictionary <string, IEnumerable <IDictionary <string, object> > > >(resultDict)); }
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); }