Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1906 lines
42 KiB

  1. -- Script: uddi.net.win.uisp.sql
  2. -- Author: [email protected]
  3. -- Description: Creates UI stored procedures.
  4. -- Note: This file is best viewed and edited with a tab width of 2.
  5. -- =============================================
  6. -- Section: Cache routines
  7. -- =============================================
  8. -- =============================================
  9. -- name: UI_getSessionCache
  10. -- =============================================
  11. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'UI_getSessionCache' AND type = 'P')
  12. DROP PROCEDURE UI_getSessionCache
  13. GO
  14. CREATE PROCEDURE UI_getSessionCache
  15. @PUID nvarchar(450),
  16. @context nvarchar(20) = NULL
  17. WITH ENCRYPTION
  18. AS
  19. BEGIN
  20. IF NOT EXISTS (SELECT * FROM [UDS_sessionCache] WHERE [PUID] = @PUID AND [context] = @context)
  21. RETURN 1
  22. SELECT
  23. [cacheValue]
  24. FROM
  25. [UDS_sessionCache]
  26. WHERE
  27. ([PUID] = @PUID) AND
  28. ([context] = @context)
  29. RETURN 0
  30. END
  31. GO
  32. -- =============================================
  33. -- name: UI_setSessionCache
  34. -- =============================================
  35. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'UI_setSessionCache' AND type = 'P')
  36. DROP PROCEDURE UI_setSessionCache
  37. GO
  38. CREATE PROCEDURE UI_setSessionCache
  39. @PUID nvarchar(450),
  40. @context nvarchar(20) = NULL,
  41. @cacheValue ntext
  42. WITH ENCRYPTION
  43. AS
  44. BEGIN
  45. IF NOT EXISTS(SELECT * FROM [UDS_sessionCache] WHERE [PUID] = @PUID AND [context] = @context)
  46. BEGIN
  47. INSERT INTO [UDS_sessionCache] (
  48. [PUID],
  49. [context],
  50. [cacheValue])
  51. VALUES (
  52. @PUID,
  53. @context,
  54. @cacheValue)
  55. END
  56. ELSE
  57. BEGIN
  58. UPDATE
  59. [UDS_sessionCache]
  60. SET
  61. [cacheValue] = @cacheValue
  62. WHERE
  63. ([PUID] = @PUID) AND
  64. ([context] = @context)
  65. END
  66. RETURN 0
  67. END
  68. GO
  69. -- =============================================
  70. -- name: UI_removeSessionCache
  71. -- =============================================
  72. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'UI_removeSessionCache' AND type = 'P')
  73. DROP PROCEDURE UI_removeSessionCache
  74. GO
  75. CREATE PROCEDURE UI_removeSessionCache
  76. @PUID nvarchar(450),
  77. @context nvarchar(20) = NULL
  78. WITH ENCRYPTION
  79. AS
  80. BEGIN
  81. IF NOT EXISTS (SELECT * FROM [UDS_sessionCache] WHERE [PUID] = @PUID AND [context] = @context)
  82. RETURN 1
  83. DELETE FROM
  84. [UDS_sessionCache]
  85. WHERE
  86. ([PUID] = @PUID) AND
  87. ([context] = @context)
  88. RETURN 0
  89. END
  90. GO
  91. -- =============================================
  92. -- Section: Publisher routines
  93. -- =============================================
  94. -- =============================================
  95. -- name: UI_savePublisher
  96. -- =============================================
  97. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'UI_savePublisher' AND type = 'P')
  98. DROP PROCEDURE UI_savePublisher
  99. GO
  100. CREATE PROCEDURE UI_savePublisher
  101. @PUID nvarchar(450),
  102. @isoLangCode varchar(17) = 'en',
  103. @name nvarchar(100),
  104. @email nvarchar(450),
  105. @phone nvarchar(50),
  106. @companyName nvarchar(100) = NULL,
  107. @altPhone nvarchar(50) = NULL,
  108. @addressLine1 nvarchar(4000) = NULL,
  109. @addressLine2 nvarchar(4000) = NULL,
  110. @city nvarchar(100) = NULL,
  111. @stateProvince nvarchar(100) = NULL,
  112. @postalCode nvarchar(100) = NULL,
  113. @country nvarchar(100) = NULL,
  114. @flag int = 0,
  115. @securityToken uniqueidentifier = NULL,
  116. @tier nvarchar(256) = '2'
  117. WITH ENCRYPTION
  118. AS
  119. BEGIN
  120. DECLARE
  121. @error int,
  122. @context nvarchar(4000)
  123. IF 0 = LEN( RTRIM( LTRIM( @PUID ) ) )--blank PUID
  124. BEGIN
  125. SET @error = 60150 -- E_unknownUser
  126. SET @context = 'PUID can not be blank or null. Please re-login.'
  127. GOTO errorLabel
  128. END
  129. IF EXISTS(SELECT [PUID] FROM [UDO_publishers] WHERE [PUID]=@PUID)
  130. BEGIN
  131. UPDATE
  132. [UDO_publishers]
  133. SET
  134. [publisherStatusID] = dbo.publisherStatusID('loggedIn'),
  135. [email] = LTRIM(@email),
  136. [name] = @name,
  137. [phone] = @phone,
  138. [isoLangCode] = @isoLangCode,
  139. [companyName] = @companyName,
  140. [addressLine1] = @addressLine1,
  141. [addressLine2] = @addressLine2,
  142. [city] = @city,
  143. [stateProvince] = @stateProvince,
  144. [postalCode] = @postalCode,
  145. [country] = @country,
  146. [flag] = @flag,
  147. [securityToken] = @securityToken,
  148. [altPhone] = @altPhone
  149. WHERE
  150. [PUID] = @PUID
  151. END
  152. ELSE
  153. BEGIN
  154. INSERT [UDO_publishers] (
  155. [publisherStatusID],
  156. [PUID],
  157. [isoLangCode],
  158. [name],
  159. [email],
  160. [phone],
  161. [altPhone],
  162. [addressLine1],
  163. [addressLine2],
  164. [city],
  165. [stateProvince],
  166. [country],
  167. [flag],
  168. [securityToken],
  169. [postalCode],
  170. [companyName])
  171. VALUES (
  172. dbo.publisherStatusID('loggedIn'),
  173. @PUID,
  174. @isoLangCode,
  175. @name,
  176. LTRIM(@email),
  177. @phone,
  178. @altPhone,
  179. @addressLine1,
  180. @addressLine2,
  181. @city,
  182. @stateProvince,
  183. @country,
  184. @flag,
  185. @securityToken,
  186. @postalCode,
  187. @companyName)
  188. EXEC ADM_setPublisherTier @PUID, @tier
  189. END
  190. RETURN 0
  191. errorLabel:
  192. RAISERROR (@error, 16, 1, @context)
  193. RETURN 1
  194. END
  195. GO
  196. -- =============================================
  197. -- Name: UI_getPublisher
  198. -- =============================================
  199. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'UI_getPublisher' AND type = 'P')
  200. DROP PROCEDURE UI_getPublisher
  201. GO
  202. CREATE PROCEDURE UI_getPublisher
  203. @PUID nvarchar(450)
  204. WITH ENCRYPTION
  205. AS
  206. BEGIN
  207. SELECT
  208. [PUID],
  209. [isoLangCode],
  210. [name],
  211. [email],
  212. [phone],
  213. [companyName],
  214. [altphone],
  215. [addressLine1],
  216. [addressLine2],
  217. [city],
  218. [stateProvince],
  219. [postalCode],
  220. [country],
  221. [flag],
  222. [securityToken]
  223. FROM
  224. UDO_publishers
  225. WHERE
  226. PUID = @PUID
  227. END
  228. GO
  229. -- =============================================
  230. -- Name: UI_getPublisherFromSecurityToken
  231. -- =============================================
  232. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'UI_getPublisherFromSecurityToken' AND type = 'P')
  233. DROP PROCEDURE UI_getPublisherFromSecurityToken
  234. GO
  235. CREATE PROCEDURE UI_getPublisherFromSecurityToken
  236. @securityToken uniqueidentifier,
  237. @PUID nvarchar(450) OUTPUT
  238. WITH ENCRYPTION
  239. AS
  240. BEGIN
  241. SELECT
  242. @PUID = [PUID]
  243. FROM
  244. [UDO_publishers]
  245. WHERE
  246. [securityToken] = @securityToken
  247. END
  248. GO
  249. -- =============================================
  250. -- Name: UI_validatePublisher
  251. -- =============================================
  252. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'UI_validatePublisher' AND type = 'P')
  253. DROP PROCEDURE UI_validatePublisher
  254. GO
  255. CREATE PROCEDURE UI_validatePublisher
  256. @PUID nvarchar(450)
  257. WITH ENCRYPTION
  258. AS
  259. BEGIN
  260. DECLARE
  261. @flag int
  262. IF dbo.publisherExists(@PUID) = 0
  263. RETURN 10150
  264. IF dbo.getPublisherStatus(@PUID) <> 'loggedIn'
  265. RETURN 10110
  266. SELECT
  267. @flag = [flag]
  268. FROM
  269. UDO_publishers
  270. WHERE
  271. PUID = @PUID
  272. IF ((@flag & 0x01) <> 0x01)
  273. RETURN 50013
  274. RETURN 0
  275. END
  276. GO
  277. -- =============================================
  278. -- Section: taxonomy routines
  279. -- =============================================
  280. -- =============================================
  281. -- Name: UI_getUnhostedTaxonomyTModels
  282. -- =============================================
  283. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'UI_getUnhostedTaxonomyTModels' AND type = 'P')
  284. DROP PROCEDURE UI_getUnhostedTaxonomyTModels
  285. GO
  286. CREATE PROCEDURE UI_getUnhostedTaxonomyTModels
  287. WITH ENCRYPTION
  288. AS
  289. BEGIN
  290. SELECT DISTINCT
  291. TM.[tModelKey],
  292. TM.[name]
  293. FROM
  294. [UDC_tModels] TM
  295. INNER JOIN [UDC_categoryBag_TM] CB ON TM.[tModelID] = CB.[tModelID]
  296. LEFT OUTER JOIN [UDT_taxonomies] TX ON TM.[tModelKey] = TX.[tModelKey]
  297. WHERE
  298. CB.[tModelKey] = '{C1ACF26D-9672-4404-9D70-39B756E62AB4}' AND
  299. CB.[keyValue] = 'categorization' AND
  300. TX.[taxonomyID] IS NULL
  301. END
  302. GO
  303. -- =============================================
  304. -- name: UI_getTaxonomies
  305. -- =============================================
  306. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'UI_getTaxonomies' AND type = 'P')
  307. DROP PROCEDURE UI_getTaxonomies
  308. GO
  309. CREATE PROCEDURE UI_getTaxonomies
  310. @tModelKey uniqueidentifier = NULL
  311. WITH ENCRYPTION
  312. AS
  313. BEGIN
  314. IF @tModelKey IS NULL
  315. SELECT
  316. TX.[taxonomyID],
  317. TX.[tModelKey],
  318. TM.[name] AS [description],
  319. TX.[flag]
  320. FROM
  321. [UDT_taxonomies] TX
  322. JOIN [UDC_tModels] TM ON TX.[tModelKey] = TM.[tModelKey]
  323. ELSE
  324. SELECT
  325. TX.[taxonomyID],
  326. TX.[tModelKey],
  327. TM.[name] AS [description],
  328. TX.[flag]
  329. FROM
  330. [UDT_taxonomies] TX
  331. JOIN [UDC_tModels] TM ON TX.[tModelKey] = TM.[tModelKey]
  332. WHERE
  333. TX.[tModelKey] = @tModelKey
  334. RETURN @@ROWCOUNT
  335. END
  336. GO
  337. -- =============================================
  338. -- name: UI_getBrowsableTaxonomies
  339. -- =============================================
  340. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'UI_getBrowsableTaxonomies' AND type = 'P')
  341. DROP PROCEDURE UI_getBrowsableTaxonomies
  342. GO
  343. CREATE PROCEDURE UI_getBrowsableTaxonomies
  344. @tModelKey uniqueidentifier = NULL
  345. WITH ENCRYPTION
  346. AS
  347. BEGIN
  348. IF @tModelKey IS NULL
  349. BEGIN
  350. SELECT
  351. TX.[taxonomyID],
  352. TX.[tModelKey],
  353. TM.[name] AS [description],
  354. TX.[flag]
  355. FROM
  356. [UDT_taxonomies] TX
  357. JOIN [UDC_tModels] TM ON TX.[tModelKey] = TM.[tModelKey]
  358. WHERE
  359. (TX.[flag] & 0x2) <> 0
  360. END
  361. ELSE
  362. BEGIN
  363. SELECT
  364. TX.[taxonomyID],
  365. TX.[tModelKey],
  366. TM.[name] AS [description],
  367. TX.[flag]
  368. FROM
  369. [UDT_taxonomies] TX
  370. JOIN [UDC_tModels] TM ON TX.[tModelKey] = TM.[tModelKey]
  371. WHERE
  372. (TX.[tModelKey] = @tModelKey) AND
  373. (TX.[flag] & 0x2) <> 0
  374. END
  375. RETURN @@ROWCOUNT
  376. END
  377. GO
  378. -- =============================================
  379. -- name: UI_getTaxonomyChildrenNode
  380. -- =============================================
  381. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'UI_getTaxonomyChildrenNode' AND type = 'P')
  382. DROP PROCEDURE UI_getTaxonomyChildrenNode
  383. GO
  384. CREATE PROCEDURE UI_getTaxonomyChildrenNode
  385. @taxonomyID int,
  386. @node nvarchar(450)
  387. WITH ENCRYPTION
  388. AS
  389. BEGIN
  390. SELECT
  391. *
  392. FROM
  393. [UDT_taxonomyValues]
  394. WHERE
  395. ([taxonomyID] = @taxonomyID) AND
  396. ([parentKeyValue] = @node)
  397. ORDER BY
  398. [keyName]
  399. RETURN @@ROWCOUNT
  400. END
  401. GO
  402. -- =============================================
  403. -- name: UI_isNodeValidForClassification
  404. -- =============================================
  405. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'UI_isNodeValidForClassification' AND type = 'P')
  406. DROP PROCEDURE UI_isNodeValidForClassification
  407. GO
  408. CREATE PROCEDURE UI_isNodeValidForClassification
  409. @taxonomyID int,
  410. @node nvarchar(450)
  411. WITH ENCRYPTION
  412. AS
  413. BEGIN
  414. SELECT
  415. [valid]
  416. FROM
  417. [UDT_taxonomyValues]
  418. WHERE
  419. ([taxonomyID] = @taxonomyID) AND
  420. ([keyValue] = @node)
  421. RETURN 0
  422. END
  423. GO
  424. -- =============================================
  425. -- name: UI_isTaxonomyBrowsable
  426. -- =============================================
  427. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'UI_isTaxonomyBrowsable' AND type = 'P')
  428. DROP PROCEDURE UI_isTaxonomyBrowsable
  429. GO
  430. CREATE PROCEDURE UI_isTaxonomyBrowsable
  431. @TModelKey uniqueidentifier,
  432. @isBrowsable bit = 0 OUTPUT
  433. WITH ENCRYPTION
  434. AS
  435. BEGIN
  436. DECLARE
  437. @error int,
  438. @context char(255),
  439. @flag int
  440. SET @isBrowsable = 0
  441. SELECT
  442. @flag = [flag]
  443. FROM
  444. [UDT_taxonomies]
  445. WHERE
  446. ([tModelKey] = @tModelKey)
  447. IF (@flag IS NULL)
  448. BEGIN
  449. SET @error = 60210 --E_InvalidKeyPassed
  450. SET @context = 'tModelKey uuid:' + dbo.UUIDSTR(@tModelKey)
  451. GOTO errorLabel
  452. END
  453. IF ( @flag & 0x2 ) = 0x2
  454. SET @isBrowsable = 1
  455. ELSE
  456. SET @isBrowsable = 0
  457. RETURN 0
  458. errorLabel:
  459. RAISERROR (@error, 16, 1, @context)
  460. RETURN 1
  461. END
  462. GO
  463. -- =============================================
  464. -- name: UI_setTaxonomyBrowsable
  465. -- =============================================
  466. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'UI_setTaxonomyBrowsable' AND type = 'P')
  467. DROP PROCEDURE UI_setTaxonomyBrowsable
  468. GO
  469. CREATE PROCEDURE UI_setTaxonomyBrowsable
  470. @tModelKey uniqueidentifier,
  471. @enabled bit = 0
  472. WITH ENCRYPTION
  473. AS
  474. BEGIN
  475. DECLARE
  476. @error int,
  477. @context char(255),
  478. @flag int
  479. SELECT
  480. @flag = [flag]
  481. FROM
  482. [UDT_taxonomies]
  483. WHERE
  484. ([tModelKey] = @tModelKey)
  485. IF @flag IS NULL
  486. BEGIN
  487. SET @error = 60210 --E_InvalidKeyPassed
  488. SET @context = 'tModelKey uuid:' + dbo.UUIDSTR(@tmodelKey)
  489. GOTO errorLabel
  490. END
  491. IF (1 = @enabled)
  492. SET @flag = @flag | 0x2
  493. ELSE
  494. BEGIN
  495. -- Remove bit 0x4
  496. IF ( @flag & 0x2 ) = 0x2
  497. BEGIN
  498. SET @flag = @flag ^ 0x2
  499. END
  500. END
  501. -- run update
  502. UPDATE
  503. [UDT_taxonomies]
  504. SET
  505. [flag] = @flag
  506. WHERE
  507. ([tModelKey] = @tModelKey)
  508. RETURN 0
  509. errorLabel:
  510. RAISERROR (@error, 16, 1, @context)
  511. RETURN 1
  512. END
  513. GO
  514. -- =============================================
  515. -- name: UI_getTaxonomyChildrenRoot
  516. -- =============================================
  517. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'UI_getTaxonomyChildrenRoot' AND type = 'P')
  518. DROP PROCEDURE UI_getTaxonomyChildrenRoot
  519. GO
  520. CREATE PROCEDURE UI_getTaxonomyChildrenRoot
  521. @taxonomyID int
  522. WITH ENCRYPTION
  523. AS
  524. BEGIN
  525. SELECT
  526. *
  527. FROM
  528. [UDT_taxonomyValues]
  529. WHERE
  530. ([taxonomyID]=@taxonomyID) AND
  531. ([parentKeyValue]='')
  532. ORDER BY
  533. [keyName]
  534. RETURN @@ROWCOUNT
  535. END
  536. GO
  537. -- =============================================
  538. -- name: UI_getTaxonomyName
  539. -- =============================================
  540. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'UI_getTaxonomyName' AND type = 'P')
  541. DROP PROCEDURE UI_getTaxonomyName
  542. GO
  543. CREATE PROCEDURE UI_getTaxonomyName
  544. @TaxonomyID int,
  545. @ID varchar(450)
  546. WITH ENCRYPTION
  547. AS
  548. BEGIN
  549. SELECT
  550. [KeyName]
  551. FROM
  552. [UDT_taxonomyValues]
  553. WHERE
  554. ([taxonomyID]=@TaxonomyID) AND
  555. ([keyValue]=@ID)
  556. END
  557. GO
  558. -- =============================================
  559. -- name: UI_getTaxonomyParent
  560. -- =============================================
  561. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'UI_getTaxonomyParent' AND type = 'P')
  562. DROP PROCEDURE UI_getTaxonomyParent
  563. GO
  564. CREATE PROCEDURE UI_getTaxonomyParent
  565. @TaxonomyID int,
  566. @ID varchar(450)
  567. WITH ENCRYPTION
  568. AS
  569. BEGIN
  570. SELECT
  571. [parentKeyValue]
  572. FROM
  573. [UDT_taxonomyValues]
  574. WHERE
  575. ([taxonomyID]=@TaxonomyID) AND
  576. ([keyValue]=@ID)
  577. END
  578. GO
  579. -- =============================================
  580. -- Section: identifier routines
  581. -- =============================================
  582. -- =============================================
  583. -- name: UI_getIdentifierTModels
  584. -- =============================================
  585. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'UI_getIdentifierTModels' AND type = 'P')
  586. DROP PROCEDURE UI_getIdentifierTModels
  587. GO
  588. CREATE PROCEDURE UI_getIdentifierTModels
  589. WITH ENCRYPTION
  590. AS
  591. BEGIN
  592. SELECT DISTINCT
  593. TM.[tModelKey],
  594. TM.[name]
  595. FROM
  596. [UDC_categoryBag_TM] CB
  597. INNER JOIN
  598. [UDC_tModels] TM
  599. ON
  600. TM.tModelID = CB.tModelID
  601. WHERE
  602. CB.[tModelKey] = '{C1ACF26D-9672-4404-9D70-39B756E62AB4}' AND
  603. CB.[keyValue] = 'identifier' AND
  604. TM.[flag] = 0
  605. RETURN @@ROWCOUNT
  606. END
  607. GO
  608. -- =============================================
  609. -- Section: Statistics routines
  610. -- =============================================
  611. -- =============================================
  612. -- Name: UI_getEntityCounts
  613. -- =============================================
  614. IF EXISTS (SELECT name FROM sysobjects WHERE name = N'UI_getEntityCounts' AND type = 'P')
  615. DROP PROCEDURE UI_getEntityCounts
  616. GO
  617. CREATE PROCEDURE UI_getEntityCounts
  618. WITH ENCRYPTION
  619. AS
  620. BEGIN
  621. DECLARE
  622. @error int,
  623. @context nvarchar(4000),
  624. @count bigint,
  625. @reportID sysname,
  626. @reportStatusID tinyint,
  627. @RC int
  628. DECLARE @results TABLE(
  629. [sortOrder] int,
  630. [section] nvarchar(250),
  631. [label] nvarchar(250),
  632. [value] nvarchar(3500))
  633. SET @reportID = 'UI_getEntityCounts'
  634. IF dbo.isReportRunning( @reportID, GETDATE() ) = 1
  635. RETURN 0
  636. SET @reportStatusID = dbo.reportStatusID('Processing')
  637. EXEC @RC=net_report_update @reportID, @reportStatusID
  638. IF @RC<> 0
  639. BEGIN
  640. SET @error=50006 -- E_subProcFailure
  641. SET @context=''
  642. GOTO errorLabel
  643. END
  644. DELETE
  645. [UDO_reportLines]
  646. WHERE
  647. ([reportID] = @reportID)
  648. INSERT [UDO_reportLines] (
  649. [reportID],
  650. [section],
  651. [label],
  652. [value])
  653. VALUES(
  654. @reportID,
  655. 'HEADING_STATISTICS_LABEL_RECALCINPROGRESS',
  656. 'HEADING_STATISTICS_LABEL_RECALCINPROGRESS',
  657. '')
  658. -- Calculate tModel count
  659. SELECT @count = COUNT(*) FROM [UDC_tModels] WHERE [flag] = 0
  660. INSERT @results VALUES(
  661. 1,
  662. N'HEADING_STATISTICS_SECTION_ENTITYCOUNTS',
  663. N'HEADING_STATISTICS_LABEL_TMODELCOUNT',
  664. @count)
  665. -- Calculate businessEntity count
  666. SELECT @count = COUNT(*) FROM [UDC_businessEntities]
  667. INSERT @results VALUES(
  668. 2,
  669. N'HEADING_STATISTICS_SECTION_ENTITYCOUNTS',
  670. N'HEADING_STATISTICS_LABEL_BUSINESSCOUNT',
  671. @count)
  672. -- Calculate businessService count
  673. SELECT @count = COUNT(*) FROM [UDC_businessServices]
  674. INSERT @results VALUES(
  675. 3,
  676. N'HEADING_STATISTICS_SECTION_ENTITYCOUNTS',
  677. N'HEADING_STATISTICS_LABEL_SERVICECOUNT',
  678. @count)
  679. -- Calculate bindingTemplate count
  680. SELECT @count = COUNT(*) FROM [UDC_bindingTemplates]
  681. INSERT @results VALUES(
  682. 4,
  683. N'HEADING_STATISTICS_SECTION_ENTITYCOUNTS',
  684. N'HEADING_STATISTICS_LABEL_BINDINGCOUNT',
  685. @count)
  686. BEGIN TRANSACTION
  687. DELETE
  688. [UDO_reportLines]
  689. WHERE
  690. ([reportID] = @reportID)
  691. INSERT [UDO_reportLines](
  692. [reportID],
  693. [section],
  694. [label],
  695. [value])
  696. SELECT
  697. @reportID,
  698. [section],
  699. [label],
  700. [value]
  701. FROM
  702. @results
  703. ORDER BY
  704. [section],
  705. [sortOrder]
  706. COMMIT TRANSACTION
  707. SET @reportStatusID = dbo.reportStatusID('Available')
  708. EXEC @RC=net_report_update @reportID, @reportStatusID
  709. IF @RC<> 0
  710. BEGIN
  711. SET @error=50006
  712. SET @context=''
  713. GOTO errorLabel
  714. END
  715. RETURN 0
  716. errorLabel:
  717. RAISERROR (@error, 16, 1, @context)
  718. RETURN 1
  719. END -- UI_getEntityCounts
  720. GO
  721. -- =============================================
  722. -- Name: UI_getPublisherStats
  723. -- =============================================
  724. IF EXISTS (SELECT name FROM sysobjects WHERE name = N'UI_getPublisherStats' AND type = 'P')
  725. DROP PROCEDURE UI_getPublisherStats
  726. GO
  727. CREATE PROCEDURE UI_getPublisherStats
  728. WITH ENCRYPTION
  729. AS
  730. BEGIN
  731. DECLARE
  732. @error int,
  733. @context nvarchar(4000),
  734. @count bigint,
  735. @reportID sysname,
  736. @reportStatusID tinyint,
  737. @RC int
  738. DECLARE @results TABLE(
  739. [sortOrder] int,
  740. [section] nvarchar(250),
  741. [label] nvarchar(250),
  742. [value] nvarchar(3500))
  743. SET @reportID = 'UI_getPublisherStats'
  744. IF dbo.isReportRunning( @reportID, GETDATE() ) = 1
  745. RETURN 0
  746. SET @reportStatusID = dbo.reportStatusID('Processing')
  747. EXEC @RC=net_report_update @reportID, @reportStatusID
  748. IF @RC<> 0
  749. BEGIN
  750. SET @error=50006 -- E_subProcFailure
  751. SET @context=''
  752. GOTO errorLabel
  753. END
  754. DELETE
  755. [UDO_reportLines]
  756. WHERE
  757. ([reportID] = @reportID)
  758. INSERT [UDO_reportLines] (
  759. [reportID],
  760. [section],
  761. [label],
  762. [value])
  763. VALUES(
  764. @reportID,
  765. 'HEADING_STATISTICS_LABEL_RECALCINPROGRESS',
  766. 'HEADING_STATISTICS_LABEL_RECALCINPROGRESS',
  767. '')
  768. -- Calculate publisher count
  769. SELECT @count = COUNT(*) FROM [UDO_publishers]
  770. INSERT @results VALUES(
  771. 1,
  772. N'HEADING_STATISTICS_SECTION_PUBSTATS',
  773. N'HEADING_STATISTICS_LABEL_PUBCOUNT',
  774. CAST(@count AS nvarchar(3500)))
  775. -- Calculate publishers with active publications
  776. DECLARE @publishers TABLE(
  777. [publisherID] int)
  778. INSERT @publishers (
  779. [publisherID])
  780. SELECT DISTINCT
  781. [publisherID]
  782. FROM
  783. [UDC_tModels]
  784. WHERE
  785. ([flag] = 0)
  786. INSERT @publishers (
  787. [publisherID])
  788. SELECT DISTINCT
  789. [publisherID]
  790. FROM
  791. [UDC_businessEntities]
  792. SELECT @count = COUNT(DISTINCT [publisherID]) FROM @publishers
  793. INSERT @results VALUES(
  794. 2,
  795. N'HEADING_STATISTICS_SECTION_PUBSTATS',
  796. N'HEADING_STATISTICS_LABEL_PUBWITHPUB',
  797. CAST(@count AS nvarchar(3500)))
  798. BEGIN TRANSACTION
  799. DELETE
  800. [UDO_reportLines]
  801. WHERE
  802. ([reportID] = @reportID)
  803. INSERT [UDO_reportLines](
  804. [reportID],
  805. [section],
  806. [label],
  807. [value])
  808. SELECT
  809. @reportID,
  810. [section],
  811. [label],
  812. [value]
  813. FROM
  814. @results
  815. ORDER BY
  816. [section],
  817. [sortOrder]
  818. COMMIT TRANSACTION
  819. SET @reportStatusID = dbo.reportStatusID('Available')
  820. EXEC @RC=net_report_update @reportID, @reportStatusID
  821. IF @RC<> 0
  822. BEGIN
  823. SET @error=50006
  824. SET @context=''
  825. GOTO errorLabel
  826. END
  827. RETURN 0
  828. errorLabel:
  829. RAISERROR (@error, 16, 1, @context)
  830. RETURN 1
  831. END -- UI_getPublisherStats
  832. GO
  833. -- =============================================
  834. -- Name: UI_getTopPublishers
  835. -- =============================================
  836. IF EXISTS (SELECT name FROM sysobjects WHERE name = N'UI_getTopPublishers' AND type = 'P')
  837. DROP PROCEDURE UI_getTopPublishers
  838. GO
  839. CREATE PROCEDURE UI_getTopPublishers
  840. WITH ENCRYPTION
  841. AS
  842. BEGIN
  843. DECLARE
  844. @error int,
  845. @context nvarchar(4000),
  846. @count int,
  847. @reportID sysname,
  848. @reportStatusID tinyint,
  849. @RC int
  850. DECLARE @results TABLE(
  851. [sortOrder] int,
  852. [section] nvarchar(250),
  853. [label] nvarchar(250),
  854. [value] bigint)
  855. SET @reportID = 'UI_getTopPublishers'
  856. IF dbo.isReportRunning( @reportID, GETDATE() ) = 1
  857. RETURN 0
  858. SET @reportStatusID = dbo.reportStatusID('Processing')
  859. EXEC @RC=net_report_update @reportID, @reportStatusID
  860. IF @RC<> 0
  861. BEGIN
  862. SET @error=50006 -- E_subProcFailure
  863. SET @context=''
  864. GOTO errorLabel
  865. END
  866. DELETE
  867. [UDO_reportLines]
  868. WHERE
  869. ([reportID] = @reportID)
  870. INSERT [UDO_reportLines] (
  871. [reportID],
  872. [section],
  873. [label],
  874. [value])
  875. VALUES(
  876. @reportID,
  877. 'HEADING_STATISTICS_LABEL_RECALCINPROGRESS',
  878. 'HEADING_STATISTICS_LABEL_RECALCINPROGRESS',
  879. '')
  880. -- Calculate top 10 tModel publishers
  881. INSERT @results (
  882. [sortOrder],
  883. [section],
  884. [label],
  885. [value])
  886. SELECT TOP 10
  887. 1,
  888. N'HEADING_STATISTICS_LABEL_TMODELCOUNT',
  889. PU.[name],
  890. COUNT(PU.[name])
  891. FROM
  892. [UDO_publishers] PU
  893. JOIN [UDC_tModels] TM ON PU.[publisherID] = TM.[publisherID]
  894. WHERE
  895. (TM.[flag] = 0)
  896. GROUP BY
  897. PU.[name]
  898. ORDER BY
  899. 4 DESC
  900. -- Calculate top 10 businessEntity publishers
  901. INSERT @results (
  902. [sortOrder],
  903. [section],
  904. [label],
  905. [value])
  906. SELECT TOP 10
  907. 2,
  908. N'HEADING_STATISTICS_LABEL_BUSINESSCOUNT',
  909. PU.[name],
  910. COUNT(PU.[name])
  911. FROM
  912. [UDO_publishers] PU
  913. JOIN [UDC_businessEntities] BE ON PU.[publisherID] = BE.[publisherID]
  914. GROUP BY
  915. PU.[name]
  916. ORDER BY
  917. 4 DESC
  918. -- Calculate top 10 businessService publishers
  919. INSERT @results (
  920. [sortOrder],
  921. [section],
  922. [label],
  923. [value])
  924. SELECT TOP 10
  925. 3,
  926. N'HEADING_STATISTICS_LABEL_SERVICECOUNT',
  927. PU.[name],
  928. COUNT(PU.[name])
  929. FROM
  930. [UDO_publishers] PU
  931. JOIN [UDC_businessEntities] BE ON PU.[publisherID] = BE.[publisherID]
  932. JOIN [UDC_businessServices] BS ON BE.[businessID] = BS.[businessID]
  933. GROUP BY
  934. PU.[name]
  935. ORDER BY
  936. 4 DESC
  937. -- Calculate top 10 bindingTemplate publishers
  938. INSERT @results (
  939. [sortOrder],
  940. [section],
  941. [label],
  942. [value])
  943. SELECT TOP 10
  944. 4,
  945. N'HEADING_STATISTICS_LABEL_BINDINGCOUNT',
  946. PU.[name],
  947. COUNT(PU.[name])
  948. FROM
  949. [UDO_publishers] PU
  950. JOIN [UDC_businessEntities] BE ON PU.[publisherID] = BE.[publisherID]
  951. JOIN [UDC_businessServices] BS ON BE.[businessID] = BS.[businessID]
  952. JOIN [UDC_bindingTemplates] BT ON BS.[serviceID] = BT.[serviceID]
  953. GROUP BY
  954. PU.[name]
  955. ORDER BY
  956. 4 DESC
  957. BEGIN TRANSACTION
  958. DELETE
  959. [UDO_reportLines]
  960. WHERE
  961. ([reportID] = @reportID)
  962. INSERT [UDO_reportLines](
  963. [reportID],
  964. [section],
  965. [label],
  966. [value])
  967. SELECT
  968. @reportID,
  969. [section],
  970. [label],
  971. CAST([value] AS nvarchar(3500))
  972. FROM
  973. @results
  974. ORDER BY
  975. [sortOrder]
  976. COMMIT TRANSACTION
  977. SET @reportStatusID = dbo.reportStatusID('Available')
  978. EXEC @RC=net_report_update @reportID, @reportStatusID
  979. IF @RC<> 0
  980. BEGIN
  981. SET @error=50006
  982. SET @context=''
  983. GOTO errorLabel
  984. END
  985. RETURN 0
  986. errorLabel:
  987. RAISERROR (@error, 16, 1, @context)
  988. RETURN 1
  989. END -- UI_getTopPublishers
  990. GO
  991. -- =============================================
  992. -- Name: UI_getTaxonomyStats
  993. -- =============================================
  994. IF EXISTS (SELECT name FROM sysobjects WHERE name = N'UI_getTaxonomyStats' AND type = 'P')
  995. DROP PROCEDURE UI_getTaxonomyStats
  996. GO
  997. CREATE PROCEDURE UI_getTaxonomyStats
  998. WITH ENCRYPTION
  999. AS
  1000. BEGIN
  1001. DECLARE
  1002. @error int,
  1003. @context nvarchar(4000),
  1004. @count int,
  1005. @taxCursor cursor,
  1006. @taxCursorStatus int,
  1007. @taxonomyID int,
  1008. @tModelKey uniqueidentifier,
  1009. @sortOrder int,
  1010. @section nvarchar(250),
  1011. @label nvarchar(250),
  1012. @value nvarchar(3500),
  1013. @valCursor cursor,
  1014. @valCursorStatus int,
  1015. @keyValue nvarchar(128),
  1016. @keyName nvarchar(128),
  1017. @reportID sysname,
  1018. @reportStatusID tinyint,
  1019. @RC int
  1020. DECLARE @results TABLE(
  1021. [sortOrder] int,
  1022. [section] nvarchar(250),
  1023. [label] nvarchar(250),
  1024. [value] nvarchar(3500))
  1025. DECLARE @taxCounts TABLE(
  1026. [taxonomyID] bigint,
  1027. [tModelKey] uniqueidentifier,
  1028. [count] bigint)
  1029. DECLARE @valCounts TABLE(
  1030. [keyName] nvarchar(128),
  1031. [keyValue] nvarchar(128),
  1032. [count] bigint)
  1033. SET @reportID = 'UI_getTaxonomyStats'
  1034. IF dbo.isReportRunning( @reportID, GETDATE() ) = 1
  1035. RETURN 0
  1036. SET @reportStatusID = dbo.reportStatusID('Processing')
  1037. EXEC @RC=net_report_update @reportID, @reportStatusID
  1038. IF @RC<> 0
  1039. BEGIN
  1040. SET @error=50006 -- E_subProcFailure
  1041. SET @context=''
  1042. GOTO errorLabel
  1043. END
  1044. DELETE
  1045. [UDO_reportLines]
  1046. WHERE
  1047. ([reportID] = @reportID)
  1048. INSERT [UDO_reportLines] (
  1049. [reportID],
  1050. [section],
  1051. [label],
  1052. [value])
  1053. VALUES(
  1054. @reportID,
  1055. 'HEADING_STATISTICS_LABEL_RECALCINPROGRESS',
  1056. 'HEADING_STATISTICS_LABEL_RECALCINPROGRESS',
  1057. '')
  1058. -- Loop through each taxonomy and calculate the total number of references
  1059. SET @taxCursor = CURSOR LOCAL FORWARD_ONLY READ_ONLY FOR
  1060. SELECT
  1061. [taxonomyID],
  1062. [tModelKey]
  1063. FROM
  1064. [UDT_taxonomies]
  1065. OPEN @taxCursor
  1066. FETCH NEXT FROM @taxCursor INTO
  1067. @taxonomyID,
  1068. @tModelKey
  1069. SET @taxCursorStatus = @@FETCH_STATUS
  1070. WHILE @taxCursorStatus = 0
  1071. BEGIN
  1072. SET @count = 0
  1073. -- Calculate the number of categorizations for tModels
  1074. SELECT
  1075. @count = @count + COUNT(*)
  1076. FROM
  1077. [UDC_categoryBag_TM]
  1078. WHERE
  1079. ([tModelKey] = @tModelKey)
  1080. SELECT
  1081. @count = @count + COUNT(*)
  1082. FROM
  1083. [UDC_identifierBag_TM]
  1084. WHERE
  1085. ([tModelKey] = @tModelKey)
  1086. -- Calculate the number of categorizations for businessEntities
  1087. SELECT
  1088. @count = @count + COUNT(*)
  1089. FROM
  1090. [UDC_categoryBag_BE]
  1091. WHERE
  1092. ([tModelKey] = @tModelKey)
  1093. SELECT
  1094. @count = @count + COUNT(*)
  1095. FROM
  1096. [UDC_identifierBag_BE]
  1097. WHERE
  1098. ([tModelKey] = @tModelKey)
  1099. -- Calculate the number of categorizations for businessServices
  1100. SELECT
  1101. @count = @count + COUNT(*)
  1102. FROM
  1103. [UDC_categoryBag_BS]
  1104. WHERE
  1105. ([tModelKey] = @tModelKey)
  1106. INSERT @taxCounts(
  1107. [taxonomyID],
  1108. [tModelKey],
  1109. [count])
  1110. VALUES(
  1111. @taxonomyID,
  1112. @tModelKey,
  1113. @count)
  1114. FETCH NEXT FROM @taxCursor INTO
  1115. @taxonomyID,
  1116. @tModelKey
  1117. SET @taxCursorStatus = @@FETCH_STATUS
  1118. END -- taxCursor
  1119. CLOSE @taxCursor
  1120. DEALLOCATE @taxCursor
  1121. -- Loop through each taxonomy sorted by total references in descending order
  1122. SET @taxCursor = CURSOR LOCAL FORWARD_ONLY READ_ONLY FOR
  1123. SELECT
  1124. [taxonomyID],
  1125. [tModelKey],
  1126. [count]
  1127. FROM
  1128. @taxCounts
  1129. ORDER BY
  1130. [count] DESC
  1131. OPEN @taxCursor
  1132. FETCH NEXT FROM @taxCursor INTO
  1133. @taxonomyID,
  1134. @tModelKey,
  1135. @count
  1136. SET @taxCursorStatus = @@FETCH_STATUS
  1137. SET @sortOrder = 0
  1138. WHILE @taxCursorStatus = 0
  1139. BEGIN
  1140. SET @sortOrder = @sortOrder + 1
  1141. SELECT
  1142. @section = [name] + ' (' + dbo.addURN(@tModelKey) +')'
  1143. FROM
  1144. [UDC_tModels]
  1145. WHERE
  1146. [tModelKey] = @tModelKey
  1147. SET @label = 'HEADING_STATISTICS_LABEL_TAXREFS'
  1148. SET @value = CAST(@count AS nvarchar(3500))
  1149. -- Add taxonomy row to results
  1150. INSERT @results VALUES(
  1151. @sortOrder,
  1152. @section,
  1153. @label,
  1154. @value)
  1155. DELETE @valCounts
  1156. -- Calculate the top ten categorizations for the current taxonomy
  1157. SET @valCursor = CURSOR LOCAL READ_ONLY FORWARD_ONLY FOR
  1158. SELECT
  1159. [keyName],
  1160. [keyValue]
  1161. FROM
  1162. [UDT_taxonomyValues]
  1163. WHERE
  1164. ([taxonomyID] = @taxonomyID)
  1165. OPEN @valCursor
  1166. FETCH NEXT FROM @valCursor INTO
  1167. @keyName,
  1168. @keyValue
  1169. SET @valCursorStatus = @@FETCH_STATUS
  1170. WHILE @valCursorStatus = 0
  1171. BEGIN
  1172. SET @count = 0
  1173. -- Calculate the number of categorizations for tModels
  1174. SELECT
  1175. @count = @count + COUNT(*)
  1176. FROM
  1177. [UDC_categoryBag_TM]
  1178. WHERE
  1179. ([tModelKey] = @tModelKey) AND ([keyValue] = @keyValue)
  1180. SELECT
  1181. @count = @count + COUNT(*)
  1182. FROM
  1183. [UDC_identifierBag_TM]
  1184. WHERE
  1185. ([tModelKey] = @tModelKey) AND ([keyValue] = @keyValue)
  1186. -- Calculate the number of categorizations for businessEntities
  1187. SELECT
  1188. @count = @count + COUNT(*)
  1189. FROM
  1190. [UDC_categoryBag_BE]
  1191. WHERE
  1192. ([tModelKey] = @tModelKey) AND ([keyValue] = @keyValue)
  1193. SELECT
  1194. @count = @count + COUNT(*)
  1195. FROM
  1196. [UDC_identifierBag_BE]
  1197. WHERE
  1198. ([tModelKey] = @tModelKey) AND ([keyValue] = @keyValue)
  1199. -- Calculate the number of categorizations for businessServices
  1200. SELECT
  1201. @count = @count + COUNT(*)
  1202. FROM
  1203. [UDC_categoryBag_BS]
  1204. WHERE
  1205. ([tModelKey] = @tModelKey) AND ([keyValue] = @keyValue)
  1206. IF (@count > 0)
  1207. BEGIN
  1208. INSERT @valCounts VALUES(
  1209. @keyName,
  1210. @keyValue,
  1211. @count)
  1212. END
  1213. FETCH NEXT FROM @valCursor INTO
  1214. @keyName,
  1215. @keyValue
  1216. SET @valCursorStatus = @@FETCH_STATUS
  1217. END -- valCursor
  1218. CLOSE @valCursor
  1219. IF (SELECT COUNT(*) FROM @valCounts) > 0
  1220. BEGIN
  1221. SET @label = 'HEADING_STATISTICS_LABEL_TAXVALREFS'
  1222. INSERT @results (
  1223. [sortOrder],
  1224. [section],
  1225. [label],
  1226. [value])
  1227. SELECT TOP 10
  1228. @sortOrder,
  1229. '-- ' + ISNULL([keyName], N'') + ' (' + [keyValue] + ')',
  1230. @label,
  1231. CAST([count] AS nvarchar(3500))
  1232. FROM
  1233. @valCounts
  1234. ORDER BY
  1235. [count] DESC
  1236. END
  1237. FETCH NEXT FROM @taxCursor INTO
  1238. @taxonomyID,
  1239. @tModelKey,
  1240. @count
  1241. SET @taxCursorStatus = @@FETCH_STATUS
  1242. END
  1243. CLOSE @taxCursor
  1244. BEGIN TRANSACTION
  1245. DELETE
  1246. [UDO_reportLines]
  1247. WHERE
  1248. ([reportID] = @reportID)
  1249. INSERT [UDO_reportLines](
  1250. [reportID],
  1251. [section],
  1252. [label],
  1253. [value])
  1254. SELECT
  1255. @reportID,
  1256. [section],
  1257. [label],
  1258. [value]
  1259. FROM
  1260. @results
  1261. ORDER BY
  1262. [sortOrder]
  1263. COMMIT TRANSACTION
  1264. SET @reportStatusID = dbo.reportStatusID('Available')
  1265. EXEC @RC=net_report_update @reportID, @reportStatusID
  1266. IF @RC<> 0
  1267. BEGIN
  1268. SET @error=50006
  1269. SET @context=''
  1270. GOTO errorLabel
  1271. END
  1272. RETURN 0
  1273. errorLabel:
  1274. RAISERROR (@error, 16, 1, @context)
  1275. RETURN 1
  1276. END -- UI_getTaxonomyStats
  1277. GO
  1278. -- =============================================
  1279. -- Section: Visual Studio Procedures
  1280. -- =============================================
  1281. -- =============================================
  1282. -- Name: VS_business_get
  1283. -- =============================================
  1284. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'VS_business_get' AND type = 'P')
  1285. DROP PROCEDURE VS_business_get
  1286. GO
  1287. CREATE PROCEDURE VS_business_get
  1288. @businessName nvarchar(450)
  1289. WITH ENCRYPTION
  1290. AS
  1291. BEGIN
  1292. DECLARE
  1293. @typesTModelKey uniqueidentifier,
  1294. @wsdlKeyValue nvarchar(255)
  1295. SET @typesTModelKey = 'C1ACF26D-9672-4404-9D70-39B756E62AB4'
  1296. SET @wsdlKeyValue = 'wsdlSpec'
  1297. DECLARE @wsdlTModelKeys TABLE (
  1298. [tModelKey] uniqueidentifier)
  1299. DECLARE @tempBusiness TABLE (
  1300. [businessID] bigint)
  1301. INSERT @wsdlTModelKeys
  1302. SELECT DISTINCT
  1303. TM.[tModelKey]
  1304. FROM
  1305. [UDC_tModels] TM
  1306. JOIN [UDC_categoryBag_TM] CB ON TM.[tModelID] = CB.[tModelID]
  1307. WHERE
  1308. (CB.[tModelKey] = @typesTModelKey) AND
  1309. (CB.[keyValue] = @wsdlKeyValue)
  1310. INSERT @tempBusiness(
  1311. [businessID])
  1312. SELECT DISTINCT
  1313. BN.[businessID]
  1314. FROM
  1315. [UDC_names_BE] BN
  1316. WHERE
  1317. (BN.[name] LIKE @businessName + '%')
  1318. SELECT DISTINCT
  1319. (SELECT TOP 1 BN.[name] FROM [UDC_names_BE] BN WHERE BN.[businessID] = BE.[businessID]) AS [name],
  1320. BE.[businessKey]
  1321. FROM
  1322. [UDC_businessEntities] BE
  1323. JOIN [UDC_businessServices] BS ON BE.[businessID] = BS.[businessID]
  1324. JOIN [UDC_bindingTemplates] BT ON BS.[serviceID] = BT.[serviceID]
  1325. JOIN [UDC_tModelInstances] TMI ON BT.[bindingID] = TMI.[bindingID]
  1326. WHERE
  1327. (BE.[businessID] IN (SELECT TB.[businessID] FROM @tempBusiness TB)) AND
  1328. (TMI.[tModelKey] IN (SELECT [tModelKey] FROM @wsdlTModelKeys))
  1329. ORDER BY
  1330. 1 ASC
  1331. RETURN @@ROWCOUNT
  1332. END -- VS_business_get
  1333. GO
  1334. -- =============================================
  1335. -- Name: VS_service_get
  1336. -- =============================================
  1337. IF EXISTS (SELECT name FROM dbo.sysobjects WHERE name = 'VS_service_get' AND type = 'P')
  1338. DROP PROCEDURE [dbo].[VS_service_get]
  1339. GO
  1340. CREATE PROCEDURE VS_service_get
  1341. @businessKey uniqueidentifier
  1342. WITH ENCRYPTION
  1343. AS
  1344. BEGIN
  1345. DECLARE
  1346. @typesTModelKey uniqueidentifier,
  1347. @wsdlKeyValue nvarchar(255)
  1348. SET @typesTModelKey = 'C1ACF26D-9672-4404-9D70-39B756E62AB4'
  1349. SET @wsdlKeyValue = 'wsdlSpec'
  1350. DECLARE @wsdlTModelKeys TABLE (
  1351. [tModelKey] uniqueidentifier)
  1352. INSERT @wsdlTModelKeys
  1353. SELECT DISTINCT
  1354. TM.[tModelKey]
  1355. FROM
  1356. [UDC_tModels] TM
  1357. JOIN [UDC_categoryBag_TM] CB ON TM.[tModelID] = CB.[tModelID]
  1358. WHERE
  1359. (CB.[tModelKey] = @typesTModelKey) AND
  1360. (CB.[keyValue] = @wsdlKeyValue)
  1361. IF @@ROWCOUNT = 0
  1362. -- There were no tModels with the wsdl categorization, so return a non-zero return code to indicate an error
  1363. RETURN -1
  1364. SELECT
  1365. (SELECT TOP 1 BN.[name] FROM [UDC_names_BE] BN WHERE BN.[businessID] = BE.[businessID]) AS [businessName],
  1366. BS.[serviceKey],
  1367. (SELECT TOP 1 SN.[name] FROM [UDC_names_BS] SN WHERE SN.[serviceID] = BS.[serviceID]) AS [serviceName],
  1368. SD.[description],
  1369. BT.[accessPoint],
  1370. TM.[name] AS [tModelName],
  1371. TMD.[description] AS [tModelDescription],
  1372. TM.[overviewURL]
  1373. FROM
  1374. [UDC_businessEntities] BE
  1375. JOIN [UDC_businessServices] BS ON BE.[businessID] = BS.[businessID]
  1376. JOIN [UDC_bindingTemplates] BT ON BS.[serviceID] = BT.[serviceID]
  1377. JOIN [UDC_tModelInstances] TMI ON BT.[bindingID] = TMI.[bindingID]
  1378. JOIN [UDC_tModels] TM ON TM.[tModelKey] = TMI.[tModelKey]
  1379. LEFT OUTER JOIN [UDC_serviceDesc] SD ON BS.[serviceID] = SD.[serviceID]
  1380. LEFT OUTER JOIN [UDC_tModelDesc] TMD ON (TM.[tModelID] = TMD.[tModelID] AND TMD.[isoLangCode] = 'en' AND TMD.[elementID] = 1 )
  1381. WHERE
  1382. (BE.[businessKey] = @businessKey) AND
  1383. (TMI.[tModelKey] IN (SELECT [tModelKey] FROM @wsdlTModelKeys))
  1384. ORDER BY
  1385. 3 DESC,
  1386. BS.[serviceKey]
  1387. RETURN 0
  1388. END -- VS_service_get
  1389. GO
  1390. -- =============================================
  1391. -- Name: VS_AWR_businesses_get
  1392. -- =============================================
  1393. IF EXISTS (SELECT name FROM sysobjects WHERE name = 'VS_AWR_businesses_get' AND type = 'P')
  1394. DROP PROCEDURE VS_AWR_businesses_get
  1395. GO
  1396. CREATE PROCEDURE VS_AWR_businesses_get
  1397. @businessName nvarchar(450)
  1398. WITH ENCRYPTION
  1399. AS
  1400. BEGIN
  1401. DECLARE
  1402. @typesTModelKey uniqueidentifier,
  1403. @wsdlKeyValue nvarchar(255),
  1404. @services cursor,
  1405. @serviceID bigint,
  1406. @serviceKey uniqueidentifier,
  1407. @businessID bigint,
  1408. @businessName2 nvarchar(450),
  1409. @businessKey uniqueidentifier,
  1410. @serviceName nvarchar(450)
  1411. --
  1412. -- Get a list of tModel keys for tModels categorized as a wsdlSpec
  1413. --
  1414. SET @typesTModelKey = 'C1ACF26D-9672-4404-9D70-39B756E62AB4'
  1415. SET @wsdlKeyValue = 'wsdlSpec'
  1416. DECLARE @wsdlTModelKeys TABLE (
  1417. [tModelKey] uniqueidentifier)
  1418. INSERT @wsdlTModelKeys
  1419. SELECT DISTINCT
  1420. TM.[tModelKey]
  1421. FROM
  1422. [UDC_tModels] TM
  1423. JOIN [UDC_categoryBag_TM] CB ON TM.[tModelID] = CB.[tModelID]
  1424. WHERE
  1425. (CB.[tModelKey] = @typesTModelKey) AND
  1426. (CB.[keyValue] = @wsdlKeyValue)
  1427. --
  1428. -- Setup temporary table for staging results
  1429. --
  1430. DECLARE @results TABLE(
  1431. [businessName] nvarchar(450),
  1432. [businessKey] uniqueidentifier,
  1433. [serviceName] nvarchar(450),
  1434. [serviceKey] uniqueidentifier)
  1435. --
  1436. -- Cursor through every service that:
  1437. -- 1. Has a tModelInstance that references a wsdlTModelKey
  1438. -- 2. Is owned by a business that meets the name search criteria
  1439. -- Build results from this list of services
  1440. --
  1441. SET @services = CURSOR LOCAL READ_ONLY FORWARD_ONLY FOR
  1442. SELECT
  1443. BS.[serviceID],
  1444. BS.[serviceKey],
  1445. BS.[businessID]
  1446. FROM
  1447. [UDC_businessServices] BS
  1448. JOIN [UDC_bindingTemplates] BT ON BS.[serviceID] = BT.[serviceID]
  1449. JOIN [UDC_tModelInstances] TMI ON BT.[bindingID] = TMI.[bindingID]
  1450. WHERE
  1451. (TMI.[tModelKey] IN (SELECT [tModelKey] FROM @wsdlTModelKeys)) AND
  1452. (BS.[businessID] IN (SELECT DISTINCT BN.[businessID] FROM [UDC_names_BE] BN WHERE (BN.[name] LIKE @businessName + '%')))
  1453. OPEN @services
  1454. FETCH NEXT FROM @services INTO
  1455. @serviceID,
  1456. @serviceKey,
  1457. @businessID
  1458. WHILE @@FETCH_STATUS = 0
  1459. BEGIN
  1460. --
  1461. -- Retrieve the name of the business that owns the service
  1462. --
  1463. SET @businessName2 = (SELECT TOP 1 BN.[name] FROM [UDC_names_BE] BN WHERE (BN.[businessID] = @businessID))
  1464. --
  1465. -- Retrieve the key of the business that owns the service
  1466. --
  1467. SET @businessKey = dbo.businessKey(@businessID)
  1468. --
  1469. -- Retrieve the name of the service
  1470. --
  1471. SET @serviceName = (SELECT TOP 1 SN.[name] FROM [UDC_names_BS] SN WHERE (SN.[serviceID] = @serviceID))
  1472. --
  1473. -- Add results to results table
  1474. --
  1475. INSERT @results VALUES(
  1476. @businessName2,
  1477. @businessKey,
  1478. @serviceName,
  1479. @serviceKey)
  1480. FETCH NEXT FROM @services INTO
  1481. @serviceID,
  1482. @serviceKey,
  1483. @businessID
  1484. END
  1485. CLOSE @services
  1486. --
  1487. -- Return results
  1488. --
  1489. SELECT * FROM @results
  1490. END
  1491. GO
  1492. -- =============================================
  1493. -- Name: VS_AWR_services_get
  1494. -- =============================================
  1495. IF EXISTS (SELECT name FROM dbo.sysobjects WHERE name = 'VS_AWR_services_get' AND type = 'P')
  1496. DROP PROCEDURE [dbo].[VS_AWR_services_get]
  1497. GO
  1498. CREATE PROCEDURE VS_AWR_services_get
  1499. @serviceName nvarchar(450)
  1500. WITH ENCRYPTION
  1501. AS
  1502. BEGIN
  1503. DECLARE
  1504. @typesTModelKey uniqueidentifier,
  1505. @wsdlKeyValue nvarchar(255)
  1506. SET @typesTModelKey = 'C1ACF26D-9672-4404-9D70-39B756E62AB4'
  1507. SET @wsdlKeyValue = 'wsdlSpec'
  1508. DECLARE @wsdlTModelKeys TABLE (
  1509. [tModelKey] uniqueidentifier)
  1510. INSERT @wsdlTModelKeys
  1511. SELECT DISTINCT
  1512. TM.[tModelKey]
  1513. FROM
  1514. [UDC_tModels] TM
  1515. JOIN [UDC_categoryBag_TM] CB ON TM.[tModelID] = CB.[tModelID]
  1516. WHERE
  1517. (CB.[tModelKey] = @typesTModelKey) AND
  1518. (CB.[keyValue] = @wsdlKeyValue)
  1519. IF @@ROWCOUNT = 0
  1520. -- There were no tModels with the wsdl categorization, so return a non-zero return code to indicate an error
  1521. RETURN -1
  1522. SELECT DISTINCT
  1523. (SELECT TOP 1 BN.[name] FROM [UDC_names_BE] BN WHERE BN.[businessID] = BE.[businessID]) AS [businessName],
  1524. BE.[businessKey],
  1525. SN.[name] AS [serviceName],
  1526. BS.[serviceKey]
  1527. FROM
  1528. [UDC_businessEntities] BE
  1529. JOIN [UDC_businessServices] BS ON BE.[businessID] = BS.[businessID]
  1530. JOIN [UDC_bindingTemplates] BT ON BS.[serviceID] = BT.[serviceID]
  1531. JOIN [UDC_tModelInstances] TMI ON BT.[bindingID] = TMI.[bindingID]
  1532. JOIN [UDC_tModels] TM ON TM.[tModelKey] = TMI.[tModelKey]
  1533. JOIN [UDC_names_BS] SN ON SN.[serviceID] = BT.[serviceID]
  1534. LEFT OUTER JOIN [UDC_serviceDesc] SD ON BS.[serviceID] = SD.[serviceID]
  1535. LEFT OUTER JOIN [UDC_tModelDesc] TMD ON (TM.[tModelID] = TMD.[tModelID] AND TMD.[isoLangCode] = 'en' AND TMD.[elementID] = 1 )
  1536. WHERE
  1537. (TMI.[tModelKey] IN (SELECT [tModelKey] FROM @wsdlTModelKeys)) AND
  1538. SN.[name] like @serviceName + '%'
  1539. ORDER BY
  1540. 1 ASC
  1541. RETURN 0
  1542. END
  1543. GO
  1544. -- =============================================
  1545. -- Name: VS_AWR_categorization_get
  1546. -- =============================================
  1547. -- This sproc will return all business services that are categorized by the given tModelKey, regardless of
  1548. -- whether the business entity that they belong to is categorized by that same tModelKey
  1549. IF EXISTS (SELECT name FROM dbo.sysobjects WHERE name = 'VS_AWR_categorization_get' AND type = 'P')
  1550. DROP PROCEDURE [dbo].[VS_AWR_categorization_get]
  1551. GO
  1552. CREATE PROCEDURE VS_AWR_categorization_get
  1553. @tModelKey uniqueidentifier,
  1554. @keyValue nvarchar(255)
  1555. WITH ENCRYPTION
  1556. AS
  1557. BEGIN
  1558. DECLARE
  1559. @typesTModelKey uniqueidentifier,
  1560. @wsdlKeyValue nvarchar(255)
  1561. SET @typesTModelKey = 'C1ACF26D-9672-4404-9D70-39B756E62AB4'
  1562. SET @wsdlKeyValue = 'wsdlSpec'
  1563. DECLARE @wsdlTModelKeys TABLE (
  1564. [tModelKey] uniqueidentifier)
  1565. INSERT @wsdlTModelKeys
  1566. SELECT DISTINCT
  1567. TM.[tModelKey]
  1568. FROM
  1569. [UDC_tModels] TM
  1570. JOIN [UDC_categoryBag_TM] CB ON TM.[tModelID] = CB.[tModelID]
  1571. WHERE
  1572. (CB.[tModelKey] = @typesTModelKey) AND
  1573. (CB.[keyValue] = @wsdlKeyValue)
  1574. IF @@ROWCOUNT = 0
  1575. -- There were no tModels that match, so return a non-zero return code to indicate an error
  1576. RETURN -1
  1577. SELECT DISTINCT
  1578. (SELECT TOP 1 BN.[name] FROM [UDC_names_BE] BN WHERE BN.[businessID] = BE.[businessID]) AS [businessName],
  1579. BE.[businessKey],
  1580. SN.[name] AS [serviceName],
  1581. BS.[serviceKey]
  1582. FROM
  1583. [UDC_businessEntities] BE
  1584. JOIN [UDC_businessServices] BS ON BE.[businessID] = BS.[businessID]
  1585. JOIN [UDC_bindingTemplates] BT ON BS.[serviceID] = BT.[serviceID]
  1586. JOIN [UDC_tModelInstances] TMI ON BT.[bindingID] = TMI.[bindingID]
  1587. JOIN [UDC_tModels] TM ON TM.[tModelKey] = TMI.[tModelKey]
  1588. JOIN [UDC_names_BS] SN ON SN.[serviceID] = BT.[serviceID]
  1589. LEFT OUTER JOIN [UDC_categoryBag_BE] CBE ON CBE.[businessID] = BS.[businessID]
  1590. lEFT OUTER JOIN [UDC_categoryBag_BS] CBS ON CBS.[serviceID] = BT.[serviceID]
  1591. LEFT OUTER JOIN [UDC_serviceDesc] SD ON BS.[serviceID] = SD.[serviceID]
  1592. LEFT OUTER JOIN [UDC_tModelDesc] TMD ON (TM.[tModelID] = TMD.[tModelID] AND TMD.[isoLangCode] = 'en' AND TMD.[elementID] = 1 )
  1593. WHERE
  1594. (TMI.[tModelKey] IN (SELECT [tModelKey] FROM @wsdlTModelKeys)) AND
  1595. (CBS.[tModelKey] = @tModelKey AND CBS.[keyValue] LIKE @keyValue) OR
  1596. (CBE.[tModelKey] = @tModelKey AND CBE.[keyValue] LIKE @keyValue)
  1597. ORDER BY
  1598. 1 ASC
  1599. RETURN 0
  1600. END
  1601. GO