Advertisement
Guest User

Untitled

a guest
Jun 1st, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.85 KB | None | 0 0
  1. url = "jdbc:sqlserver://ukcdmdb1.database.windows.net;databaseName=dyfedpowyscommunitymessaging"
  2. driver: "com.microsoft.sqlserver.jdbc.SQLServerDriver"
  3. user = "dyfedpowyscommunitymessagingread"
  4. password = "dsN3vrZVRxBJnsnk"
  5. country = "GB"
  6.  
  7. sql = """
  8. SELECT
  9. 'U' op,
  10. CAST(p.SerID AS VARCHAR) + '.' + CAST (a.SerID AS VARCHAR) id,
  11. ISNULL(p.Firstname, '') + ' ' + ISNULL(p.Lastname, '') name,
  12. CASE
  13. WHEN BusinessType > 0 THEN 'company'
  14. ELSE 'private'
  15. END category,
  16. 'sms' [contact-1-type],
  17. CASE WHEN MobilePhoneYN = 1 AND MobileNumber IS NOT NULL AND MobileNumberPrefix IS NOT NULL
  18. THEN SUBSTRING(MobileNumberPrefix, 2, LEN(MobileNumberPrefix)) + REPLACE(SUBSTRING(MobileNumber, PATINDEX('%[^0]%', MobileNumber + '.'), LEN(MobileNumber)), ' ', '')
  19. ELSE ''
  20. END [contact-1-address],
  21. 'voice' [contact-2-type],
  22. CASE WHEN HomePhoneYN = 1 AND HomePhone IS NOT NULL AND HomePhonePrefix IS NOT NULL
  23. THEN SUBSTRING(HomePhonePrefix, 2, LEN(HomePhonePrefix)) + REPLACE(SUBSTRING(HomePhone, PATINDEX('%[^0]%', HomePhone + '.'), LEN(HomePhone)), ' ', '')
  24. ELSE ''
  25. END [contact-2-address],
  26. 'email' [contact-3-type],
  27. CASE WHEN EmailAddressYN = 1 AND EmailAddress IS NOT NULL
  28. THEN p.EmailAddress
  29. ELSE ''
  30. END [contact-3-address],
  31. 'smartphone' [contact-4-type],
  32. CASE WHEN AppYN = 1 AND DeviceID IS NOT NULL AND p.DeviceType IS NOT NULL
  33. THEN p.DeviceType + ':' + p.DeviceID
  34. ELSE ''
  35. END [contact-4-address],
  36. AgeRange [birthyear-agerange],
  37. Ethnicity [option-ethnicity],
  38. Nationality [option-nationality],
  39. Disability [option-disability],
  40. NWatchYN [option-nhw_role],
  41. Gender [option-gender],
  42. Religion [option-religion],
  43. Source [option-source],
  44. BusinessType [option-business_type],
  45. CASE Language
  46. WHEN 'C' THEN 'cv'
  47. ELSE 'en'
  48. END [meta-language],
  49. Interests [option-interests],
  50. Address_StreetName [meta-streetname],
  51. Address_HouseNumber [meta-housenumber],
  52. Address_HouseName [meta-housename],
  53. CASE
  54. WHEN BusinessType > 0 THEN 'company'
  55. ELSE 'private'
  56. END [meta-usertype],
  57.  
  58. Latitude [adr-1-lat],
  59. Longitude [adr-1-lon],
  60. Address_HouseNumber + ' ' + Address_StreetName [adr-1-address],
  61. Address_Zipcode [adr-1-zip],
  62. Address_Place [adr-1-city]
  63. FROM
  64. PersonAddress a JOIN Person p ON a.PersonSerID=p.SerID
  65. WHERE a.UpdatedOn > DATEADD(year, """${year}"""-1900, DATEADD(month, """${month}"""-1, DATEADD(day, """${day}"""-1, 0)))
  66. OR p.UpdatedOn > DATEADD(year, """${year}"""-1900, DATEADD(month, """${month}"""-1, DATEADD(day, """${day}"""-1, 0)))
  67. OR p.CreatedOn > DATEADD(year, """${year}"""-1900, DATEADD(month, """${month}"""-1, DATEADD(day, """${day}"""-1, 0)))
  68. OR p.UpdatedOn > DATEADD(year, """${year}"""-1900, DATEADD(month, """${month}"""-1, DATEADD(day, """${day}"""-1, 0)))
  69. UNION ALL
  70. SELECT
  71. 'D' op,
  72. CAST(PersonSerId AS VARCHAR) + '.' + CAST(SerId AS VARCHAR) + '-0' id,
  73. '' name,
  74. 'private' category,
  75. 'sms' [contact-1-type],
  76. '' [contact-1-address],
  77. 'voice' [contact-2-type],
  78. '' [contact-2-address],
  79. 'email' [contact-3-type],
  80. '' [contact-3-address],
  81. 'smartphone' [contact-4-type],
  82. '' [contact-4-address],
  83. NULL [birthyear-agerange],
  84. NULL [option-ethnicity],
  85. NULL [option-nationality],
  86. NULL [option-disability],
  87. NULL [option-nhw_role],
  88. NULL [option-gender],
  89. NULL [option-religion],
  90. NULL [option-source],
  91. NULL [option-business_type],
  92. NULL [meta-language],
  93. NULL [option-interests],
  94. NULL [meta-streetname],
  95. NULL [meta-housenumber],
  96. NULL [meta-housename],
  97. NULL [meta-usertype],
  98. NULL [adr-1-lat],
  99. NULL [adr-1-lon],
  100. NULL [adr-1-address],
  101. NULL [adr-1-zip],
  102. NULL [adr-1-city]
  103. FROM DeletedPersonAddresses
  104. WHERE DeletedOn > DATEADD(year, """${year}"""-1900, DATEADD(month, """${month}"""-1, DATEADD(day, """${day}"""-1, 0)))
  105. """
  106. schemaSpec = """
  107. {
  108. "fields" : [ {
  109. "@type" : "group",
  110. "field" : "type",
  111. "name" : "User Type",
  112. "groupEntries" : [ {
  113. "name" : "Individual",
  114. "fields" : [ {
  115. "@type" : "fixed",
  116. "field" : "metaData.usertype",
  117. "value" : "private",
  118. "name" : ""
  119. }, {
  120. "@type" : "select",
  121. "field" : "metaData.agerange",
  122. "name" : "Age Range",
  123. "options" : [ {
  124. "name" : "0 - 18",
  125. "value" : "6810"
  126. }, {
  127. "name" : "19 - 34",
  128. "value" : "7037"
  129. }, {
  130. "name" : "35 - 54",
  131. "value" : "7264"
  132. }, {
  133. "name" : "55 - 74",
  134. "value" : "7491"
  135. }, {
  136. "name" : "75+",
  137. "value" : "7718"
  138. } ]
  139. }, {
  140. "@type" : "sqlOptions",
  141. "field" : "metaData.gender",
  142. "name" : "Gender",
  143. "multiselct" : false,
  144. "any" : "Any",
  145. "sqlSelect" : "select LOV_ID, DisplayValue from LOV where SegmentKey = 'GENDER' and EnabledYN = 1"
  146. }, {
  147. "@type" : "sqlOptions",
  148. "field" : "metaData.ethnicity",
  149. "name" : "Ethnicity",
  150. "multiselct" : true,
  151. "any" : "Any",
  152. "sqlSelect" : "select LOV_ID, DisplayValue from LOV where SegmentKey = 'ETHNICITY' and EnabledYN = 1"
  153. }, {
  154. "@type" : "sqlOptions",
  155. "field" : "metaData.nationality",
  156. "name" : "Nationality",
  157. "multiselct" : true,
  158. "any" : "Any",
  159. "sqlSelect" : "select LOV_ID, DisplayValue from LOV where SegmentKey = 'NATIONALITY' and EnabledYN = 1"
  160. }, {
  161. "@type" : "sqlOptions",
  162. "field" : "metaData.religion",
  163. "name" : "Religion",
  164. "multiselct" : false,
  165. "any" : "Any",
  166. "sqlSelect" : "select LOV_ID, DisplayValue from LOV where SegmentKey = 'RELIGION' and EnabledYN = 1"
  167. }, {
  168. "@type" : "sqlOptions",
  169. "field" : "metaData.disability",
  170. "name" : "Disablity",
  171. "multiselct" : true,
  172. "any" : "Any",
  173. "sqlSelect" : "select LOV_ID, DisplayValue from LOV where SegmentKey = 'DISABILITY' and EnabledYN = 1"
  174. }, {
  175. "@type" : "sqlOptions",
  176. "field" : "metaData.nhw_role",
  177. "name" : "NHW role",
  178. "multiselct" : true,
  179. "any" : "Any",
  180. "sqlSelect" : "select LOV_ID, DisplayValue from LOV where SegmentKey = 'NWYN' and EnabledYN = 1"
  181. } ]
  182. }, {
  183. "name" : "Business",
  184. "fields" : [ {
  185. "@type" : "fixed",
  186. "field" : "metaData.usertype",
  187. "value" : "company",
  188. "name" : ""
  189. }, {
  190. "@type" : "sqlOptions",
  191. "field" : "metaData.business_type",
  192. "name" : "Business Type",
  193. "multiselct" : false,
  194. "any" : "Any",
  195. "sqlSelect" : "select LOV_ID, DisplayValue from LOV where SegmentKey = 'BUSINESSTYPE' and EnabledYN = 1"
  196. } ]
  197. }, {
  198. "name" : "Any",
  199. "fields" : [ ]
  200. } ]
  201. }, {
  202. "@type" : "sqlOptions",
  203. "field" : "metaData.interests",
  204. "name" : "Interests",
  205. "multiselct" : true,
  206. "any" : "None",
  207. "sqlSelect" : "select LOV_ID, DisplayValue from LOV where SegmentKey = 'INTERESTS' and EnabledYN = 1"
  208. }, {
  209. "@type" : "sqlOptions",
  210. "field" : "metaData.source",
  211. "name" : "How did you hear about us",
  212. "multiselct" : true,
  213. "any" : "None",
  214. "sqlSelect" : "select LOV_ID, DisplayValue from LOV where SegmentKey = 'SOURCE' and EnabledYN = 1"
  215. } ]
  216. }"""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement