Ejemplo n.º 1
0
        /// ****************************************************************
        ///   public Find
        /// ----------------------------------------------------------------
        ///   <summary>
        ///   </summary>
        /// ****************************************************************
        ///
        public RelatedBusinessList Find()
        {
            if (MaxRows < 0)
            {
                throw new UDDIException(
                          ErrorType.E_fatalError,
                          "UDDI_ERROR_FATALERROR_FINDRELATEDBE_MAXROWSLESSTHANZERO");
            }

            RelatedBusinessList relatedBusinessList = new RelatedBusinessList();

            //
            // Process each find constraint.
            //
            FindBuilder find = new FindBuilder(EntityType.BusinessEntity, FindQualifiers);

            //
            // If no search arguments are specified, return an empty result
            // set.
            //

            //
            // Validate find parameters.
            //
            Utility.IsValidKey(EntityType.BusinessEntity, BusinessKey);

            // TODO: Override may be better for these calls to KeyedReference.Validate because no parent key is used

            //
            // TODO: This not an Assertion so we should not pass KeyedReferenceType.Assertion.
            //
            if (null != KeyedReference)
            {
                KeyedReference.Validate("", KeyedReferenceType.IdentifierBag);
            }

            try
            {
                //
                // Read in the find results.
                //
                SqlDataReaderAccessor      reader;
                SqlStoredProcedureAccessor sp;

                sp = find.FindRelatedBusinesses(
                    BusinessKey,
                    KeyedReference,
                    MaxRows);

                reader = sp.ExecuteReader();

                try
                {
                    while (reader.Read())
                    {
                        relatedBusinessList.RelatedBusinessInfos.Add(
                            reader.GetString("entityKey"));
                    }
                }
                finally
                {
                    reader.Close();
                }

                if (sp.Parameters.GetBool("@truncated"))
                {
                    relatedBusinessList.Truncated = Truncated.True;
                }
                else
                {
                    relatedBusinessList.Truncated = Truncated.False;
                }

                relatedBusinessList.BusinessKey = BusinessKey;

                foreach (RelatedBusinessInfo relatedBusinessInfo in relatedBusinessList.RelatedBusinessInfos)
                {
                    relatedBusinessInfo.Get(BusinessKey);
                }
            }
            catch (Exception)
            {
                find.Abort();
                throw;
            }

            return(relatedBusinessList);
        }
Ejemplo n.º 2
0
        public BindingDetail Find()
        {
            BindingDetail bindingDetail = new BindingDetail();

            QueryLog.Write(QueryType.Find, EntityType.BindingTemplate);

            //
            // Validate find parameters.
            //
            Utility.IsValidKey(EntityType.BusinessService, ServiceKey);

            //
            // Process each find constraint.
            //
            FindBuilder find = new FindBuilder(EntityType.BindingTemplate, FindQualifiers, ServiceKey);

            //
            // If no search arguments are specified, return an empty result
            // set.
            //
            if (Utility.CollectionEmpty(TModelBag))
            {
                return(bindingDetail);
            }

            try
            {
                int rows = 1;

                //
                // Find entities with matching parent key.
                //
                if (!Utility.StringEmpty(ServiceKey))
                {
                    rows = find.FindByParentKey(ServiceKey);
                }

                //
                // Find entities with matching TModel bag items.
                //
                if (!Utility.CollectionEmpty(TModelBag))
                {
                    rows = find.FindByTModelBag(TModelBag);
                }

                //
                // Process the find result set.
                //
                if (0 == rows)
                {
                    //
                    // Cleanup any temporary tables.
                    //
                    find.Abort();
                }
                else if (0 == MaxRows)
                {
                    bindingDetail.Truncated = Truncated.True;
                    return(bindingDetail);
                }
                else
                {
                    //
                    // Read in the find results.
                    //
                    SqlDataReaderAccessor      reader;
                    SqlStoredProcedureAccessor sp;
                    sp = find.RetrieveResults(MaxRows);

                    reader = sp.ExecuteReader();

                    try
                    {
                        while (reader.Read())
                        {
                            bindingDetail.BindingTemplates.Add(reader.GetGuidString("entityKey"));
                        }
                    }
                    finally
                    {
                        reader.Close();
                    }

                    if (sp.Parameters.GetBool("@truncated"))
                    {
                        bindingDetail.Truncated = Truncated.True;
                    }
                    else
                    {
                        bindingDetail.Truncated = Truncated.False;
                    }

                    foreach (BindingTemplate bindingTemplate in bindingDetail.BindingTemplates)
                    {
                        bindingTemplate.Get();
                    }
                }
            }
            catch (Exception)
            {
                find.Abort();
                throw;
            }

            return(bindingDetail);
        }
Ejemplo n.º 3
0
        public BusinessList Find()
        {
            BusinessList businessList = new BusinessList();

            QueryLog.Write(QueryType.Find, EntityType.BusinessEntity);

            //
            // Process each find constraint.
            //
            FindBuilder find = new FindBuilder(EntityType.BusinessEntity, FindQualifiers);

            //
            // If no search arguments are specified, return an empty result
            // set.
            //
            if (Utility.CollectionEmpty(Names) &&
                Utility.CollectionEmpty(DiscoveryUrls) &&
                Utility.CollectionEmpty(IdentifierBag) &&
                Utility.CollectionEmpty(CategoryBag) &&
                Utility.CollectionEmpty(TModelBag))
            {
                return(businessList);
            }

            //
            // Validate find parameters.
            //

            if (!Utility.CollectionEmpty(Names))
            {
                Names.ValidateForFind();
            }
            else
            {
                Debug.Verify(!find.CaseSensitiveMatch && !find.ExactNameMatch,
                             "UDDI_ERROR_UNSUPPORTED_FINDBE_NAMEFQNONAMES", ErrorType.E_unsupported);
            }


            //
            // TODO: Override may be better for these calls to KeyedReference.Validate because no parent key is used
            //
            if (!Utility.CollectionEmpty(IdentifierBag))
            {
                IdentifierBag.Validate("", KeyedReferenceType.IdentifierBag);
            }

            if (!Utility.CollectionEmpty(CategoryBag))
            {
                CategoryBag.Validate("", KeyedReferenceType.CategoryBag);
            }

            try
            {
                int rows = 1;

                //
                // Find entities with matching identifier bag items.
                //
                if (!Utility.CollectionEmpty(IdentifierBag))
                {
                    rows = find.FindByKeyedReferences(KeyedReferenceType.IdentifierBag, IdentifierBag);
                }

                //
                // Find entities with matching category bag items.
                //
                if (rows > 0 && !Utility.CollectionEmpty(CategoryBag))
                {
                    rows = find.FindByKeyedReferences(KeyedReferenceType.CategoryBag, CategoryBag);
                }

                //
                // Find entities with matching TModel bag items.
                //
                if (rows > 0 && !Utility.CollectionEmpty(TModelBag))
                {
                    rows = find.FindByTModelBag(TModelBag);
                }

                //
                // Find entities with matching discovery URLs
                //
                if (rows > 0 && !Utility.CollectionEmpty(DiscoveryUrls))
                {
                    rows = find.FindByDiscoveryUrls(DiscoveryUrls);
                }

                //
                // Find entities with matching names
                //
                if (rows > 0 && !Utility.CollectionEmpty(Names))
                {
                    rows = find.FindByNames(Names);
                }

                //
                // Process the find result set.
                //
                if (0 == rows)
                {
                    //
                    // Cleanup any temporary tables.
                    //
                    find.Abort();
                }                 // TODO: review
                else if (0 == MaxRows)
                {
                    businessList.Truncated = Truncated.True;
                    return(businessList);
                }
                else
                {
                    //
                    // Read in the find results.
                    //
                    SqlDataReaderAccessor      reader;
                    SqlStoredProcedureAccessor sp;
                    sp = find.RetrieveResults(MaxRows);
//
// TODO: return reader, not the whole SPA
//
                    reader = sp.ExecuteReader();

                    try
                    {
                        if (find.ServiceSubset)
                        {
                            //
                            // For a service subset search, we limit the result set
                            // to those services that matched the category bag
                            // search criteria.
                            //
                            BusinessInfo businessInfo = null;
                            string       prevKey      = null;

                            while (reader.Read())
                            {
                                string businessKey = reader.GetString("entityKey");

                                if (prevKey != businessKey)
                                {
                                    businessInfo = new BusinessInfo(businessKey);
                                    businessList.BusinessInfos.Add(businessInfo);
                                }

                                businessInfo.ServiceInfos.Add(
                                    reader.GetString("subEntityKey"),
                                    businessKey);

                                prevKey = businessKey;
                            }
                        }
                        else
                        {
                            //
                            // For non-service subset searches, we will simply
                            // return a list of businesses with all services.
                            //
                            while (reader.Read())
                            {
                                businessList.BusinessInfos.Add(reader.GetString("entityKey"));
                            }
                        }
                    }
                    finally
                    {
                        reader.Close();
                    }

                    if (sp.Parameters.GetBool("@truncated"))
                    {
                        businessList.Truncated = Truncated.True;
                    }
                    else
                    {
                        businessList.Truncated = Truncated.False;
                    }

                    //
                    // Get the actual business info and service info data.  For
                    // a service subset, we'll grab just those services that we
                    // populated.  For all other searches, we'll get all service
                    // infos.
                    //
                    if (find.ServiceSubset)
                    {
                        foreach (BusinessInfo businessInfo in businessList.BusinessInfos)
                        {
                            businessInfo.Get(false);

                            foreach (ServiceInfo serviceInfo in businessInfo.ServiceInfos)
                            {
                                serviceInfo.Get();
                            }
                        }
                    }
                    else
                    {
                        foreach (BusinessInfo businessInfo in businessList.BusinessInfos)
                        {
                            businessInfo.Get(true);
                        }
                    }
                }
            }
            catch (Exception)
            {
                find.Abort();
                throw;
            }

            return(businessList);
        }