Showing
100 changed files
with
421 additions
and
2011 deletions
1 | -grogEE.iml | ||
2 | -.idea/ | ||
3 | lib/ | 1 | lib/ |
4 | target/ | 2 | target/ |
3 | +!.mvn/wrapper/maven-wrapper.jar | ||
4 | + | ||
5 | +### STS ### | ||
6 | +.apt_generated | ||
7 | +.classpath | ||
8 | +.factorypath | ||
9 | +.project | ||
10 | +.settings | ||
11 | +.springBeans | ||
12 | + | ||
13 | +### IntelliJ IDEA ### | ||
14 | +.idea | ||
15 | +*.iws | ||
16 | +*.iml | ||
17 | +*.ipr | ||
18 | + | ||
19 | +### NetBeans ### | ||
20 | +nbproject/private/ | ||
21 | +build/ | ||
22 | +nbbuild/ | ||
23 | +dist/ | ||
24 | +nbdist/ | ||
25 | +.nb-gradle/ | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
grog-entities/pom.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
3 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
4 | + <modelVersion>4.0.0</modelVersion> | ||
5 | + | ||
6 | + <name>Data layer of GROG</name> | ||
7 | + <url>http://legrog.org</url> | ||
8 | + | ||
9 | + <parent> | ||
10 | + <groupId>org.legrog</groupId> | ||
11 | + <artifactId>grog-cubi</artifactId> | ||
12 | + <version>3.0-SNAPSHOT</version> | ||
13 | + </parent> | ||
14 | + <artifactId>grog-entities</artifactId> | ||
15 | + <packaging>jar</packaging> | ||
16 | + | ||
17 | + <properties> | ||
18 | + <hibernate-commons-annotations.version>5.0.1.Final</hibernate-commons-annotations.version> | ||
19 | + <hibernate-jpa-2.1-api.version>1.0.0.Final</hibernate-jpa-2.1-api.version> | ||
20 | + <solr.version>6.3.0</solr.version> | ||
21 | + </properties> | ||
22 | + | ||
23 | + | ||
24 | + <dependencies> | ||
25 | + | ||
26 | + <dependency> | ||
27 | + <groupId>org.apache.solr</groupId> | ||
28 | + <artifactId>solr-solrj</artifactId> | ||
29 | + <version>${solr.version}</version> | ||
30 | + </dependency> | ||
31 | + | ||
32 | + | ||
33 | + <!-- **** TOOLS : LOGS + UTILS **** --> | ||
34 | + | ||
35 | + <dependency> | ||
36 | + <groupId>org.slf4j</groupId> | ||
37 | + <artifactId>slf4j-api</artifactId> | ||
38 | + </dependency> | ||
39 | + | ||
40 | + <dependency> | ||
41 | + <groupId>ch.qos.logback</groupId> | ||
42 | + <artifactId>logback-classic</artifactId> | ||
43 | + </dependency> | ||
44 | + | ||
45 | + | ||
46 | + <dependency> | ||
47 | + <groupId>org.springframework.data</groupId> | ||
48 | + <artifactId>spring-data-jpa</artifactId> | ||
49 | + </dependency> | ||
50 | + | ||
51 | + <!-- ** Hibernate deps ** --> | ||
52 | + <dependency> | ||
53 | + <groupId>antlr</groupId> | ||
54 | + <artifactId>antlr</artifactId> | ||
55 | + </dependency> | ||
56 | + <dependency> | ||
57 | + <groupId>dom4j</groupId> | ||
58 | + <artifactId>dom4j</artifactId> | ||
59 | + </dependency> | ||
60 | + <dependency> | ||
61 | + <groupId>org.hibernate.common</groupId> | ||
62 | + <artifactId>hibernate-commons-annotations</artifactId> | ||
63 | + <version>${hibernate-commons-annotations.version}</version> | ||
64 | + </dependency> | ||
65 | + <dependency> | ||
66 | + <groupId>org.hibernate.javax.persistence</groupId> | ||
67 | + <artifactId>hibernate-jpa-2.1-api</artifactId> | ||
68 | + <version>${hibernate-jpa-2.1-api.version}</version> | ||
69 | + </dependency> | ||
70 | + <dependency> | ||
71 | + <groupId>org.hibernate</groupId> | ||
72 | + <artifactId>hibernate-core</artifactId> | ||
73 | + </dependency> | ||
74 | + <dependency> | ||
75 | + <groupId>org.hibernate</groupId> | ||
76 | + <artifactId>hibernate-ehcache</artifactId> | ||
77 | + </dependency> | ||
78 | + <dependency> | ||
79 | + <groupId>org.hibernate</groupId> | ||
80 | + <artifactId>hibernate-entitymanager</artifactId> | ||
81 | + </dependency> | ||
82 | + <dependency> | ||
83 | + <groupId>org.hibernate</groupId> | ||
84 | + <artifactId>hibernate-validator</artifactId> | ||
85 | + </dependency> | ||
86 | + <dependency> | ||
87 | + <groupId>org.jboss.logging</groupId> | ||
88 | + <artifactId>jboss-logging</artifactId> | ||
89 | + </dependency> | ||
90 | + <dependency> | ||
91 | + <groupId>org.javassist</groupId> | ||
92 | + <artifactId>javassist</artifactId> | ||
93 | + </dependency> | ||
94 | + | ||
95 | + </dependencies> | ||
96 | + | ||
97 | +</project> |
migration/db-generator/pom.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
3 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
4 | + <modelVersion>4.0.0</modelVersion> | ||
5 | + | ||
6 | + <name>Executable to import empty DB of GROG</name> | ||
7 | + <url>http://legrog.org</url> | ||
8 | + | ||
9 | + <parent> | ||
10 | + <groupId>org.legrog</groupId> | ||
11 | + <artifactId>grog-cubi</artifactId> | ||
12 | + <version>3.0-SNAPSHOT</version> | ||
13 | + <relativePath>../..</relativePath> | ||
14 | + </parent> | ||
15 | + <artifactId>grog-db-generator</artifactId> | ||
16 | + <packaging>jar</packaging> | ||
17 | + | ||
18 | + <dependencies> | ||
19 | + <dependency> | ||
20 | + <groupId>org.springframework.boot</groupId> | ||
21 | + <artifactId>spring-boot-starter-data-jpa</artifactId> | ||
22 | + </dependency> | ||
23 | + | ||
24 | + <dependency> | ||
25 | + <groupId>org.springframework.boot</groupId> | ||
26 | + <artifactId>spring-boot-starter-test</artifactId> | ||
27 | + <scope>test</scope> | ||
28 | + </dependency> | ||
29 | + | ||
30 | + <dependency> | ||
31 | + <groupId>org.legrog</groupId> | ||
32 | + <artifactId>grog-entities</artifactId> | ||
33 | + <version>3.0-SNAPSHOT</version> | ||
34 | + </dependency> | ||
35 | + | ||
36 | + </dependencies> | ||
37 | + | ||
38 | + <build> | ||
39 | + <plugins> | ||
40 | + <plugin> | ||
41 | + <groupId>org.springframework.boot</groupId> | ||
42 | + <artifactId>spring-boot-maven-plugin</artifactId> | ||
43 | + </plugin> | ||
44 | + </plugins> | ||
45 | + </build> | ||
46 | + | ||
47 | +</project> |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 | -package org.legrog.entities; | ||
2 | - | ||
3 | -import javax.persistence.*; | ||
4 | - | ||
5 | -/* | ||
6 | - Entité persistante représentant les propriétés qui sont paramétrées pour un utilisateur. | ||
7 | - Migréee depuis la v2. | ||
8 | - */ | ||
9 | -@Entity | ||
10 | -public class AccountAttribute { | ||
11 | - @Id | ||
12 | - @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
13 | - private int userAttributeId; | ||
14 | - | ||
15 | - public int getUserAttributeId() { | ||
16 | - return userAttributeId; | ||
17 | - } | ||
18 | - | ||
19 | - /** | ||
20 | - * The linked account. | ||
21 | - */ | ||
22 | - @ManyToOne | ||
23 | - private Account account; | ||
24 | - | ||
25 | - /** | ||
26 | - * Retrieve the account this attribute is attached to. | ||
27 | - * hibernate.many-to-one | ||
28 | - * column="ID_UTILISATEUR" | ||
29 | - * class="org.roliste.data.db.Account" | ||
30 | - * not-null="true" | ||
31 | - * access="property" | ||
32 | - * lazy="proxy" | ||
33 | - * properties-name="PropertyPerUser" | ||
34 | - * foreign-key="FK_ATTRIBUTUTILISATEUR_UTILISATEUR" | ||
35 | - * @return the {link org.roliste.data.db.Account} this attribute is attached to. | ||
36 | - * Shall not be <code>null</code>. | ||
37 | - * see #setAccount(org.roliste.data.db.Account) | ||
38 | - */ | ||
39 | - public Account getAccount() { | ||
40 | - return account; | ||
41 | - } | ||
42 | - | ||
43 | - /** | ||
44 | - * Set the account this attribute is attached to. | ||
45 | - * @param account the new {link org.roliste.data.db.Account} this attribute will be attached to. Shall not be <code>null</code>. | ||
46 | - * @see #getAccount() | ||
47 | - */ | ||
48 | - public void setAccount(Account account) { | ||
49 | - this.account = account; | ||
50 | - } | ||
51 | - | ||
52 | - /** | ||
53 | - * The linked property. | ||
54 | - */ | ||
55 | - @ManyToOne | ||
56 | - private AccountProperty accountProperty; | ||
57 | - | ||
58 | - /** | ||
59 | - * Retrieve the property this attribute is attached to. | ||
60 | - * hibernate.many-to-one | ||
61 | - * column="ID_PROP" | ||
62 | - * class="org.roliste.data.db.AccountProperty" | ||
63 | - * not-null="true" | ||
64 | - * access="property" | ||
65 | - * lazy="false" | ||
66 | - * properties-name="PropertyPerUser" | ||
67 | - * foreign-key="FK_ATTRIBUTUTILISATEUR_PROPRIETE" | ||
68 | - * @return the {link org.roliste.data.db.AccountProperty} this attribute is attached to. | ||
69 | - * Shall not be <code>null</code>. | ||
70 | - * see #setProperty(org.roliste.data.db.AccountProperty) | ||
71 | - */ | ||
72 | - public AccountProperty getProperty() { | ||
73 | - return accountProperty; | ||
74 | - } | ||
75 | - | ||
76 | - /** | ||
77 | - * Set the property this attribute is attached to. | ||
78 | - * @param prop the new {link org.roliste.data.db.AccountProperty} this attribute will be attached to. Shall not be <code>null</code>. | ||
79 | - * @see #getProperty() | ||
80 | - */ | ||
81 | - public void setProperty(AccountProperty prop) { | ||
82 | - accountProperty = prop; | ||
83 | - } | ||
84 | - | ||
85 | - /** | ||
86 | - * The property value. | ||
87 | - */ | ||
88 | - private String value; | ||
89 | - | ||
90 | - /** | ||
91 | - * Returns the property value. | ||
92 | - * @return the {@link String} value. If property is known to be some other kind of value, you shall | ||
93 | - * convert it yourself. May be <code>null</code>, in cases where the sole existence of the attribute | ||
94 | - * is the value, or for unset attributes. | ||
95 | - * @see #setValue(String) | ||
96 | - * hibernate.property | ||
97 | - * column="ATTR_VALUE" | ||
98 | - * access="property" | ||
99 | - * length="200" | ||
100 | - */ | ||
101 | - public String getValue() { | ||
102 | - return value; | ||
103 | - } | ||
104 | - | ||
105 | - /** | ||
106 | - * Initializes attribute value. | ||
107 | - * @param value the new {@link String} value. | ||
108 | - * @see #getValue() | ||
109 | - */ | ||
110 | - public void setValue(String value) { | ||
111 | - this.value = value; | ||
112 | - } | ||
113 | - | ||
114 | - /** | ||
115 | - * Returns a string representation of this account attribute definition. | ||
116 | - * @return a string representing this account attribute definition. | ||
117 | - * hidden | ||
118 | - */ | ||
119 | - @Override | ||
120 | - public String toString() | ||
121 | - { | ||
122 | - return "ID_ATTR=" + getUserAttributeId() + " ATTR_PROP=" + accountProperty + " ATTR_VALUE=" + value; | ||
123 | - } | ||
124 | - | ||
125 | -} |
1 | -package org.legrog.entities; | ||
2 | - | ||
3 | -import javax.persistence.*; | ||
4 | - | ||
5 | -/* | ||
6 | - Entité persistente représentant la codification des propriétés qui peuvent être paramétrées pour un utilisateur. | ||
7 | - Importée depuis la v2. | ||
8 | - */ | ||
9 | -@Entity | ||
10 | -public class AccountProperty { | ||
11 | - @Id | ||
12 | - @GeneratedValue(strategy = GenerationType.IDENTITY) /* Permet la population */ | ||
13 | - private int userPropertyId; | ||
14 | - | ||
15 | - /** | ||
16 | - * | ||
17 | - * hibernate.id | ||
18 | - * generator-class="identity" | ||
19 | - * column="ID_PROP" | ||
20 | - * access="property" | ||
21 | - */ | ||
22 | - public Integer getUserPropertyId() { | ||
23 | - return userPropertyId; | ||
24 | - } | ||
25 | - | ||
26 | - /** | ||
27 | - * The property name. | ||
28 | - */ | ||
29 | - private String name; | ||
30 | - | ||
31 | - /** | ||
32 | - * Returns the property name. | ||
33 | - * @return the {@link String} attribute identifier. | ||
34 | - * @see #setName(String) | ||
35 | - * hibernate.property | ||
36 | - * column="ATTR_NAME" | ||
37 | - * not-null="true" | ||
38 | - * unique="true" | ||
39 | - * access="property" | ||
40 | - * length="50" | ||
41 | - */ | ||
42 | - public String getName() { | ||
43 | - return name; | ||
44 | - } | ||
45 | - | ||
46 | - /** | ||
47 | - * Initializes the property name. | ||
48 | - * @param name the new {@link String} identifier. | ||
49 | - * @see #getName() | ||
50 | - */ | ||
51 | - public void setName(String name) { | ||
52 | - this.name = name; | ||
53 | - } | ||
54 | - | ||
55 | - /** | ||
56 | - * The property tag. | ||
57 | - */ | ||
58 | - private String tag; | ||
59 | - | ||
60 | - /** | ||
61 | - * Returns the property tag. | ||
62 | - * @return the {@link String} value. | ||
63 | - * @see #setTag(String) | ||
64 | - * hibernate.property | ||
65 | - * column="PROP_TAG" | ||
66 | - * access="property" | ||
67 | - * length="100" | ||
68 | - */ | ||
69 | - public String getTag() { | ||
70 | - return tag; | ||
71 | - } | ||
72 | - | ||
73 | - /** | ||
74 | - * Initializes property tag. | ||
75 | - * @param tag the new {@link String} tag. | ||
76 | - * @see #getTag() | ||
77 | - */ | ||
78 | - public void setTag(String tag) { | ||
79 | - this.tag = tag; | ||
80 | - } | ||
81 | - | ||
82 | - /** | ||
83 | - * The property validation status. | ||
84 | - * A property may be temporarily deactivated. | ||
85 | - */ | ||
86 | - private boolean visible; | ||
87 | - | ||
88 | - /** | ||
89 | - * Indicates if the property is visible / usable. | ||
90 | - * If not, users should not be able to access the privileges | ||
91 | - * they inherit from having this property set. | ||
92 | - * @return the visible flag. | ||
93 | - * @see #setVisible(boolean) | ||
94 | - * hibernate.property | ||
95 | - * column="IND_VISIBLE" | ||
96 | - * access="property" | ||
97 | - */ | ||
98 | - public boolean isVisible() { | ||
99 | - return visible; | ||
100 | - } | ||
101 | - | ||
102 | - /** | ||
103 | - * Initializes the property visible flag. | ||
104 | - * @param visible the new flag value. | ||
105 | - * @see #isVisible | ||
106 | - */ | ||
107 | - public void setVisible(boolean visible) { | ||
108 | - this.visible = visible; | ||
109 | - } | ||
110 | - | ||
111 | - /** | ||
112 | - * Returns a string representation of this property definition. | ||
113 | - * @return a string representing this property definition. | ||
114 | - * hidden | ||
115 | - */ | ||
116 | - @Override | ||
117 | - public String toString() | ||
118 | - { | ||
119 | - | ||
120 | - return "ID_PROP=" + getUserPropertyId() + "PROP_NAME=" + name + " PROP_TAG=" + tag + " IND_VISIBLE=" + visible; | ||
121 | - } | ||
122 | - | ||
123 | -} | ||
... | \ 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.JpaRepository; | ||
4 | - | ||
5 | -import java.util.List; | ||
6 | - | ||
7 | -public interface AccountRepository extends JpaRepository<Account, Integer> { | ||
8 | - /** | ||
9 | - * | ||
10 | - * @param integers list of Ids for the Accounts we're looking for | ||
11 | - * @return Accounts looked for | ||
12 | - */ | ||
13 | - List<Account> findByUserIdIn(List<Integer> integers); | ||
14 | - | ||
15 | - /** | ||
16 | - * | ||
17 | - * @return accounts that have a presentation | ||
18 | - */ | ||
19 | - List<Account> findByPresentationIsNotNull(); | ||
20 | -} |
1 | -package org.legrog.entities; | ||
2 | - | ||
3 | -import java.util.HashSet; | ||
4 | -import java.util.Set; | ||
5 | - | ||
6 | -import javax.persistence.*; | ||
7 | - | ||
8 | -/** | ||
9 | - * The database representation of a account role or group. | ||
10 | - * A given {@link Account} may be part of one or more {@link AccountRole}. | ||
11 | - * <br/> | ||
12 | - * Warning: due to laziness of mapped objects, private attributes of all DB entities shall never be used directly. | ||
13 | - * You shall always use the getter/setter methods. | ||
14 | - * alias AccountRole | ||
15 | - * | ||
16 | - */ | ||
17 | -/* | ||
18 | - Importé depuis la v2. | ||
19 | - */ | ||
20 | -@Entity | ||
21 | -// TODO évaluer extend v2 | ||
22 | -public class AccountRole /* extends org.roliste.data.DbEntity */ | ||
23 | -{ | ||
24 | - @Id | ||
25 | - @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
26 | - private int userRoleId; | ||
27 | - | ||
28 | - /** | ||
29 | - * The role identifier. | ||
30 | - */ | ||
31 | - private String rolename; | ||
32 | - | ||
33 | - /** | ||
34 | - * The {@link Account}s for this account role. | ||
35 | - */ | ||
36 | - @ManyToMany(mappedBy = "roles") | ||
37 | - private Set<Account> accounts; | ||
38 | - | ||
39 | - /** | ||
40 | - * Builds a new and empty account role definition. | ||
41 | - * All attributes are set to their default value. | ||
42 | - * <br/> | ||
43 | - * Needed by Hibernate for Java reflection. | ||
44 | - */ | ||
45 | - public AccountRole() { | ||
46 | - super(); | ||
47 | - rolename = null; | ||
48 | - visible = true; | ||
49 | - // no need to synchronize this | ||
50 | - accounts = new HashSet<Account>(); | ||
51 | - } | ||
52 | - | ||
53 | - public int getUserRoleId() { | ||
54 | - return userRoleId; | ||
55 | - } | ||
56 | - | ||
57 | - public void setUserRoleId(int userRoleId) { | ||
58 | - this.userRoleId = userRoleId; | ||
59 | - } | ||
60 | - | ||
61 | - /** | ||
62 | - * Returns the role identifier. | ||
63 | - * @return the {@link String} identifier. | ||
64 | - * @see #setRolename(String) | ||
65 | - * hibernate.property | ||
66 | - * column="NOM_ROLE" | ||
67 | - * not-null="true" | ||
68 | - * unique="true" | ||
69 | - * access="property" | ||
70 | - * length="50" | ||
71 | - */ | ||
72 | - public String getRolename() { | ||
73 | - return rolename; | ||
74 | - } | ||
75 | - | ||
76 | - /** | ||
77 | - * Initializes the role identifier. | ||
78 | - * @param name the new {@link String} identifier. | ||
79 | - * @see #getRolename() | ||
80 | - */ | ||
81 | - public void setRolename(String name) { | ||
82 | - rolename = name; | ||
83 | - } | ||
84 | - | ||
85 | - /** | ||
86 | - * The role validation status. | ||
87 | - * A role may be temporarily deactivated. | ||
88 | - */ | ||
89 | - private boolean visible; | ||
90 | - | ||
91 | - /** | ||
92 | - * Indicates if the role is visible. | ||
93 | - * If not, accounts should not be able to access the privileges | ||
94 | - * they inherit from being part of this role. | ||
95 | - * @return the visible flag. | ||
96 | - * @see #setVisible(boolean) | ||
97 | - * hibernate.property | ||
98 | - * column="IND_VISIBLE" | ||
99 | - * access="property" | ||
100 | - */ | ||
101 | - public boolean isVisible() { | ||
102 | - return visible; | ||
103 | - } | ||
104 | - | ||
105 | - /** | ||
106 | - * Initializes the account visible flag. | ||
107 | - * @param visible the new flag value. | ||
108 | - * @see #isVisible | ||
109 | - */ | ||
110 | - public void setVisible(boolean visible) { | ||
111 | - this.visible = visible; | ||
112 | - } | ||
113 | - | ||
114 | - /** | ||
115 | - * Retrieves the list of {@link Account}s for this account role. | ||
116 | - * SHALL be used as a read-only attribute. In particular, avoid | ||
117 | - * using {@link Set#add(Object)} or {@link Set#remove(Object)} on | ||
118 | - * the returned value without caution. | ||
119 | - * @return a {@link Set} of {@link Account}. May be <code>null</code>. | ||
120 | - * @see #setAccounts(Set) | ||
121 | - * hibernate.many-to-many | ||
122 | - * column="UTILISATEUR_FK" | ||
123 | - * class="org.roliste.data.db.Person" | ||
124 | - * foreign-key="FK_UTILISATEURROLE_UTILISATEUR" | ||
125 | - * hibernate.key | ||
126 | - * column="ROLE_FK" | ||
127 | - * not-null="true" | ||
128 | - * foreign-key="FK_UTILISATEURROLE_ROLEUTILISATEUR" | ||
129 | - * hibernate.set | ||
130 | - * access="property" | ||
131 | - * table="role_utilisateur" | ||
132 | - * lazy="true" | ||
133 | - * inverse="true" | ||
134 | - */ | ||
135 | - public Set<Account> getAccounts() { | ||
136 | - return accounts; | ||
137 | - } | ||
138 | - | ||
139 | - /** | ||
140 | - * Sets the list of {@link Account}s for this account role. | ||
141 | - * @param accounts the new {@link Set} of {@link Account}s. May be | ||
142 | - * <code>null</code> (we don't handle the relation from this side). | ||
143 | - * @see #getAccounts() | ||
144 | - */ | ||
145 | - protected void setAccounts(Set<Account> accounts) { | ||
146 | - this.accounts = accounts; | ||
147 | - } | ||
148 | - | ||
149 | - /** | ||
150 | - * Returns a string representation of this account role definition. | ||
151 | - * @return a string representing this account role definition. | ||
152 | - * hidden | ||
153 | - */ | ||
154 | - @Override | ||
155 | - public String toString() { | ||
156 | - return "ID_ROLE=" + getUserRoleId() + " NOM_ROLE=" + rolename + " IND_VISIBLE=" + visible; | ||
157 | - } | ||
158 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -package org.legrog.entities; | ||
2 | - | ||
3 | -import java.util.List; | ||
4 | - | ||
5 | -/** | ||
6 | - * Search interface for IndexedAccount | ||
7 | - */ | ||
8 | -public interface AccountSearchRepository { | ||
9 | - /** | ||
10 | - * | ||
11 | - * @param string String searched in indexed Accounts | ||
12 | - * @return Accounts that match the string | ||
13 | - */ | ||
14 | - List<IndexedAccount> search(String string) throws SearchingException; | ||
15 | - | ||
16 | - /** | ||
17 | - * | ||
18 | - * @param indexedAccounts IndexedAccounts to reindex | ||
19 | - */ | ||
20 | - public void reindex(List<IndexedAccount> indexedAccounts) throws IndexingException; | ||
21 | -} |
1 | -package org.legrog.entities; | ||
2 | - | ||
3 | -import org.apache.solr.client.solrj.SolrClient; | ||
4 | -import org.apache.solr.client.solrj.SolrQuery; | ||
5 | -import org.apache.solr.client.solrj.SolrServerException; | ||
6 | -import org.apache.solr.client.solrj.response.QueryResponse; | ||
7 | -import org.apache.solr.client.solrj.response.UpdateResponse; | ||
8 | -import org.slf4j.Logger; | ||
9 | -import org.slf4j.LoggerFactory; | ||
10 | - | ||
11 | -import javax.inject.Inject; | ||
12 | -import java.io.IOException; | ||
13 | -import java.util.ArrayList; | ||
14 | -import java.util.List; | ||
15 | - | ||
16 | -/** | ||
17 | - * Implementation of AccountSearchRepository using SolrJ | ||
18 | - */ | ||
19 | -public class AccountSearchRepositorySolrj implements AccountSearchRepository { | ||
20 | - Logger logger = LoggerFactory.getLogger(getClass()); | ||
21 | - | ||
22 | - SolrClient solrClient; | ||
23 | - | ||
24 | - protected static String collectionName = "accounts"; | ||
25 | - | ||
26 | - @Inject | ||
27 | - AccountSearchRepositorySolrj(SolrClient solrClient) { | ||
28 | - this.solrClient = solrClient; | ||
29 | - } | ||
30 | - | ||
31 | - //no args constructor to make it proxyable | ||
32 | - AccountSearchRepositorySolrj() { | ||
33 | - } | ||
34 | - | ||
35 | - @Override | ||
36 | - public List<IndexedAccount> search(String string) throws SearchingException { | ||
37 | - SolrQuery solrQuery = new SolrQuery(string); | ||
38 | - QueryResponse queryResponse; | ||
39 | - try { | ||
40 | - queryResponse = solrClient.query(collectionName, solrQuery); | ||
41 | - } catch (IOException ioe) { | ||
42 | - throw new SearchingException(ioe); | ||
43 | - } catch (SolrServerException sse) { | ||
44 | - logger.error("SolrServerException {}", sse); | ||
45 | - throw new SearchingException(sse.getRootCause()); | ||
46 | - } | ||
47 | - | ||
48 | - if (queryResponse != null) { | ||
49 | - return queryResponse.getBeans(IndexedAccount.class); | ||
50 | - } else { | ||
51 | - return new ArrayList<>(); | ||
52 | - } | ||
53 | - } | ||
54 | - | ||
55 | - @Override | ||
56 | - public void reindex(List<IndexedAccount> indexedAccounts) throws IndexingException { | ||
57 | - try { | ||
58 | - UpdateResponse updateResponse = solrClient.addBeans(collectionName, indexedAccounts); | ||
59 | - solrClient.commit(collectionName); | ||
60 | - logger.trace("reindex indexedAccounts SolrJ UpdateResponse {}", updateResponse); | ||
61 | - } catch (IOException ioe) { | ||
62 | - throw new IndexingException(ioe); | ||
63 | - } catch (SolrServerException sse) { | ||
64 | - logger.error("SolrServerException {}", sse); | ||
65 | - throw new IndexingException(sse.getRootCause()); | ||
66 | - } | ||
67 | - } | ||
68 | -} |
1 | -package org.legrog.entities; | ||
2 | - | ||
3 | -import javax.persistence.*; | ||
4 | - | ||
5 | -/** | ||
6 | - * Country persistence entity | ||
7 | - * Id and name seem enough | ||
8 | - */ | ||
9 | -@Entity | ||
10 | -public class Country { | ||
11 | - @Id | ||
12 | - @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
13 | - private Integer countryId; | ||
14 | - private String countryName; | ||
15 | - | ||
16 | - public Integer getCountryId() { | ||
17 | - return countryId; | ||
18 | - } | ||
19 | - | ||
20 | - public void setCountryId(Integer countryId) { | ||
21 | - this.countryId = countryId; | ||
22 | - } | ||
23 | - | ||
24 | - public String getCountryName() { | ||
25 | - return countryName; | ||
26 | - } | ||
27 | - | ||
28 | - public void setCountryName(String countryName) { | ||
29 | - this.countryName = countryName; | ||
30 | - } | ||
31 | - | ||
32 | - @Override | ||
33 | - public String toString() | ||
34 | - { | ||
35 | - return "ID_PAYS=" + countryId + " LIB_PAYS=" + countryName; | ||
36 | - } | ||
37 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -package org.legrog.entities; | ||
2 | - | ||
3 | -/* DbMaskableEntity en v2, mais je pense le nouveau nom plus clair */ | ||
4 | -public interface DisplayNameConfigurable { | ||
5 | - String getFirstName(); | ||
6 | - | ||
7 | - String getLastName(); | ||
8 | - | ||
9 | - String getNickName(); | ||
10 | - | ||
11 | -/* ScreenName en v2, mais je pense la nouveau nom plus clair */ | ||
12 | - String getDisplayName(); | ||
13 | -} |
1 | -package org.legrog.entities; | ||
2 | - | ||
3 | -/** | ||
4 | - * This enumeration provide options for name masking of authors and users. | ||
5 | - * Every {link org.roliste.data.DbMaskableEntity} provide first name, last name and nickname | ||
6 | - * capabilities, that may be "masked", thus shown in some specific way depending on chosen | ||
7 | - * NameMask. | ||
8 | - */ | ||
9 | -/* | ||
10 | - v3 {@link org.legrog.entities.DisplayNameConfigurable} | ||
11 | - */ | ||
12 | -public enum DisplayNameMask | ||
13 | -{ | ||
14 | - PRENOMNOM("Prénom Nom") | ||
15 | - { | ||
16 | - public String listMask(DisplayNameConfigurable person) | ||
17 | - { | ||
18 | - return NOMPRENOM.getDisplayName(person); | ||
19 | - } | ||
20 | - | ||
21 | - public String getDisplayName(DisplayNameConfigurable person) | ||
22 | - { | ||
23 | - StringBuilder sb = new StringBuilder(); | ||
24 | - if (person.getFirstName() != null) | ||
25 | - { | ||
26 | - sb.append(person.getFirstName()); | ||
27 | - } | ||
28 | - if (person.getLastName() != null) | ||
29 | - { | ||
30 | - sb.append(' '); | ||
31 | - sb.append(person.getLastName()); | ||
32 | - } | ||
33 | - return sb.toString(); | ||
34 | - } | ||
35 | - }, | ||
36 | - | ||
37 | - NOMPRENOM("Nom, Prénom") | ||
38 | - { | ||
39 | - public String listMask(DisplayNameConfigurable person) | ||
40 | - { | ||
41 | - return NOMPRENOM.getDisplayName(person); | ||
42 | - } | ||
43 | - | ||
44 | - public String getDisplayName(DisplayNameConfigurable person) | ||
45 | - { | ||
46 | - StringBuilder sb = new StringBuilder(); | ||
47 | - if (person.getLastName() != null) | ||
48 | - { | ||
49 | - sb.append(person.getLastName()); | ||
50 | - if (person.getFirstName() != null) | ||
51 | - { | ||
52 | - sb.append(", "); | ||
53 | - sb.append(person.getFirstName()); | ||
54 | - } | ||
55 | - } | ||
56 | - else | ||
57 | - { | ||
58 | - sb.append("!Pas de nom"); | ||
59 | - } | ||
60 | - return sb.toString(); | ||
61 | - } | ||
62 | - }, | ||
63 | - | ||
64 | - PSEUDO("Pseudo") | ||
65 | - { | ||
66 | - public String listMask(DisplayNameConfigurable person) | ||
67 | - { | ||
68 | - return PSEUDO.getDisplayName(person); | ||
69 | - } | ||
70 | - | ||
71 | - public String getDisplayName(DisplayNameConfigurable person) | ||
72 | - { | ||
73 | - StringBuilder sb = new StringBuilder(); | ||
74 | - if (person.getNickName() != null) | ||
75 | - { | ||
76 | - sb.append(person.getNickName()); | ||
77 | - } | ||
78 | - else | ||
79 | - { | ||
80 | - sb.append("!Pas de pseudo"); | ||
81 | - } | ||
82 | - return sb.toString(); | ||
83 | - } | ||
84 | - }, | ||
85 | - | ||
86 | - COMPLET("Prénom 'Pseudo' Nom") | ||
87 | - { | ||
88 | - public String listMask(DisplayNameConfigurable person) | ||
89 | - { | ||
90 | - return NOMPRENOM.getDisplayName(person); | ||
91 | - } | ||
92 | - | ||
93 | - public String getDisplayName(DisplayNameConfigurable person) | ||
94 | - { | ||
95 | - StringBuilder myResult = new StringBuilder(); | ||
96 | - | ||
97 | - if (person.getFirstName() != null) | ||
98 | - { | ||
99 | - myResult.append(person.getFirstName()); | ||
100 | - myResult.append(' '); | ||
101 | - } | ||
102 | - if ( person.getNickName() != null ) | ||
103 | - { | ||
104 | - myResult.append('\''); | ||
105 | - myResult.append(person.getNickName()); | ||
106 | - myResult.append('\''); | ||
107 | - myResult.append(' '); | ||
108 | - } | ||
109 | - if (person.getLastName() != null) | ||
110 | - { | ||
111 | - myResult.append(person.getLastName()); | ||
112 | - } | ||
113 | - return myResult.toString(); | ||
114 | - } | ||
115 | - }; | ||
116 | - | ||
117 | - private final String symbol; | ||
118 | - | ||
119 | - DisplayNameMask(String symbol) { | ||
120 | - this.symbol = symbol; | ||
121 | - } | ||
122 | - | ||
123 | - public String getSymbol() | ||
124 | - { | ||
125 | - return symbol; | ||
126 | - } | ||
127 | - | ||
128 | - public String toString() | ||
129 | - { | ||
130 | - return symbol; | ||
131 | - } | ||
132 | - | ||
133 | - public abstract String getDisplayName(DisplayNameConfigurable person); | ||
134 | - | ||
135 | - public abstract String listMask(DisplayNameConfigurable person); | ||
136 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -package org.legrog.entities; | ||
2 | - | ||
3 | -import org.apache.solr.client.solrj.beans.Field; | ||
4 | -import javax.persistence.Id; | ||
5 | -import javax.persistence.Lob; | ||
6 | - | ||
7 | -/** | ||
8 | - * Simplified class for searching indexed Accounts | ||
9 | - */ | ||
10 | -public class IndexedAccount { | ||
11 | - @Id | ||
12 | - @Field | ||
13 | - private Integer userId; | ||
14 | - @Lob | ||
15 | - @Field | ||
16 | - private String presentation; | ||
17 | - | ||
18 | - /** | ||
19 | - * | ||
20 | - * @param account Account to be simplified as IndexedAccount | ||
21 | - */ | ||
22 | - public IndexedAccount(Account account) { | ||
23 | - this.userId = account.getUserId(); | ||
24 | - this.presentation = account.getPresentation(); | ||
25 | - } | ||
26 | - | ||
27 | - public IndexedAccount() { | ||
28 | - //no args constructor to make it proxyable | ||
29 | - } | ||
30 | - | ||
31 | - public Integer getUserId() { | ||
32 | - return userId; | ||
33 | - } | ||
34 | - | ||
35 | - public void setUserId(Integer userId) { | ||
36 | - this.userId = userId; | ||
37 | - } | ||
38 | - | ||
39 | - public String getPresentation() { | ||
40 | - return presentation; | ||
41 | - } | ||
42 | - | ||
43 | - public void setPresentation(String presentation) { | ||
44 | - this.presentation = presentation; | ||
45 | - } | ||
46 | -} |
1 | -package org.legrog.entities; | ||
2 | -import org.apache.solr.client.solrj.beans.Field; | ||
3 | -import javax.persistence.Id; | ||
4 | -import javax.persistence.Lob; | ||
5 | - | ||
6 | -/** | ||
7 | - * Simplified class for indexing and searching validated publishers: content from PublisherVersion with id from Publisher | ||
8 | - */ | ||
9 | -public class IndexedPublisher { | ||
10 | - @Id | ||
11 | - @Field | ||
12 | - private Integer publisherId; | ||
13 | - @Field | ||
14 | - private String publisherName; | ||
15 | - @Lob | ||
16 | - @Field | ||
17 | - private String publisherHistory; | ||
18 | - | ||
19 | - /** | ||
20 | - * Extracts data needed for indexing from Publisher and its validated PublisherVersion | ||
21 | - * | ||
22 | - * @param publisher Publisher we want to be indexed | ||
23 | - */ | ||
24 | - public IndexedPublisher(Publisher publisher) { | ||
25 | - PublisherVersion publisherVersion = publisher.getValidatedVersion(); | ||
26 | - this.publisherId = publisher.getPublisherId(); | ||
27 | - this.publisherName = publisherVersion.getPublisherName(); | ||
28 | - this.publisherHistory = publisherVersion.getPublisherHistory(); | ||
29 | - } | ||
30 | - | ||
31 | - public IndexedPublisher() { | ||
32 | - //no args constructor to make it proxyable | ||
33 | - } | ||
34 | - | ||
35 | - public Integer getPublisherId() { | ||
36 | - return publisherId; | ||
37 | - } | ||
38 | - | ||
39 | - public String getPublisherName() { | ||
40 | - return publisherName; | ||
41 | - } | ||
42 | - | ||
43 | - public String getPublisherHistory() { | ||
44 | - return publisherHistory; | ||
45 | - } | ||
46 | - | ||
47 | - public void setPublisherId(Integer publisherId) { | ||
48 | - this.publisherId = publisherId; | ||
49 | - } | ||
50 | - | ||
51 | - public void setPublisherName(String publisherName) { | ||
52 | - this.publisherName = publisherName; | ||
53 | - } | ||
54 | - | ||
55 | - public void setPublisherHistory(String publisherHistory) { | ||
56 | - this.publisherHistory = publisherHistory; | ||
57 | - } | ||
58 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -package org.legrog.entities; | ||
2 | - | ||
3 | -import javax.ejb.ApplicationException; | ||
4 | - | ||
5 | -/** | ||
6 | - * Exception when indexing fails, whatever the reason. Has to be dealt with at service level. | ||
7 | - */ | ||
8 | -@ApplicationException(rollback = true) | ||
9 | -public class IndexingException extends Exception { | ||
10 | - final Throwable rootCause; | ||
11 | - | ||
12 | - IndexingException(Throwable rootCause) { | ||
13 | - this.rootCause = rootCause; | ||
14 | - } | ||
15 | - | ||
16 | - public Throwable getRootCause() { | ||
17 | - return rootCause; | ||
18 | - } | ||
19 | -} |
1 | -package org.legrog.entities; | ||
2 | - | ||
3 | -import javax.persistence.*; | ||
4 | -import java.util.Set; | ||
5 | - | ||
6 | -/** | ||
7 | - * Persisted entity for a publisher | ||
8 | - * Has versions of type PublisherVersion | ||
9 | - * May have a validated PublisherVersion among those | ||
10 | - * Has access to PublisherAction related to it | ||
11 | - */ | ||
12 | -@Entity | ||
13 | -public class Publisher /* extends org.roliste.data.DbLinkableEntity */ { | ||
14 | -// TODO L'éventuel usage de Linkable reste à confirmer https://tree.taiga.io/project/jr-utily-grog-v3/us/48 | ||
15 | -// TODO Attention, en v2 Linkable implique Traceable (journalisable) qui devrait aussi être évalué | ||
16 | - @Id | ||
17 | - @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
18 | - private Integer publisherId; | ||
19 | - | ||
20 | - @OneToOne | ||
21 | - private PublisherVersion validatedVersion; | ||
22 | - | ||
23 | - @OneToMany(mappedBy = "publisher", fetch = FetchType.EAGER) | ||
24 | - private Set<PublisherVersion> versions; | ||
25 | - | ||
26 | - @OneToMany(mappedBy = "publisher", fetch = FetchType.EAGER) | ||
27 | - private Set<PublisherAction> actions; | ||
28 | - | ||
29 | - public Integer getPublisherId() { | ||
30 | - return publisherId; | ||
31 | - } | ||
32 | - | ||
33 | - public void setPublisherId(Integer publisherId) { | ||
34 | - this.publisherId = publisherId; | ||
35 | - } | ||
36 | - | ||
37 | - public PublisherVersion getValidatedVersion() { | ||
38 | - return validatedVersion; | ||
39 | - } | ||
40 | - | ||
41 | - public void setValidatedVersion(PublisherVersion activeVersion) { | ||
42 | - this.validatedVersion = activeVersion; | ||
43 | - } | ||
44 | - | ||
45 | - public Set<PublisherVersion> getVersions() { | ||
46 | - return versions; | ||
47 | - } | ||
48 | - | ||
49 | - public void setVersions(Set<PublisherVersion> versions) { | ||
50 | - this.versions = versions; | ||
51 | - } | ||
52 | - | ||
53 | - public Set<PublisherAction> getActions() { | ||
54 | - return actions; | ||
55 | - } | ||
56 | - | ||
57 | - public void setActions(Set<PublisherAction> actions) { | ||
58 | - this.actions = actions; | ||
59 | - } | ||
60 | - | ||
61 | - @Override | ||
62 | - public String toString() { | ||
63 | - return "PUBLISHER_ID = " + publisherId + ", Validated Version = " + validatedVersion; | ||
64 | - } | ||
65 | -} |
1 | -package org.legrog.entities; | ||
2 | - | ||
3 | -import javax.persistence.*; | ||
4 | -import java.sql.Timestamp; | ||
5 | - | ||
6 | -/** | ||
7 | - * Pesisted entity for actions made on PublisherVersion | ||
8 | - */ | ||
9 | -@Entity | ||
10 | -public class PublisherAction { | ||
11 | - @Id | ||
12 | - @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
13 | - private Integer publisherActionId; | ||
14 | - | ||
15 | - @Enumerated | ||
16 | - private ActionType actionType; | ||
17 | - @ManyToOne | ||
18 | - private Account publisherActionActor; | ||
19 | - @ManyToOne | ||
20 | - private PublisherVersion publisherVersion; | ||
21 | - | ||
22 | - private Timestamp publisherActionDatetime; | ||
23 | - | ||
24 | - // Simplified access instead of going through PublisherVersion | ||
25 | - @ManyToOne | ||
26 | - private Publisher publisher; | ||
27 | - | ||
28 | - public void setPublisherActionActor(Account publisherActionActor) { | ||
29 | - this.publisherActionActor = publisherActionActor; | ||
30 | - } | ||
31 | - | ||
32 | - public void setPublisherActionDatetime(Timestamp publisherActionDatetime) { | ||
33 | - this.publisherActionDatetime = publisherActionDatetime; | ||
34 | - } | ||
35 | - | ||
36 | - public void setActionType(ActionType actionType) { | ||
37 | - this.actionType = actionType; | ||
38 | - } | ||
39 | - | ||
40 | - public void setPublisherVersion(PublisherVersion publisherVersion) { | ||
41 | - this.publisherVersion = publisherVersion; | ||
42 | - } | ||
43 | - | ||
44 | - public void setPublisher(Publisher publisher) { | ||
45 | - this.publisher = publisher; | ||
46 | - } | ||
47 | - | ||
48 | - public ActionType getActionType() { | ||
49 | - return actionType; | ||
50 | - } | ||
51 | - | ||
52 | - public Account getPublisherActionActor() { | ||
53 | - return publisherActionActor; | ||
54 | - } | ||
55 | - | ||
56 | - public PublisherVersion getPublisherVersion() { | ||
57 | - return publisherVersion; | ||
58 | - } | ||
59 | - | ||
60 | - public Timestamp getPublisherActionDatetime() { | ||
61 | - return publisherActionDatetime; | ||
62 | - } | ||
63 | - | ||
64 | - public Publisher getPublisher() { | ||
65 | - return publisher; | ||
66 | - } | ||
67 | - | ||
68 | - public Integer getPublisherActionId() { | ||
69 | - return publisherActionId; | ||
70 | - } | ||
71 | - | ||
72 | - public void setPublisherActionId(Integer publisherActionId) { | ||
73 | - this.publisherActionId = publisherActionId; | ||
74 | - } | ||
75 | - | ||
76 | - @Override | ||
77 | - public String toString() { | ||
78 | - return "publisherActionId = " + publisherActionId + ", actionType = " + actionType + | ||
79 | - ", publisherActionAuthor = " + publisherActionActor + ", publisherVersion = " + publisherVersion + | ||
80 | - ", publisherActionDatetime = " + publisherActionDatetime + ", publisher = " + publisher; | ||
81 | - } | ||
82 | -} | ||
... | \ 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.JpaRepository; | ||
4 | - | ||
5 | -import java.util.List; | ||
6 | - | ||
7 | -/** | ||
8 | - * Interface for accessing PublisherAction | ||
9 | - */ | ||
10 | -public interface PublisherActionRepository extends JpaRepository<PublisherAction, Integer> { | ||
11 | - | ||
12 | - /** | ||
13 | - * Returns last action of a type for a publisher | ||
14 | - * | ||
15 | - * @param actionType ActionType requested | ||
16 | - * @param publisher Publisher concerned by the action | ||
17 | - * @return PublisherAction | ||
18 | - */ | ||
19 | - PublisherAction findFirstByActionTypeAndPublisherOrderByPublisherActionDatetimeDesc(ActionType actionType, Publisher publisher); | ||
20 | - | ||
21 | - /** | ||
22 | - * Returns all actions for a PublisherVersion | ||
23 | - * | ||
24 | - * @param publisherVersion PublisherVersion concerned by the actions | ||
25 | - * @return List<PublisherAction> | ||
26 | - */ | ||
27 | - List<PublisherAction> findByPublisherVersion(PublisherVersion publisherVersion); | ||
28 | -} |
1 | -package org.legrog.entities; | ||
2 | - | ||
3 | -import java.util.List; | ||
4 | - | ||
5 | -/** | ||
6 | - * Indexing/Search interface for IndexedPublisher | ||
7 | - */ | ||
8 | -public interface PublisherSearchRepository { | ||
9 | - /** | ||
10 | - * Indexes an IndexedPublisher | ||
11 | - * | ||
12 | - * @param indexedPublisher IndexedPublisher to be indexed | ||
13 | - * @return IndexedPublisher | ||
14 | - */ | ||
15 | - IndexedPublisher save(IndexedPublisher indexedPublisher) throws IndexingException; | ||
16 | - | ||
17 | - /** | ||
18 | - * Searches for IndexedPublishers | ||
19 | - * | ||
20 | - * @param string String looked for in IndexedPublishers | ||
21 | - * @return list of matching IndexedPublishers | ||
22 | - */ | ||
23 | - List<IndexedPublisher> search(String string) throws SearchingException; | ||
24 | - | ||
25 | - /** | ||
26 | - * | ||
27 | - * @param inxdexedPublishers IndexedPublishers to reindex | ||
28 | - */ | ||
29 | - public void reindex(List<IndexedPublisher> inxdexedPublishers) throws IndexingException; | ||
30 | -} |
1 | -package org.legrog.entities; | ||
2 | - | ||
3 | -import org.apache.solr.client.solrj.SolrClient; | ||
4 | -import org.apache.solr.client.solrj.SolrQuery; | ||
5 | -import org.apache.solr.client.solrj.SolrServerException; | ||
6 | -import org.apache.solr.client.solrj.response.QueryResponse; | ||
7 | -import org.apache.solr.client.solrj.response.UpdateResponse; | ||
8 | -import org.slf4j.Logger; | ||
9 | -import org.slf4j.LoggerFactory; | ||
10 | - | ||
11 | -import javax.inject.Inject; | ||
12 | -import java.io.IOException; | ||
13 | -import java.util.ArrayList; | ||
14 | -import java.util.List; | ||
15 | - | ||
16 | -/** | ||
17 | - * Implementation of PublisherSearchRepository using SolrJ | ||
18 | - */ | ||
19 | -public class PublisherSearchRepositorySolrj implements PublisherSearchRepository { | ||
20 | - Logger logger = LoggerFactory.getLogger(getClass()); | ||
21 | - | ||
22 | - SolrClient solrClient; | ||
23 | - | ||
24 | - protected static String collectionName = "publishers"; | ||
25 | - | ||
26 | - @Inject | ||
27 | - PublisherSearchRepositorySolrj(SolrClient solrClient) { | ||
28 | - this.solrClient = solrClient; | ||
29 | - } | ||
30 | - | ||
31 | - //no args constructor to make it proxyable | ||
32 | - PublisherSearchRepositorySolrj() { | ||
33 | - } | ||
34 | - | ||
35 | - @Override | ||
36 | - public IndexedPublisher save(IndexedPublisher indexedPublisher) throws IndexingException { | ||
37 | - try { | ||
38 | - UpdateResponse updateResponse = solrClient.addBean(collectionName, indexedPublisher, 1); | ||
39 | - logger.trace("validatePublisherVersion SolrJ UpdateResponse {}", updateResponse); | ||
40 | - } catch (IOException ioe) { | ||
41 | - throw new IndexingException(ioe); | ||
42 | - } catch (SolrServerException sse) { | ||
43 | - logger.error("SolrServerException {}", sse); | ||
44 | - throw new IndexingException(sse.getRootCause()); | ||
45 | - } | ||
46 | - | ||
47 | - return indexedPublisher; | ||
48 | - } | ||
49 | - | ||
50 | - @Override | ||
51 | - public List<IndexedPublisher> search(String string) throws SearchingException { | ||
52 | - SolrQuery solrQuery = new SolrQuery(string); | ||
53 | - QueryResponse queryResponse; | ||
54 | - try { | ||
55 | - queryResponse = solrClient.query(collectionName, solrQuery); | ||
56 | - } catch (IOException ioe) { | ||
57 | - throw new SearchingException(ioe); | ||
58 | - } catch (SolrServerException sse) { | ||
59 | - logger.error("SolrServerException {}", sse); | ||
60 | - throw new SearchingException(sse.getRootCause()); | ||
61 | - } | ||
62 | - | ||
63 | - if (queryResponse != null) { | ||
64 | - return queryResponse.getBeans(IndexedPublisher.class); | ||
65 | - } else { | ||
66 | - return new ArrayList<>(); | ||
67 | - } | ||
68 | - } | ||
69 | - | ||
70 | - @Override | ||
71 | - public void reindex(List<IndexedPublisher> indexedPublishers) throws IndexingException { | ||
72 | - try { | ||
73 | - UpdateResponse updateResponse = solrClient.addBeans(collectionName, indexedPublishers); | ||
74 | - solrClient.commit(collectionName); | ||
75 | - logger.trace("reindex inxdexedPublishers SolrJ UpdateResponse {}", updateResponse); | ||
76 | - } catch (IOException ioe) { | ||
77 | - throw new IndexingException(ioe); | ||
78 | - } catch (SolrServerException sse) { | ||
79 | - logger.error("SolrServerException {}", sse); | ||
80 | - throw new IndexingException(sse.getRootCause()); | ||
81 | - } | ||
82 | - } | ||
83 | -} |
1 | -package org.legrog.entities; | ||
2 | - | ||
3 | -import javax.persistence.*; | ||
4 | -import java.sql.Timestamp; | ||
5 | - | ||
6 | -/** | ||
7 | - * Persisted entity for a publisher version | ||
8 | - * Contains the data | ||
9 | - * Postal Address is split according to http://schema.org/PostalAddress | ||
10 | - */ | ||
11 | -@Entity | ||
12 | -public class PublisherVersion { | ||
13 | - @Id | ||
14 | - @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
15 | - private Integer publisherVersionId; | ||
16 | - @ManyToOne | ||
17 | - private Publisher publisher; | ||
18 | - private String publisherName; | ||
19 | - private String publisherStreetAddress; | ||
20 | - private String publisherPostalCode; | ||
21 | - private String publisherPostOfficeBoxNumber; | ||
22 | - private String publisherAddressRegion; | ||
23 | - private String publisherAddressLocality; | ||
24 | - @ManyToOne | ||
25 | - private Country publisherAddressCountry; | ||
26 | - private String publisherTelephone; | ||
27 | - private String publisherEmail; | ||
28 | - private String publisherURL; | ||
29 | - @Lob | ||
30 | - private String publisherHistory; | ||
31 | - @ManyToOne | ||
32 | - private Account publisherVersionCreator; | ||
33 | - private Timestamp publisherVersionDatetime; | ||
34 | - | ||
35 | - public Timestamp getPublisherVersionDatetime() { | ||
36 | - return publisherVersionDatetime; | ||
37 | - } | ||
38 | - | ||
39 | - public void setPublisherVersionDatetime(Timestamp publisherVersionDatetime) { | ||
40 | - this.publisherVersionDatetime = publisherVersionDatetime; | ||
41 | - } | ||
42 | - | ||
43 | - public String getPublisherHistory() { | ||
44 | - return publisherHistory; | ||
45 | - } | ||
46 | - | ||
47 | - public void setPublisherHistory(String publisherHistory) { | ||
48 | - this.publisherHistory = publisherHistory; | ||
49 | - } | ||
50 | - | ||
51 | - public String getPublisherStreetAddress() { | ||
52 | - return publisherStreetAddress; | ||
53 | - } | ||
54 | - | ||
55 | - public void setPublisherStreetAddress(String publisherStreetAddress) { | ||
56 | - this.publisherStreetAddress = publisherStreetAddress; | ||
57 | - } | ||
58 | - | ||
59 | - public String getPublisherPostalCode() { | ||
60 | - return publisherPostalCode; | ||
61 | - } | ||
62 | - | ||
63 | - public void setPublisherPostalCode(String publisherPostalCode) { | ||
64 | - this.publisherPostalCode = publisherPostalCode; | ||
65 | - } | ||
66 | - | ||
67 | - public String getPublisherPostOfficeBoxNumber() { | ||
68 | - return publisherPostOfficeBoxNumber; | ||
69 | - } | ||
70 | - | ||
71 | - public void setPublisherPostOfficeBoxNumber(String publisherPostOfficeBoxNumber) { | ||
72 | - this.publisherPostOfficeBoxNumber = publisherPostOfficeBoxNumber; | ||
73 | - } | ||
74 | - | ||
75 | - public String getPublisherAddressRegion() { | ||
76 | - return publisherAddressRegion; | ||
77 | - } | ||
78 | - | ||
79 | - public void setPublisherAddressRegion(String publisherAddressRegion) { | ||
80 | - this.publisherAddressRegion = publisherAddressRegion; | ||
81 | - } | ||
82 | - | ||
83 | - public String getPublisherAddressLocality() { | ||
84 | - return publisherAddressLocality; | ||
85 | - } | ||
86 | - | ||
87 | - public void setPublisherAddressLocality(String publisherAddressLocality) { | ||
88 | - this.publisherAddressLocality = publisherAddressLocality; | ||
89 | - } | ||
90 | - | ||
91 | - public String getPublisherTelephone() { | ||
92 | - return publisherTelephone; | ||
93 | - } | ||
94 | - | ||
95 | - public void setPublisherTelephone(String publisherTelephone) { | ||
96 | - this.publisherTelephone = publisherTelephone; | ||
97 | - } | ||
98 | - | ||
99 | - public String getPublisherEmail() { | ||
100 | - return publisherEmail; | ||
101 | - } | ||
102 | - | ||
103 | - public void setPublisherEmail(String publisherEmail) { | ||
104 | - this.publisherEmail = publisherEmail; | ||
105 | - } | ||
106 | - | ||
107 | - public String getPublisherURL() { | ||
108 | - return publisherURL; | ||
109 | - } | ||
110 | - | ||
111 | - public void setPublisherURL(String publisherURL) { | ||
112 | - this.publisherURL = publisherURL; | ||
113 | - } | ||
114 | - | ||
115 | - public Integer getPublisherVersionId() { | ||
116 | - return publisherVersionId; | ||
117 | - } | ||
118 | - | ||
119 | - public void setPublisherVersionId(Integer publisherVersionId) { | ||
120 | - this.publisherVersionId = publisherVersionId; | ||
121 | - } | ||
122 | - | ||
123 | - public String getPublisherName() { | ||
124 | - return publisherName; | ||
125 | - } | ||
126 | - | ||
127 | - public void setPublisherName(String publisherName) { | ||
128 | - this.publisherName = publisherName; | ||
129 | - } | ||
130 | - | ||
131 | - public Country getPublisherAddressCountry() { | ||
132 | - return publisherAddressCountry; | ||
133 | - } | ||
134 | - | ||
135 | - public void setPublisherAddressCountry(Country publisherAddressCountry) { | ||
136 | - this.publisherAddressCountry = publisherAddressCountry; | ||
137 | - } | ||
138 | - | ||
139 | - public Account getPublisherVersionCreator() { | ||
140 | - return publisherVersionCreator; | ||
141 | - } | ||
142 | - | ||
143 | - public void setPublisherVersionCreator(Account publisherVersionCreator) { | ||
144 | - this.publisherVersionCreator = publisherVersionCreator; | ||
145 | - } | ||
146 | - | ||
147 | - @Override | ||
148 | - public String toString() { | ||
149 | - return "PUBLISHER_VERSION_ID = " + publisherVersionId + ", Name = " + publisherName + ", St Address = " + | ||
150 | - publisherStreetAddress + ", CP = " + publisherPostalCode + ", BP = " + publisherPostOfficeBoxNumber + | ||
151 | - ", Region = " + publisherAddressRegion + ", Ville = " + publisherAddressLocality + ", Pays = " + | ||
152 | - publisherAddressCountry + ", Telephone = " + publisherTelephone + ", email = " + publisherEmail + | ||
153 | - ", URL = " + publisherURL + ", History = " + publisherHistory + | ||
154 | - ", Version Author = " + publisherVersionCreator + ", Version DateTime = " + publisherVersionDatetime; | ||
155 | - } | ||
156 | - | ||
157 | - public Publisher getPublisher() { | ||
158 | - return publisher; | ||
159 | - } | ||
160 | - | ||
161 | - public void setPublisher(Publisher publisher) { | ||
162 | - this.publisher = publisher; | ||
163 | - } | ||
164 | -} | ||
... | \ 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.JpaRepository; | ||
4 | - | ||
5 | -import java.util.List; | ||
6 | - | ||
7 | -public interface PublisherVersionRepository extends JpaRepository<PublisherVersion, Integer> { | ||
8 | - /** | ||
9 | - * | ||
10 | - * @param integers list of Ids for the PublisherVersions we're looking for | ||
11 | - * @return PublisherVersions looked for | ||
12 | - */ | ||
13 | - List<PublisherVersion> findByPublisherVersionIdIn(List<Integer> integers); | ||
14 | -} |
1 | -package org.legrog.entities; | ||
2 | - | ||
3 | -/** | ||
4 | - * Exception when searching fails, whatever the reason. Has to be dealt with at service level. | ||
5 | - */ | ||
6 | -public class SearchingException extends Exception { | ||
7 | - final Throwable rootCause; | ||
8 | - | ||
9 | - SearchingException(Throwable rootCause) { | ||
10 | - this.rootCause = rootCause; | ||
11 | - } | ||
12 | - | ||
13 | - public Throwable getRootCause() { | ||
14 | - return rootCause; | ||
15 | - } | ||
16 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -package org.legrog.util; | ||
2 | -// Code copied from org.h2.server.web.WebSession | ||
3 | -/* | ||
4 | - * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0, | ||
5 | - * and the EPL 1.0 (http://h2database.com/html/license.html). | ||
6 | - * Initial Developer: H2 Group | ||
7 | - */ | ||
8 | -///package org.h2.server.web; | ||
9 | - | ||
10 | - import java.sql.Connection; | ||
11 | - import java.sql.DatabaseMetaData; | ||
12 | - import java.sql.ResultSet; | ||
13 | - import java.sql.SQLException; | ||
14 | - import java.sql.Statement; | ||
15 | - import java.sql.Timestamp; | ||
16 | - import java.util.ArrayList; | ||
17 | - import java.util.HashMap; | ||
18 | - import java.util.Locale; | ||
19 | - | ||
20 | - import org.h2.bnf.Bnf; | ||
21 | - import org.h2.bnf.context.DbContents; | ||
22 | - import org.h2.bnf.context.DbContextRule; | ||
23 | - import org.h2.message.DbException; | ||
24 | - import org.h2.util.New; | ||
25 | -import org.h2.server.web.*; | ||
26 | - | ||
27 | -/** | ||
28 | - * The web session keeps all data of a user session. | ||
29 | - * This class is used by the H2 Console. | ||
30 | - */ | ||
31 | -class WebSession { | ||
32 | - | ||
33 | - private static final int MAX_HISTORY = 1000; | ||
34 | - | ||
35 | - /** | ||
36 | - * The last time this client sent a request. | ||
37 | - */ | ||
38 | - long lastAccess; | ||
39 | - | ||
40 | - /** | ||
41 | - * The session attribute map. | ||
42 | - */ | ||
43 | - final HashMap<String, Object> map = New.hashMap(); | ||
44 | - | ||
45 | - /** | ||
46 | - * The current locale. | ||
47 | - */ | ||
48 | - Locale locale; | ||
49 | - | ||
50 | - /** | ||
51 | - * The currently executing statement. | ||
52 | - */ | ||
53 | - Statement executingStatement; | ||
54 | - | ||
55 | - /** | ||
56 | - * The current updatable result set. | ||
57 | - */ | ||
58 | - ResultSet result; | ||
59 | - | ||
60 | - private final WebServer server; | ||
61 | - | ||
62 | - private final ArrayList<String> commandHistory; | ||
63 | - | ||
64 | - private Connection conn; | ||
65 | - private DatabaseMetaData meta; | ||
66 | - private DbContents contents = new DbContents(); | ||
67 | - private Bnf bnf; | ||
68 | - private boolean shutdownServerOnDisconnect; | ||
69 | - | ||
70 | - WebSession(WebServer server) { | ||
71 | - this.server = server; | ||
72 | - // This must be stored in the session rather than in the server. | ||
73 | - // Otherwise, one client could allow | ||
74 | - // saving history for others (insecure). | ||
75 | - this.commandHistory = server.getCommandHistoryList(); | ||
76 | - } | ||
77 | - | ||
78 | - /** | ||
79 | - * Put an attribute value in the map. | ||
80 | - * | ||
81 | - * @param key the key | ||
82 | - * @param value the new value | ||
83 | - */ | ||
84 | - void put(String key, Object value) { | ||
85 | - map.put(key, value); | ||
86 | - } | ||
87 | - | ||
88 | - /** | ||
89 | - * Get the value for the given key. | ||
90 | - * | ||
91 | - * @param key the key | ||
92 | - * @return the value | ||
93 | - */ | ||
94 | - Object get(String key) { | ||
95 | - if ("sessions".equals(key)) { | ||
96 | - return server.getSessions(); | ||
97 | - } | ||
98 | - return map.get(key); | ||
99 | - } | ||
100 | - | ||
101 | - /** | ||
102 | - * Remove a session attribute from the map. | ||
103 | - * | ||
104 | - * @param key the key | ||
105 | - */ | ||
106 | - void remove(String key) { | ||
107 | - map.remove(key); | ||
108 | - } | ||
109 | - | ||
110 | - /** | ||
111 | - * Get the BNF object. | ||
112 | - * | ||
113 | - * @return the BNF object | ||
114 | - */ | ||
115 | - Bnf getBnf() { | ||
116 | - return bnf; | ||
117 | - } | ||
118 | - | ||
119 | - /** | ||
120 | - * Load the SQL grammar BNF. | ||
121 | - */ | ||
122 | - void loadBnf() { | ||
123 | - try { | ||
124 | - Bnf newBnf = Bnf.getInstance(null); | ||
125 | - DbContextRule columnRule = | ||
126 | - new DbContextRule(contents, DbContextRule.COLUMN); | ||
127 | - DbContextRule newAliasRule = | ||
128 | - new DbContextRule(contents, DbContextRule.NEW_TABLE_ALIAS); | ||
129 | - DbContextRule aliasRule = | ||
130 | - new DbContextRule(contents, DbContextRule.TABLE_ALIAS); | ||
131 | - DbContextRule tableRule = | ||
132 | - new DbContextRule(contents, DbContextRule.TABLE); | ||
133 | - DbContextRule schemaRule = | ||
134 | - new DbContextRule(contents, DbContextRule.SCHEMA); | ||
135 | - DbContextRule columnAliasRule = | ||
136 | - new DbContextRule(contents, DbContextRule.COLUMN_ALIAS); | ||
137 | - DbContextRule procedure = | ||
138 | - new DbContextRule(contents, DbContextRule.PROCEDURE); | ||
139 | - newBnf.updateTopic("procedure", procedure); | ||
140 | - newBnf.updateTopic("column_name", columnRule); | ||
141 | - newBnf.updateTopic("new_table_alias", newAliasRule); | ||
142 | - newBnf.updateTopic("table_alias", aliasRule); | ||
143 | - newBnf.updateTopic("column_alias", columnAliasRule); | ||
144 | - newBnf.updateTopic("table_name", tableRule); | ||
145 | - newBnf.updateTopic("schema_name", schemaRule); | ||
146 | - newBnf.linkStatements(); | ||
147 | - bnf = newBnf; | ||
148 | - } catch (Exception e) { | ||
149 | - // ok we don't have the bnf | ||
150 | - server.traceError(e); | ||
151 | - } | ||
152 | - } | ||
153 | - | ||
154 | - /** | ||
155 | - * Get the SQL statement from history. | ||
156 | - * | ||
157 | - * @param id the history id | ||
158 | - * @return the SQL statement | ||
159 | - */ | ||
160 | - String getCommand(int id) { | ||
161 | - return commandHistory.get(id); | ||
162 | - } | ||
163 | - | ||
164 | - /** | ||
165 | - * Add a SQL statement to the history. | ||
166 | - * | ||
167 | - * @param sql the SQL statement | ||
168 | - */ | ||
169 | - void addCommand(String sql) { | ||
170 | - if (sql == null) { | ||
171 | - return; | ||
172 | - } | ||
173 | - sql = sql.trim(); | ||
174 | - if (sql.length() == 0) { | ||
175 | - return; | ||
176 | - } | ||
177 | - if (commandHistory.size() > MAX_HISTORY) { | ||
178 | - commandHistory.remove(0); | ||
179 | - } | ||
180 | - int idx = commandHistory.indexOf(sql); | ||
181 | - if (idx >= 0) { | ||
182 | - commandHistory.remove(idx); | ||
183 | - } | ||
184 | - commandHistory.add(sql); | ||
185 | - if (server.isCommandHistoryAllowed()) { | ||
186 | - server.saveCommandHistoryList(commandHistory); | ||
187 | - } | ||
188 | - } | ||
189 | - | ||
190 | - /** | ||
191 | - * Get the list of SQL statements in the history. | ||
192 | - * | ||
193 | - * @return the commands | ||
194 | - */ | ||
195 | - ArrayList<String> getCommandHistory() { | ||
196 | - return commandHistory; | ||
197 | - } | ||
198 | - | ||
199 | - /** | ||
200 | - * Update session meta data information and get the information in a map. | ||
201 | - * | ||
202 | - * @return a map containing the session meta data | ||
203 | - */ | ||
204 | - HashMap<String, Object> getInfo() { | ||
205 | - HashMap<String, Object> m = New.hashMap(); | ||
206 | - m.putAll(map); | ||
207 | - m.put("lastAccess", new Timestamp(lastAccess).toString()); | ||
208 | - try { | ||
209 | - m.put("url", conn == null ? | ||
210 | - "${text.admin.notConnected}" : conn.getMetaData().getURL()); | ||
211 | - m.put("user", conn == null ? | ||
212 | - "-" : conn.getMetaData().getUserName()); | ||
213 | - m.put("lastQuery", commandHistory.size() == 0 ? | ||
214 | - "" : commandHistory.get(0)); | ||
215 | - m.put("executing", executingStatement == null ? | ||
216 | - "${text.admin.no}" : "${text.admin.yes}"); | ||
217 | - } catch (SQLException e) { | ||
218 | - DbException.traceThrowable(e); | ||
219 | - } | ||
220 | - return m; | ||
221 | - } | ||
222 | - | ||
223 | - void setConnection(Connection conn) throws SQLException { | ||
224 | - this.conn = conn; | ||
225 | - if (conn == null) { | ||
226 | - meta = null; | ||
227 | - } else { | ||
228 | - meta = conn.getMetaData(); | ||
229 | - } | ||
230 | - contents = new DbContents(); | ||
231 | - } | ||
232 | - | ||
233 | - DatabaseMetaData getMetaData() { | ||
234 | - return meta; | ||
235 | - } | ||
236 | - | ||
237 | - Connection getConnection() { | ||
238 | - return conn; | ||
239 | - } | ||
240 | - | ||
241 | - DbContents getContents() { | ||
242 | - return contents; | ||
243 | - } | ||
244 | - | ||
245 | - /** | ||
246 | - * Shutdown the server when disconnecting. | ||
247 | - */ | ||
248 | - void setShutdownServerOnDisconnect() { | ||
249 | - this.shutdownServerOnDisconnect = true; | ||
250 | - } | ||
251 | - | ||
252 | - boolean getShutdownServerOnDisconnect() { | ||
253 | - return shutdownServerOnDisconnect; | ||
254 | - } | ||
255 | - | ||
256 | - /** | ||
257 | - * Close the connection and stop the statement if one is currently | ||
258 | - * executing. | ||
259 | - */ | ||
260 | - void close() { | ||
261 | - if (executingStatement != null) { | ||
262 | - try { | ||
263 | - executingStatement.cancel(); | ||
264 | - } catch (Exception e) { | ||
265 | - // ignore | ||
266 | - } | ||
267 | - } | ||
268 | - if (conn != null) { | ||
269 | - try { | ||
270 | - conn.close(); | ||
271 | - } catch (Exception e) { | ||
272 | - // ignore | ||
273 | - } | ||
274 | - } | ||
275 | - | ||
276 | - } | ||
277 | - | ||
278 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -package org.legrog.entities; | ||
2 | - | ||
3 | -import org.apache.solr.client.solrj.SolrClient; | ||
4 | -import org.apache.solr.client.solrj.SolrQuery; | ||
5 | -import org.apache.solr.client.solrj.SolrServerException; | ||
6 | -import org.apache.solr.client.solrj.beans.BindingException; | ||
7 | -import org.apache.solr.common.params.SolrParams; | ||
8 | -import org.junit.jupiter.api.*; | ||
9 | -import org.junit.jupiter.api.extension.ExtendWith; | ||
10 | -import org.junit.platform.runner.JUnitPlatform; | ||
11 | -import org.junit.runner.RunWith; | ||
12 | -import org.legrog.test.MockitoExtension; | ||
13 | -import org.mockito.ArgumentCaptor; | ||
14 | -import org.mockito.Captor; | ||
15 | -import org.mockito.Mock; | ||
16 | -import org.mockito.Mockito; | ||
17 | -import org.slf4j.Logger; | ||
18 | -import org.slf4j.LoggerFactory; | ||
19 | - | ||
20 | -import java.io.IOException; | ||
21 | - | ||
22 | -import static org.assertj.core.api.Assertions.assertThat; | ||
23 | -import static org.mockito.Mockito.verify; | ||
24 | -import static org.mockito.Mockito.when; | ||
25 | - | ||
26 | -/** | ||
27 | - * Classe testant AccountSearchRepositorySolrj | ||
28 | - */ | ||
29 | -@RunWith(JUnitPlatform.class) | ||
30 | -@ExtendWith(MockitoExtension.class) | ||
31 | -@DisplayName("Indexes and searches with SearchRepository") | ||
32 | - | ||
33 | -public class AccountSearchRepositorySolrjTest { | ||
34 | - Logger logger = LoggerFactory.getLogger(getClass()); | ||
35 | - | ||
36 | - private AccountSearchRepository accountSearchRepository; | ||
37 | - private SolrClient solrClient; | ||
38 | - | ||
39 | - @Captor | ||
40 | - ArgumentCaptor<SolrParams> solrParamsArgumentCaptor; | ||
41 | - | ||
42 | - @BeforeEach | ||
43 | - public void setup(@Mock SolrClient solrClient) { | ||
44 | - accountSearchRepository = new AccountSearchRepositorySolrj(solrClient); | ||
45 | - this.solrClient = solrClient; | ||
46 | - } | ||
47 | - | ||
48 | - @Nested | ||
49 | - @DisplayName("search method") | ||
50 | - class SearchTests { | ||
51 | - | ||
52 | - @DisplayName("when repository in IO error, should throw a SearchingException") | ||
53 | - @Test | ||
54 | - public void searchIOETest() throws IOException, SolrServerException{ | ||
55 | - when(solrClient.query(Mockito.anyString(), Mockito.any())).thenThrow(new IOException()); | ||
56 | - Assertions.assertThrows(SearchingException.class, () -> accountSearchRepository.search("a")); | ||
57 | - } | ||
58 | - | ||
59 | - @DisplayName("when repository in SolrServerException, should throw an SearchingException with its root cause") | ||
60 | - @Test | ||
61 | - public void searchSSETest() throws SolrServerException, IOException { | ||
62 | - when(solrClient.query(Mockito.any())).thenThrow(new SolrServerException(new BindingException("BE test 2"))); | ||
63 | - try { | ||
64 | - accountSearchRepository.search("b"); | ||
65 | - } catch (SearchingException se) { | ||
66 | - logger.error("SearchingException {}", se); | ||
67 | - assertThat(se.getRootCause().getClass()).isEqualTo(BindingException.class); | ||
68 | - } | ||
69 | - } | ||
70 | - | ||
71 | - @DisplayName("when called, it parameter should be embedded in a query sent through SolrClient") | ||
72 | - @Test | ||
73 | - public void searchParameterTest() throws IOException, SolrServerException { | ||
74 | - try { | ||
75 | - accountSearchRepository.search("c"); | ||
76 | - Mockito.verify(solrClient).query(Mockito.anyString(), solrParamsArgumentCaptor.capture()); | ||
77 | - } catch (SearchingException se) { | ||
78 | - logger.error("SearchingException {}", se); | ||
79 | - } | ||
80 | - SolrQuery solrQuery = (SolrQuery) solrParamsArgumentCaptor.getValue(); | ||
81 | - assertThat(solrQuery.getQuery()).isEqualTo("c"); | ||
82 | - } | ||
83 | - | ||
84 | - } | ||
85 | - | ||
86 | - | ||
87 | -} |
1 | -package org.legrog.entities; | ||
2 | - | ||
3 | -import org.apache.solr.client.solrj.SolrClient; | ||
4 | -import org.apache.solr.client.solrj.SolrQuery; | ||
5 | -import org.apache.solr.client.solrj.SolrServerException; | ||
6 | -import org.apache.solr.client.solrj.beans.BindingException; | ||
7 | -import org.apache.solr.common.params.SolrParams; | ||
8 | -import org.junit.jupiter.api.*; | ||
9 | -import org.junit.jupiter.api.extension.ExtendWith; | ||
10 | -import org.junit.platform.runner.JUnitPlatform; | ||
11 | -import org.junit.runner.RunWith; | ||
12 | -import org.legrog.test.MockitoExtension; | ||
13 | -import org.mockito.ArgumentCaptor; | ||
14 | -import org.mockito.Captor; | ||
15 | -import org.mockito.Mock; | ||
16 | -import org.mockito.Mockito; | ||
17 | -import org.slf4j.Logger; | ||
18 | -import org.slf4j.LoggerFactory; | ||
19 | - | ||
20 | -import java.io.IOException; | ||
21 | - | ||
22 | -import static org.mockito.Mockito.verify; | ||
23 | -import static org.mockito.Mockito.when; | ||
24 | - | ||
25 | -import static org.assertj.core.api.Assertions.assertThat; | ||
26 | - | ||
27 | -/** | ||
28 | - * Classe testant PublisherSearchRepositorySolrj | ||
29 | - */ | ||
30 | -@RunWith(JUnitPlatform.class) | ||
31 | -@ExtendWith(MockitoExtension.class) | ||
32 | -@DisplayName("Indexes and searches with SearchRepository") | ||
33 | - | ||
34 | -public class PublisherSearchRepositorySolrjTest { | ||
35 | - Logger logger = LoggerFactory.getLogger(getClass()); | ||
36 | - | ||
37 | - private PublisherSearchRepository publisherSearchRepository; | ||
38 | - private SolrClient solrClient; | ||
39 | - | ||
40 | - @Captor | ||
41 | - ArgumentCaptor<SolrParams> solrParamsArgumentCaptor; | ||
42 | - | ||
43 | - @BeforeEach | ||
44 | - public void setup(@Mock SolrClient solrClient) { | ||
45 | - publisherSearchRepository = new PublisherSearchRepositorySolrj(solrClient); | ||
46 | - this.solrClient = solrClient; | ||
47 | - } | ||
48 | - | ||
49 | - @Nested | ||
50 | - @DisplayName("save method") | ||
51 | - class SaveTests { | ||
52 | - | ||
53 | - @Test | ||
54 | - @DisplayName("when called with right parameters, should addBean IndexedPublisher with commitWithinMs of 1 to repository") | ||
55 | - public void addBeanTest(@Mock IndexedPublisher indexedPublisher) throws IndexingException, SolrServerException, IOException { | ||
56 | - publisherSearchRepository.save(indexedPublisher); | ||
57 | - verify(solrClient).addBean(PublisherSearchRepositorySolrj.collectionName, indexedPublisher, 1); | ||
58 | - } | ||
59 | - | ||
60 | - @Test | ||
61 | - @DisplayName("When repository in IO error, should throw an IndexingException") | ||
62 | - public void addBeanIOETest(@Mock IndexedPublisher indexedPublisher) throws SolrServerException, IOException { | ||
63 | - when(solrClient.addBean(PublisherSearchRepositorySolrj.collectionName, indexedPublisher, 1)).thenThrow(new IOException()); | ||
64 | - Assertions.assertThrows(IndexingException.class, () -> publisherSearchRepository.save(indexedPublisher)); | ||
65 | - } | ||
66 | - | ||
67 | - @Test | ||
68 | - @DisplayName("When repository in SolrServerException, should throw an IndexingException with its root cause") | ||
69 | - public void addBeanSSETest(@Mock IndexedPublisher indexedPublisher) throws SolrServerException, IOException{ | ||
70 | - when(solrClient.addBean(indexedPublisher, 1)).thenThrow(new SolrServerException(new BindingException("BE test"))); | ||
71 | - try { | ||
72 | - publisherSearchRepository.save(indexedPublisher); | ||
73 | - } catch (IndexingException ie) { | ||
74 | - logger.error("IndexingException {}", ie); | ||
75 | - assertThat(ie.getRootCause().getClass()).isEqualTo(BindingException.class); | ||
76 | - } | ||
77 | - } | ||
78 | - } | ||
79 | - | ||
80 | - @Nested | ||
81 | - @DisplayName("search method") | ||
82 | - class SearchTests { | ||
83 | - | ||
84 | - @DisplayName("when repository in IO error, should throw a SearchingException") | ||
85 | - @Test | ||
86 | - public void searchIOETest() throws IOException, SolrServerException{ | ||
87 | - when(solrClient.query(Mockito.anyString(), Mockito.any())).thenThrow(new IOException()); | ||
88 | - Assertions.assertThrows(SearchingException.class, () -> publisherSearchRepository.search("a")); | ||
89 | - } | ||
90 | - | ||
91 | - @DisplayName("when repository in SolrServerException, should throw an SearchingException with its root cause") | ||
92 | - @Test | ||
93 | - public void searchSSETest() throws SolrServerException, IOException { | ||
94 | - when(solrClient.query(Mockito.any())).thenThrow(new SolrServerException(new BindingException("BE test 2"))); | ||
95 | - try { | ||
96 | - publisherSearchRepository.search("b"); | ||
97 | - } catch (SearchingException se) { | ||
98 | - logger.error("SearchingException {}", se); | ||
99 | - assertThat(se.getRootCause().getClass()).isEqualTo(BindingException.class); | ||
100 | - } | ||
101 | - } | ||
102 | - | ||
103 | - @DisplayName("when called, it parameter should be embedded in a query sent through SolrClient") | ||
104 | - @Test | ||
105 | - public void searchParameterTest() throws IOException, SolrServerException { | ||
106 | - try { | ||
107 | - publisherSearchRepository.search("c"); | ||
108 | - Mockito.verify(solrClient).query(Mockito.anyString(), solrParamsArgumentCaptor.capture()); | ||
109 | - } catch (SearchingException se) { | ||
110 | - logger.error("SearchingException {}", se); | ||
111 | - } | ||
112 | - SolrQuery solrQuery = (SolrQuery) solrParamsArgumentCaptor.getValue(); | ||
113 | - assertThat(solrQuery.getQuery()).isEqualTo("c"); | ||
114 | - } | ||
115 | - | ||
116 | - } | ||
117 | - | ||
118 | - | ||
119 | -} |
1 | -package org.legrog.test; | ||
2 | - | ||
3 | -/* | ||
4 | - | ||
5 | -TAKEN FROM JUnit 5 Sample | ||
6 | -https://github.com/junit-team/junit5-samples/blob/master/junit5-mockito-extension/src/main/java/com/example/mockito/MockitoExtension.java | ||
7 | - | ||
8 | -*/ | ||
9 | - | ||
10 | -/* | ||
11 | - * Copyright 2015-2016 the original author or authors. | ||
12 | - * | ||
13 | - * All rights reserved. This program and the accompanying materials are | ||
14 | - * made available under the terms of the Eclipse Public License v1.0 which | ||
15 | - * accompanies this distribution and is available at | ||
16 | - * | ||
17 | - * http://www.eclipse.org/legal/epl-v10.html | ||
18 | - * | ||
19 | - */ | ||
20 | - | ||
21 | - | ||
22 | -import static org.mockito.Mockito.mock; | ||
23 | - | ||
24 | -import java.lang.reflect.Parameter; | ||
25 | - | ||
26 | -import org.junit.jupiter.api.extension.ExtensionContext; | ||
27 | -import org.junit.jupiter.api.extension.ExtensionContext.Namespace; | ||
28 | -import org.junit.jupiter.api.extension.ExtensionContext.Store; | ||
29 | -import org.junit.jupiter.api.extension.ParameterContext; | ||
30 | -import org.junit.jupiter.api.extension.ParameterResolver; | ||
31 | -import org.junit.jupiter.api.extension.TestInstancePostProcessor; | ||
32 | -import org.mockito.Mock; | ||
33 | -import org.mockito.MockitoAnnotations; | ||
34 | - | ||
35 | -/** | ||
36 | - * {@code MockitoExtension} showcases the {@link TestInstancePostProcessor} | ||
37 | - * and {@link ParameterResolver} extension APIs of JUnit 5 by providing | ||
38 | - * dependency injection support at the field level and at the method parameter | ||
39 | - * level via Mockito 2.x's {@link Mock @Mock} annotation. | ||
40 | - */ | ||
41 | -public class MockitoExtension implements TestInstancePostProcessor, ParameterResolver { | ||
42 | - | ||
43 | - @Override | ||
44 | - public void postProcessTestInstance(Object testInstance, ExtensionContext context) { | ||
45 | - MockitoAnnotations.initMocks(testInstance); | ||
46 | - } | ||
47 | - | ||
48 | - @Override | ||
49 | - public boolean supports(ParameterContext parameterContext, ExtensionContext extensionContext) { | ||
50 | - return parameterContext.getParameter().isAnnotationPresent(Mock.class); | ||
51 | - } | ||
52 | - | ||
53 | - @Override | ||
54 | - public Object resolve(ParameterContext parameterContext, ExtensionContext extensionContext) { | ||
55 | - return getMock(parameterContext.getParameter(), extensionContext); | ||
56 | - } | ||
57 | - | ||
58 | - private Object getMock(Parameter parameter, ExtensionContext extensionContext) { | ||
59 | - Class<?> mockType = parameter.getType(); | ||
60 | - Store mocks = extensionContext.getStore(Namespace.create(MockitoExtension.class, mockType)); | ||
61 | - String mockName = getMockName(parameter); | ||
62 | - | ||
63 | - if (mockName != null) { | ||
64 | - return mocks.getOrComputeIfAbsent(mockName, key -> mock(mockType, mockName)); | ||
65 | - } else { | ||
66 | - return mocks.getOrComputeIfAbsent(mockType.getCanonicalName(), key -> mock(mockType)); | ||
67 | - } | ||
68 | - } | ||
69 | - | ||
70 | - private String getMockName(Parameter parameter) { | ||
71 | - String explicitMockName = parameter.getAnnotation(Mock.class).name().trim(); | ||
72 | - if (!explicitMockName.isEmpty()) { | ||
73 | - return explicitMockName; | ||
74 | - } else if (parameter.isNamePresent()) { | ||
75 | - return parameter.getName(); | ||
76 | - } | ||
77 | - return null; | ||
78 | - } | ||
79 | - | ||
80 | -} | ||
81 | - |
1 | -package org.legrog.web.xyz; | ||
2 | - | ||
3 | -import org.junit.jupiter.api.BeforeEach; | ||
4 | -import org.junit.jupiter.api.DisplayName; | ||
5 | -import org.junit.jupiter.api.Nested; | ||
6 | -import org.junit.jupiter.api.Test; | ||
7 | -import org.junit.jupiter.api.extension.ExtendWith; | ||
8 | -import org.junit.platform.runner.JUnitPlatform; | ||
9 | -import org.junit.runner.RunWith; | ||
10 | -import org.legrog.entities.Account; | ||
11 | -import org.legrog.entities.PublisherVersion; | ||
12 | -import org.legrog.entities.SearchingException; | ||
13 | -import org.legrog.test.MockitoExtension; | ||
14 | -import org.legrog.web.account.AccountService; | ||
15 | -import org.legrog.web.publisher.PublisherSearchView; | ||
16 | -import org.legrog.web.publisher.PublisherService; | ||
17 | -import org.mockito.Mock; | ||
18 | -import org.mockito.Mockito; | ||
19 | - | ||
20 | -import java.util.ArrayList; | ||
21 | -import java.util.List; | ||
22 | - | ||
23 | -import static org.assertj.core.api.Assertions.assertThat; | ||
24 | -import static org.mockito.Mockito.when; | ||
25 | - | ||
26 | -/** | ||
27 | - * Classe testant SearchView | ||
28 | - */ | ||
29 | -@RunWith(JUnitPlatform.class) | ||
30 | -@ExtendWith(MockitoExtension.class) | ||
31 | -@DisplayName("Searches for an indexed publisher") | ||
32 | -public class SearchViewTest { | ||
33 | - | ||
34 | - private SearchView searchView; | ||
35 | - private PublisherService publisherService; | ||
36 | - private AccountService accountService; | ||
37 | - | ||
38 | - @BeforeEach | ||
39 | - public void setUp(@Mock PublisherService publisherService, @Mock AccountService accountService) { | ||
40 | - this.publisherService = publisherService; | ||
41 | - this.accountService = accountService; | ||
42 | - this.searchView = new SearchView(publisherService, accountService); | ||
43 | - } | ||
44 | - | ||
45 | - @Nested | ||
46 | - @DisplayName("search method") | ||
47 | - class SearchTests { | ||
48 | - | ||
49 | - @Test | ||
50 | - @DisplayName("when called, should delegate search to PublisherService and AccountService with same string") | ||
51 | - public void searchUsesPublisherService(@Mock PublisherService publisherService, @Mock AccountService accountService) throws SearchingException{ | ||
52 | - searchView.setSearchString("1"); | ||
53 | - searchView.search(); | ||
54 | - Mockito.verify(publisherService).search("1"); | ||
55 | - Mockito.verify(accountService).search("1"); | ||
56 | - } | ||
57 | - | ||
58 | - @Test | ||
59 | - @DisplayName("when called, should return the answer it gets from PublisherService") | ||
60 | - public void searchReturnsDataFromPublisherService(@Mock PublisherService publisherService) throws SearchingException { | ||
61 | - List<PublisherVersion> publisherVersionList = new ArrayList<>(); | ||
62 | - when(publisherService.search("2")).thenReturn(publisherVersionList); | ||
63 | - searchView.setSearchString("2"); | ||
64 | - searchView.search(); | ||
65 | - assertThat(searchView.getPublisherVersions()).isEqualTo(publisherVersionList); | ||
66 | - } | ||
67 | - | ||
68 | - @Test | ||
69 | - @DisplayName("when called, should return the answer it gets from AccountService") | ||
70 | - public void searchReturnsDataFromAccountService(@Mock AccountService accountService) throws SearchingException { | ||
71 | - List<Account> publisherVersionList = new ArrayList<>(); | ||
72 | - when(accountService.search("3")).thenReturn(publisherVersionList); | ||
73 | - searchView.setSearchString("3"); | ||
74 | - searchView.search(); | ||
75 | - assertThat(searchView.getPublisherVersions()).isEqualTo(publisherVersionList); | ||
76 | - } | ||
77 | - | ||
78 | - } | ||
79 | -} |
webapp/pom.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
3 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
4 | + <modelVersion>4.0.0</modelVersion> | ||
5 | + | ||
6 | + <name>Web-application of GROG</name> | ||
7 | + <url>http://legrog.org</url> | ||
8 | + <description> | ||
9 | + Le Guide du Roliste Galactique (GROG) est une encyclopedie en ligne référençant tous les jeux de rôles connus. | ||
10 | + Cette version CUBI est la 3e mouture du site. | ||
11 | + </description> | ||
12 | + | ||
13 | + | ||
14 | + <parent> | ||
15 | + <groupId>org.legrog</groupId> | ||
16 | + <artifactId>grog-cubi</artifactId> | ||
17 | + <version>3.0-SNAPSHOT</version> | ||
18 | + </parent> | ||
19 | + <artifactId>grog-webapp</artifactId> | ||
20 | + <packaging>war</packaging> | ||
21 | + | ||
22 | + | ||
23 | + <properties> | ||
24 | + <!-- dependencies version --> | ||
25 | + <spring.platform-bom.version>Athens-SR1</spring.platform-bom.version> | ||
26 | + <omnifaces.version>2.5.1</omnifaces.version> | ||
27 | + <primefaces.version>6.0</primefaces.version> | ||
28 | + <myfaces.version>2.2.10</myfaces.version> | ||
29 | + <tomee.javaee-api.version>7.0</tomee.javaee-api.version> | ||
30 | + <assertj-core.version>1.6.1</assertj-core.version> | ||
31 | + <openjpa.version>2.4.1</openjpa.version> | ||
32 | + <rewrite.version>3.4.1.Final</rewrite.version> | ||
33 | + <hibernate-commons-annotations.version>5.0.1.Final</hibernate-commons-annotations.version> | ||
34 | + <hibernate-jpa-2.1-api.version>1.0.0.Final</hibernate-jpa-2.1-api.version> | ||
35 | + <junit.platform.version>1.0.0-M3</junit.platform.version> | ||
36 | + <junit.jupiter.version>5.0.0-M3</junit.jupiter.version> | ||
37 | + <mockito-core.version>2.2.16</mockito-core.version> | ||
38 | + <spring-data-solr.version>3.0.0.M1</spring-data-solr.version> | ||
39 | + <solr.version>6.3.0</solr.version> | ||
40 | + | ||
41 | + <!-- paths --> | ||
42 | + <custom.web.dir>src/main/java/org/legrog/web</custom.web.dir> | ||
43 | + | ||
44 | + <!-- misc --> | ||
45 | + <debug.jvm.args /> | ||
46 | + <tomee.autoreload /> | ||
47 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
48 | + <maven.compiler.source>1.8</maven.compiler.source> | ||
49 | + <maven.compiler.target>1.8</maven.compiler.target> | ||
50 | + | ||
51 | + | ||
52 | + </properties> | ||
53 | + | ||
54 | + <profiles> | ||
55 | + <profile> | ||
56 | + <id>debug</id> | ||
57 | + <!-- | ||
58 | + activate this one to be able to attach a remote debbuger on tomee | ||
59 | + --> | ||
60 | + <properties> | ||
61 | + <debug.jvm.args>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005</debug.jvm.args> | ||
62 | + </properties> | ||
63 | + </profile> | ||
64 | + | ||
65 | + <profile> | ||
66 | + <id>autoreload</id> | ||
67 | + <!-- | ||
68 | + activate this one for tomee to reload (takes times) every times it detect a synchro | ||
69 | + reminder : you can always force a reload by typing reload in the console while tomee:run is active | ||
70 | + --> | ||
71 | + <properties> | ||
72 | + <tomee.autoreload>true</tomee.autoreload> | ||
73 | + </properties> | ||
74 | + </profile> | ||
75 | + </profiles> | ||
76 | + | ||
77 | + | ||
78 | + <dependencies> | ||
79 | + | ||
80 | + <dependency> | ||
81 | + <groupId>org.legrog</groupId> | ||
82 | + <artifactId>grog-entities</artifactId> | ||
83 | + <version>3.0-SNAPSHOT</version> | ||
84 | + </dependency> | ||
85 | + | ||
86 | + <dependency> | ||
87 | + <groupId>org.apache.solr</groupId> | ||
88 | + <artifactId>solr-solrj</artifactId> | ||
89 | + <version>${solr.version}</version> | ||
90 | + </dependency> | ||
91 | + | ||
92 | + | ||
93 | + <!-- https://mvnrepository.com/artifact/org.omnifaces/omnifaces --> | ||
94 | + <dependency> | ||
95 | + <groupId>org.omnifaces</groupId> | ||
96 | + <artifactId>omnifaces</artifactId> | ||
97 | + <version>${omnifaces.version}</version> | ||
98 | + </dependency> | ||
99 | + | ||
100 | + <!-- https://mvnrepository.com/artifact/org.primefaces/primefaces --> | ||
101 | + <dependency> | ||
102 | + <groupId>org.primefaces</groupId> | ||
103 | + <artifactId>primefaces</artifactId> | ||
104 | + <version>${primefaces.version}</version> | ||
105 | + </dependency> | ||
106 | + | ||
107 | + <dependency> | ||
108 | + <groupId>org.apache.myfaces.core</groupId> | ||
109 | + <artifactId>myfaces-api</artifactId> | ||
110 | + <version>${myfaces.version}</version> | ||
111 | + </dependency> | ||
112 | + <dependency> | ||
113 | + <groupId>org.apache.myfaces.core</groupId> | ||
114 | + <artifactId>myfaces-impl</artifactId> | ||
115 | + <version>${myfaces.version}</version> | ||
116 | + <scope>runtime</scope> | ||
117 | + </dependency> | ||
118 | + | ||
119 | + | ||
120 | + <!-- Rewriting tool --> | ||
121 | + | ||
122 | + <dependency> | ||
123 | + <groupId>org.ocpsoft.rewrite</groupId> | ||
124 | + <artifactId>rewrite-servlet</artifactId> | ||
125 | + <version>${rewrite.version}</version> | ||
126 | + </dependency> | ||
127 | + | ||
128 | + <dependency> | ||
129 | + <groupId>org.ocpsoft.rewrite</groupId> | ||
130 | + <artifactId>rewrite-integration-faces</artifactId> | ||
131 | + <version>${rewrite.version}</version> | ||
132 | + </dependency> | ||
133 | + | ||
134 | + <dependency> | ||
135 | + <groupId>org.ocpsoft.rewrite</groupId> | ||
136 | + <artifactId>rewrite-integration-cdi</artifactId> | ||
137 | + <version>${rewrite.version}</version> | ||
138 | + </dependency> | ||
139 | + | ||
140 | + | ||
141 | + <!-- **** TOOLS : LOGS + UTILS **** --> | ||
142 | + | ||
143 | + <dependency> | ||
144 | + <groupId>org.slf4j</groupId> | ||
145 | + <artifactId>slf4j-api</artifactId> | ||
146 | + </dependency> | ||
147 | + | ||
148 | + <dependency> | ||
149 | + <groupId>ch.qos.logback</groupId> | ||
150 | + <artifactId>logback-classic</artifactId> | ||
151 | + </dependency> | ||
152 | + | ||
153 | + | ||
154 | + <!-- **** DATA MANAGEMENT **** --> | ||
155 | + | ||
156 | + <dependency> | ||
157 | + <groupId>com.h2database</groupId> | ||
158 | + <artifactId>h2</artifactId> | ||
159 | + </dependency> | ||
160 | + | ||
161 | + <dependency> | ||
162 | + <groupId>mysql</groupId> | ||
163 | + <artifactId>mysql-connector-java</artifactId> | ||
164 | + <!-- | ||
165 | + <version>5.1.6</version> | ||
166 | + --> | ||
167 | + </dependency> | ||
168 | + | ||
169 | + </dependencies> | ||
170 | + | ||
171 | + <build> | ||
172 | + <plugins> | ||
173 | + | ||
174 | + <plugin> | ||
175 | + <groupId>org.apache.maven.plugins</groupId> | ||
176 | + <artifactId>maven-war-plugin</artifactId> | ||
177 | + <version>2.6</version> | ||
178 | + <configuration> | ||
179 | + <failOnMissingWebXml>false</failOnMissingWebXml> | ||
180 | + <webResources> | ||
181 | + <resource> | ||
182 | + <!-- this is relative to the pom.xml directory --> | ||
183 | + <directory>${custom.web.dir}</directory> | ||
184 | + <excludes> | ||
185 | + <exclude>**/*.java</exclude> | ||
186 | + </excludes> | ||
187 | + | ||
188 | + </resource> | ||
189 | + </webResources> | ||
190 | + | ||
191 | + </configuration> | ||
192 | + </plugin> | ||
193 | + | ||
194 | + | ||
195 | + <!-- **** TOMEE **** --> | ||
196 | + <!-- For now we just get a generic one from the repo and put it in target dir --> | ||
197 | + <!-- For production release, we will need another pom doing a real provisionning and build it with grog-cubi already inside --> | ||
198 | + <!-- | ||
199 | + see http://tomee.apache.org/ng/developer/tools/maven/tomee.html | ||
200 | + and http://tomee.apache.org/maven/index.html | ||
201 | + for conf references (I love when a new reference page doesn't get the same info as the former one) | ||
202 | + --> | ||
203 | + <plugin> | ||
204 | + <groupId>org.apache.tomee.maven</groupId> | ||
205 | + <artifactId>tomee-maven-plugin</artifactId> | ||
206 | + <version>7.0.1</version> | ||
207 | + <configuration> | ||
208 | + <context>ROOT</context> | ||
209 | + | ||
210 | + <!-- debug agent to attach a remote debbuger, activate profile for that --> | ||
211 | + <args>${debug.jvm.args}</args> | ||
212 | + | ||
213 | + <systemVariables> | ||
214 | + <!-- | ||
215 | + taken from http://tomee-openejb.979440.n4.nabble.com/7-0-0-M3-synchronization-td4677806.html for synchro to work | ||
216 | + --> | ||
217 | + <openejb.system.apps>true</openejb.system.apps> | ||
218 | + <tomee.serialization.class.blacklist>-</tomee.serialization.class.blacklist> | ||
219 | + </systemVariables> | ||
220 | + | ||
221 | + | ||
222 | + <synchronization> | ||
223 | + <resourcesDir>${custom.web.dir}</resourcesDir> | ||
224 | + <extensions> | ||
225 | + <extension>.class</extension> <!-- update each time you build with mvn compile --> | ||
226 | + <extension>.xhtml</extension> <!-- update each time you save an xhtml in custom web dir --> | ||
227 | + </extensions> | ||
228 | + </synchronization> | ||
229 | + <reloadOnUpdate>${tomee.autoreload}</reloadOnUpdate> | ||
230 | + | ||
231 | + </configuration> | ||
232 | + </plugin> | ||
233 | + </plugins> | ||
234 | + </build> | ||
235 | + | ||
236 | +</project> |
... | @@ -15,7 +15,7 @@ public class JpaConfiguration { | ... | @@ -15,7 +15,7 @@ public class JpaConfiguration { |
15 | */ | 15 | */ |
16 | @Produces | 16 | @Produces |
17 | @RequestScoped | 17 | @RequestScoped |
18 | - @PersistenceContext(unitName = "migration-pu") | 18 | + @PersistenceContext(unitName = "development-pu") |
19 | public EntityManager entityManager; | 19 | public EntityManager entityManager; |
20 | 20 | ||
21 | } | 21 | } | ... | ... |
src/main/java/org/legrog/util/PageParser.java
→
webapp/src/main/java/org/legrog/util/PageParser.java
File moved
File moved
File moved
File moved
src/main/java/org/legrog/web/navigation.xhtml
→
webapp/src/main/java/org/legrog/web/navigation.xhtml
File moved
... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
10 | <link rel="stylesheet" type="text/css" href="/minimal.css"/> | 10 | <link rel="stylesheet" type="text/css" href="/minimal.css"/> |
11 | </head> | 11 | </head> |
12 | <body> | 12 | <body> |
13 | -<ui:include src="/navigation.xhtml" /> | 13 | +<ui:include src="/org/legrog/web/navigation.xhtml" /> |
14 | 14 | ||
15 | <a jsf:outcome="listPublisherActions" jsf:rendered="#{not listPublisherActionsView.viewAll}">Voir toutes les actions</a> | 15 | <a jsf:outcome="listPublisherActions" jsf:rendered="#{not listPublisherActionsView.viewAll}">Voir toutes les actions</a> |
16 | 16 | ... | ... |
... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
10 | <link rel="stylesheet" type="text/css" href="/minimal.css"/> | 10 | <link rel="stylesheet" type="text/css" href="/minimal.css"/> |
11 | </head> | 11 | </head> |
12 | <body> | 12 | <body> |
13 | -<ui:include src="/navigation.xhtml" /> | 13 | +<ui:include src="/org/legrog/web/navigation.xhtml" /> |
14 | 14 | ||
15 | <a jsf:outcome="listPublisherVersions" jsf:rendered="#{not listPublisherVersionsView.viewAll}">Voir toutes les versions d'éditeurs</a> | 15 | <a jsf:outcome="listPublisherVersions" jsf:rendered="#{not listPublisherVersionsView.viewAll}">Voir toutes les versions d'éditeurs</a> |
16 | <p jsf:rendered="#{listPublisherVersionsView.publisherVersions.isEmpty()}">Liste des révisions est vide</p> | 16 | <p jsf:rendered="#{listPublisherVersionsView.publisherVersions.isEmpty()}">Liste des révisions est vide</p> | ... | ... |
... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
10 | <link rel="stylesheet" type="text/css" href="/minimal.css"/> | 10 | <link rel="stylesheet" type="text/css" href="/minimal.css"/> |
11 | </head> | 11 | </head> |
12 | <body> | 12 | <body> |
13 | -<ui:include src="/navigation.xhtml" /> | 13 | +<ui:include src="/org/legrog/web/navigation.xhtml" /> |
14 | 14 | ||
15 | <form action="" jsf:id="search"> | 15 | <form action="" jsf:id="search"> |
16 | <h:panelGrid columns="2"> | 16 | <h:panelGrid columns="2"> | ... | ... |
... | @@ -9,7 +9,7 @@ | ... | @@ -9,7 +9,7 @@ |
9 | <head> | 9 | <head> |
10 | </head> | 10 | </head> |
11 | <body> | 11 | <body> |
12 | -<ui:include src="/navigation.xhtml" /> | 12 | +<ui:include src="/org/legrog/web/navigation.xhtml" /> |
13 | 13 | ||
14 | <form jsf:id="publisherVersion" action=""> | 14 | <form jsf:id="publisherVersion" action=""> |
15 | <h:panelGrid columns="2"> | 15 | <h:panelGrid columns="2"> | ... | ... |
... | @@ -6,7 +6,7 @@ | ... | @@ -6,7 +6,7 @@ |
6 | xmlns:jsf="http://xmlns.jcp.org/jsf" | 6 | xmlns:jsf="http://xmlns.jcp.org/jsf" |
7 | xmlns:ui="http://java.sun.com/jsf/facelets"> | 7 | xmlns:ui="http://java.sun.com/jsf/facelets"> |
8 | <body> | 8 | <body> |
9 | -<ui:include src="/navigation.xhtml" /> | 9 | +<ui:include src="/org/legrog/web/navigation.xhtml" /> |
10 | 10 | ||
11 | <form action="" jsf:id="country"> | 11 | <form action="" jsf:id="country"> |
12 | <h:panelGrid columns="2"> | 12 | <h:panelGrid columns="2"> | ... | ... |
... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
5 | xmlns:ui="http://xmlns.jcp.org/jsf/facelets" | 5 | xmlns:ui="http://xmlns.jcp.org/jsf/facelets" |
6 | xmlns:jsf="http://xmlns.jcp.org/jsf"> | 6 | xmlns:jsf="http://xmlns.jcp.org/jsf"> |
7 | <body> | 7 | <body> |
8 | -<ui:include src="/navigation.xhtml" /> | 8 | +<ui:include src="/org/legrog/web/navigation.xhtml" /> |
9 | 9 | ||
10 | <ul> | 10 | <ul> |
11 | <ui:repeat value="#{listCountriesView.countries}" var="country"> | 11 | <ui:repeat value="#{listCountriesView.countries}" var="country"> | ... | ... |
... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
7 | xmlns:f="http://xmlns.jcp.org/jsf/core" | 7 | xmlns:f="http://xmlns.jcp.org/jsf/core" |
8 | xmlns:jsf="http://xmlns.jcp.org/jsf"> | 8 | xmlns:jsf="http://xmlns.jcp.org/jsf"> |
9 | <body> | 9 | <body> |
10 | -<ui:include src="/navigation.xhtml" /> | 10 | +<ui:include src="/org/legrog/web/navigation.xhtml" /> |
11 | 11 | ||
12 | <form action="" jsf:id="reindex"> | 12 | <form action="" jsf:id="reindex"> |
13 | <button jsf:action="#{reindexView.reindexAll}">Réindexer</button> | 13 | <button jsf:action="#{reindexView.reindexAll}">Réindexer</button> | ... | ... |
src/main/java/org/legrog/web/xyz/search.xhtml
→
webapp/src/main/java/org/legrog/web/xyz/search.xhtml
... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
10 | <link rel="stylesheet" type="text/css" href="/minimal.css"/> | 10 | <link rel="stylesheet" type="text/css" href="/minimal.css"/> |
11 | </head> | 11 | </head> |
12 | <body> | 12 | <body> |
13 | -<ui:include src="/navigation.xhtml" /> | 13 | +<ui:include src="/org/legrog/web/navigation.xhtml" /> |
14 | 14 | ||
15 | <form action="" jsf:id="search"> | 15 | <form action="" jsf:id="search"> |
16 | <h:panelGrid columns="2"> | 16 | <h:panelGrid columns="2"> | ... | ... |
File moved
File moved
... | @@ -2,15 +2,15 @@ | ... | @@ -2,15 +2,15 @@ |
2 | <tomee> | 2 | <tomee> |
3 | <Resource id="H2Database" type="javax.sql.DataSource"> | 3 | <Resource id="H2Database" type="javax.sql.DataSource"> |
4 | JdbcDriver = org.h2.Driver | 4 | JdbcDriver = org.h2.Driver |
5 | - JdbcUrl = jdbc:h2:mem:test | 5 | + JdbcUrl = jdbc:h2:~/grog-dev.db |
6 | UserName = sa | 6 | UserName = sa |
7 | JtaManaged= true | 7 | JtaManaged= true |
8 | </Resource> | 8 | </Resource> |
9 | - <Resource id="migrationDatabase" type="javax.sql.DataSource"> | 9 | + <!--<Resource id="migrationDatabase" type="javax.sql.DataSource">--> |
10 | - JdbcDriver = com.mysql.jdbc.Driver | 10 | + <!--JdbcDriver = com.mysql.jdbc.Driver--> |
11 | - JdbcUrl = jdbc:mysql://localhost/migration?useSSL=false | 11 | + <!--JdbcUrl = jdbc:mysql://localhost/migration?useSSL=false--> |
12 | - UserName = grogdev | 12 | + <!--UserName = grogdev--> |
13 | - password = grogdev | 13 | + <!--password = grogdev--> |
14 | - JtaManaged= true | 14 | + <!--JtaManaged= true--> |
15 | - </Resource> | 15 | + <!--</Resource>--> |
16 | </tomee> | 16 | </tomee> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -5,6 +5,6 @@ | ... | @@ -5,6 +5,6 @@ |
5 | xmlns:jsf="http://xmlns.jcp.org/jsf" | 5 | xmlns:jsf="http://xmlns.jcp.org/jsf" |
6 | xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> | 6 | xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> |
7 | <body> | 7 | <body> |
8 | -<ui:include src="/navigation.xhtml" /> | 8 | +<ui:include src="/org/legrog/web/navigation.xhtml" /> |
9 | </body> | 9 | </body> |
10 | </html> | 10 | </html> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment