コード例 #1
0
        public static CompiledGroupedAttributeValueQuery Compile(MIA_Management miaManagement,
                                                                 IEnumerable <Guid> necessaryRequestedMIATypeIDs,
                                                                 MediaItemAspectMetadata.AttributeSpecification selectAttribute, IAttributeFilter selectAttributeFilter,
                                                                 SelectProjectionFunction selectProjectionFunction, Type projectionValueType, IFilter filter)
        {
            IDictionary <Guid, MediaItemAspectMetadata> availableMIATypes = miaManagement.ManagedMediaItemAspectTypes;

            // If we're doing a complex query, we can optimize if we have an extra select attribute filter, i.e. a restriction
            // on the result set of values. See ComplexAttributeQueryBuilder.GenerateSqlGroupByStatement().
            bool    simpleQuery    = selectAttribute.Cardinality == Cardinality.Inline || selectAttribute.Cardinality == Cardinality.ManyToOne;
            IFilter combinedFilter = simpleQuery ?
                                     BooleanCombinationFilter.CombineFilters(BooleanOperator.And, new IFilter[] { filter, selectAttributeFilter }) : filter;

            selectAttributeFilter = simpleQuery ? null : selectAttributeFilter;

            ICollection <MediaItemAspectMetadata> necessaryMIATypes = new List <MediaItemAspectMetadata>();

            // Raise exception if necessary MIA types are not present
            foreach (Guid miaTypeID in necessaryRequestedMIATypeIDs)
            {
                MediaItemAspectMetadata miam;
                if (!availableMIATypes.TryGetValue(miaTypeID, out miam))
                {
                    throw new InvalidDataException("Necessary requested MIA type of ID '{0}' is not present in the media library", miaTypeID);
                }
                necessaryMIATypes.Add(miam);
            }
            return(new CompiledGroupedAttributeValueQuery(miaManagement, necessaryMIATypes, selectAttribute, selectAttributeFilter,
                                                          selectProjectionFunction, projectionValueType, combinedFilter));
        }
コード例 #2
0
 public MIAQueryBuilder(MIA_Management miaManagement, IEnumerable <QueryAttribute> simpleSelectAttributes,
                        SelectProjectionFunction selectProjectionFunction,
                        IEnumerable <MediaItemAspectMetadata> necessaryRequestedMIAs, IEnumerable <MediaItemAspectMetadata> optionalRequestedMIAs,
                        IFilter filter, IFilter subqueryFilter, IList <ISortInformation> sortInformation, Guid?userProfileId = null) : base(miaManagement, simpleSelectAttributes,
                                                                                                                                            selectProjectionFunction,
                                                                                                                                            necessaryRequestedMIAs, optionalRequestedMIAs,
                                                                                                                                            filter, subqueryFilter, sortInformation, userProfileId)
 {
 }
コード例 #3
0
 /// <summary>
 /// Creates a new <see cref="ComplexAttributeQueryBuilder"/> instance.
 /// </summary>
 /// <param name="miaManagement">MIAM management instance from media library.</param>
 /// <param name="complexQueryAttribute">Complex attribute, which is requested by this query. Only attributes
 /// with a cardinality different from <see cref="Cardinality.Inline"/> are allowed here.</param>
 /// <param name="selectProjectionFunction">This delegate function will be called for the selected attribute.
 /// It must return an SQL projection expression whose return value is the requested value for that attribute.
 /// If this delegate function is <c>null</c>, the actual attribute is selected without a projection function.</param>
 /// <param name="necessaryRequestedMIAs">MIAs which must be present for the media item to match the query.</param>
 /// <param name="filter">Filter which must be applied to the media items to match the query.</param>
 public ComplexAttributeQueryBuilder(
     MIA_Management miaManagement,
     MediaItemAspectMetadata.AttributeSpecification complexQueryAttribute,
     SelectProjectionFunction selectProjectionFunction,
     IEnumerable <MediaItemAspectMetadata> necessaryRequestedMIAs, IFilter filter) : base(miaManagement)
 {
     _queryAttribute           = complexQueryAttribute;
     _selectProjectionFunction = selectProjectionFunction;
     _necessaryRequestedMIAs   = necessaryRequestedMIAs;
     _filter = filter;
 }
コード例 #4
0
 /// <summary>
 /// Creates a new <see cref="ComplexAttributeQueryBuilder"/> instance.
 /// </summary>
 /// <param name="miaManagement">MIAM management instance from media library.</param>
 /// <param name="complexQueryAttribute">Complex attribute, which is requested by this query. Only attributes
 /// with a cardinality different from <see cref="Cardinality.Inline"/> are allowed here.</param>
 /// <param name="selectProjectionFunction">This delegate function will be called for the selected attribute.
 /// It must return an SQL projection expression whose return value is the requested value for that attribute.
 /// If this delegate function is <c>null</c>, the actual attribute is selected without a projection function.</param>
 /// <param name="necessaryRequestedMIAs">MIAs which must be present for the media item to match the query.</param>
 /// <param name="filter">Filter which must be applied to the media items to match the query.</param>
 public ComplexAttributeQueryBuilder(
     MIA_Management miaManagement,
     MediaItemAspectMetadata.AttributeSpecification complexQueryAttribute,
     SelectProjectionFunction selectProjectionFunction,
     IEnumerable<MediaItemAspectMetadata> necessaryRequestedMIAs, IFilter filter) : base(miaManagement)
 {
   _queryAttribute = complexQueryAttribute;
   _selectProjectionFunction = selectProjectionFunction;
   _necessaryRequestedMIAs = necessaryRequestedMIAs;
   _filter = filter;
 }
コード例 #5
0
 /// <summary>
 /// Creates a new <see cref="MainQueryBuilder"/> instance.
 /// </summary>
 /// <param name="miaManagement">MIAM management instance from media library.</param>
 /// <param name="simpleSelectAttributes">Enumeration of media item aspect attributes, given as
 /// <see cref="QueryAttribute"/> instances, which should be selected by this main query. Only attributes with
 /// cardinalities of <see cref="Cardinality.Inline"/> and <see cref="Cardinality.ManyToOne"/> are allowed here.
 /// Both necessary and optional attributes are allowed in this enumeration.</param>
 /// <param name="selectProjectionFunction">This delegate function will be called for each selected attribute.
 /// It must return an SQL projection expression whose return value is the requested value for that attribute.
 /// If this delegate function is <c>null</c>, the actual attribute is selected without a projection function.</param>
 /// <param name="necessaryRequestedMIAs">MIAs which must be present for the media item to match the query.</param>
 /// <param name="optionalRequestedMIAs">MIAs which will be returned if they are attached to items which are
 /// already returned.</param>
 /// <param name="filter">Filter to restrict the result set.</param>
 /// <param name="sortInformation">List of sorting criteria.</param>
 public MainQueryBuilder(MIA_Management miaManagement, IEnumerable <QueryAttribute> simpleSelectAttributes,
                         SelectProjectionFunction selectProjectionFunction,
                         IEnumerable <MediaItemAspectMetadata> necessaryRequestedMIAs, IEnumerable <MediaItemAspectMetadata> optionalRequestedMIAs,
                         IFilter filter, IList <SortInformation> sortInformation) : base(miaManagement)
 {
     _necessaryRequestedMIAs   = necessaryRequestedMIAs;
     _optionalRequestedMIAs    = optionalRequestedMIAs;
     _selectAttributes         = new List <QueryAttribute>(simpleSelectAttributes);
     _selectProjectionFunction = selectProjectionFunction;
     _filter          = filter;
     _sortInformation = sortInformation;
 }
コード例 #6
0
 public CompiledGroupedAttributeValueQuery(
     MIA_Management miaManagement,
     IEnumerable <MediaItemAspectMetadata> necessaryRequestedMIATypes,
     MediaItemAspectMetadata.AttributeSpecification selectedAttribute, IAttributeFilter selectAttributeFilter,
     SelectProjectionFunction selectProjectionFunction, Type projectionValueType,
     IFilter filter)
 {
     _miaManagement = miaManagement;
     _necessaryRequestedMIATypes = necessaryRequestedMIATypes;
     _selectAttribute            = selectedAttribute;
     _selectAttributeFilter      = selectAttributeFilter;
     _selectProjectionFunction   = selectProjectionFunction;
     _projectionValueType        = projectionValueType;
     _filter = filter;
 }
コード例 #7
0
 public CompiledGroupedAttributeValueQuery(
     MIA_Management miaManagement,
     IEnumerable<MediaItemAspectMetadata> necessaryRequestedMIATypes,
     MediaItemAspectMetadata.AttributeSpecification selectedAttribute, IAttributeFilter selectAttributeFilter,
     SelectProjectionFunction selectProjectionFunction, Type projectionValueType,
     IFilter filter)
 {
   _miaManagement = miaManagement;
   _necessaryRequestedMIATypes = necessaryRequestedMIATypes;
   _selectAttribute = selectedAttribute;
   _selectAttributeFilter = selectAttributeFilter;
   _selectProjectionFunction = selectProjectionFunction;
   _projectionValueType = projectionValueType;
   _filter = filter;
 }
コード例 #8
0
 /// <summary>
 /// Creates a new <see cref="MainQueryBuilder"/> instance.
 /// </summary>
 /// <param name="miaManagement">MIAM management instance from media library.</param>
 /// <param name="simpleSelectAttributes">Enumeration of media item aspect attributes, given as
 /// <see cref="QueryAttribute"/> instances, which should be selected by this main query. Only attributes with
 /// cardinalities of <see cref="Cardinality.Inline"/> and <see cref="Cardinality.ManyToOne"/> are allowed here.
 /// Both necessary and optional attributes are allowed in this enumeration.</param>
 /// <param name="selectProjectionFunction">This delegate function will be called for each selected attribute.
 /// It must return an SQL projection expression whose return value is the requested value for that attribute.
 /// If this delegate function is <c>null</c>, the actual attribute is selected without a projection function.</param>
 /// <param name="necessaryRequestedMIAs">MIAs which must be present for the media item to match the query.</param>
 /// <param name="optionalRequestedMIAs">MIAs which will be returned if they are attached to items which are
 /// already returned.</param>
 /// <param name="filter">Filter to restrict the result set.</param>
 /// <param name="sortInformation">List of sorting criteria.</param>
 public MainQueryBuilder(MIA_Management miaManagement, IEnumerable <QueryAttribute> simpleSelectAttributes,
                         SelectProjectionFunction selectProjectionFunction,
                         IEnumerable <MediaItemAspectMetadata> necessaryRequestedMIAs, IEnumerable <MediaItemAspectMetadata> optionalRequestedMIAs,
                         IFilter filter, IFilter subqueryFilter, IList <ISortInformation> sortInformation, Guid?userProfileId = null, uint?limit = null, uint?offset = null)
     : base(miaManagement)
 {
     _necessaryRequestedMIAs   = necessaryRequestedMIAs;
     _optionalRequestedMIAs    = optionalRequestedMIAs;
     _selectAttributes         = new List <QueryAttribute>(simpleSelectAttributes);
     _selectProjectionFunction = selectProjectionFunction;
     _filter          = filter;
     _subqueryFilter  = subqueryFilter;
     _sortInformation = sortInformation;
     _limit           = limit;
     _offset          = offset;
     _userProfileId   = userProfileId;
 }
コード例 #9
0
 public string GetDeclarationWithAlias(Namespace ns, SelectProjectionFunction selectProjectionFunction, out string alias)
 {
     alias = GetAlias(ns);
     return(selectProjectionFunction(_requestedTable.GetAlias(ns) + "." + _columnName) + " " + alias);
 }
コード例 #10
0
    public static CompiledGroupedAttributeValueQuery Compile(MIA_Management miaManagement,
        IEnumerable<Guid> necessaryRequestedMIATypeIDs,
        MediaItemAspectMetadata.AttributeSpecification selectAttribute, IAttributeFilter selectAttributeFilter,
        SelectProjectionFunction selectProjectionFunction, Type projectionValueType, IFilter filter)
    {
      IDictionary<Guid, MediaItemAspectMetadata> availableMIATypes = miaManagement.ManagedMediaItemAspectTypes;

      // If we're doing a complex query, we can optimize if we have an extra select attribute filter, i.e. a restriction
      // on the result set of values. See ComplexAttributeQueryBuilder.GenerateSqlGroupByStatement().
      bool simpleQuery = selectAttribute.Cardinality == Cardinality.Inline || selectAttribute.Cardinality == Cardinality.ManyToOne;
      IFilter combinedFilter = simpleQuery ?
          BooleanCombinationFilter.CombineFilters(BooleanOperator.And, new IFilter[] {filter, selectAttributeFilter}) : filter;
      selectAttributeFilter = simpleQuery ? null : selectAttributeFilter;

      ICollection<MediaItemAspectMetadata> necessaryMIATypes = new List<MediaItemAspectMetadata>();
      // Raise exception if necessary MIA types are not present
      foreach (Guid miaTypeID in necessaryRequestedMIATypeIDs)
      {
        MediaItemAspectMetadata miam;
        if (!availableMIATypes.TryGetValue(miaTypeID, out miam))
          throw new InvalidDataException("Necessary requested MIA type of ID '{0}' is not present in the media library", miaTypeID);
        necessaryMIATypes.Add(miam);
      }
      return new CompiledGroupedAttributeValueQuery(miaManagement, necessaryMIATypes, selectAttribute, selectAttributeFilter,
          selectProjectionFunction, projectionValueType, combinedFilter);
    }
コード例 #11
0
 public string GetDeclarationWithAlias(Namespace ns, SelectProjectionFunction selectProjectionFunction, out string alias)
 {
   alias = GetAlias(ns);
   return selectProjectionFunction(_requestedTable.GetAlias(ns) + "." + _columnName) + " " + alias;
 }
コード例 #12
0
 /// <summary>
 /// Creates a new <see cref="MainQueryBuilder"/> instance.
 /// </summary>
 /// <param name="miaManagement">MIAM management instance from media library.</param>
 /// <param name="simpleSelectAttributes">Enumeration of media item aspect attributes, given as
 /// <see cref="QueryAttribute"/> instances, which should be selected by this main query. Only attributes with
 /// cardinalities of <see cref="Cardinality.Inline"/> and <see cref="Cardinality.ManyToOne"/> are allowed here.
 /// Both necessary and optional attributes are allowed in this enumeration.</param>
 /// <param name="selectProjectionFunction">This delegate function will be called for each selected attribute.
 /// It must return an SQL projection expression whose return value is the requested value for that attribute.
 /// If this delegate function is <c>null</c>, the actual attribute is selected without a projection function.</param>
 /// <param name="necessaryRequestedMIAs">MIAs which must be present for the media item to match the query.</param>
 /// <param name="optionalRequestedMIAs">MIAs which will be returned if they are attached to items which are
 /// already returned.</param>
 /// <param name="filter">Filter to restrict the result set.</param>
 /// <param name="sortInformation">List of sorting criteria.</param>
 public MainQueryBuilder(MIA_Management miaManagement, IEnumerable<QueryAttribute> simpleSelectAttributes,
     SelectProjectionFunction selectProjectionFunction,
     IEnumerable<MediaItemAspectMetadata> necessaryRequestedMIAs, IEnumerable<MediaItemAspectMetadata> optionalRequestedMIAs,
     IFilter filter, IList<SortInformation> sortInformation) : base(miaManagement)
 {
   _necessaryRequestedMIAs = necessaryRequestedMIAs;
   _optionalRequestedMIAs = optionalRequestedMIAs;
   _selectAttributes = new List<QueryAttribute>(simpleSelectAttributes);
   _selectProjectionFunction = selectProjectionFunction;
   _filter = filter;
   _sortInformation = sortInformation;
 }