Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e87084a

Browse files
author
Gerald Unterrainer
committed
Merge branch 'develop'
2 parents 2865962 + b64c218 commit e87084a

File tree

6 files changed

+69
-81
lines changed

6 files changed

+69
-81
lines changed

‎pom.xml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<modelVersion>4.0.0</modelVersion>
1717
<artifactId>http-server</artifactId>
18-
<version>0.3.10</version>
18+
<version>0.3.11</version>
1919
<name>HttpServer</name>
2020
<packaging>jar</packaging>
2121

@@ -28,12 +28,12 @@
2828
<dependency>
2929
<groupId>info.unterrainer.commons</groupId>
3030
<artifactId>jre-utils</artifactId>
31-
<version>0.3.6</version>
31+
<version>0.3.7</version>
3232
</dependency>
3333
<dependency>
3434
<groupId>info.unterrainer.commons</groupId>
3535
<artifactId>rdb-utils</artifactId>
36-
<version>0.2.2</version>
36+
<version>0.2.3</version>
3737
</dependency>
3838
<dependency>
3939
<groupId>info.unterrainer.commons</groupId>

‎src/main/java/info/unterrainer/commons/httpserver/daos/AsyncJpqlDao.java‎

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package info.unterrainer.commons.httpserver.daos;
22

3-
import jakarta.persistence.EntityManagerFactory;
4-
53
import info.unterrainer.commons.httpserver.jpas.BasicPermissionJpa;
64
import info.unterrainer.commons.rdbutils.entities.BasicAsyncJpa;
5+
import jakarta.persistence.EntityManagerFactory;
76

87
public class AsyncJpqlDao<P extends BasicAsyncJpa> extends BasicJpqlDao<P> {
98

@@ -80,38 +79,6 @@ public <T> AsyncListQueryBuilder<P, T> select(final Class<T> resultType) {
8079
return new AsyncListQueryBuilder<>(emf, this, resultType);
8180
}
8281

83-
/**
84-
* Build a SELECT-query with a custom select-clause. The result will be of the
85-
* given type (use this for a COUNT(*) query, for example).
86-
*
87-
* @param <T> the type the result will be
88-
* @param selectClause your custom select-clause (the base-object has the alias
89-
* 'o'. So the default would be "o" internally resulting in
90-
* a "SELECT o")
91-
* @param resultType the type the result will be
92-
* @return a query-builder
93-
*/
94-
public <T> AsyncListQueryBuilder<P, T> select(final String selectClause, final Class<T> resultType) {
95-
AsyncListQueryBuilder<P, T> b = new AsyncListQueryBuilder<>(emf, this, resultType);
96-
b.setSelect(selectClause);
97-
return b;
98-
}
99-
100-
/**
101-
* Build a SELECT-query with a custom select-clause. The result will be of the
102-
* underlying generic type.
103-
*
104-
* @param selectClause your custom select-clause (the base-object has the alias
105-
* 'o'. So the default would be "o" internally resulting in
106-
* a "SELECT o")
107-
* @return a query-builder
108-
*/
109-
public AsyncJpaListQueryBuilder<P> select(final String selectClause) {
110-
AsyncJpaListQueryBuilder<P> b = new AsyncJpaListQueryBuilder<>(emf, this, type);
111-
b.setSelect(selectClause);
112-
return b;
113-
}
114-
11582
/**
11683
* Get an element by ID.
11784
*

‎src/main/java/info/unterrainer/commons/httpserver/daos/BasicListQueryBuilder.java‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
import java.util.HashMap;
44

5+
import info.unterrainer.commons.rdbutils.entities.BasicJpa;
56
import jakarta.persistence.EntityManager;
67
import jakarta.persistence.EntityManagerFactory;
78
import jakarta.persistence.TypedQuery;
8-
9-
import info.unterrainer.commons.rdbutils.entities.BasicJpa;
109
import lombok.AccessLevel;
1110
import lombok.Getter;
1211
import lombok.RequiredArgsConstructor;
@@ -20,16 +19,9 @@ public class BasicListQueryBuilder<P extends BasicJpa, X, R extends BasicListQue
2019
protected final BasicJpqlDao<P> dao;
2120
protected final Class<X> resultType;
2221

23-
protected String selectClause = "o";
2422
protected String orderByClause;
2523
protected boolean lockPessimistic = false;
2624

27-
void setSelect(final String selectClause) {
28-
this.selectClause = selectClause;
29-
if (this.selectClause == null || this.selectClause.isBlank())
30-
this.selectClause = "o";
31-
}
32-
3325
public TypedQuery<X> getTypedQuery(final EntityManager em) {
3426
return dao.coreDao.getQuery(em, selectClause, joinClause, whereClause, parameters, resultType, orderByClause,
3527
lockPessimistic, null, readTenantIds);

‎src/main/java/info/unterrainer/commons/httpserver/daos/BasicQueryGeneralBuilder.java‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,31 @@
1111
public class BasicQueryGeneralBuilder<P extends BasicJpa, T, R extends BasicQueryGeneralBuilder<P, T, R>>
1212
extends BasicQueryEntityManagerBuilder<P, T, R> {
1313

14+
protected String selectClause = "o";
1415
protected String joinClause;
1516
protected String whereClause;
1617

1718
protected Map<String, Object> parameters = new HashMap<>();
1819

20+
/**
21+
* Sets a custom select-clause.
22+
* <p>
23+
* Default is "o"<br>
24+
* To reset it to default, set it to null or directly to "o".
25+
*
26+
* @param selectClause your custom select-clause (the base-object has the alias
27+
* 'o'. So the default would be changed to "o" internally
28+
* resulting in a "SELECT o")
29+
* @return an instance of this builder to provide a fluent interface
30+
*/
31+
@SuppressWarnings("unchecked")
32+
public R selectClause(final String selectClause) {
33+
this.selectClause = selectClause;
34+
if (this.selectClause == null || this.selectClause.isBlank())
35+
this.selectClause = "o";
36+
return (R) this;
37+
}
38+
1939
/**
2040
* Sets a custom join-clause.
2141
* <p>

‎src/main/java/info/unterrainer/commons/httpserver/daos/JpqlDao.java‎

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
import java.util.function.Function;
44

5-
import jakarta.persistence.EntityManagerFactory;
6-
75
import info.unterrainer.commons.httpserver.jpas.BasicPermissionJpa;
86
import info.unterrainer.commons.rdbutils.entities.BasicJpa;
97
import io.javalin.http.Context;
8+
import jakarta.persistence.EntityManagerFactory;
109

1110
public class JpqlDao<P extends BasicJpa> extends BasicJpqlDao<P> {
1211

@@ -144,38 +143,6 @@ public <T> ListQueryBuilder<P, T> select(final Class<T> resultType) {
144143
return new ListQueryBuilder<>(emf, this, resultType);
145144
}
146145

147-
/**
148-
* Build a SELECT-query with a custom select-clause. The result will be of the
149-
* given type (use this for a COUNT(*) query, for example).
150-
*
151-
* @param <T> the type the result will be
152-
* @param selectClause your custom select-clause (the base-object has the alias
153-
* 'o'. So the default would be "o" internally resulting in
154-
* a "SELECT o")
155-
* @param resultType the type the result will be
156-
* @return a query-builder
157-
*/
158-
public <T> ListQueryBuilder<P, T> select(final String selectClause, final Class<T> resultType) {
159-
ListQueryBuilder<P, T> b = new ListQueryBuilder<>(emf, this, resultType);
160-
b.setSelect(selectClause);
161-
return b;
162-
}
163-
164-
/**
165-
* Build a SELECT-query with a custom select-clause. The result will be of the
166-
* underlying generic type.
167-
*
168-
* @param selectClause your custom select-clause (the base-object has the alias
169-
* 'o'. So the default would be "o" internally resulting in
170-
* a "SELECT o")
171-
* @return a query-builder
172-
*/
173-
public JpaListQueryBuilder<P> select(final String selectClause) {
174-
JpaListQueryBuilder<P> b = new JpaListQueryBuilder<>(emf, this, type);
175-
b.setSelect(selectClause);
176-
return b;
177-
}
178-
179146
/**
180147
* Get an element by ID.
181148
*
Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,52 @@
11
package info.unterrainer.commons.httpserver;
22

3+
import java.util.concurrent.LinkedBlockingQueue;
4+
import java.util.concurrent.ThreadPoolExecutor;
5+
import java.util.concurrent.TimeUnit;
6+
37
import org.junit.jupiter.api.Test;
48

9+
import info.unterrainer.commons.httpserver.accessmanager.RoleBuilder;
10+
import info.unterrainer.commons.httpserver.daos.JpqlDao;
11+
import info.unterrainer.commons.httpserver.enums.Endpoint;
12+
import info.unterrainer.commons.httpserver.scripts.LocalTestServer;
13+
import info.unterrainer.commons.httpserver.scripts.jpas.TestJpa;
14+
import info.unterrainer.commons.httpserver.scripts.jsons.TestJson;
15+
import info.unterrainer.commons.rdbutils.RdbUtils;
16+
import info.unterrainer.commons.rdbutils.exceptions.RdbUtilException;
17+
import info.unterrainer.commons.serialization.jsonmapper.JsonMapper;
18+
import info.unterrainer.commons.serialization.objectmapper.ObjectMapper;
19+
import jakarta.persistence.EntityManagerFactory;
20+
521
public class HttpServerTests {
622

723
@Test
8-
public void test() {
24+
public void test() throws RdbUtilException {
25+
EntityManagerFactory emf;
26+
emf = RdbUtils.createAutoclosingEntityManagerFactory(LocalTestServer.class, "test");
27+
JsonMapper jsonMapper = JsonMapper.create();
28+
ObjectMapper objectMapper = new ObjectMapper();
29+
ThreadPoolExecutor executorService = new ThreadPoolExecutor(20, 20, 60L, TimeUnit.SECONDS,
30+
new LinkedBlockingQueue<Runnable>());
31+
executorService.allowCoreThreadTimeOut(true);
32+
HttpServer server = HttpServer.builder()
33+
.applicationName("elite-server")
34+
.jsonMapper(jsonMapper)
35+
.objectMapper(objectMapper)
36+
.executorService(executorService)
37+
.appVersionFqns(new String[] { "at.elitezettl.server.eliteserver.Information",
38+
"info.unterrainer.commons.httpserver.Information",
39+
"at.elitezettl.commons.opcuabrowser.Information",
40+
"info.unterrainer.commons.crontabscheduler.Information",
41+
"info.unterrainer.commons.jreutils.Information",
42+
"info.unterrainer.commons.rdbutils.Information",
43+
"info.unterrainer.commons.serialization.Information" })
44+
.build();
45+
JpqlDao<TestJpa> basicDao = new JpqlDao<>(emf, TestJpa.class);
46+
server.handlerGroupFor(TestJpa.class, TestJson.class, basicDao)
47+
.path("tests")
48+
.endpoints(Endpoint.ALL)
49+
.addRoleFor(Endpoint.ALL, RoleBuilder.open())
50+
.add();
951
}
1052
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /