Permalink
Browse files

DATASOLR-2 - update packages, groupId, artifactId, version

move sources from at.pagu.soldockr to org.springframework.data.solr
update pom.xml and set version to 0.1.0.BUILD-SNAPSHOT
update leagal header and license
reformat code/organize imports
remove at.pagu packages
  • Loading branch information...
1 parent 9504f23 commit 97e9491b31e10de6f0af87efdcf3fc282662bb42 @christophstrobl christophstrobl committed Sep 12, 2012
Showing with 7,320 additions and 7,270 deletions.
  1. +1 −1 LICENSE
  2. +34 −51 pom.xml
  3. +0 −81 src/main/java/at/pagu/soldockr/core/EmbeddedSolrServerFactory.java
  4. +0 −123 src/main/java/at/pagu/soldockr/core/HttpSolrServerFactory.java
  5. +0 −186 src/main/java/at/pagu/soldockr/core/QueryParser.java
  6. +0 −81 src/main/java/at/pagu/soldockr/core/ResultHelper.java
  7. +0 −177 src/main/java/at/pagu/soldockr/core/SolrOperations.java
  8. +0 −352 src/main/java/at/pagu/soldockr/core/SolrTemplate.java
  9. +0 −86 src/main/java/at/pagu/soldockr/core/convert/DateTimeConverters.java
  10. +0 −118 src/main/java/at/pagu/soldockr/core/convert/MappingSolrConverter.java
  11. +0 −87 src/main/java/at/pagu/soldockr/core/convert/SolrjConverters.java
  12. +0 −70 src/main/java/at/pagu/soldockr/core/mapping/SimpleSolrPersistentEntity.java
  13. +0 −75 src/main/java/at/pagu/soldockr/core/mapping/SimpleSolrPersistentProperty.java
  14. +0 −55 src/main/java/at/pagu/soldockr/core/query/AbstractQuery.java
  15. +0 −628 src/main/java/at/pagu/soldockr/core/query/Criteria.java
  16. +0 −188 src/main/java/at/pagu/soldockr/core/query/FacetOptions.java
  17. +0 −91 src/main/java/at/pagu/soldockr/core/query/Query.java
  18. +0 −62 src/main/java/at/pagu/soldockr/core/query/SimpleFacetQuery.java
  19. +0 −154 src/main/java/at/pagu/soldockr/core/query/SimpleQuery.java
  20. +0 −83 src/main/java/at/pagu/soldockr/core/query/result/FacetPage.java
  21. +0 −61 src/main/java/at/pagu/soldockr/core/query/result/SimpleFacetEntry.java
  22. +0 −254 src/main/java/at/pagu/soldockr/repository/SimpleSolrRepository.java
  23. +0 −58 src/main/java/at/pagu/soldockr/repository/cdi/SolrRepositoryBean.java
  24. +0 −74 src/main/java/at/pagu/soldockr/repository/cdi/SolrRepositoryExtension.java
  25. +0 −122 src/main/java/at/pagu/soldockr/repository/query/AbstractSolrQuery.java
  26. +0 −50 src/main/java/at/pagu/soldockr/repository/query/PartTreeSolrQuery.java
  27. +0 −126 src/main/java/at/pagu/soldockr/repository/query/SolrQueryCreator.java
  28. +0 −67 src/main/java/at/pagu/soldockr/repository/query/SolrQueryMethod.java
  29. +0 −100 src/main/java/at/pagu/soldockr/repository/query/StringBasedSolrQuery.java
  30. +0 −75 src/main/java/at/pagu/soldockr/repository/support/MappingSolrEntityInformation.java
  31. +0 −48 src/main/java/at/pagu/soldockr/repository/support/SolrEntityInformationCreatorImpl.java
  32. +0 −107 src/main/java/at/pagu/soldockr/repository/support/SolrRepositoryFactory.java
  33. +19 −20 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/ApiUsageException.java
  34. +18 −19 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/QueryException.java
  35. +19 −19 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/SolDockRException.java
  36. +17 −17 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/SolrServerFactory.java
  37. +81 −0 src/main/java/org/springframework/data/solr/core/EmbeddedSolrServerFactory.java
  38. +123 −0 src/main/java/org/springframework/data/solr/core/HttpSolrServerFactory.java
  39. +183 −0 src/main/java/org/springframework/data/solr/core/QueryParser.java
  40. +81 −0 src/main/java/org/springframework/data/solr/core/ResultHelper.java
  41. +13 −14 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/core/SolrCallback.java
  42. +175 −0 src/main/java/org/springframework/data/solr/core/SolrOperations.java
  43. +352 −0 src/main/java/org/springframework/data/solr/core/SolrTemplate.java
  44. +88 −0 src/main/java/org/springframework/data/solr/core/convert/DateTimeConverters.java
  45. +120 −0 src/main/java/org/springframework/data/solr/core/convert/MappingSolrConverter.java
  46. +20 −20 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/core/convert/NumberConverters.java
  47. +26 −26 ...in/java/{at/pagu/soldockr → org/springframework/data/solr}/core/convert/SimpleSolrTypeMapper.java
  48. +12 −10 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/core/convert/SolrConverter.java
  49. +6 −6 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/core/convert/SolrTypeMapper.java
  50. +89 −0 src/main/java/org/springframework/data/solr/core/convert/SolrjConverters.java
  51. +19 −18 ...ava/{at/pagu/soldockr → org/springframework/data/solr}/core/mapping/SimpleSolrMappingContext.java
  52. +72 −0 src/main/java/org/springframework/data/solr/core/mapping/SimpleSolrPersistentEntity.java
  53. +78 −0 src/main/java/org/springframework/data/solr/core/mapping/SimpleSolrPersistentProperty.java
  54. +8 −8 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/core/mapping/SolrDocument.java
  55. +8 −8 ...in/java/{at/pagu/soldockr → org/springframework/data/solr}/core/mapping/SolrPersistentEntity.java
  56. +12 −12 .../java/{at/pagu/soldockr → org/springframework/data/solr}/core/mapping/SolrPersistentProperty.java
  57. +56 −0 src/main/java/org/springframework/data/solr/core/query/AbstractQuery.java
  58. +635 −0 src/main/java/org/springframework/data/solr/core/query/Criteria.java
  59. +191 −0 src/main/java/org/springframework/data/solr/core/query/FacetOptions.java
  60. +20 −20 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/core/query/FacetQuery.java
  61. +13 −12 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/core/query/Field.java
  62. +7 −8 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/core/query/FilterQuery.java
  63. +91 −0 src/main/java/org/springframework/data/solr/core/query/Query.java
  64. +11 −10 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/core/query/QueryStringHolder.java
  65. +62 −0 src/main/java/org/springframework/data/solr/core/query/SimpleFacetQuery.java
  66. +19 −19 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/core/query/SimpleField.java
  67. +10 −9 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/core/query/SimpleFilterQuery.java
  68. +155 −0 src/main/java/org/springframework/data/solr/core/query/SimpleQuery.java
  69. +15 −16 ...main/java/{at/pagu/soldockr → org/springframework/data/solr}/core/query/SimpleStringCriteria.java
  70. +18 −19 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/core/query/SolDockRQuery.java
  71. +26 −23 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/core/query/result/FacetEntry.java
  72. +82 −0 src/main/java/org/springframework/data/solr/core/query/result/FacetPage.java
  73. +62 −0 src/main/java/org/springframework/data/solr/core/query/result/SimpleFacetEntry.java
  74. +7 −7 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/repository/Query.java
  75. +257 −0 src/main/java/org/springframework/data/solr/repository/SimpleSolrRepository.java
  76. +12 −13 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/repository/SolrCrudRepository.java
  77. +11 −11 src/main/java/{at/pagu/soldockr → org/springframework/data/solr}/repository/SolrRepository.java
  78. +58 −0 src/main/java/org/springframework/data/solr/repository/cdi/SolrRepositoryBean.java
  79. +74 −0 src/main/java/org/springframework/data/solr/repository/cdi/SolrRepositoryExtension.java
  80. +121 −0 src/main/java/org/springframework/data/solr/repository/query/AbstractSolrQuery.java
  81. +49 −0 src/main/java/org/springframework/data/solr/repository/query/PartTreeSolrQuery.java
  82. +7 −7 ...va/{at/pagu/soldockr → org/springframework/data/solr}/repository/query/SolrEntityInformation.java
  83. +6 −6 ...pagu/soldockr → org/springframework/data/solr}/repository/query/SolrEntityInformationCreator.java
  84. +5 −5 ...va/{at/pagu/soldockr → org/springframework/data/solr}/repository/query/SolrParameterAccessor.java
  85. +8 −8 ...u/soldockr → org/springframework/data/solr}/repository/query/SolrParametersParameterAccessor.java
  86. +127 −0 src/main/java/org/springframework/data/solr/repository/query/SolrQueryCreator.java
  87. +66 −0 src/main/java/org/springframework/data/solr/repository/query/SolrQueryMethod.java
  88. +100 −0 src/main/java/org/springframework/data/solr/repository/query/StringBasedSolrQuery.java
  89. +75 −0 src/main/java/org/springframework/data/solr/repository/support/MappingSolrEntityInformation.java
  90. +49 −0 src/main/java/org/springframework/data/solr/repository/support/SolrEntityInformationCreatorImpl.java
  91. +108 −0 src/main/java/org/springframework/data/solr/repository/support/SolrRepositoryFactory.java
  92. +1 −1 src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
  93. +0 −128 src/test/java/at/pagu/soldockr/ExampleSolrBean.java
  94. +0 −96 src/test/java/at/pagu/soldockr/core/HttpSolrServerFactoryTest.java
  95. +0 −134 src/test/java/at/pagu/soldockr/core/ITestSolrTemplate.java
  96. +0 −223 src/test/java/at/pagu/soldockr/core/QueryParserTest.java
  97. +0 −133 src/test/java/at/pagu/soldockr/core/ResultHelperTest.java
  98. +0 −214 src/test/java/at/pagu/soldockr/core/SolrTemplateTest.java
  99. +0 −69 src/test/java/at/pagu/soldockr/core/convert/DateTimeConvertersTest.java
  100. +0 −123 src/test/java/at/pagu/soldockr/core/convert/MappingSolrConverterTest.java
  101. +0 −96 src/test/java/at/pagu/soldockr/core/convert/NumberConvertersTest.java
  102. +0 −74 src/test/java/at/pagu/soldockr/core/mapping/SimpleSolrPersistentEntityTest.java
  103. +0 −120 src/test/java/at/pagu/soldockr/core/query/FacetOptionsTest.java
  104. +0 −124 src/test/java/at/pagu/soldockr/core/query/ITestCriteriaExecution.java
  105. +0 −179 src/test/java/at/pagu/soldockr/core/query/SimpleQueryTest.java
  106. +0 −39 src/test/java/at/pagu/soldockr/core/query/SimpleStringCriteriaTest.java
  107. +0 −96 src/test/java/at/pagu/soldockr/repository/ITestSimpleSolrRepository.java
  108. +0 −113 src/test/java/at/pagu/soldockr/repository/ProductBean.java
  109. +0 −83 src/test/java/at/pagu/soldockr/repository/SimpleSolrRepositoryTest.java
  110. +0 −78 src/test/java/at/pagu/soldockr/repository/cdi/ITestCdiRepository.java
  111. +0 −56 src/test/java/at/pagu/soldockr/repository/cdi/SolrTemplateProducer.java
  112. +0 −283 src/test/java/at/pagu/soldockr/repository/query/SolrQueryCreatorTest.java
  113. +0 −109 src/test/java/at/pagu/soldockr/repository/query/StringBasedSolrQueryTest.java
  114. +0 −167 src/test/java/at/pagu/soldockr/repository/support/ITestSolrRepositoryFactory.java
  115. +0 −67 src/test/java/at/pagu/soldockr/repository/support/MappingSolrEntityInformationTest.java
  116. +0 −95 src/test/java/at/pagu/soldockr/repository/support/SolrRepositoryFactoryTest.java
  117. +30 −29 .../java/{at/pagu/soldockr → org/springframework/data/solr}/AbstractITestWithEmbeddedSolrServer.java
  118. +128 −0 src/test/java/org/springframework/data/solr/ExampleSolrBean.java
  119. +97 −0 src/test/java/org/springframework/data/solr/core/HttpSolrServerFactoryTest.java
  120. +134 −0 src/test/java/org/springframework/data/solr/core/ITestSolrTemplate.java
  121. +225 −0 src/test/java/org/springframework/data/solr/core/QueryParserTest.java
  122. +138 −0 src/test/java/org/springframework/data/solr/core/ResultHelperTest.java
  123. +28 −27 src/test/java/{at/pagu/soldockr → org/springframework/data/solr}/core/SimpleJavaObject.java
  124. +214 −0 src/test/java/org/springframework/data/solr/core/SolrTemplateTest.java
  125. +73 −0 src/test/java/org/springframework/data/solr/core/convert/DateTimeConvertersTest.java
  126. +123 −0 src/test/java/org/springframework/data/solr/core/convert/MappingSolrConverterTest.java
  127. +96 −0 src/test/java/org/springframework/data/solr/core/convert/NumberConvertersTest.java
  128. +80 −0 src/test/java/org/springframework/data/solr/core/mapping/SimpleSolrPersistentEntityTest.java
  129. +6 −6 src/test/java/{at/pagu/soldockr → org/springframework/data/solr}/core/query/CriteriaTest.java
  130. +116 −0 src/test/java/org/springframework/data/solr/core/query/FacetOptionsTest.java
  131. +127 −0 src/test/java/org/springframework/data/solr/core/query/ITestCriteriaExecution.java
  132. +174 −0 src/test/java/org/springframework/data/solr/core/query/SimpleQueryTest.java
  133. +39 −0 src/test/java/org/springframework/data/solr/core/query/SimpleStringCriteriaTest.java
  134. +6 −6 ...java/{at/pagu/soldockr → org/springframework/data/solr}/repository/ExampleSolrBeanRepository.java
  135. +95 −0 src/test/java/org/springframework/data/solr/repository/ITestSimpleSolrRepository.java
  136. +128 −0 src/test/java/org/springframework/data/solr/repository/ProductBean.java
  137. +85 −0 src/test/java/org/springframework/data/solr/repository/SimpleSolrRepositoryTest.java
  138. +7 −8 .../java/{at/pagu/soldockr → org/springframework/data/solr}/repository/cdi/CdiProductRepository.java
  139. +13 −13 ...t/java/{at/pagu/soldockr → org/springframework/data/solr}/repository/cdi/CdiRepositoryClient.java
  140. +77 −0 src/test/java/org/springframework/data/solr/repository/cdi/ITestCdiRepository.java
  141. +56 −0 src/test/java/org/springframework/data/solr/repository/cdi/SolrTemplateProducer.java
  142. +296 −0 src/test/java/org/springframework/data/solr/repository/query/SolrQueryCreatorTest.java
  143. +112 −0 src/test/java/org/springframework/data/solr/repository/query/StringBasedSolrQueryTest.java
  144. +166 −0 src/test/java/org/springframework/data/solr/repository/support/ITestSolrRepositoryFactory.java
  145. +69 −0 src/test/java/org/springframework/data/solr/repository/support/MappingSolrEntityInformationTest.java
  146. +94 −0 src/test/java/org/springframework/data/solr/repository/support/SolrRepositoryFactoryTest.java
  147. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/admin-extra.html
  148. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/currency.xml
  149. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/elevate.xml
  150. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/contractions_ca.txt
  151. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/contractions_fr.txt
  152. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/contractions_ga.txt
  153. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/contractions_it.txt
  154. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/hyphenations_ga.txt
  155. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stemdict_nl.txt
  156. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stoptags_ja.txt
  157. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_ar.txt
  158. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_bg.txt
  159. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_ca.txt
  160. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_cz.txt
  161. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_da.txt
  162. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_de.txt
  163. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_el.txt
  164. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_en.txt
  165. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_es.txt
  166. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_eu.txt
  167. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_fa.txt
  168. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_fi.txt
  169. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_fr.txt
  170. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_ga.txt
  171. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_gl.txt
  172. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_hi.txt
  173. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_hu.txt
  174. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_hy.txt
  175. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_id.txt
  176. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_it.txt
  177. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_ja.txt
  178. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_lv.txt
  179. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_nl.txt
  180. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_no.txt
  181. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_pt.txt
  182. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_ro.txt
  183. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_ru.txt
  184. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_sv.txt
  185. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_th.txt
  186. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/stopwords_tr.txt
  187. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/lang/userdict_ja.txt
  188. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/mapping-FoldToASCII.txt
  189. 0 ...est/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/mapping-ISOLatin1Accent.txt
  190. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/protwords.txt
  191. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/schema.xml
  192. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/scripts.conf
  193. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/solrconfig.xml
  194. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/spellings.txt
  195. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/stopwords.txt
  196. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/synonyms.txt
  197. 0 ...t/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/VM_global_library.vm
  198. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/browse.vm
  199. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/cluster.vm
  200. 0 ...test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/clusterResults.vm
  201. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/doc.vm
  202. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/facet_fields.vm
  203. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/facet_queries.vm
  204. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/facet_ranges.vm
  205. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/facets.vm
  206. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/footer.vm
  207. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/head.vm
  208. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/header.vm
  209. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/hit.vm
  210. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/hitGrouped.vm
  211. 0 ...esources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/jquery.autocomplete.css
  212. 0 ...resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/jquery.autocomplete.js
  213. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/layout.vm
  214. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/main.css
  215. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/query.vm
  216. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/querySpatial.vm
  217. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/suggest.vm
  218. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/velocity/tabs.vm
  219. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/xslt/example.xsl
  220. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/xslt/example_atom.xsl
  221. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/xslt/example_rss.xsl
  222. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/xslt/luke.xsl
  223. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/conf/xslt/updateXml.xsl
  224. 0 src/test/resources/{at/pagu/soldockr → org/springframework/data/solr}/solr.xml
View
2 LICENSE
@@ -1,4 +1,4 @@
-sol-dock-r
+spring-data-solr
Apache License
Version 2.0, January 2004
View
85 pom.xml
@@ -1,16 +1,12 @@
-<!-- Copyright (C) 2012 sol-dock-r authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless
- required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
- and limitations under the License. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>at.pagu</groupId>
- <artifactId>sol-dock-r</artifactId>
- <version>0.3.0-SNAPSHOT</version>
+ <groupId>org.springframework.data</groupId>
+ <artifactId>spring-data-solr</artifactId>
+ <version>0.1.0.BUILD-SNAPSHOT</version>
<packaging>jar</packaging>
<inceptionYear>2012</inceptionYear>
- <url>http://code.google.com/p/sol-dock-r/</url>
- <name>sol-dock-r</name>
- <description>Spring Data Centric Access to Apache Solr</description>
+ <url>http://github.com/SpringSource/spring-data-solr</url>
+ <name>Spring Data Solr</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -33,18 +29,28 @@
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
+ <comments>
+ Copyright 2010 the original author or authors.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ </comments>
</license>
</licenses>
- <scm>
- <connection>scm:svn:https://sol-dock-r.googlecode.com/svn/trunk/sol-dock-r</connection>
- <developerConnection>scm:svn:https://sol-dock-r.googlecode.com/svn/trunk/sol-dock-r</developerConnection>
- <url>https://sol-dock-r.googlecode.com/svn/trunk/sol-dock-r</url>
- </scm>
-
<issueManagement>
- <system>Google Code Issue Tracking</system>
- <url>http://code.google.com/p/sol-dock-r/issues/list</url>
+ <system>JIRA</system>
+ <url>https://jira.springsource.org/browse/DATASOLR</url>
</issueManagement>
<dependencies>
@@ -252,46 +258,23 @@
</plugins>
</build>
</profile>
- <profile>
- <id>code-upload</id>
- <build>
- <plugins>
- <plugin>
- <groupId>com.googlecode.maven-gcu-plugin</groupId>
- <artifactId>maven-gcu-plugin</artifactId>
- <version>1.1</version>
- <executions>
- <execution>
- <id>gcode-upload</id>
- <goals>
- <goal>upload</goal>
- </goals>
- <phase>install</phase>
- </execution>
- </executions>
- <configuration>
- <uploads>
- <upload>
- <file>${project.build.directory}/${project.artifactId}-${project.version}.${project.packaging}</file>
- <summary>${project.name} sources bundle ${project.version}</summary>
- <labels>
- <label>Snapshot</label>
- <label>Type-Archive</label>
- </labels>
- </upload>
- </uploads>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
</profiles>
<developers>
<developer>
- <id>j73x73r</id>
+ <id>christophstrobl</id>
<name>Christoph Strobl</name>
<timezone>+1</timezone>
</developer>
+ <developer>
+ <id>ogierke</id>
+ <name>Oliver Gierke</name>
+ <timezone>+1</timezone>
+ </developer>
+ <developer>
+ <id>mpollack</id>
+ <name>Mark Pollack</name>
+ <timezone>-5</timezone>
+ </developer>
</developers>
</project>
View
81 src/main/java/at/pagu/soldockr/core/EmbeddedSolrServerFactory.java
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2012 sol-dock-r authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.pagu.soldockr.core;
-
-import java.io.File;
-import java.io.IOException;
-
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.solr.client.solrj.SolrServer;
-import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
-import org.apache.solr.core.CoreContainer;
-import org.springframework.util.ResourceUtils;
-import org.xml.sax.SAXException;
-
-import at.pagu.soldockr.SolrServerFactory;
-
-/**
- * The EmbeddedSolrServerFactory allows hosting of an SolrServer instance in embedded mode.
- * Configuration files are loaded via {@link ResourceUtils}, therefore it is possible to place them in classpath.
- * Use this class for Testing. It is not recommended for production.
- *
- * @author Christoph Strobl
- */
-public class EmbeddedSolrServerFactory implements SolrServerFactory {
-
- private static final String SOLR_HOME_SYSTEM_PROPERTY = "solr.solr.home";
-
- private EmbeddedSolrServer solrServer;
-
- /**
- * @param path Any Path expression valid for use with {@link ResourceUtils}
- * @throws ParserConfigurationException
- * @throws IOException
- * @throws SAXException
- */
-public EmbeddedSolrServerFactory(String path) throws ParserConfigurationException, IOException, SAXException {
- this.solrServer = createPathConfiguredSolrServer(path);
- }
-
- /**
- * @param path Any Path expression valid for use with {@link ResourceUtils}
- * @return new instance of {@link EmbeddedSolrServer}
- * @throws ParserConfigurationException
- * @throws IOException
- * @throws SAXException
- */
- public final EmbeddedSolrServer createPathConfiguredSolrServer(String path) throws ParserConfigurationException, IOException, SAXException {
- String solrHome = System.getProperty(SOLR_HOME_SYSTEM_PROPERTY);
-
- if (StringUtils.isBlank(solrHome)) {
- solrHome = StringUtils.remove(ResourceUtils.getURL(path).toString(), "file:/");
- }
- return new EmbeddedSolrServer(new CoreContainer(solrHome, new File(solrHome + "/solr.xml")), null);
- }
-
- @Override
- public SolrServer getSolrServer() {
- return this.solrServer;
- }
-
- @Override
- public String getCore() {
- return null;
- }
-
-}
View
123 src/main/java/at/pagu/soldockr/core/HttpSolrServerFactory.java
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2012 sol-dock-r authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.pagu.soldockr.core;
-
-import java.util.Arrays;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.params.AuthPNames;
-import org.apache.http.client.HttpClient;
-import org.apache.http.impl.client.AbstractHttpClient;
-import org.apache.solr.client.solrj.SolrServer;
-import org.apache.solr.client.solrj.impl.HttpSolrServer;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.util.Assert;
-
-import at.pagu.soldockr.SolrServerFactory;
-
-/**
- * The HttpSolrServerFactory configures an {@link HttpSolrServer} to work with the provided core.
- * If provided Credentials eg. (@link UsernamePasswordCredentials} and AuthPolicy (eg. BASIC, DIGEST,...) will be applied to the underlying
- * HttpClient.
- *
- * @author Christoph Strobl
- */
-public class HttpSolrServerFactory implements SolrServerFactory, DisposableBean {
-
- private static final String SLASH = "/";
- private final SolrServer solrServer;
- private final String core;
- private final Credentials credentials;
- private final String authPolicy;
-
- public HttpSolrServerFactory(SolrServer solrServer) {
- this(solrServer, null);
- }
-
- public HttpSolrServerFactory(SolrServer solrServer, String core) {
- this(solrServer, core, null, null);
- }
-
- public HttpSolrServerFactory(SolrServer solrServer, String core, Credentials credentials, String authPolicy) {
- Assert.notNull(solrServer, "SolrServer must not be null");
- if (authPolicy != null) {
- Assert.hasText(authPolicy);
- }
-
- this.core = core;
- this.solrServer = solrServer;
- this.credentials = credentials;
- this.authPolicy = authPolicy;
-
- appendCoreToBaseUrl(this.core, this.solrServer);
- appendAuthentication(this.credentials, this.authPolicy, this.solrServer);
- }
-
- @Override
- public SolrServer getSolrServer() {
- return this.solrServer;
- }
-
- @Override
- public String getCore() {
- return this.core;
- }
-
- private void appendCoreToBaseUrl(String core, SolrServer solrServer) {
- if (StringUtils.isNotEmpty(core) && assertSolrServerInstance(solrServer)) {
- HttpSolrServer httpSolrServer = (HttpSolrServer) solrServer;
-
- String url = httpSolrServer.getBaseURL();
- if (!StringUtils.endsWith(SLASH, url)) {
- url = url + SLASH;
- }
- url = url + core;
- httpSolrServer.setBaseURL(url);
- }
- }
-
- private void appendAuthentication(Credentials credentials, String authPolicy, SolrServer solrServer) {
- if (assertSolrServerInstance(solrServer)) {
- HttpSolrServer httpSolrServer = (HttpSolrServer) solrServer;
-
- if (credentials != null && StringUtils.isNotBlank(authPolicy) && assertHttpClientInstance(httpSolrServer.getHttpClient())) {
- AbstractHttpClient httpClient = (AbstractHttpClient) httpSolrServer.getHttpClient();
- httpClient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY), credentials);
- httpClient.getParams().setParameter(AuthPNames.TARGET_AUTH_PREF, Arrays.asList(authPolicy));
- }
- }
- }
-
- private boolean assertSolrServerInstance(SolrServer solrServer) {
- return (solrServer instanceof HttpSolrServer);
- }
-
- private boolean assertHttpClientInstance(HttpClient httpClient) {
- Assert.isInstanceOf(AbstractHttpClient.class, httpClient,
- "HttpClient has to be derivate of AbstractHttpClient in order to allow authentication.");
- return true;
- }
-
- @Override
- public void destroy() {
- if (solrServer instanceof HttpSolrServer) {
- ((HttpSolrServer) solrServer).shutdown();
- }
- }
-
-}
View
186 src/main/java/at/pagu/soldockr/core/QueryParser.java
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2012 sol-dock-r authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.pagu.soldockr.core;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.common.params.CommonParams;
-import org.apache.solr.common.params.FacetParams;
-import org.apache.solr.common.params.GroupParams;
-import org.springframework.data.domain.Pageable;
-import org.springframework.util.Assert;
-import org.springframework.util.CollectionUtils;
-
-import at.pagu.soldockr.ApiUsageException;
-import at.pagu.soldockr.core.query.FacetOptions;
-import at.pagu.soldockr.core.query.FacetQuery;
-import at.pagu.soldockr.core.query.Field;
-import at.pagu.soldockr.core.query.FilterQuery;
-import at.pagu.soldockr.core.query.Query;
-import at.pagu.soldockr.core.query.SolDockRQuery;
-
-/**
- * The QueryParser takes a sol-dock-r Query and returns a SolrQuery.
- * All Query parameters are translated into the according SolrQuery fields.
- * <b>Example:</b>
- * <code>
- * Query query = new SimpleQuery(new Criteria("field_1").is("value_1").and("field_2").startsWith("value_2")).addProjection("field_3").setPageRequest(new PageRequest(0, 10));
- * </code>
- * Will be parsed to a SolrQuery that outputs the following
- * <code>
- * q=field_1%3Avalue_1+AND+field_2%3Avalue_2*&fl=field_3&start=0&rows=10
- * </code>
- *
- * @author Christoph Strobl
- */
-public class QueryParser {
-
- /**
- * Convert given Query into a SolrQuery executable via {@link SolrServer}
- *
- * @param query
- * @return
- */
- public final SolrQuery constructSolrQuery(SolDockRQuery query) {
- Assert.notNull(query, "Cannot construct solrQuery from null value.");
- Assert.notNull(query.getCriteria(), "Query has to have a criteria.");
-
- SolrQuery solrQuery = new SolrQuery();
- solrQuery.setParam(CommonParams.Q, getQueryString(query));
- if (query instanceof Query) {
- processQueryOptions(solrQuery, (Query) query);
- }
- if (query instanceof FacetQuery) {
- processFacetOptions(solrQuery, (FacetQuery) query);
- }
- return solrQuery;
- }
-
- private void processQueryOptions(SolrQuery solrQuery, Query query) {
- appendPagination(solrQuery, query.getPageRequest());
- appendProjectionOnFields(solrQuery, query.getProjectionOnFields());
- appendGroupByFields(solrQuery, query.getGroupByFields());
- appendFilterQuery(solrQuery, query.getFilterQueries());
- }
-
- private void processFacetOptions(SolrQuery solrQuery, FacetQuery query) {
- appendFacetingOnFields(solrQuery, (FacetQuery) query);
- }
-
- /**
- * Get the queryString to use withSolrQuery.setParam(CommonParams.Q, "queryString"}
- *
- * @param query
- * @return String representation of query without faceting, pagination, projection...
- */
- public String getQueryString(SolDockRQuery query) {
- if (query.getCriteria() == null) {
- return null;
- }
- return query.getCriteria().createQueryString();
- }
-
- private void appendPagination(SolrQuery query, Pageable pageable) {
- if (pageable == null) {
- return;
- }
- query.setStart(pageable.getOffset());
- query.setRows(pageable.getPageSize());
- }
-
- private void appendProjectionOnFields(SolrQuery solrQuery, List<Field> fields) {
- if (CollectionUtils.isEmpty(fields)) {
- return;
- }
- solrQuery.setParam(CommonParams.FL, StringUtils.join(fields, ","));
- }
-
- private void appendFacetingOnFields(SolrQuery solrQuery, FacetQuery query) {
- FacetOptions facetOptions = query.getFacetOptions();
- if (facetOptions == null || !facetOptions.hasFields()) {
- return;
- }
- solrQuery.setFacet(true);
- solrQuery.addFacetField(convertFieldListToStringArray(facetOptions.getFacetOnFields()));
- solrQuery.setFacetMinCount(facetOptions.getFacetMinCount());
- solrQuery.setFacetLimit(facetOptions.getPageable().getPageSize());
- if (facetOptions.getPageable().getPageNumber() > 0) {
- solrQuery.set(FacetParams.FACET_OFFSET, facetOptions.getPageable().getOffset());
- }
- if (FacetOptions.FacetSort.INDEX.equals(facetOptions.getFacetSort())) {
- solrQuery.setFacetSort(FacetParams.FACET_SORT_INDEX);
- }
- }
-
- private void appendGroupByFields(SolrQuery solrQuery, List<Field> fields) {
- if (CollectionUtils.isEmpty(fields)) {
- return;
- }
-
- if (fields.size() > 1) {
- // there is a bug in solj which prevents multiple grouping
- // although available via HTTP call
- throw new ApiUsageException("Cannot group on more than one field with current SolrJ API. Group on single field insead");
- }
-
- solrQuery.set(GroupParams.GROUP, true);
- solrQuery.setParam(GroupParams.GROUP_MAIN, true);
-
- for (Field field : fields) {
- solrQuery.add(GroupParams.GROUP_FIELD, field.getName());
- }
- }
-
- private void appendFilterQuery(SolrQuery solrQuery, List<FilterQuery> filterQueries) {
- if (CollectionUtils.isEmpty(filterQueries)) {
- return;
- }
- List<String> filterQueryStrings = getFilterQueryStrings(filterQueries);
-
- if (!filterQueryStrings.isEmpty()) {
- solrQuery.setFilterQueries(convertStringListToArray(filterQueryStrings));
- }
- }
-
- private String[] convertFieldListToStringArray(List<Field> fields) {
- String[] strResult = new String[fields.size()];
- for (int i = 0; i < fields.size(); i++) {
- strResult[i] = fields.get(i).getName();
- }
- return strResult;
- }
-
- private String[] convertStringListToArray(List<String> listOfString) {
- String[] strResult = new String[listOfString.size()];
- listOfString.toArray(strResult);
- return strResult;
- }
-
- private List<String> getFilterQueryStrings(List<FilterQuery> filterQueries) {
- List<String> filterQueryStrings = new ArrayList<String>(filterQueries.size());
-
- for (FilterQuery filterQuery : filterQueries) {
- String filterQueryString = getQueryString(filterQuery);
- if (StringUtils.isNotBlank(filterQueryString)) {
- filterQueryStrings.add(filterQueryString);
- }
- }
- return filterQueryStrings;
- }
-}
View
81 src/main/java/at/pagu/soldockr/core/ResultHelper.java
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2012 sol-dock-r authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.pagu.soldockr.core;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.solr.client.solrj.response.FacetField;
-import org.apache.solr.client.solrj.response.FacetField.Count;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.springframework.data.domain.Page;
-import org.springframework.util.Assert;
-
-import at.pagu.soldockr.core.query.FacetQuery;
-import at.pagu.soldockr.core.query.Field;
-import at.pagu.soldockr.core.query.SimpleField;
-import at.pagu.soldockr.core.query.result.FacetEntry;
-import at.pagu.soldockr.core.query.result.FacetPage;
-import at.pagu.soldockr.core.query.result.SimpleFacetEntry;
-
-/**
- * Use Result Helper to extract various parameters from the QueryResponse and convert it into a proper Format
- * taking care of non existent and null elements with the response.
- *
- * @author Christoph Strobl
- */
-final class ResultHelper {
-
- private ResultHelper() {}
-
- static Map<Field, Page<FacetEntry>> convertFacetQueryResponseToFacetPageMap(FacetQuery query, QueryResponse response) {
- Assert.notNull(query, "Cannot convert response for 'null', query");
-
- if (!query.hasFacetOptions() || response == null) {
- return Collections.emptyMap();
- }
- Map<Field, Page<FacetEntry>> facetResult = new HashMap<Field, Page<FacetEntry>>();
-
- if (CollectionUtils.isNotEmpty(response.getFacetFields())) {
- int initalPageSize = query.getFacetOptions().getPageable().getPageSize();
- for (FacetField facetField : response.getFacetFields()) {
- if (facetField != null && StringUtils.isNotBlank(facetField.getName())) {
- Field field = new SimpleField(facetField.getName());
- if (CollectionUtils.isNotEmpty(facetField.getValues())) {
- List<FacetEntry> pageEntries = new ArrayList<FacetEntry>(initalPageSize);
- for (Count count : facetField.getValues()) {
- if (count != null) {
- pageEntries.add(new SimpleFacetEntry(field, count.getName(), count.getCount()));
- }
- }
- facetResult.put(field,
- new FacetPage<FacetEntry>(pageEntries, query.getFacetOptions().getPageable(), facetField.getValueCount()));
- } else {
- facetResult.put(field,
- new FacetPage<FacetEntry>(Collections.<FacetEntry> emptyList(), query.getFacetOptions().getPageable(), 0));
- }
- }
- }
- }
- return facetResult;
- }
-
-}
View
177 src/main/java/at/pagu/soldockr/core/SolrOperations.java
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2012 sol-dock-r authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.pagu.soldockr.core;
-
-import java.util.Collection;
-
-import org.apache.solr.client.solrj.SolrServer;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.client.solrj.response.SolrPingResponse;
-import org.apache.solr.client.solrj.response.UpdateResponse;
-import org.apache.solr.common.SolrInputDocument;
-import org.springframework.data.domain.Page;
-
-import at.pagu.soldockr.core.convert.SolrConverter;
-import at.pagu.soldockr.core.query.FacetQuery;
-import at.pagu.soldockr.core.query.Query;
-import at.pagu.soldockr.core.query.SolDockRQuery;
-import at.pagu.soldockr.core.query.result.FacetPage;
-
-/**
- * Interface that specifies a basic set of Solr operations.
- *
- * @author Christoph Strobl
- */
-public interface SolrOperations {
-
- /**
- * Get the underlying SolrServer instance
- *
- * @return
- */
- SolrServer getSolrServer();
-
- /**
- * Execute ping against solrServer and return duration in msec
- *
- * @return
- */
- SolrPingResponse executePing();
-
- /**
- * return number of elements found by for given query
- *
- * @param query
- * @return
- */
- long executeCount(SolDockRQuery query);
-
- /**
- * Execute add operation against solr
- *
- * @param obj
- * @return
- */
- UpdateResponse executeAddBean(Object obj);
-
- /**
- * Add a collection of beans to solr
- *
- * @param beans
- * @return
- */
- UpdateResponse executeAddBeans(Collection<?> beans);
-
- /**
- * Add a solrj input document to solr
- *
- * @param document
- * @return
- */
- UpdateResponse executeAddDocument(SolrInputDocument document);
-
- /**
- * Add multiple solrj input documents to solr
- *
- * @param documents
- * @return
- */
- UpdateResponse executeAddDocuments(Collection<SolrInputDocument> documents);
-
- /**
- * Find and delete all objects matching the provided Query
- *
- * @param query
- * @return
- */
- UpdateResponse executeDelete(SolDockRQuery query);
-
- /**
- * Detele the one object with provided id
- *
- * @param id
- * @return
- */
- UpdateResponse executeDeleteById(String id);
-
- /**
- * Delete objects with given ids
- *
- * @param id
- * @return
- */
- UpdateResponse executeDeleteById(Collection<String> id);
-
- /**
- * Execute query against Solr
- *
- * @param query
- * @return
- */
- QueryResponse executeQuery(SolDockRQuery query);
-
- /**
- * Execute the query against solr and return the first returned object
- *
- * @param query
- * @param clazz
- * @return the first matching object
- */
- <T> T executeObjectQuery(Query query, Class<T> clazz);
-
- /**
- * Execute the query against solr and retrun result as {@link Page}
- *
- * @param query
- * @param clazz
- * @return
- */
- <T> Page<T> executeListQuery(Query query, Class<T> clazz);
-
- /**
- * Execute a facet query against solr
- * facet result will be returned along with query result within the FacetPage
- *
- * @param query
- * @param clazz
- * @return
- */
- <T> FacetPage<T> executeFacetQuery(FacetQuery query, Class<T> clazz);
-
- /**
- * Send commit command
- */
- void executeCommit();
-
- /**
- * send rollback command
- */
- void executeRollback();
-
- /**
- * Convert given bean into a solrj InputDocument
- *
- * @param bean
- * @return
- */
- SolrInputDocument convertBeanToSolrInputDocument(Object bean);
-
- /**
- * @return Converter in use
- */
- SolrConverter getConverter();
-
-}
View
352 src/main/java/at/pagu/soldockr/core/SolrTemplate.java
@@ -1,352 +0,0 @@
-/*
- * Copyright (C) 2012 sol-dock-r authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.pagu.soldockr.core;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrServer;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.response.QueryResponse;
-import org.apache.solr.client.solrj.response.SolrPingResponse;
-import org.apache.solr.client.solrj.response.UpdateResponse;
-import org.apache.solr.common.SolrInputDocument;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.PageImpl;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.util.Assert;
-
-import at.pagu.soldockr.SolDockRException;
-import at.pagu.soldockr.SolrServerFactory;
-import at.pagu.soldockr.core.convert.MappingSolrConverter;
-import at.pagu.soldockr.core.convert.SolrConverter;
-import at.pagu.soldockr.core.mapping.SimpleSolrMappingContext;
-import at.pagu.soldockr.core.query.FacetQuery;
-import at.pagu.soldockr.core.query.Query;
-import at.pagu.soldockr.core.query.SolDockRQuery;
-import at.pagu.soldockr.core.query.result.FacetPage;
-
-/**
- * Implementation of SolrOperations
- *
- * @author Christoph Strobl
- */
-public class SolrTemplate implements SolrOperations, InitializingBean, ApplicationContextAware {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(SolrTemplate.class);
- private static final QueryParser DEFAULT_QUERY_PARSER = new QueryParser();
-
- @SuppressWarnings("serial")
- private static final List<String> ITERABLE_CLASSES = new ArrayList<String>() {
- {
- add(List.class.getName());
- add(Collection.class.getName());
- add(Iterator.class.getName());
- }
- };
-
- private SolrServerFactory solrServerFactory;
- private QueryParser queryParser = DEFAULT_QUERY_PARSER;
- private final SolrConverter solrConverter;
-
- public SolrTemplate(SolrServer solrServer) {
- this(solrServer, null);
- }
-
- public SolrTemplate(SolrServer solrServer, String core) {
- this(new HttpSolrServerFactory(solrServer, core));
- }
-
- public SolrTemplate(SolrServerFactory solrServerFactory) {
- this(solrServerFactory, null);
- }
-
- public SolrTemplate(SolrServerFactory solrServerFactory, SolrConverter solrConverter) {
- Assert.notNull(solrServerFactory, "SolrServerFactory must not be 'null'.");
- Assert.notNull(solrServerFactory.getSolrServer(), "SolrServerFactory has to return a SolrServer.");
-
- this.solrServerFactory = solrServerFactory;
- this.solrConverter = solrConverter == null ? getDefaultSolrConverter(solrServerFactory) : solrConverter;
- }
-
- public <T> T execute(SolrCallback<T> action) {
- Assert.notNull(action);
-
- try {
- SolrServer solrServer = this.getSolrServer();
- return action.doInSolr(solrServer);
- } catch (Exception e) {
- throw new SolDockRException(e);
- }
- }
-
- @Override
- public SolrPingResponse executePing() {
- return execute(new SolrCallback<SolrPingResponse>() {
- @Override
- public SolrPingResponse doInSolr(SolrServer solrServer) throws SolrServerException, IOException {
- return solrServer.ping();
- }
- });
- }
-
- @Override
- public long executeCount(final SolDockRQuery query) {
- Assert.notNull(query, "Query must not be 'null'.");
-
- return execute(new SolrCallback<Long>() {
-
- @Override
- public Long doInSolr(SolrServer solrServer) throws SolrServerException, IOException {
- SolrQuery solrQuery = queryParser.constructSolrQuery(query);
- solrQuery.setStart(0);
- solrQuery.setRows(0);
-
- return solrServer.query(solrQuery).getResults().getNumFound();
- }
- });
- }
-
- @Override
- public UpdateResponse executeAddBean(final Object objectToAdd) {
- assertNoCollection(objectToAdd);
- return execute(new SolrCallback<UpdateResponse>() {
- @Override
- public UpdateResponse doInSolr(SolrServer solrServer) throws SolrServerException, IOException {
- return solrServer.add(convertBeanToSolrInputDocument(objectToAdd));
- }
- });
- }
-
- @Override
- public UpdateResponse executeAddBeans(final Collection<?> beansToAdd) {
- return execute(new SolrCallback<UpdateResponse>() {
- @Override
- public UpdateResponse doInSolr(SolrServer solrServer) throws SolrServerException, IOException {
- return solrServer.add(convertBeansToSolrInputDocuments(beansToAdd));
- }
- });
- }
-
- @Override
- public UpdateResponse executeAddDocument(final SolrInputDocument documentToAdd) {
- return execute(new SolrCallback<UpdateResponse>() {
- @Override
- public UpdateResponse doInSolr(SolrServer solrServer) throws SolrServerException, IOException {
- return solrServer.add(documentToAdd);
- }
- });
- }
-
- @Override
- public UpdateResponse executeAddDocuments(final Collection<SolrInputDocument> documentsToAdd) {
- return execute(new SolrCallback<UpdateResponse>() {
- @Override
- public UpdateResponse doInSolr(SolrServer solrServer) throws SolrServerException, IOException {
- return solrServer.add(documentsToAdd);
- }
- });
- }
-
- @Override
- public UpdateResponse executeDelete(SolDockRQuery query) {
- Assert.notNull(query, "Query must not be 'null'.");
-
- final String queryString = this.queryParser.getQueryString(query);
-
- return execute(new SolrCallback<UpdateResponse>() {
- @Override
- public UpdateResponse doInSolr(SolrServer solrServer) throws SolrServerException, IOException {
- return solrServer.deleteByQuery(queryString);
- }
- });
- }
-
- @Override
- public UpdateResponse executeDeleteById(final String id) {
- Assert.notNull(id, "Cannot delete 'null' id.");
-
- return execute(new SolrCallback<UpdateResponse>() {
- @Override
- public UpdateResponse doInSolr(SolrServer solrServer) throws SolrServerException, IOException {
- return solrServer.deleteById(id);
- }
- });
- }
-
- @Override
- public UpdateResponse executeDeleteById(Collection<String> ids) {
- Assert.notNull(ids, "Cannot delete 'null' collection.");
-
- final List<String> toBeDeleted = new ArrayList<String>(ids);
- return execute(new SolrCallback<UpdateResponse>() {
- @Override
- public UpdateResponse doInSolr(SolrServer solrServer) throws SolrServerException, IOException {
- return solrServer.deleteById(toBeDeleted);
- }
- });
- }
-
- @Override
- public <T> T executeObjectQuery(Query query, Class<T> clazz) {
- Assert.notNull(query, "Query must not be 'null'.");
- Assert.notNull(clazz, "Target class must not be 'null'.");
-
- query.setPageRequest(new PageRequest(0, 1));
- QueryResponse response = executeQuery(query);
-
- if (response.getResults().size() > 0) {
- if (response.getResults().size() > 1) {
- LOGGER.warn("More than 1 result found for singe result query ('{}'), returning first entry in list");
- }
- return response.getBeans(clazz).get(0);
- }
- return null;
- }
-
- public <T> Page<T> executeListQuery(Query query, Class<T> clazz) {
- Assert.notNull(query, "Query must not be 'null'.");
- Assert.notNull(clazz, "Target class must not be 'null'.");
-
- QueryResponse response = executeQuery(query);
- // TODO: implement the following for grouping results
- // if (query.hasGroupBy() && query.getGroupBy().size() > 1) {
- // return SolrResultHelper.flattenGroupedQueryResult(query, response, clazz, getSolrServer().getBinder());
- // }
- return new PageImpl<T>(response.getBeans(clazz), query.getPageRequest(), response.getResults().getNumFound());
- }
-
- @Override
- public <T> FacetPage<T> executeFacetQuery(FacetQuery query, Class<T> clazz) {
- Assert.notNull(query, "Query must not be 'null'.");
- Assert.notNull(clazz, "Target class must not be 'null'.");
-
- QueryResponse response = executeQuery(query);
-
- FacetPage<T> page = new FacetPage<T>(response.getBeans(clazz), query.getPageRequest(), response.getResults().getNumFound());
- page.addAllFacetResultPages(ResultHelper.convertFacetQueryResponseToFacetPageMap(query, response));
-
- return page;
- }
-
- public final QueryResponse executeQuery(SolDockRQuery query) {
- Assert.notNull(query, "Query must not be 'null'");
-
- SolrQuery solrQuery = queryParser.constructSolrQuery(query);
- LOGGER.debug("Executing query '" + solrQuery + "' against solr.");
-
- return executeSolrQuery(solrQuery);
- }
-
- final QueryResponse executeSolrQuery(final SolrQuery solrQuery) {
- return execute(new SolrCallback<QueryResponse>() {
- @Override
- public QueryResponse doInSolr(SolrServer solrServer) throws SolrServerException, IOException {
- return solrServer.query(solrQuery);
- }
- });
- }
-
- @Override
- public void executeCommit() {
- execute(new SolrCallback<UpdateResponse>() {
- @Override
- public UpdateResponse doInSolr(SolrServer solrServer) throws SolrServerException, IOException {
- return solrServer.commit();
- }
- });
- }
-
- @Override
- public void executeRollback() {
- execute(new SolrCallback<UpdateResponse>() {
- @Override
- public UpdateResponse doInSolr(SolrServer solrServer) throws SolrServerException, IOException {
- return solrServer.rollback();
- }
- });
- }
-
- @Override
- public SolrInputDocument convertBeanToSolrInputDocument(Object bean) {
- if (bean instanceof SolrInputDocument) {
- return (SolrInputDocument) bean;
- }
-
- SolrInputDocument document = new SolrInputDocument();
- getConverter().write(bean, document);
- return document;
- }
-
- private Collection<SolrInputDocument> convertBeansToSolrInputDocuments(Iterable<?> beans) {
- if (beans == null) {
- return Collections.emptyList();
- }
- List<SolrInputDocument> resultList = new ArrayList<SolrInputDocument>();
- for (Object bean : beans) {
- resultList.add(convertBeanToSolrInputDocument(bean));
- }
- return resultList;
- }
-
- protected void assertNoCollection(Object o) {
- if (null != o) {
- if (o.getClass().isArray() || ITERABLE_CLASSES.contains(o.getClass().getName())) {
- throw new IllegalArgumentException("Collections are not supported for this operation");
- }
- }
- }
-
- private static final SolrConverter getDefaultSolrConverter(SolrServerFactory factory) {
- MappingSolrConverter converter = new MappingSolrConverter(factory, new SimpleSolrMappingContext());
- converter.afterPropertiesSet(); // have to call this one to initialize default converters
- return converter;
- }
-
- @Override
- public final SolrServer getSolrServer() {
- return solrServerFactory.getSolrServer();
- }
-
- @Override
- public SolrConverter getConverter() {
- return this.solrConverter;
- }
-
- @Override
- public void setApplicationContext(ApplicationContext applicationContext) {
- // future use
- }
-
- @Override
- public void afterPropertiesSet() {
- if (this.queryParser == null) {
- LOGGER.warn("QueryParser not set, using default one.");
- queryParser = DEFAULT_QUERY_PARSER;
- }
- }
-
-}
View
86 src/main/java/at/pagu/soldockr/core/convert/DateTimeConverters.java
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2012 sol-dock-r authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.pagu.soldockr.core.convert;
-
-import java.util.Date;
-
-import org.apache.solr.client.solrj.util.ClientUtils;
-import org.joda.time.DateTimeZone;
-import org.joda.time.LocalDateTime;
-import org.joda.time.ReadableInstant;
-import org.joda.time.format.DateTimeFormatter;
-import org.joda.time.format.ISODateTimeFormat;
-import org.springframework.core.convert.converter.Converter;
-
-/**
- * Converts a Date values into a solr readable String that can be directly used within the 'q' parameter.
- * Note that Dates have to be UTC.
- * <code>
- * Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- * calendar.set(2012, 7, 23, 6, 10, 0);
- * </code> will be formatted as
- *
- * <pre>
- * 2012\-08\-23T06\:10\:00.000Z
- * <pre>
- *
- * @author Christoph Strobl
- */
-public final class DateTimeConverters {
-
- private static DateTimeFormatter formatter = ISODateTimeFormat.dateTime().withZoneUTC();
-
- public enum JodaDateTimeConverter implements Converter<ReadableInstant, String> {
- INSTANCE;
-
- @Override
- public String convert(ReadableInstant source) {
- if (source == null) {
- return null;
- }
- return (ClientUtils.escapeQueryChars(formatter.print(source.getMillis())));
- }
-
- }
-
- public enum JodaLocalDateTimeConverter implements Converter<LocalDateTime, String> {
- INSTANCE;
-
- @Override
- public String convert(LocalDateTime source) {
- if (source == null) {
- return null;
- }
- return ClientUtils.escapeQueryChars(formatter.print(source.toDateTime(DateTimeZone.UTC).getMillis()));
- }
-
- }
-
- public enum JavaDateConverter implements Converter<Date, String> {
- INSTANCE;
-
- @Override
- public String convert(Date source) {
- if (source == null) {
- return null;
- }
-
- return ClientUtils.escapeQueryChars(formatter.print(source.getTime()));
- }
-
- }
-
-}
View
118 src/main/java/at/pagu/soldockr/core/convert/MappingSolrConverter.java
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2012 sol-dock-r authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.pagu.soldockr.core.convert;
-
-import java.util.Map;
-
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrInputDocument;
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.core.convert.ConversionService;
-import org.springframework.core.convert.support.DefaultConversionService;
-import org.springframework.core.convert.support.GenericConversionService;
-import org.springframework.data.mapping.context.MappingContext;
-import org.springframework.data.util.ClassTypeInformation;
-import org.springframework.data.util.TypeInformation;
-import org.springframework.util.Assert;
-
-import at.pagu.soldockr.SolrServerFactory;
-import at.pagu.soldockr.core.mapping.SolrPersistentEntity;
-import at.pagu.soldockr.core.mapping.SolrPersistentProperty;
-
-/**
- * @author Christoph Strobl
- */
-public class MappingSolrConverter implements SolrConverter, ApplicationContextAware, InitializingBean {
-
- private final MappingContext<? extends SolrPersistentEntity<?>, SolrPersistentProperty> mappingContext;
- private final GenericConversionService conversionService;
-
- @SuppressWarnings("unused")
- private ApplicationContext applicationContext;
- private SolrServerFactory solrServerFactory;
- private SolrTypeMapper typeMapper;
-
- public MappingSolrConverter(SolrServerFactory solrServerFactory, MappingContext<? extends SolrPersistentEntity<?>, SolrPersistentProperty> mappingContext) {
- Assert.notNull(solrServerFactory);
- Assert.notNull(mappingContext);
-
- this.solrServerFactory = solrServerFactory;
- this.mappingContext = mappingContext;
- this.typeMapper = new SimpleSolrTypeMapper(mappingContext);
- conversionService = new DefaultConversionService();
- }
-
- @Override
- public MappingContext<? extends SolrPersistentEntity<?>, SolrPersistentProperty> getMappingContext() {
- return mappingContext;
- }
-
- @Override
- public ConversionService getConversionService() {
- return this.conversionService;
- }
-
- @Override
- public <R> R read(Class<R> type, Map<String, ?> source) {
- return read(ClassTypeInformation.from(type), source);
- }
-
- protected <S extends Object> S read(TypeInformation<S> targetTypeInformation, Map<String, ?> source) {
- TypeInformation<? extends S> typeToUse = typeMapper.readType(source, targetTypeInformation);
- Class<? extends S> rawType = typeToUse.getType();
-
- if (!conversionService.canConvert(SolrDocument.class, rawType)) {
- initializeTypedConverter(source, rawType);
- }
-
- return conversionService.convert(source, rawType);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void write(Object source, @SuppressWarnings("rawtypes") Map target) {
- if (source == null) {
- return;
- }
-
- SolrInputDocument convertedDocument = conversionService.convert(source, SolrInputDocument.class);
- target.putAll(convertedDocument);
- }
-
- @Override
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
- this.applicationContext = applicationContext;
- }
-
- public void afterPropertiesSet() {
- initializeConverters();
- }
-
- private void initializeConverters() {
- if (!conversionService.canConvert(Object.class, SolrInputDocument.class)) {
- conversionService.addConverter(new SolrjConverters.ObjectToSolrInputDocumentConverter(solrServerFactory.getSolrServer().getBinder()));
- }
- }
-
- @SuppressWarnings("unchecked")
- private <S> void initializeTypedConverter(Map<String, ?> source, Class<? extends S> rawType) {
- conversionService.addConverter(source.getClass(), rawType, new SolrjConverters.SolrInputDocumentToObjectConverter<S>((Class<S>) rawType));
- }
-
-}
View
87 src/main/java/at/pagu/soldockr/core/convert/SolrjConverters.java
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2012 sol-dock-r authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.pagu.soldockr.core.convert;
-
-import java.util.Map;
-
-import org.apache.solr.client.solrj.beans.DocumentObjectBinder;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrInputDocument;
-import org.springframework.core.convert.converter.Converter;
-
-/**
- * Offers classes that can convert from SolrDocument to any Object and vice versa using the solrj DocumentObjectBinder
- *
- * @author Christoph Strobl
- */
-final class SolrjConverters {
-
- private SolrjConverters() {
-
- }
-
- abstract static class DocumentBinderConverter {
- protected final DocumentObjectBinder documentObejctBinder;
-
- public DocumentBinderConverter(DocumentObjectBinder binder) {
- this.documentObejctBinder = binder != null ? binder : new DocumentObjectBinder();
- }
-
- }
-
- public static class ObjectToSolrInputDocumentConverter extends DocumentBinderConverter implements Converter<Object, SolrInputDocument> {
-
- public ObjectToSolrInputDocumentConverter(DocumentObjectBinder binder) {
- super(binder);
- }
-
- @Override
- public SolrInputDocument convert(Object source) {
- if (source == null) {
- return null;
- }
-
- return documentObejctBinder.toSolrInputDocument(source);
- }
- }
-
- public static class SolrInputDocumentToObjectConverter<T> extends DocumentBinderConverter implements Converter<Map<String, ?>, T> {
-
- private Class<T> clazz;
-
- public SolrInputDocumentToObjectConverter(Class<T> clazz) {
- this(clazz, null);
- }
-
- public SolrInputDocumentToObjectConverter(Class<T> clazz, DocumentObjectBinder binder) {
- super(binder);
- this.clazz = clazz;
- }
-
- @Override
- public T convert(Map<String, ?> source) {
- if (source == null) {
- return null;
- }
- SolrDocument document = new SolrDocument();
- document.putAll(source);
-
- return documentObejctBinder.getBean(clazz, document);
- }
-
- }
-
-}
View
70 src/main/java/at/pagu/soldockr/core/mapping/SimpleSolrPersistentEntity.java
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2012 sol-dock-r authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.pagu.soldockr.core.mapping;
-
-import java.util.Locale;
-
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.expression.BeanFactoryAccessor;
-import org.springframework.context.expression.BeanFactoryResolver;
-import org.springframework.data.mapping.model.BasicPersistentEntity;
-import org.springframework.data.util.TypeInformation;
-import org.springframework.expression.spel.support.StandardEvaluationContext;
-import org.springframework.util.StringUtils;
-
-/**
- * Solr specific {@link PersistentEntity} implementation holding eg. name of solr core
- *
- * @param <T>
- * @author Christoph Strobl
- */
-public class SimpleSolrPersistentEntity<T> extends BasicPersistentEntity<T, SolrPersistentProperty> implements SolrPersistentEntity<T>, ApplicationContextAware {
-
- private final StandardEvaluationContext context;
- private String solrCoreName;
-
- public SimpleSolrPersistentEntity(TypeInformation<T> typeInformation) {
- super(typeInformation);
- this.context = new StandardEvaluationContext();
- this.solrCoreName = derivateSolrCoreNameFromClass(typeInformation.getType());
- }
-
- @Override
- public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
- context.addPropertyAccessor(new BeanFactoryAccessor());
- context.setBeanResolver(new BeanFactoryResolver(applicationContext));
- context.setRootObject(applicationContext);
- }
-
- private String derivateSolrCoreNameFromClass(Class<?> clazz) {
- String derivativeSolrCoreName = clazz.getSimpleName().toLowerCase(Locale.ENGLISH);
- if (clazz.isAnnotationPresent(SolrDocument.class)) {
- SolrDocument solrDocument = clazz.getAnnotation(SolrDocument.class);
- if (StringUtils.hasText(solrDocument.solrCoreName())) {
- derivativeSolrCoreName = solrDocument.solrCoreName();
- }
- }
- return derivativeSolrCoreName;
- }
-
- @Override
- public String getSolrCoreName() {
- return this.solrCoreName;
- }
-
-}
View
75 src/main/java/at/pagu/soldockr/core/mapping/SimpleSolrPersistentProperty.java
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2012 sol-dock-r authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.pagu.soldockr.core.mapping;
-
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Field;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.springframework.data.mapping.Association;
-import org.springframework.data.mapping.PersistentEntity;
-import org.springframework.data.mapping.model.AnnotationBasedPersistentProperty;
-import org.springframework.data.mapping.model.SimpleTypeHolder;
-import org.springframework.util.StringUtils;
-
-/**
- * Solr specific {@link PersistentProperty} implementation processing taking {@link org.apache.solr.client.solrj.beans.Field} into account
- *
- * @author Christoph Strobl
- *
- */
-public class SimpleSolrPersistentProperty extends AnnotationBasedPersistentProperty<SolrPersistentProperty> implements
- SolrPersistentProperty {
-
- private static final Set<Class<?>> SUPPORTED_ID_TYPES = new HashSet<Class<?>>();
- private static final Set<String> SUPPORTED_ID_PROPERTY_NAMES = new HashSet<String>();
-
- static {
- SUPPORTED_ID_TYPES.add(String.class);
- SUPPORTED_ID_PROPERTY_NAMES.add("id");
- }
-
- public SimpleSolrPersistentProperty(Field field, PropertyDescriptor propertyDescriptor,
- PersistentEntity<?, SolrPersistentProperty> owner, SimpleTypeHolder simpleTypeHolder) {
- super(field, propertyDescriptor, owner, simpleTypeHolder);
- }
-
- @Override
- public String getFieldName() {
- org.apache.solr.client.solrj.beans.Field annotation = getField().getAnnotation(org.apache.solr.client.solrj.beans.Field.class);
-
- if (StringUtils.hasText(annotation.value()) && !("#default".equals(annotation.value()))) {
- return annotation.value();
- }
- return field.getName();
- }
-
- @Override
- public boolean isIdProperty() {
- if (super.isIdProperty()) {
- return true;
- }
-
- return SUPPORTED_ID_PROPERTY_NAMES.contains(getFieldName());
- }
-
- @Override
- protected Association<SolrPersistentProperty> createAssociation() {
- return null;
- }
-
-}
View
55 src/main/java/at/pagu/soldockr/core/query/AbstractQuery.java
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2012 sol-dock-r authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.pagu.soldockr.core.query;
-
-import org.springframework.util.Assert;
-
-/**
- * Base QueryImplementation enables and conjunction by adding criterias
- *
- * @author Christoph Strobl
- */
-class AbstractQuery {
-
- private Criteria criteria;
-
- AbstractQuery() {}
-
- AbstractQuery(Criteria criteria) {
- this.addCriteria(criteria);
- }
-
- @SuppressWarnings("unchecked")
- public final <T extends SolDockRQuery> T addCriteria(Criteria criteria) {
- Assert.notNull(criteria, "Cannot add null criteria.");
- if (!(criteria instanceof SimpleStringCriteria)) {
- Assert.notNull(criteria.getField(), "Cannot add criteria for null field.");
- Assert.hasText(criteria.getField().getName(), "Criteria.field.name must not be null/empty.");
- }
-
- if (this.criteria == null) {
- this.criteria = criteria;
- } else {
- this.criteria.and(criteria);
- }
- return (T) this;
- }
-
- public Criteria getCriteria() {
- return this.criteria;
- }
-
-}
View
628 src/main/java/at/pagu/soldockr/core/query/Criteria.java
@@ -1,628 +0,0 @@
-/*
- * Copyright (C) 2012 sol-dock-r authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package at.pagu.soldockr.core.query;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Set;
-
-import org.apache.commons.lang.StringUtils;
-import org.springframework.core.convert.converter.Converter;
-import org.springframework.core.convert.support.GenericConversionService;
-import org.springframework.util.Assert;
-
-import at.pagu.soldockr.ApiUsageException;
-import at.pagu.soldockr.core.convert.DateTimeConverters;
-import at.pagu.soldockr.core.convert.NumberConverters;
-
-/**
- * Criteria is the central class when constructing queries.
- * It follows more or less a fluent API style, which allows to easily chain together multiple criteria.
- *
- * @author Christoph Strobl
- */
-public class Criteria implements QueryStringHolder {
-
- public static final String WILDCARD = "*";
- public static final String CRITERIA_VALUE_SEPERATOR = " ";
-
- private static final String OR_OPERATOR = " OR ";
- private static final String DELIMINATOR = ":";
- private static final String AND_OPERATOR = " AND ";
- private static final String RANGE_OPERATOR = " TO ";
- private static final String DOUBLEQUOTE = "\"";
- private static final String[] RESERVED_CHARS = {DOUBLEQUOTE, "+", "-", "&&", "||", "!", "(", ")", "{", "}", "[", "]", "^", "~", "*", "?", ":", "\\"};
- private static final String[] RESERVED_CHARS_REPLACEMENT = {"\\" + DOUBLEQUOTE, "\\+", "\\-", "\\&\\&", "\\|\\|", "\\!", "\\(", "\\)", "\\{", "\\}", "\\[", "\\]", "\\^", "\\~", "\\*", "\\?", "\\:",
- "\\\\"};
-
- private final GenericConversionService conversionService = new GenericConversionService();
-
- private Field field;
- private float boost = Float.NaN;
-
- private List<Criteria> criteriaChain = new ArrayList<Criteria>(1);
-
- private Set<CriteriaEntry> criteria = new LinkedHashSet<CriteriaEntry>();
-
- {
- if (!conversionService.canConvert(java.util.Date.class, String.class)) {
- conversionService.addConverter(DateTimeConverters.JavaDateConverter.INSTANCE);
- }
- if (!conversionService.canConvert(org.joda.time.ReadableInstant.class, String.class)) {
- conversionService.addConverter(DateTimeConverters.JodaDateTimeConverter.INSTANCE);
- }
- if (!conversionService.canConvert(org.joda.time.LocalDateTime.class, String.class)) {
- conversionService.addConverter(DateTimeConverters.JodaLocalDateTimeConverter.INSTANCE);
- }
- if (!conversionService.canConvert(Number.class, String.class)) {
- conversionService.addConverter(NumberConverters.NumberConverter.INSTANCE);
- }
- }
-
- public Criteria() {}
-
- /**
- * Creates a new Criteria for the Filed with provided name
- *
- * @param fieldname
- */
- public Criteria(String fieldname) {
- this(new SimpleField(fieldname));
- }
-
- /**
- * Creates a new Criteria for the given field
- *
- * @param field
- */
- public Criteria(Field field) {
- Assert.notNull(field, "Field for criteria must not be null");
- Assert.hasText(field.getName(), "Field.name for criteria must not be null/empty");
-
- this.criteriaChain.add(this);
- this.field = field;
- }
-
- protected Criteria(List<Criteria> criteriaChain, String fieldname) {
- this(criteriaChain, new SimpleField(fieldname));
- }
-
- protected Criteria(List<Criteria> criteriaChain, Field field) {
- Assert.notNull(criteriaChain, "CriteriaChain must not be null");
- Assert.notNull(field, "Field for criteria must not be null");
- Assert.hasText(field.getName(), "Field.name for criteria must not be null/empty");
-
- this.criteriaChain.addAll(criteriaChain);
- this.criteriaChain.add(this);
- this.field = field;
- }
-
- /**
- * Static factory method to create a new Criteria for field with given name
- *
- * @param field
- * @return
- */
- public static Criteria where(String field) {
- return where(new SimpleField(field));
- }
-
- /**
- * Static factory method to create a new Criteria for provided field
- *
- * @param field
- * @return
- */
- public static Criteria where(Field field) {
- return new Criteria(field);
- }
-
- /**
- * Chain using AND
- *
- * @param field
- * @return
- */
- public Criteria and(Field field) {
- return new Criteria(this.criteriaChain, field);
- }
-
- /**
- * Chain using AND
- *
- * @param field
- * @return
- */
- public Criteria and(String fieldname) {
- return new Criteria(this.criteriaChain, fieldname);
- }
-
- /**
- * Chain using AND
- *
- * @param field
- * @return
- */
- public Criteria and(Criteria criteria) {
- this.criteriaChain.add(criteria);
- return this;
- }
-
- /**
- * Chain using AND
- *
- * @param field
- * @return
- */
- public Criteria and(Criteria... criterias) {
- this.criteriaChain.addAll(Arrays.asList(criterias));
- return this;
- }
-
- /**
- * Chain using OR
- *
- * @param field
- * @return
- */
- public Criteria or(Field field) {
- return new OrCriteria(this.criteriaChain, field);
- }
-
- /**
- * Chain using OR
- *
- * @param field
- * @return
- */
- public Criteria or(Criteria criteria) {
- Assert.notNull(criteria, "Cannot chain 'null' criteria.");
-
- Criteria orConnectedCritiera = new OrCriteria(this.criteriaChain, criteria.getField());
- orConnectedCritiera.criteria.addAll(criteria.criteria);
- return orConnectedCritiera;
- }
-
- /**
- * Chain using OR
- *
- * @param field
- * @return
- */
- public Criteria or(String fieldname) {
- return or(new SimpleField(fieldname));
- }
-
- /**
- * Crates new CriteriaEntry without any wildcards
- *
- * @param o
- * @return
- */
- public Criteria is(Object o) {
- criteria.add(new CriteriaEntry(OperationKey.EQUALS, o));
- return this;
- }
-
- /**
- * Crates new CriteriaEntry with leading and trailing wildcards
- *
- * @param o
- * @return
- */
- public Criteria contains(String s) {
- assertNoBlankInWildcardedQuery(s, true, true);
- criteria.add(new CriteriaEntry(OperationKey.CONTAINS, s));
- return this;
- }
-
- /**
- * Crates new CriteriaEntry with leading wildcard
- *
- * @param o
- * @return
- */
- public Criteria startsWith(String s) {
- assertNoBlankInWildcardedQuery(s, true, false);
- criteria.add(new CriteriaEntry(OperationKey.STARTS_WITH, s));
- return this;
- }
-
- /**
- * Crates new CriteriaEntry with trailing wildcards
- *
- * @param o
- * @return
- */
- public Criteria endsWith(String s) {
- assertNoBlankInWildcardedQuery(s, false, true);
- criteria.add(new CriteriaEntry(OperationKey.ENDS_WITH, s));
- return this;
- }
-
- /**
- * Crates new CriteriaEntry with trailing -
- *
- * @param s
- * @return
- */
- public Criteria isNot(Object o) {
- criteria.add(new CriteriaEntry(OperationKey.IS_NOT, o));
- return this;
- }
-
- /**
- * Crates new CriteriaEntry with trailing ~
- *
- * @param s
- * @return
- */
- public