Jean-Francois Leveque

Début implantation intégration indexation.

11.1 KB | W: | H:

36.8 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
1 @startuml 1 @startuml
2 +Actor Visiteur
3 +Visiteur -> PublisherSearchPage: (String)
4 +PublisherSearchPage -> PublisherSearchView: search(String)
5 +
2 Activate PublisherSearchView 6 Activate PublisherSearchView
3 -PublisherSearchView -> PublisherService: search 7 +PublisherSearchView -> PublisherService: search(String)
4 Activate PublisherService 8 Activate PublisherService
5 -PublisherService -> PublisherServiceSpring: search 9 +PublisherService -> PublisherServiceSpring: search(String)
6 Activate PublisherServiceSpring 10 Activate PublisherServiceSpring
7 11
8 -PublisherServiceSpring -> PublisherSearchRepository: search 12 +PublisherServiceSpring -> PublisherSearchRepository: search(String)
9 Activate PublisherSearchRepository 13 Activate PublisherSearchRepository
10 -PublisherSearchRepository --> PublisherServiceSpring 14 +PublisherSearchRepository --> PublisherServiceSpring: (List<IndexedPublisher>)
11 Deactivate PublisherSearchRepository 15 Deactivate PublisherSearchRepository
16 +PublisherServiceSpring -> PublisherServiceSpring: convert(List<IndexedPublisher>)
17 +Activate PublisherServiceSpring
18 +PublisherServiceSpring -> PublisherVersionRepository: findByPublisherVersionIdIn(List<int>)
19 +Activate PublisherVersionRepository
20 +PublisherVersionRepository --> PublisherServiceSpring: (List<PublisherVersion>)
21 +Deactivate PublisherVersionRepository
22 +PublisherServiceSpring --> PublisherServiceSpring: (List<PublisherVersion>)
23 +Deactivate PublisherServiceSpring
12 24
13 -PublisherServiceSpring --> PublisherService 25 +PublisherServiceSpring --> PublisherService: (List<PublisherVersion>)
14 Deactivate PublisherServiceSpring 26 Deactivate PublisherServiceSpring
15 -PublisherService --> PublisherSearchView 27 +PublisherService --> PublisherSearchView: (List<PublisherVersion>)
16 Deactivate PublisherService 28 Deactivate PublisherService
29 +PublisherSearchView --> PublisherSearchPage: (List<PublisherVersion>)
17 Deactivate PublisherSearchView 30 Deactivate PublisherSearchView
31 +PublisherSearchPage --> Visiteur: resultPage
18 @enduml 32 @enduml
...\ No newline at end of file ...\ No newline at end of file
......

20.1 KB | W: | H:

35 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
1 @startuml 1 @startuml
2 +Actor Validator
3 +Validator -> ListPublisherVersionsPage: validate(PublisherVersion)
4 +ListPublisherVersionsPage -> ListPublisherVersionsView: validate(PublisherVersion)
2 Activate ListPublisherVersionsView 5 Activate ListPublisherVersionsView
3 -ListPublisherVersionsView -> PublisherService: validatePublisherVersion 6 +
7 +ListPublisherVersionsView -> PublisherService: validatePublisherVersion(PublisherVersion)
4 Activate PublisherService 8 Activate PublisherService
5 -PublisherService -> PublisherServiceSpring: validatePublisherVersion 9 +PublisherService -> PublisherServiceSpring: validatePublisherVersion(PublisherVersion)
6 Activate PublisherServiceSpring 10 Activate PublisherServiceSpring
7 -PublisherServiceSpring -> PublisherServiceSpring: savePublisher 11 +PublisherServiceSpring -> PublisherServiceSpring: savePublisher(Publisher)
8 -
9 Activate PublisherServiceSpring 12 Activate PublisherServiceSpring
10 -PublisherServiceSpring -> PublisherRepository: save 13 +
14 +PublisherServiceSpring -> PublisherRepository: save(Publisher)
11 Activate PublisherRepository 15 Activate PublisherRepository
12 PublisherRepository --> PublisherServiceSpring 16 PublisherRepository --> PublisherServiceSpring
13 Deactivate PublisherRepository 17 Deactivate PublisherRepository
14 -PublisherServiceSpring -> PublisherActionRepository: save 18 +Deactivate PublisherServiceSpring
15 -Activate PublisherActionRepository 19 +
16 -PublisherActionRepository --> PublisherServiceSpring 20 +PublisherServiceSpring -> PublisherSearchRepository: save(IndexedPublisher)
17 -Deactivate PublisherActionRepository
18 -PublisherServiceSpring -> PublisherSearchRepository: save
19 Activate PublisherSearchRepository 21 Activate PublisherSearchRepository
20 PublisherSearchRepository --> PublisherServiceSpring 22 PublisherSearchRepository --> PublisherServiceSpring
21 Deactivate PublisherSearchRepository 23 Deactivate PublisherSearchRepository
22 -Deactivate PublisherServiceSpring 24 +
25 +PublisherServiceSpring -> PublisherActionRepository: save(PublisherAction)
26 +Activate PublisherActionRepository
27 +PublisherActionRepository --> PublisherServiceSpring
28 +Deactivate PublisherActionRepository
23 29
24 PublisherServiceSpring --> PublisherService 30 PublisherServiceSpring --> PublisherService
25 Deactivate PublisherServiceSpring 31 Deactivate PublisherServiceSpring
26 PublisherService --> ListPublisherVersionsView 32 PublisherService --> ListPublisherVersionsView
27 Deactivate PublisherService 33 Deactivate PublisherService
34 +
35 +ListPublisherVersionsView --> ListPublisherVersionsPage
28 Deactivate ListPublisherVersionsView 36 Deactivate ListPublisherVersionsView
37 +ListPublisherVersionsPage -> Validator: (resultPage)
29 @enduml 38 @enduml
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
31 <junit.platform.version>1.0.0-M2</junit.platform.version> 31 <junit.platform.version>1.0.0-M2</junit.platform.version>
32 <junit.jupiter.version>5.0.0-M2</junit.jupiter.version> 32 <junit.jupiter.version>5.0.0-M2</junit.jupiter.version>
33 <mockito-core.version>2.2.16</mockito-core.version> 33 <mockito-core.version>2.2.16</mockito-core.version>
34 + <spring-data-solr.version>3.0.0.M1</spring-data-solr.version>
35 + <solr.version>6.3.0</solr.version>
34 36
35 <!-- paths --> 37 <!-- paths -->
36 <custom.web.dir>src/main/java/org/legrog/web</custom.web.dir> 38 <custom.web.dir>src/main/java/org/legrog/web</custom.web.dir>
...@@ -81,7 +83,23 @@ ...@@ -81,7 +83,23 @@
81 </dependencyManagement> 83 </dependencyManagement>
82 84
83 <dependencies> 85 <dependencies>
84 - 86 + <dependency>
87 + <groupId>org.apache.solr</groupId>
88 + <artifactId>solr-core</artifactId>
89 + <version>${solr.version}</version>
90 + </dependency>
91 + <dependency>
92 + <artifactId>solr-solrj</artifactId>
93 + <groupId>org.apache.solr</groupId>
94 + <version>${solr.version}</version>
95 + <type>jar</type>
96 + <scope>compile</scope>
97 + </dependency>
98 + <dependency>
99 + <groupId>org.springframework.data</groupId>
100 + <artifactId>spring-data-solr</artifactId>
101 + <version>${spring-data-solr.version}</version>
102 + </dependency>
85 103
86 <!-- **** FRAMEWORK : JSF + CDI **** --> 104 <!-- **** FRAMEWORK : JSF + CDI **** -->
87 105
...@@ -372,6 +390,9 @@ ...@@ -372,6 +390,9 @@
372 <groupId>org.apache.maven.plugins</groupId> 390 <groupId>org.apache.maven.plugins</groupId>
373 <artifactId>maven-surefire-plugin</artifactId> 391 <artifactId>maven-surefire-plugin</artifactId>
374 <version>2.19.1</version> 392 <version>2.19.1</version>
393 + <configuration>
394 + <trimStackTrace>false</trimStackTrace>
395 + </configuration>
375 </plugin> 396 </plugin>
376 <plugin> 397 <plugin>
377 <groupId>org.apache.maven.plugins</groupId> 398 <groupId>org.apache.maven.plugins</groupId>
...@@ -494,6 +515,16 @@ ...@@ -494,6 +515,16 @@
494 <name>Apache Snapshot Repository</name> 515 <name>Apache Snapshot Repository</name>
495 <url>https://repository.apache.org/content/groups/snapshots/</url> 516 <url>https://repository.apache.org/content/groups/snapshots/</url>
496 </repository> 517 </repository>
518 + <repository>
519 + <id>alfresco-public</id>
520 + <name>Alfresco Public Repository</name>
521 + <url>https://artifacts.alfresco.com/nexus/content/repositories/public/</url>
522 + </repository>
523 + <repository>
524 + <id>maven2-central</id>
525 + <name>Central Repository</name>
526 + <url>http://central.maven.org/maven2/</url>
527 + </repository>
497 </repositories> 528 </repositories>
498 529
499 </project> 530 </project>
......
1 +package org.legrog.entities;
2 +/*
3 +import org.apache.solr.client.solrj.beans.Field;
4 +import org.springframework.data.solr.core.mapping.SolrDocument;
5 +*/
6 +import javax.persistence.Id;
7 +import javax.persistence.Lob;
8 +
9 +//@SolrDocument(solrCoreName = "publishers")
10 +public class IndexedPublisher {
11 + @Id
12 +// @Field
13 + private int publisherId;
14 +// @Field
15 + private String publisherName;
16 + @Lob
17 +// @Field
18 + private String publisherHistory;
19 +
20 + public IndexedPublisher(Publisher publisher) {
21 + PublisherVersion publisherVersion = publisher.getValidatedVersion();
22 + this.publisherId = publisher.getPublisherId();
23 + this.publisherName = publisherVersion.getPublisherName();
24 + this.publisherHistory = publisherVersion.getPublisherHistory();
25 + }
26 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package org.legrog.entities;
2 +
3 +import org.springframework.data.jpa.repository.Query;
4 +//import org.springframework.data.solr.repository.SolrCrudRepository;
5 +
6 +import java.util.List;
7 +
8 +public interface PublisherSearchRepository /*extends SolrCrudRepository<IndexedPublisher, Integer>*/ {
9 + @Query("?0")
10 + List<IndexedPublisher> search(String search);
11 +}
...@@ -8,6 +8,7 @@ import org.slf4j.LoggerFactory; ...@@ -8,6 +8,7 @@ import org.slf4j.LoggerFactory;
8 8
9 import javax.ejb.Stateless; 9 import javax.ejb.Stateless;
10 import javax.inject.Inject; 10 import javax.inject.Inject;
11 +import javax.transaction.Transactional;
11 import java.sql.Timestamp; 12 import java.sql.Timestamp;
12 import java.util.Date; 13 import java.util.Date;
13 import java.util.HashSet; 14 import java.util.HashSet;
...@@ -25,16 +26,19 @@ public class PublisherServiceSpring implements PublisherService { ...@@ -25,16 +26,19 @@ public class PublisherServiceSpring implements PublisherService {
25 PublisherRepository publisherRepository; 26 PublisherRepository publisherRepository;
26 PublisherVersionRepository publisherVersionRepository; 27 PublisherVersionRepository publisherVersionRepository;
27 PublisherActionRepository publisherActionRepository; 28 PublisherActionRepository publisherActionRepository;
29 + PublisherSearchRepository publisherSearchRepository;
28 SharedService sharedService; 30 SharedService sharedService;
29 31
30 @Inject 32 @Inject
31 public PublisherServiceSpring(PublisherRepository publisherRepository, 33 public PublisherServiceSpring(PublisherRepository publisherRepository,
32 PublisherVersionRepository publisherVersionRepository, 34 PublisherVersionRepository publisherVersionRepository,
33 PublisherActionRepository publisherActionRepository, 35 PublisherActionRepository publisherActionRepository,
36 + PublisherSearchRepository publisherSearchRepository,
34 SharedService sharedService) { 37 SharedService sharedService) {
35 this.publisherRepository = publisherRepository; 38 this.publisherRepository = publisherRepository;
36 this.publisherVersionRepository = publisherVersionRepository; 39 this.publisherVersionRepository = publisherVersionRepository;
37 this.publisherActionRepository = publisherActionRepository; 40 this.publisherActionRepository = publisherActionRepository;
41 + this.publisherSearchRepository = publisherSearchRepository;
38 this.sharedService = sharedService; 42 this.sharedService = sharedService;
39 } 43 }
40 44
...@@ -69,6 +73,7 @@ public class PublisherServiceSpring implements PublisherService { ...@@ -69,6 +73,7 @@ public class PublisherServiceSpring implements PublisherService {
69 return publisherVersion; 73 return publisherVersion;
70 } 74 }
71 75
76 + @Transactional
72 public PublisherAction validatePublisherVersion(PublisherVersion publisherVersion) { 77 public PublisherAction validatePublisherVersion(PublisherVersion publisherVersion) {
73 Publisher publisher = publisherVersion.getPublisher(); 78 Publisher publisher = publisherVersion.getPublisher();
74 publisher.setValidatedVersion(publisherVersion); 79 publisher.setValidatedVersion(publisherVersion);
...@@ -79,6 +84,8 @@ public class PublisherServiceSpring implements PublisherService { ...@@ -79,6 +84,8 @@ public class PublisherServiceSpring implements PublisherService {
79 publisherAction.setPublisherVersion(publisherVersion); 84 publisherAction.setPublisherVersion(publisherVersion);
80 publisherAction.setPublisher(publisher); 85 publisherAction.setPublisher(publisher);
81 this.savePublisher(publisher); 86 this.savePublisher(publisher);
87 + IndexedPublisher indexedPublisher = new IndexedPublisher(publisher);
88 +// publisherSearchRepository.save(indexedPublisher);
82 publisherActionRepository.save(publisherAction); 89 publisherActionRepository.save(publisherAction);
83 return publisherAction; 90 return publisherAction;
84 } 91 }
......
1 -package org.legrog.web.book;
2 -
3 -import org.junit.Before;
4 -import org.junit.jupiter.api.Test;
5 -import org.junit.jupiter.api.BeforeEach;
6 -import org.junit.jupiter.api.extension.ExtendWith;
7 -import org.junit.platform.runner.JUnitPlatform;
8 -import org.junit.runner.RunWith;
9 -import org.legrog.entities.Book;
10 -import org.legrog.test.MockitoExtension;
11 -import org.legrog.web.book.BookServiceOld;
12 -import org.mockito.Answers;
13 -import org.mockito.Mock;
14 -import org.mockito.Mockito;
15 -import org.mockito.runners.MockitoJUnitRunner;
16 -
17 -import javax.persistence.EntityManager;
18 -import javax.persistence.criteria.CriteriaQuery;
19 -import java.util.Arrays;
20 -import java.util.List;
21 -
22 -import static org.assertj.core.api.Assertions.assertThat;
23 -
24 -
25 -@RunWith(JUnitPlatform.class)
26 -@ExtendWith(MockitoExtension.class)
27 - public class BookServiceOldTest {
28 -
29 - @Mock(answer = Answers.RETURNS_DEEP_STUBS)
30 - private EntityManager entityManager;
31 -
32 - private BookServiceOld bookServiceOld;
33 -
34 - @BeforeEach
35 - public void setUp() {
36 - bookServiceOld = new BookServiceOld(entityManager);
37 - }
38 -
39 - @Test
40 - public void testAddBook() {
41 - Book book = new Book();
42 - bookServiceOld.addBook(book);
43 - Mockito.verify(entityManager).persist(book);
44 - }
45 -
46 -
47 - @Test
48 - public void testAllBooks() {
49 -
50 - Book book = new Book();
51 - book.setBookId(0);
52 -
53 - CriteriaQuery<Book> cq = Mockito.mock(CriteriaQuery.class);
54 - Mockito.when(entityManager.getCriteriaBuilder().createQuery(Book.class))
55 - .thenReturn(cq);
56 - Mockito.when(entityManager.createQuery(cq).getResultList())
57 - .thenReturn(Arrays.asList(book));
58 -
59 - List<Book> allBooks = bookServiceOld.getAllBooks();
60 -
61 - assertThat(allBooks).as("book list")
62 - .hasSize(1)
63 - .contains(book);
64 -
65 - }
66 -}
...\ No newline at end of file ...\ No newline at end of file
...@@ -42,9 +42,10 @@ public class PublisherServiceSpringTest { ...@@ -42,9 +42,10 @@ public class PublisherServiceSpringTest {
42 public void setUp(@Mock PublisherRepository publisherRepository, 42 public void setUp(@Mock PublisherRepository publisherRepository,
43 @Mock PublisherVersionRepository publisherVersionRepository, 43 @Mock PublisherVersionRepository publisherVersionRepository,
44 @Mock PublisherActionRepository publisherActionRepository, 44 @Mock PublisherActionRepository publisherActionRepository,
45 + @Mock PublisherSearchRepository publisherSearchRepository,
45 @Mock SharedService sharedService) throws Exception { 46 @Mock SharedService sharedService) throws Exception {
46 publisherServiceSpring = new PublisherServiceSpring(publisherRepository, 47 publisherServiceSpring = new PublisherServiceSpring(publisherRepository,
47 - publisherVersionRepository, publisherActionRepository, sharedService); 48 + publisherVersionRepository, publisherActionRepository, publisherSearchRepository, sharedService);
48 publisherVersion = new PublisherVersion(); 49 publisherVersion = new PublisherVersion();
49 publisherVersion1 = new PublisherVersion(); 50 publisherVersion1 = new PublisherVersion();
50 this.publisherRepository = publisherRepository; 51 this.publisherRepository = publisherRepository;
......