Toggle navigation
Toggle navigation
This project
Loading...
Sign in
grogv3
/
grog-cubi
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jean-Francois Leveque
2017-02-02 10:35:40 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9b33387470216584fdf78ad13aeb27c4a192d356
9b333874
1 parent
882afe0f
Indexation éditeur avec couche abstraction.
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
13 deletions
pom.xml
src/main/java/org/legrog/configuration/SolrJConfiguration.java
src/main/java/org/legrog/entities/IndexedPublisher.java
src/main/java/org/legrog/entities/PublisherSearchRepository.java
src/main/java/org/legrog/entities/PublisherSearchRepositorySolrj.java
src/main/java/org/legrog/web/publisher/PublisherServiceSpring.java
pom.xml
View file @
9b33387
...
...
@@ -81,8 +81,14 @@
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>
org.apache.solr
</groupId>
<artifactId>
solr-solrj
</artifactId>
<version>
${solr.version}
</version>
</dependency>
<!--
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-core</artifactId>
...
...
@@ -100,7 +106,7 @@
<artifactId>spring-data-solr</artifactId>
<version>${spring-data-solr.version}</version>
</dependency>
-->
<!-- **** FRAMEWORK : JSF + CDI **** -->
<dependency>
...
...
src/main/java/org/legrog/configuration/SolrJConfiguration.java
0 → 100644
View file @
9b33387
package
org
.
legrog
.
configuration
;
import
org.apache.solr.client.solrj.SolrClient
;
import
org.apache.solr.client.solrj.impl.HttpSolrClient
;
import
javax.enterprise.inject.Produces
;
public
class
SolrJConfiguration
{
@Produces
public
SolrClient
createSolrClient
()
{
return
new
HttpSolrClient
.
Builder
(
"http://localhost:8983/solr/publishers"
).
build
();
}
}
src/main/java/org/legrog/entities/IndexedPublisher.java
View file @
9b33387
package
org
.
legrog
.
entities
;
/*
import
org.apache.solr.client.solrj.beans.Field
;
/*
import org.springframework.data.solr.core.mapping.SolrDocument;
*/
import
javax.persistence.Id
;
...
...
@@ -9,12 +9,12 @@ import javax.persistence.Lob;
//@SolrDocument(solrCoreName = "publishers")
public
class
IndexedPublisher
{
@Id
//
@Field
@Field
private
int
publisherId
;
//
@Field
@Field
private
String
publisherName
;
@Lob
//
@Field
@Field
private
String
publisherHistory
;
public
IndexedPublisher
(
Publisher
publisher
)
{
...
...
src/main/java/org/legrog/entities/PublisherSearchRepository.java
View file @
9b33387
package
org
.
legrog
.
entities
;
import
org.springframework.data.jpa.repository.Query
;
//import org.springframework.data.solr.repository.SolrCrudRepository;
//import org.springframework.data.solr.repository.Query;
import
java.util.List
;
public
interface
PublisherSearchRepository
/*extends SolrCrudRepository<IndexedPublisher, Integer>*/
{
@Query
(
"?0"
)
List
<
IndexedPublisher
>
search
(
String
search
);
// @Query("?0")
// List<IndexedPublisher> search(String search);
public
IndexedPublisher
save
(
IndexedPublisher
indexedPublisher
);
}
...
...
src/main/java/org/legrog/entities/PublisherSearchRepositorySolrj.java
0 → 100644
View file @
9b33387
package
org
.
legrog
.
entities
;
import
org.apache.solr.client.solrj.SolrClient
;
import
org.apache.solr.client.solrj.SolrServerException
;
import
org.apache.solr.client.solrj.response.UpdateResponse
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.inject.Inject
;
import
java.io.IOException
;
public
class
PublisherSearchRepositorySolrj
implements
PublisherSearchRepository
{
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
SolrClient
solrClient
;
@Inject
PublisherSearchRepositorySolrj
(
SolrClient
solrClient
)
{
this
.
solrClient
=
solrClient
;
}
//no args constructor to make it proxyable
PublisherSearchRepositorySolrj
()
{
}
@Override
public
IndexedPublisher
save
(
IndexedPublisher
indexedPublisher
)
{
try
{
UpdateResponse
updateResponse
=
solrClient
.
addBean
(
indexedPublisher
,
1
);
logger
.
trace
(
"validatePublisherVersion SolrJ UpdateResponse {}"
,
updateResponse
);
}
catch
(
IOException
ioe
)
{
logger
.
error
(
"validatePublisherVersion IOException {}"
,
ioe
.
getMessage
());
}
catch
(
SolrServerException
sse
)
{
logger
.
error
(
"validatePublisherVersion SolrServerException {}"
,
sse
.
getMessage
());
}
return
indexedPublisher
;
}
}
src/main/java/org/legrog/web/publisher/PublisherServiceSpring.java
View file @
9b33387
...
...
@@ -8,7 +8,6 @@ import org.slf4j.LoggerFactory;
import
javax.ejb.Stateless
;
import
javax.inject.Inject
;
import
javax.transaction.Transactional
;
import
java.sql.Timestamp
;
import
java.util.Date
;
import
java.util.HashSet
;
...
...
@@ -73,7 +72,6 @@ public class PublisherServiceSpring implements PublisherService {
return
publisherVersion
;
}
@Transactional
public
PublisherAction
validatePublisherVersion
(
PublisherVersion
publisherVersion
)
{
Publisher
publisher
=
publisherVersion
.
getPublisher
();
publisher
.
setValidatedVersion
(
publisherVersion
);
...
...
@@ -85,7 +83,7 @@ public class PublisherServiceSpring implements PublisherService {
publisherAction
.
setPublisher
(
publisher
);
this
.
savePublisher
(
publisher
);
IndexedPublisher
indexedPublisher
=
new
IndexedPublisher
(
publisher
);
//
publisherSearchRepository.save(indexedPublisher);
publisherSearchRepository
.
save
(
indexedPublisher
);
publisherActionRepository
.
save
(
publisherAction
);
return
publisherAction
;
}
...
...
@@ -108,7 +106,7 @@ public class PublisherServiceSpring implements PublisherService {
}
public
PublisherAction
getLastValidate
(
Publisher
publisher
)
{
return
publisherActionRepository
.
findFirstByActionTypeAndPublisherOrderByPublisherActionDatetime
(
ActionType
.
VALIDATE
,
publisher
);
return
publisherActionRepository
.
findFirstByActionTypeAndPublisherOrderByPublisherActionDatetime
Desc
(
ActionType
.
VALIDATE
,
publisher
);
}
public
List
<
PublisherAction
>
getAllPublisherActions
()
{
...
...
Please
register
or
login
to post a comment