esoe
1 year ago
129 changed files with 1735 additions and 0 deletions
@ -0,0 +1,8 @@ |
|||||||
|
# Default ignored files |
||||||
|
/shelf/ |
||||||
|
/workspace.xml |
||||||
|
# Datasource local storage ignored files |
||||||
|
/dataSources/ |
||||||
|
/dataSources.local.xml |
||||||
|
# Editor-based HTTP Client requests |
||||||
|
/httpRequests/ |
@ -0,0 +1,14 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project version="4"> |
||||||
|
<component name="CompilerConfiguration"> |
||||||
|
<annotationProcessing> |
||||||
|
<profile default="true" name="Default" enabled="true" /> |
||||||
|
<profile name="Maven default annotation processors profile" enabled="true"> |
||||||
|
<sourceOutputDir name="target/generated-sources/annotations" /> |
||||||
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> |
||||||
|
<outputRelativeToContentRoot value="true" /> |
||||||
|
<module name="CustomeRestClient" /> |
||||||
|
</profile> |
||||||
|
</annotationProcessing> |
||||||
|
</component> |
||||||
|
</project> |
@ -0,0 +1,20 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project version="4"> |
||||||
|
<component name="RemoteRepositoriesConfiguration"> |
||||||
|
<remote-repository> |
||||||
|
<option name="id" value="central" /> |
||||||
|
<option name="name" value="Central Repository" /> |
||||||
|
<option name="url" value="https://repo.maven.apache.org/maven2" /> |
||||||
|
</remote-repository> |
||||||
|
<remote-repository> |
||||||
|
<option name="id" value="central" /> |
||||||
|
<option name="name" value="Maven Central repository" /> |
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" /> |
||||||
|
</remote-repository> |
||||||
|
<remote-repository> |
||||||
|
<option name="id" value="jboss.community" /> |
||||||
|
<option name="name" value="JBoss Community repository" /> |
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" /> |
||||||
|
</remote-repository> |
||||||
|
</component> |
||||||
|
</project> |
@ -0,0 +1,17 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project version="4"> |
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" /> |
||||||
|
<component name="MavenProjectsManager"> |
||||||
|
<option name="originalFiles"> |
||||||
|
<list> |
||||||
|
<option value="$PROJECT_DIR$/pom.xml" /> |
||||||
|
</list> |
||||||
|
</option> |
||||||
|
</component> |
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="corretto-11" project-jdk-type="JavaSDK"> |
||||||
|
<output url="file://$PROJECT_DIR$/out" /> |
||||||
|
</component> |
||||||
|
<component name="ProjectType"> |
||||||
|
<option name="id" value="jpab" /> |
||||||
|
</component> |
||||||
|
</project> |
@ -0,0 +1,10 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project version="4"> |
||||||
|
<component name="RunConfigurationProducerService"> |
||||||
|
<option name="ignoredProducers"> |
||||||
|
<set> |
||||||
|
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" /> |
||||||
|
</set> |
||||||
|
</option> |
||||||
|
</component> |
||||||
|
</project> |
@ -0,0 +1,41 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
|
||||||
|
<groupId>org.example</groupId> |
||||||
|
<artifactId>CustomeRestClient</artifactId> |
||||||
|
<version>1.0-SNAPSHOT</version> |
||||||
|
|
||||||
|
<properties> |
||||||
|
<maven.compiler.source>11</maven.compiler.source> |
||||||
|
<maven.compiler.target>11</maven.compiler.target> |
||||||
|
</properties> |
||||||
|
|
||||||
|
<dependencies> |
||||||
|
<dependency> |
||||||
|
<groupId>org.glassfish.jersey.core</groupId> |
||||||
|
<artifactId>jersey-client</artifactId> |
||||||
|
<version>2.35</version> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.glassfish.jersey.inject</groupId> |
||||||
|
<artifactId>jersey-hk2</artifactId> |
||||||
|
<version>2.35</version> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.glassfish.jersey.media</groupId> |
||||||
|
<artifactId>jersey-media-json-jackson</artifactId> |
||||||
|
<version>2.35</version> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.projectlombok</groupId> |
||||||
|
<artifactId>lombok</artifactId> |
||||||
|
<version>1.18.28</version> |
||||||
|
<scope>provided</scope> |
||||||
|
</dependency> |
||||||
|
<!-- --> |
||||||
|
</dependencies> |
||||||
|
|
||||||
|
</project> |
@ -0,0 +1,16 @@ |
|||||||
|
package mainpack; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.sql.Date; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class Domain { |
||||||
|
|
||||||
|
private long id; |
||||||
|
private String domainName; |
||||||
|
private String ip; |
||||||
|
private Date dateReg; |
||||||
|
private String countryReg; |
||||||
|
private Person person; |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
package mainpack; |
||||||
|
|
||||||
|
public class MainClass { |
||||||
|
|
||||||
|
public static void main(String[] args) { |
||||||
|
RestClient client = new RestClient(); |
||||||
|
|
||||||
|
Domain domain = client.getDomainById(1L); |
||||||
|
domain.setCountryReg("Blabla"); |
||||||
|
client.updateDomain(domain); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
package mainpack; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.util.HashSet; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class Person { |
||||||
|
|
||||||
|
private long id; |
||||||
|
private String firstName; |
||||||
|
private String lastName; |
||||||
|
private String email; |
||||||
|
private String gender; |
||||||
|
private Set<Domain> domainEntitySet = new HashSet<>(); |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
package mainpack; |
||||||
|
|
||||||
|
import javax.ws.rs.client.Client; |
||||||
|
import javax.ws.rs.client.ClientBuilder; |
||||||
|
import javax.ws.rs.client.Entity; |
||||||
|
import javax.ws.rs.core.GenericType; |
||||||
|
import javax.ws.rs.core.MediaType; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
public class RestClient { |
||||||
|
private final Client client = ClientBuilder.newClient(); |
||||||
|
|
||||||
|
private String URL = "http://localhost:8080/dev_j200_2-1.0-SNAPSHOT/api/domain"; |
||||||
|
|
||||||
|
public List<Domain> getAllDomain(){ |
||||||
|
return client.target(URL).request(MediaType.APPLICATION_JSON).get(new GenericType<List<Domain>>(){}); |
||||||
|
} |
||||||
|
|
||||||
|
public Domain getDomainById(Long id) { |
||||||
|
return client.target(URL + "/" + id).request(MediaType.APPLICATION_JSON).get(Domain.class); |
||||||
|
} |
||||||
|
|
||||||
|
public void updateDomain(Domain domain){ |
||||||
|
client.target(URL).request().put(Entity.entity(domain, MediaType.APPLICATION_JSON)); |
||||||
|
} |
||||||
|
|
||||||
|
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,8 @@ |
|||||||
|
# Default ignored files |
||||||
|
/shelf/ |
||||||
|
/workspace.xml |
||||||
|
# Datasource local storage ignored files |
||||||
|
/dataSources/ |
||||||
|
/dataSources.local.xml |
||||||
|
# Editor-based HTTP Client requests |
||||||
|
/httpRequests/ |
@ -0,0 +1,16 @@ |
|||||||
|
<component name="ArtifactManager"> |
||||||
|
<artifact type="war" name="dev_j200_2:war"> |
||||||
|
<output-path>$PROJECT_DIR$/target</output-path> |
||||||
|
<properties id="maven-jee-properties"> |
||||||
|
<options> |
||||||
|
<exploded>false</exploded> |
||||||
|
<module>dev_j200_2</module> |
||||||
|
<packaging>war</packaging> |
||||||
|
<unpackNestedArchives>false</unpackNestedArchives> |
||||||
|
</options> |
||||||
|
</properties> |
||||||
|
<root id="archive" name="dev_j200_2-1.0-SNAPSHOT.war"> |
||||||
|
<element id="artifact" artifact-name="dev_j200_2:war exploded" /> |
||||||
|
</root> |
||||||
|
</artifact> |
||||||
|
</component> |
@ -0,0 +1,24 @@ |
|||||||
|
<component name="ArtifactManager"> |
||||||
|
<artifact type="exploded-war" name="dev_j200_2:war exploded"> |
||||||
|
<output-path>$PROJECT_DIR$/target/dev_j200_2-1.0-SNAPSHOT</output-path> |
||||||
|
<properties id="maven-jee-properties"> |
||||||
|
<options> |
||||||
|
<exploded>true</exploded> |
||||||
|
<module>dev_j200_2</module> |
||||||
|
<packaging>war</packaging> |
||||||
|
<unpackNestedArchives>false</unpackNestedArchives> |
||||||
|
</options> |
||||||
|
</properties> |
||||||
|
<root id="root"> |
||||||
|
<element id="directory" name="WEB-INF"> |
||||||
|
<element id="directory" name="classes"> |
||||||
|
<element id="module-output" name="dev_j200_2" /> |
||||||
|
</element> |
||||||
|
</element> |
||||||
|
<element id="directory" name="META-INF"> |
||||||
|
<element id="file-copy" path="$PROJECT_DIR$/target/dev_j200_2-1.0-SNAPSHOT/META-INF/MANIFEST.MF" /> |
||||||
|
</element> |
||||||
|
<element id="javaee-facet-resources" facet="dev_j200_2/web/Web" /> |
||||||
|
</root> |
||||||
|
</artifact> |
||||||
|
</component> |
@ -0,0 +1,16 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project version="4"> |
||||||
|
<component name="CompilerConfiguration"> |
||||||
|
<annotationProcessing> |
||||||
|
<profile name="Maven default annotation processors profile" enabled="true"> |
||||||
|
<sourceOutputDir name="target/generated-sources/annotations" /> |
||||||
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> |
||||||
|
<outputRelativeToContentRoot value="true" /> |
||||||
|
<module name="dev_j200_2" /> |
||||||
|
</profile> |
||||||
|
</annotationProcessing> |
||||||
|
<bytecodeTargetLevel> |
||||||
|
<module name="dev_j200_2" target="1.8" /> |
||||||
|
</bytecodeTargetLevel> |
||||||
|
</component> |
||||||
|
</project> |
@ -0,0 +1,12 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project version="4"> |
||||||
|
<component name="DataSourceManagerImpl" format="xml" multifile-model="true"> |
||||||
|
<data-source source="LOCAL" name="test_db" uuid="0a24117f-93d1-4099-a276-360eb655dc7f"> |
||||||
|
<driver-ref>mysql.8</driver-ref> |
||||||
|
<synchronize>true</synchronize> |
||||||
|
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver> |
||||||
|
<jdbc-url>jdbc:mysql://localhost:3306/test_db</jdbc-url> |
||||||
|
<working-dir>$ProjectFileDir$</working-dir> |
||||||
|
</data-source> |
||||||
|
</component> |
||||||
|
</project> |
@ -0,0 +1,7 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project version="4"> |
||||||
|
<component name="Encoding"> |
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" /> |
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" /> |
||||||
|
</component> |
||||||
|
</project> |
@ -0,0 +1,20 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project version="4"> |
||||||
|
<component name="RemoteRepositoriesConfiguration"> |
||||||
|
<remote-repository> |
||||||
|
<option name="id" value="central" /> |
||||||
|
<option name="name" value="Central Repository" /> |
||||||
|
<option name="url" value="https://repo.maven.apache.org/maven2" /> |
||||||
|
</remote-repository> |
||||||
|
<remote-repository> |
||||||
|
<option name="id" value="central" /> |
||||||
|
<option name="name" value="Maven Central repository" /> |
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" /> |
||||||
|
</remote-repository> |
||||||
|
<remote-repository> |
||||||
|
<option name="id" value="jboss.community" /> |
||||||
|
<option name="name" value="JBoss Community repository" /> |
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" /> |
||||||
|
</remote-repository> |
||||||
|
</component> |
||||||
|
</project> |
@ -0,0 +1,6 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project version="4"> |
||||||
|
<component name="JpaBuddyIdeaProjectConfig"> |
||||||
|
<option name="defaultUnitInitialized" value="true" /> |
||||||
|
</component> |
||||||
|
</project> |
@ -0,0 +1,13 @@ |
|||||||
|
<component name="libraryTable"> |
||||||
|
<library name="Maven: jakarta.activation:jakarta.activation-api:2.1.0"> |
||||||
|
<CLASSES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/activation/jakarta.activation-api/2.1.0/jakarta.activation-api-2.1.0.jar!/" /> |
||||||
|
</CLASSES> |
||||||
|
<JAVADOC> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/activation/jakarta.activation-api/2.1.0/jakarta.activation-api-2.1.0-javadoc.jar!/" /> |
||||||
|
</JAVADOC> |
||||||
|
<SOURCES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/activation/jakarta.activation-api/2.1.0/jakarta.activation-api-2.1.0-sources.jar!/" /> |
||||||
|
</SOURCES> |
||||||
|
</library> |
||||||
|
</component> |
@ -0,0 +1,13 @@ |
|||||||
|
<component name="libraryTable"> |
||||||
|
<library name="Maven: jakarta.ejb:jakarta.ejb-api:4.0.0"> |
||||||
|
<CLASSES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/ejb/jakarta.ejb-api/4.0.0/jakarta.ejb-api-4.0.0.jar!/" /> |
||||||
|
</CLASSES> |
||||||
|
<JAVADOC> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/ejb/jakarta.ejb-api/4.0.0/jakarta.ejb-api-4.0.0-javadoc.jar!/" /> |
||||||
|
</JAVADOC> |
||||||
|
<SOURCES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/ejb/jakarta.ejb-api/4.0.0/jakarta.ejb-api-4.0.0-sources.jar!/" /> |
||||||
|
</SOURCES> |
||||||
|
</library> |
||||||
|
</component> |
@ -0,0 +1,13 @@ |
|||||||
|
<component name="libraryTable"> |
||||||
|
<library name="Maven: jakarta.persistence:jakarta.persistence-api:3.0.0"> |
||||||
|
<CLASSES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/persistence/jakarta.persistence-api/3.0.0/jakarta.persistence-api-3.0.0.jar!/" /> |
||||||
|
</CLASSES> |
||||||
|
<JAVADOC> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/persistence/jakarta.persistence-api/3.0.0/jakarta.persistence-api-3.0.0-javadoc.jar!/" /> |
||||||
|
</JAVADOC> |
||||||
|
<SOURCES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/persistence/jakarta.persistence-api/3.0.0/jakarta.persistence-api-3.0.0-sources.jar!/" /> |
||||||
|
</SOURCES> |
||||||
|
</library> |
||||||
|
</component> |
@ -0,0 +1,13 @@ |
|||||||
|
<component name="libraryTable"> |
||||||
|
<library name="Maven: jakarta.servlet:jakarta.servlet-api:5.0.0"> |
||||||
|
<CLASSES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/servlet/jakarta.servlet-api/5.0.0/jakarta.servlet-api-5.0.0.jar!/" /> |
||||||
|
</CLASSES> |
||||||
|
<JAVADOC> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/servlet/jakarta.servlet-api/5.0.0/jakarta.servlet-api-5.0.0-javadoc.jar!/" /> |
||||||
|
</JAVADOC> |
||||||
|
<SOURCES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/servlet/jakarta.servlet-api/5.0.0/jakarta.servlet-api-5.0.0-sources.jar!/" /> |
||||||
|
</SOURCES> |
||||||
|
</library> |
||||||
|
</component> |
@ -0,0 +1,13 @@ |
|||||||
|
<component name="libraryTable"> |
||||||
|
<library name="Maven: jakarta.transaction:jakarta.transaction-api:2.0.0"> |
||||||
|
<CLASSES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/transaction/jakarta.transaction-api/2.0.0/jakarta.transaction-api-2.0.0.jar!/" /> |
||||||
|
</CLASSES> |
||||||
|
<JAVADOC> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/transaction/jakarta.transaction-api/2.0.0/jakarta.transaction-api-2.0.0-javadoc.jar!/" /> |
||||||
|
</JAVADOC> |
||||||
|
<SOURCES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/transaction/jakarta.transaction-api/2.0.0/jakarta.transaction-api-2.0.0-sources.jar!/" /> |
||||||
|
</SOURCES> |
||||||
|
</library> |
||||||
|
</component> |
@ -0,0 +1,13 @@ |
|||||||
|
<component name="libraryTable"> |
||||||
|
<library name="Maven: jakarta.ws.rs:jakarta.ws.rs-api:3.1.0"> |
||||||
|
<CLASSES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/ws/rs/jakarta.ws.rs-api/3.1.0/jakarta.ws.rs-api-3.1.0.jar!/" /> |
||||||
|
</CLASSES> |
||||||
|
<JAVADOC> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/ws/rs/jakarta.ws.rs-api/3.1.0/jakarta.ws.rs-api-3.1.0-javadoc.jar!/" /> |
||||||
|
</JAVADOC> |
||||||
|
<SOURCES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/ws/rs/jakarta.ws.rs-api/3.1.0/jakarta.ws.rs-api-3.1.0-sources.jar!/" /> |
||||||
|
</SOURCES> |
||||||
|
</library> |
||||||
|
</component> |
@ -0,0 +1,13 @@ |
|||||||
|
<component name="libraryTable"> |
||||||
|
<library name="Maven: jakarta.xml.bind:jakarta.xml.bind-api:4.0.0"> |
||||||
|
<CLASSES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/xml/bind/jakarta.xml.bind-api/4.0.0/jakarta.xml.bind-api-4.0.0.jar!/" /> |
||||||
|
</CLASSES> |
||||||
|
<JAVADOC> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/xml/bind/jakarta.xml.bind-api/4.0.0/jakarta.xml.bind-api-4.0.0-javadoc.jar!/" /> |
||||||
|
</JAVADOC> |
||||||
|
<SOURCES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/jakarta/xml/bind/jakarta.xml.bind-api/4.0.0/jakarta.xml.bind-api-4.0.0-sources.jar!/" /> |
||||||
|
</SOURCES> |
||||||
|
</library> |
||||||
|
</component> |
@ -0,0 +1,13 @@ |
|||||||
|
<component name="libraryTable"> |
||||||
|
<library name="Maven: org.apiguardian:apiguardian-api:1.1.0"> |
||||||
|
<CLASSES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar!/" /> |
||||||
|
</CLASSES> |
||||||
|
<JAVADOC> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0-javadoc.jar!/" /> |
||||||
|
</JAVADOC> |
||||||
|
<SOURCES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0-sources.jar!/" /> |
||||||
|
</SOURCES> |
||||||
|
</library> |
||||||
|
</component> |
@ -0,0 +1,13 @@ |
|||||||
|
<component name="libraryTable"> |
||||||
|
<library name="Maven: org.junit.jupiter:junit-jupiter-api:5.7.1"> |
||||||
|
<CLASSES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.7.1/junit-jupiter-api-5.7.1.jar!/" /> |
||||||
|
</CLASSES> |
||||||
|
<JAVADOC> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.7.1/junit-jupiter-api-5.7.1-javadoc.jar!/" /> |
||||||
|
</JAVADOC> |
||||||
|
<SOURCES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-api/5.7.1/junit-jupiter-api-5.7.1-sources.jar!/" /> |
||||||
|
</SOURCES> |
||||||
|
</library> |
||||||
|
</component> |
@ -0,0 +1,13 @@ |
|||||||
|
<component name="libraryTable"> |
||||||
|
<library name="Maven: org.junit.jupiter:junit-jupiter-engine:5.7.1"> |
||||||
|
<CLASSES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.7.1/junit-jupiter-engine-5.7.1.jar!/" /> |
||||||
|
</CLASSES> |
||||||
|
<JAVADOC> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.7.1/junit-jupiter-engine-5.7.1-javadoc.jar!/" /> |
||||||
|
</JAVADOC> |
||||||
|
<SOURCES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/jupiter/junit-jupiter-engine/5.7.1/junit-jupiter-engine-5.7.1-sources.jar!/" /> |
||||||
|
</SOURCES> |
||||||
|
</library> |
||||||
|
</component> |
@ -0,0 +1,13 @@ |
|||||||
|
<component name="libraryTable"> |
||||||
|
<library name="Maven: org.junit.platform:junit-platform-commons:1.7.1"> |
||||||
|
<CLASSES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.7.1/junit-platform-commons-1.7.1.jar!/" /> |
||||||
|
</CLASSES> |
||||||
|
<JAVADOC> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.7.1/junit-platform-commons-1.7.1-javadoc.jar!/" /> |
||||||
|
</JAVADOC> |
||||||
|
<SOURCES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-commons/1.7.1/junit-platform-commons-1.7.1-sources.jar!/" /> |
||||||
|
</SOURCES> |
||||||
|
</library> |
||||||
|
</component> |
@ -0,0 +1,13 @@ |
|||||||
|
<component name="libraryTable"> |
||||||
|
<library name="Maven: org.junit.platform:junit-platform-engine:1.7.1"> |
||||||
|
<CLASSES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.7.1/junit-platform-engine-1.7.1.jar!/" /> |
||||||
|
</CLASSES> |
||||||
|
<JAVADOC> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.7.1/junit-platform-engine-1.7.1-javadoc.jar!/" /> |
||||||
|
</JAVADOC> |
||||||
|
<SOURCES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/junit/platform/junit-platform-engine/1.7.1/junit-platform-engine-1.7.1-sources.jar!/" /> |
||||||
|
</SOURCES> |
||||||
|
</library> |
||||||
|
</component> |
@ -0,0 +1,13 @@ |
|||||||
|
<component name="libraryTable"> |
||||||
|
<library name="Maven: org.opentest4j:opentest4j:1.2.0"> |
||||||
|
<CLASSES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar!/" /> |
||||||
|
</CLASSES> |
||||||
|
<JAVADOC> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0-javadoc.jar!/" /> |
||||||
|
</JAVADOC> |
||||||
|
<SOURCES> |
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0-sources.jar!/" /> |
||||||
|
</SOURCES> |
||||||
|
</library> |
||||||
|
</component> |
@ -0,0 +1,19 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project version="4"> |
||||||
|
<component name="FrameworkDetectionExcludesConfiguration"> |
||||||
|
<file type="web" url="file://$PROJECT_DIR$" /> |
||||||
|
</component> |
||||||
|
<component name="MavenProjectsManager"> |
||||||
|
<option name="originalFiles"> |
||||||
|
<list> |
||||||
|
<option value="$PROJECT_DIR$/pom.xml" /> |
||||||
|
</list> |
||||||
|
</option> |
||||||
|
</component> |
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK"> |
||||||
|
<output url="file://$PROJECT_DIR$/out" /> |
||||||
|
</component> |
||||||
|
<component name="ProjectType"> |
||||||
|
<option name="id" value="jpab" /> |
||||||
|
</component> |
||||||
|
</project> |
@ -0,0 +1,8 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project version="4"> |
||||||
|
<component name="ProjectModuleManager"> |
||||||
|
<modules> |
||||||
|
<module fileurl="file://$PROJECT_DIR$/dev_j200_2.iml" filepath="$PROJECT_DIR$/dev_j200_2.iml" /> |
||||||
|
</modules> |
||||||
|
</component> |
||||||
|
</project> |
@ -0,0 +1,10 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project version="4"> |
||||||
|
<component name="RunConfigurationProducerService"> |
||||||
|
<option name="ignoredProducers"> |
||||||
|
<set> |
||||||
|
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" /> |
||||||
|
</set> |
||||||
|
</option> |
||||||
|
</component> |
||||||
|
</project> |
@ -0,0 +1,54 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> |
||||||
|
<component name="FacetManager"> |
||||||
|
<facet type="web" name="Web"> |
||||||
|
<configuration> |
||||||
|
<descriptors> |
||||||
|
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml" /> |
||||||
|
</descriptors> |
||||||
|
<webroots /> |
||||||
|
<sourceRoots> |
||||||
|
<root url="file://$MODULE_DIR$/src/main/java" /> |
||||||
|
<root url="file://$MODULE_DIR$/src/main/resources" /> |
||||||
|
</sourceRoots> |
||||||
|
</configuration> |
||||||
|
</facet> |
||||||
|
<facet type="jpa" name="JPA"> |
||||||
|
<configuration> |
||||||
|
<setting name="validation-enabled" value="true" /> |
||||||
|
<datasource-mapping> |
||||||
|
<factory-entry name="default" /> |
||||||
|
<factory-entry name="noname-a.xml@0" value="0a24117f-93d1-4099-a276-360eb655dc7f" /> |
||||||
|
</datasource-mapping> |
||||||
|
<naming-strategy-map /> |
||||||
|
<deploymentDescriptor name="persistence.xml" url="file://$MODULE_DIR$/src/main/resources/META-INF/persistence.xml" /> |
||||||
|
</configuration> |
||||||
|
</facet> |
||||||
|
</component> |
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8"> |
||||||
|
<output url="file://$MODULE_DIR$/target/classes" /> |
||||||
|
<output-test url="file://$MODULE_DIR$/target/test-classes" /> |
||||||
|
<content url="file://$MODULE_DIR$"> |
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> |
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> |
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> |
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" /> |
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" /> |
||||||
|
</content> |
||||||
|
<orderEntry type="inheritedJdk" /> |
||||||
|
<orderEntry type="sourceFolder" forTests="false" /> |
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: jakarta.ejb:jakarta.ejb-api:4.0.0" level="project" /> |
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: jakarta.transaction:jakarta.transaction-api:2.0.0" level="project" /> |
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: jakarta.persistence:jakarta.persistence-api:3.0.0" level="project" /> |
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: jakarta.servlet:jakarta.servlet-api:5.0.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: jakarta.ws.rs:jakarta.ws.rs-api:3.1.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: jakarta.xml.bind:jakarta.xml.bind-api:4.0.0" level="project" /> |
||||||
|
<orderEntry type="library" name="Maven: jakarta.activation:jakarta.activation-api:2.1.0" level="project" /> |
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.7.1" level="project" /> |
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.0" level="project" /> |
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" /> |
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.7.1" level="project" /> |
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.7.1" level="project" /> |
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.7.1" level="project" /> |
||||||
|
</component> |
||||||
|
</module> |
@ -0,0 +1,73 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
|
||||||
|
<groupId>com.example</groupId> |
||||||
|
<artifactId>dev_j200_2</artifactId> |
||||||
|
<version>1.0-SNAPSHOT</version> |
||||||
|
<name>dev_j200_2</name> |
||||||
|
<packaging>war</packaging> |
||||||
|
|
||||||
|
<properties> |
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
||||||
|
<maven.compiler.target>1.8</maven.compiler.target> |
||||||
|
<maven.compiler.source>1.8</maven.compiler.source> |
||||||
|
<junit.version>5.7.1</junit.version> |
||||||
|
</properties> |
||||||
|
|
||||||
|
<dependencies> |
||||||
|
<dependency> |
||||||
|
<groupId>jakarta.ejb</groupId> |
||||||
|
<artifactId>jakarta.ejb-api</artifactId> |
||||||
|
<version>4.0.0</version> |
||||||
|
<scope>provided</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>jakarta.persistence</groupId> |
||||||
|
<artifactId>jakarta.persistence-api</artifactId> |
||||||
|
<version>3.0.0</version> |
||||||
|
<scope>provided</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>jakarta.servlet</groupId> |
||||||
|
<artifactId>jakarta.servlet-api</artifactId> |
||||||
|
<version>5.0.0</version> |
||||||
|
<scope>provided</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>jakarta.ws.rs</groupId> |
||||||
|
<artifactId>jakarta.ws.rs-api</artifactId> |
||||||
|
<version>3.1.0</version> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>jakarta.xml.bind</groupId> |
||||||
|
<artifactId>jakarta.xml.bind-api</artifactId> |
||||||
|
<version>4.0.0</version> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>org.junit.jupiter</groupId> |
||||||
|
<artifactId>junit-jupiter-api</artifactId> |
||||||
|
<version>${junit.version}</version> |
||||||
|
<scope>test</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.junit.jupiter</groupId> |
||||||
|
<artifactId>junit-jupiter-engine</artifactId> |
||||||
|
<version>${junit.version}</version> |
||||||
|
<scope>test</scope> |
||||||
|
</dependency> |
||||||
|
</dependencies> |
||||||
|
|
||||||
|
<build> |
||||||
|
<plugins> |
||||||
|
<plugin> |
||||||
|
<groupId>org.apache.maven.plugins</groupId> |
||||||
|
<artifactId>maven-war-plugin</artifactId> |
||||||
|
<version>3.3.1</version> |
||||||
|
</plugin> |
||||||
|
</plugins> |
||||||
|
</build> |
||||||
|
</project> |
@ -0,0 +1,58 @@ |
|||||||
|
package com.example.dev_j200_2; |
||||||
|
|
||||||
|
import java.io.*; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import com.example.dev_j200_2.entities.DomainEntity; |
||||||
|
import com.example.dev_j200_2.entities.PersonEntity; |
||||||
|
import com.example.dev_j200_2.entities.UsersEntity; |
||||||
|
import com.example.dev_j200_2.repo.AppRepositoryI; |
||||||
|
import jakarta.ejb.EJB; |
||||||
|
import jakarta.servlet.ServletException; |
||||||
|
import jakarta.servlet.http.*; |
||||||
|
import jakarta.servlet.annotation.*; |
||||||
|
|
||||||
|
@WebServlet(name = "helloServlet", value = "/hello-servlet") |
||||||
|
public class HelloServlet extends HttpServlet { |
||||||
|
@EJB |
||||||
|
private AppRepositoryI repository; |
||||||
|
private String message; |
||||||
|
|
||||||
|
public void init() { |
||||||
|
message = "Hello World!"; |
||||||
|
} |
||||||
|
|
||||||
|
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { |
||||||
|
response.setContentType("text/html"); |
||||||
|
List<PersonEntity> persons = repository.findAllPerson(); |
||||||
|
List<DomainEntity> domains = repository.findAll(DomainEntity.class); |
||||||
|
// Hello
|
||||||
|
PrintWriter out = response.getWriter(); |
||||||
|
out.println("<html><body>"); |
||||||
|
out.println("<h1>" + message + "</h1>"); |
||||||
|
out.println("<h3>" + repository.findById(PersonEntity.class, 1) + "</h3>"); |
||||||
|
out.println("<h3>" + repository.findById(DomainEntity.class, 1) + "</h3>"); |
||||||
|
out.println("<h3>" + repository.findById(UsersEntity.class, 1) + "</h3>"); |
||||||
|
persons.forEach(val -> { |
||||||
|
out.println("<h3>" + val + "</h3>"); |
||||||
|
}); |
||||||
|
out.println("</body></html>"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
||||||
|
String username = request.getParameter("username"); |
||||||
|
String password = request.getParameter("password"); |
||||||
|
|
||||||
|
boolean check = new UserStore().checkUser(username, password); |
||||||
|
if(check) getServletContext().getRequestDispatcher("/ServletViewList").forward(request, response); |
||||||
|
else { |
||||||
|
String message = "Логин или пароль не найдены"; |
||||||
|
request.setAttribute("message", message); |
||||||
|
getServletContext().getRequestDispatcher("/ServletInfo").forward(request, response); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void destroy() { |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,51 @@ |
|||||||
|
package com.example.dev_j200_2; |
||||||
|
|
||||||
|
import java.util.Objects; |
||||||
|
|
||||||
|
public class Passport { |
||||||
|
private int serial; |
||||||
|
private int number; |
||||||
|
private Person person; |
||||||
|
|
||||||
|
public Passport(int serial, int number) { |
||||||
|
this.serial = serial; |
||||||
|
this.number = number; |
||||||
|
} |
||||||
|
|
||||||
|
public int getSerial() { |
||||||
|
return serial; |
||||||
|
} |
||||||
|
|
||||||
|
public void setSerial(int serial) { |
||||||
|
this.serial = serial; |
||||||
|
} |
||||||
|
|
||||||
|
public int getNumber() { |
||||||
|
return number; |
||||||
|
} |
||||||
|
|
||||||
|
public void setNumber(int number) { |
||||||
|
this.number = number; |
||||||
|
} |
||||||
|
|
||||||
|
public Person getPerson() { |
||||||
|
return person; |
||||||
|
} |
||||||
|
|
||||||
|
public void setPerson(Person person) { |
||||||
|
this.person = person; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean equals(Object o) { |
||||||
|
if (this == o) return true; |
||||||
|
if (o == null || getClass() != o.getClass()) return false; |
||||||
|
Passport passport = (Passport) o; |
||||||
|
return serial == passport.serial && number == passport.number; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int hashCode() { |
||||||
|
return Objects.hash(serial, number); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,55 @@ |
|||||||
|
package com.example.dev_j200_2; |
||||||
|
|
||||||
|
import java.util.HashSet; |
||||||
|
import java.util.Objects; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
public class Person { |
||||||
|
private long id; |
||||||
|
private String name; |
||||||
|
private Set<Passport> passports; |
||||||
|
|
||||||
|
public Person(long id, String name) { |
||||||
|
passports = new HashSet<>(); |
||||||
|
this.id = id; |
||||||
|
this.name = name; |
||||||
|
} |
||||||
|
|
||||||
|
public long getId() { |
||||||
|
return id; |
||||||
|
} |
||||||
|
|
||||||
|
public void setId(long id) { |
||||||
|
this.id = id; |
||||||
|
} |
||||||
|
|
||||||
|
public String getName() { |
||||||
|
return name; |
||||||
|
} |
||||||
|
|
||||||
|
public void setName(String name) { |
||||||
|
this.name = name; |
||||||
|
} |
||||||
|
|
||||||
|
public Set<Passport> getPassports() { |
||||||
|
return new HashSet<>(passports); |
||||||
|
} |
||||||
|
|
||||||
|
public void addPassport(Passport passport){ |
||||||
|
passports.add(passport); |
||||||
|
passport.setPerson(this); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean equals(Object o) { |
||||||
|
if (this == o) return true; |
||||||
|
if (o == null || getClass() != o.getClass()) return false; |
||||||
|
Person person = (Person) o; |
||||||
|
return id == person.id && name.equals(person.name); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int hashCode() { |
||||||
|
return Objects.hash(id, name); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
package com.example.dev_j200_2; |
||||||
|
|
||||||
|
import jakarta.ejb.Local; |
||||||
|
|
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
@Local |
||||||
|
public interface PersonService { |
||||||
|
|
||||||
|
Set<Person> getAllPerson(); |
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
package com.example.dev_j200_2; |
||||||
|
|
||||||
|
import jakarta.ejb.Stateful; |
||||||
|
|
||||||
|
import java.util.HashSet; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
@Stateful |
||||||
|
public class PersonServiceImpl implements PersonService{ |
||||||
|
|
||||||
|
private static Set<Person> persons; |
||||||
|
|
||||||
|
static { |
||||||
|
persons = new HashSet<>(); |
||||||
|
Person p1 = new Person(1, "Andrey"); |
||||||
|
p1.addPassport(new Passport(5654, 548785)); |
||||||
|
persons.add(p1); |
||||||
|
Person p2 = new Person(2, "Michail"); |
||||||
|
p2.addPassport(new Passport(1234, 55685)); |
||||||
|
p2.addPassport(new Passport(4321, 57785)); |
||||||
|
persons.add(p2); |
||||||
|
Person p3 = new Person(3, "Olga"); |
||||||
|
p3.addPassport(new Passport(4500, 236777)); |
||||||
|
persons.add(p3); |
||||||
|
Person p4 = new Person(4, "Yana"); |
||||||
|
p4.addPassport(new Passport(1204, 521004)); |
||||||
|
persons.add(p4); |
||||||
|
Person p5 = new Person(5, "Alexsandr"); |
||||||
|
p5.addPassport(new Passport(9513, 300540)); |
||||||
|
persons.add(p5); |
||||||
|
persons.add(new Person(6, "Boby")); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Set<Person> getAllPerson() { |
||||||
|
return persons; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
package com.example.dev_j200_2; |
||||||
|
|
||||||
|
import jakarta.servlet.*; |
||||||
|
import jakarta.servlet.http.*; |
||||||
|
import jakarta.servlet.annotation.*; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.io.PrintWriter; |
||||||
|
import java.io.UnsupportedEncodingException; |
||||||
|
|
||||||
|
@WebServlet(name = "ServletInfo", value = "/ServletInfo") |
||||||
|
public class ServletInfo extends HttpServlet { |
||||||
|
@Override |
||||||
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
||||||
|
sendResponse(request, response); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |
||||||
|
sendResponse(request, response); |
||||||
|
} |
||||||
|
|
||||||
|
private void sendResponse(HttpServletRequest request, HttpServletResponse response) throws IOException { |
||||||
|
response.setContentType("text/html; charset=UTF-8"); |
||||||
|
request.setCharacterEncoding("UTF-8"); |
||||||
|
String message = (String)request.getAttribute("message"); |
||||||
|
PrintWriter out = response.getWriter(); |
||||||
|
out.println("<html><body>"); |
||||||
|
out.println("<h1>" + message + "</h1>"); |
||||||
|
out.println("</body></html>"); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,93 @@ |
|||||||
|
package com.example.dev_j200_2; |
||||||
|
|
||||||
|
import jakarta.ejb.EJB; |
||||||
|
import jakarta.servlet.*; |
||||||
|
import jakarta.servlet.http.*; |
||||||
|
import jakarta.servlet.annotation.*; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.io.PrintWriter; |
||||||
|
import java.util.*; |
||||||
|
|
||||||
|
@WebServlet(name = "ServletViewList", value = "/ServletViewList") |
||||||
|
public class ServletViewList extends HttpServlet { |
||||||
|
|
||||||
|
@EJB |
||||||
|
private PersonService personService; |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { |
||||||
|
sendResponse(request, response); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { |
||||||
|
sendResponse(request, response); |
||||||
|
} |
||||||
|
|
||||||
|
private void sendResponse(HttpServletRequest request, HttpServletResponse response) throws IOException { |
||||||
|
String filterParam = request.getParameter("filter"); |
||||||
|
Map<Person, Set<Passport>> personMap = filter(personService.getAllPerson(), filterParam); |
||||||
|
response.setContentType("text/html; charset=UTF-8"); |
||||||
|
request.setCharacterEncoding("UTF-8"); |
||||||
|
PrintWriter out = response.getWriter(); |
||||||
|
out.println("<html><body>"); |
||||||
|
out.println("<h1>Все персоны</h1>"); |
||||||
|
out.println("<form action=\"ServletViewList\" method=\"get\" align=\"center\">\n" + |
||||||
|
" <input type=\"text\" name=\"filter\">\n" + |
||||||
|
" <input type=\"submit\" value=\"Filter\">\n" + |
||||||
|
"</form><br><br>"); |
||||||
|
out.println("<table align=\"center\" cellpadding=\"5\" border=\"1\" cellspacing=\"0\">"); |
||||||
|
out.println("<tr>"); |
||||||
|
out.println("<th>ID</th>"); |
||||||
|
out.println("<th>NAME</th>"); |
||||||
|
out.println("<th>SERIAL</th>"); |
||||||
|
out.println("<th>NUMBER</th>"); |
||||||
|
out.println("</tr>"); |
||||||
|
for(Person person : personMap.keySet()){ |
||||||
|
if(person.getPassports().size()>0) { |
||||||
|
for(Passport passport : personMap.get(person)) { |
||||||
|
out.println("<tr>"); |
||||||
|
out.println("<td>" + person.getId() + "</td>"); |
||||||
|
out.println("<td>" + person.getName() + "</td>"); |
||||||
|
out.println("<td>" + passport.getSerial() + "</td>"); |
||||||
|
out.println("<td>" + passport.getNumber() + "</td>"); |
||||||
|
out.println("</tr>"); |
||||||
|
} |
||||||
|
}else { |
||||||
|
out.println("<tr>"); |
||||||
|
out.println("<td>" + person.getId() + "</td>"); |
||||||
|
out.println("<td>" + person.getName() + "</td>"); |
||||||
|
out.println("<td></td>"); |
||||||
|
out.println("<td></td>"); |
||||||
|
out.println("</tr>"); |
||||||
|
} |
||||||
|
} |
||||||
|
out.println("</table>"); |
||||||
|
out.println("</body></html>"); |
||||||
|
} |
||||||
|
|
||||||
|
private Map<Person, Set<Passport>> filter(Set<Person> persons, String filterparam){ |
||||||
|
Map<Person, Set<Passport>> personMap = new HashMap<>(); |
||||||
|
for (Person person : persons) { |
||||||
|
personMap.put(person, person.getPassports()); |
||||||
|
} |
||||||
|
if(filterparam!=null && !filterparam.isEmpty()) { |
||||||
|
Iterator<Person> personIter = personMap.keySet().iterator(); |
||||||
|
while (personIter.hasNext()){ |
||||||
|
Person person = personIter.next(); |
||||||
|
if(!person.getName().toLowerCase().contains(filterparam.toLowerCase())){ |
||||||
|
Iterator<Passport> passportIter = personMap.get(person).iterator(); |
||||||
|
while (passportIter.hasNext()){ |
||||||
|
Passport passport = passportIter.next(); |
||||||
|
if(!(passport.getSerial() + "" + passport.getNumber()).contains(filterparam)){ |
||||||
|
passportIter.remove(); |
||||||
|
} |
||||||
|
} |
||||||
|
if(personMap.get(person).size()==0) personIter.remove(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return personMap; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
package com.example.dev_j200_2; |
||||||
|
|
||||||
|
import java.util.Objects; |
||||||
|
|
||||||
|
public class User { |
||||||
|
private String name; |
||||||
|
private String password; |
||||||
|
|
||||||
|
public User(String name, String password) { |
||||||
|
this.name = name; |
||||||
|
this.password = password; |
||||||
|
} |
||||||
|
|
||||||
|
public String getName() { |
||||||
|
return name; |
||||||
|
} |
||||||
|
|
||||||
|
public void setName(String name) { |
||||||
|
this.name = name; |
||||||
|
} |
||||||
|
|
||||||
|
public String getPassword() { |
||||||
|
return password; |
||||||
|
} |
||||||
|
|
||||||
|
public void setPassword(String password) { |
||||||
|
this.password = password; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean equals(Object o) { |
||||||
|
if (this == o) return true; |
||||||
|
if (o == null || getClass() != o.getClass()) return false; |
||||||
|
User user = (User) o; |
||||||
|
return name.equals(user.name); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int hashCode() { |
||||||
|
return Objects.hash(name); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,22 @@ |
|||||||
|
package com.example.dev_j200_2; |
||||||
|
|
||||||
|
import java.util.HashSet; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
public class UserStore { |
||||||
|
private static Set<User> users; |
||||||
|
|
||||||
|
static { |
||||||
|
users = new HashSet<>(); |
||||||
|
users.add(new User("Andrey", "123qwe")); |
||||||
|
users.add(new User("Michail", "123qwe")); |
||||||
|
users.add(new User("Olga", "123qwe")); |
||||||
|
users.add(new User("Yana", "123qwe")); |
||||||
|
users.add(new User("Alexsandr", "123qwe")); |
||||||
|
} |
||||||
|
|
||||||
|
public boolean checkUser(String username, String password){ |
||||||
|
User temp = new User(username, password); |
||||||
|
return users.contains(temp); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
package com.example.dev_j200_2.api; |
||||||
|
|
||||||
|
import jakarta.ws.rs.ApplicationPath; |
||||||
|
import jakarta.ws.rs.core.Application; |
||||||
|
|
||||||
|
import java.util.HashSet; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
@ApplicationPath("api") |
||||||
|
public class RestConfig extends Application { |
||||||
|
@Override |
||||||
|
public Set<Class<?>> getClasses() { |
||||||
|
Set<Class<?>> resources = new HashSet<>(); |
||||||
|
resources.add(RestPersonService.class); |
||||||
|
resources.add(RestDomainService.class); |
||||||
|
return resources; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,51 @@ |
|||||||
|
package com.example.dev_j200_2.api; |
||||||
|
|
||||||
|
import com.example.dev_j200_2.entities.DomainEntity; |
||||||
|
import com.example.dev_j200_2.repo.AppRepositoryI; |
||||||
|
import jakarta.ejb.EJB; |
||||||
|
import jakarta.ejb.Stateless; |
||||||
|
import jakarta.ws.rs.*; |
||||||
|
import jakarta.ws.rs.core.MediaType; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Stateless |
||||||
|
@Path("domain") |
||||||
|
public class RestDomainService { |
||||||
|
|
||||||
|
@EJB |
||||||
|
private AppRepositoryI repository; |
||||||
|
|
||||||
|
//localhost:8080/sameApp/api/domain/1
|
||||||
|
@GET |
||||||
|
@Produces(MediaType.APPLICATION_JSON) |
||||||
|
public List<DomainEntity> getAll(){ |
||||||
|
return repository.findAll(DomainEntity.class); |
||||||
|
} |
||||||
|
|
||||||
|
@GET |
||||||
|
@Path("{id}") |
||||||
|
@Produces(MediaType.APPLICATION_JSON) |
||||||
|
public DomainEntity getDomain(@PathParam("id") Long id){ |
||||||
|
return repository.findById(DomainEntity.class, id); |
||||||
|
} |
||||||
|
|
||||||
|
@DELETE |
||||||
|
@Path("{id}") |
||||||
|
public void delete(@PathParam("id") Long id){ |
||||||
|
repository.delete(DomainEntity.class, id); |
||||||
|
} |
||||||
|
|
||||||
|
@POST |
||||||
|
@Consumes(MediaType.APPLICATION_JSON) |
||||||
|
public void create(DomainEntity domain){ |
||||||
|
repository.save(domain); |
||||||
|
} |
||||||
|
|
||||||
|
@PUT |
||||||
|
@Consumes(MediaType.APPLICATION_JSON) |
||||||
|
public void update(DomainEntity domain){ |
||||||
|
System.out.println(domain); |
||||||
|
repository.update(domain); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,26 @@ |
|||||||
|
package com.example.dev_j200_2.api; |
||||||
|
|
||||||
|
import com.example.dev_j200_2.entities.PersonEntity; |
||||||
|
import com.example.dev_j200_2.repo.AppRepositoryI; |
||||||
|
import jakarta.ejb.EJB; |
||||||
|
import jakarta.ejb.Stateless; |
||||||
|
import jakarta.ws.rs.GET; |
||||||
|
import jakarta.ws.rs.Path; |
||||||
|
import jakarta.ws.rs.Produces; |
||||||
|
import jakarta.ws.rs.core.MediaType; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Stateless |
||||||
|
@Path("person") |
||||||
|
public class RestPersonService { |
||||||
|
|
||||||
|
@EJB |
||||||
|
private AppRepositoryI repository; |
||||||
|
|
||||||
|
@GET |
||||||
|
@Produces(MediaType.APPLICATION_JSON) |
||||||
|
public List<PersonEntity> getAll(){ |
||||||
|
return repository.findAll(PersonEntity.class); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,124 @@ |
|||||||
|
package com.example.dev_j200_2.entities; |
||||||
|
|
||||||
|
import jakarta.persistence.*; |
||||||
|
import jakarta.xml.bind.annotation.XmlRootElement; |
||||||
|
import jakarta.xml.bind.annotation.XmlTransient; |
||||||
|
|
||||||
|
import java.sql.Date; |
||||||
|
|
||||||
|
@Entity |
||||||
|
@XmlRootElement |
||||||
|
@Table(name = "domain", schema = "test_db", catalog = "") |
||||||
|
@NamedQueries({ |
||||||
|
@NamedQuery(name = "Domain.All", query = "select d from DomainEntity d") |
||||||
|
}) |
||||||
|
public class DomainEntity { |
||||||
|
@Id |
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY) |
||||||
|
@Column(name = "id") |
||||||
|
private long id; |
||||||
|
@Basic |
||||||
|
@Column(name = "domain_name") |
||||||
|
private String domainName; |
||||||
|
@Basic |
||||||
|
@Column(name = "ip") |
||||||
|
private String ip; |
||||||
|
@Basic |
||||||
|
@Column(name = "date_reg") |
||||||
|
private Date dateReg; |
||||||
|
@Basic |
||||||
|
@Column(name = "country_reg") |
||||||
|
private String countryReg; |
||||||
|
@JoinColumn(name = "person") |
||||||
|
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) |
||||||
|
private PersonEntity person; |
||||||
|
|
||||||
|
public long getId() { |
||||||
|
return id; |
||||||
|
} |
||||||
|
|
||||||
|
public void setId(long id) { |
||||||
|
this.id = id; |
||||||
|
} |
||||||
|
|
||||||
|
@XmlTransient |
||||||
|
public PersonEntity getPerson() { |
||||||
|
return person; |
||||||
|
} |
||||||
|
|
||||||
|
public void setPerson(PersonEntity person) { |
||||||
|
this.person = person; |
||||||
|
} |
||||||
|
|
||||||
|
public String getDomainName() { |
||||||
|
return domainName; |
||||||
|
} |
||||||
|
|
||||||
|
public void setDomainName(String domainName) { |
||||||
|
this.domainName = domainName; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public String getIp() { |
||||||
|
return ip; |
||||||
|
} |
||||||
|
|
||||||
|
public void setIp(String ip) { |
||||||
|
this.ip = ip; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public Date getDateReg() { |
||||||
|
return dateReg; |
||||||
|
} |
||||||
|
|
||||||
|
public void setDateReg(Date dateReg) { |
||||||
|
this.dateReg = dateReg; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public String getCountryReg() { |
||||||
|
return countryReg; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCountryReg(String countryReg) { |
||||||
|
this.countryReg = countryReg; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean equals(Object o) { |
||||||
|
if (this == o) return true; |
||||||
|
if (o == null || getClass() != o.getClass()) return false; |
||||||
|
|
||||||
|
DomainEntity that = (DomainEntity) o; |
||||||
|
|
||||||
|
if (id != that.id) return false; |
||||||
|
if (domainName != null ? !domainName.equals(that.domainName) : that.domainName != null) return false; |
||||||
|
if (ip != null ? !ip.equals(that.ip) : that.ip != null) return false; |
||||||
|
if (dateReg != null ? !dateReg.equals(that.dateReg) : that.dateReg != null) return false; |
||||||
|
if (countryReg != null ? !countryReg.equals(that.countryReg) : that.countryReg != null) return false; |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int hashCode() { |
||||||
|
int result = (int) (id ^ (id >>> 32)); |
||||||
|
result = 31 * result + (domainName != null ? domainName.hashCode() : 0); |
||||||
|
result = 31 * result + (ip != null ? ip.hashCode() : 0); |
||||||
|
result = 31 * result + (dateReg != null ? dateReg.hashCode() : 0); |
||||||
|
result = 31 * result + (countryReg != null ? countryReg.hashCode() : 0); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return "DomainEntity{" + |
||||||
|
"id=" + id + |
||||||
|
", domainName='" + domainName + '\'' + |
||||||
|
", ip='" + ip + '\'' + |
||||||
|
", dateReg=" + dateReg + |
||||||
|
", countryReg='" + countryReg + '\'' + |
||||||
|
'}'; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,120 @@ |
|||||||
|
package com.example.dev_j200_2.entities; |
||||||
|
|
||||||
|
import jakarta.persistence.*; |
||||||
|
import jakarta.xml.bind.annotation.XmlRootElement; |
||||||
|
|
||||||
|
import java.util.HashSet; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
@Entity |
||||||
|
@XmlRootElement |
||||||
|
@Table(name = "person", schema = "test_db", catalog = "") |
||||||
|
public class PersonEntity { |
||||||
|
@Id |
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY) |
||||||
|
@Column(name = "id") |
||||||
|
private long id; |
||||||
|
@Basic |
||||||
|
@Column(name = "first_name") |
||||||
|
private String firstName; |
||||||
|
@Basic |
||||||
|
@Column(name = "last_name") |
||||||
|
private String lastName; |
||||||
|
@Basic |
||||||
|
@Column(name = "email") |
||||||
|
private String email; |
||||||
|
@Basic |
||||||
|
@Column(name = "gender") |
||||||
|
private String gender; |
||||||
|
@OneToMany(mappedBy = "person", fetch = FetchType.EAGER) |
||||||
|
private Set<DomainEntity> domainEntitySet = new HashSet<>(); |
||||||
|
|
||||||
|
public long getId() { |
||||||
|
return id; |
||||||
|
} |
||||||
|
|
||||||
|
public void setId(long id) { |
||||||
|
this.id = id; |
||||||
|
} |
||||||
|
|
||||||
|
public Set<DomainEntity> getDomainEntitySet() { |
||||||
|
return domainEntitySet; |
||||||
|
} |
||||||
|
|
||||||
|
public void setDomainEntitySet(Set<DomainEntity> domainEntitySet) { |
||||||
|
this.domainEntitySet = domainEntitySet; |
||||||
|
} |
||||||
|
|
||||||
|
public String getFirstName() { |
||||||
|
return firstName; |
||||||
|
} |
||||||
|
|
||||||
|
public void setFirstName(String firstName) { |
||||||
|
this.firstName = firstName; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public String getLastName() { |
||||||
|
return lastName; |
||||||
|
} |
||||||
|
|
||||||
|
public void setLastName(String lastName) { |
||||||
|
this.lastName = lastName; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public String getEmail() { |
||||||
|
return email; |
||||||
|
} |
||||||
|
|
||||||
|
public void setEmail(String email) { |
||||||
|
this.email = email; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public String getGender() { |
||||||
|
return gender; |
||||||
|
} |
||||||
|
|
||||||
|
public void setGender(String gender) { |
||||||
|
this.gender = gender; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean equals(Object o) { |
||||||
|
if (this == o) return true; |
||||||
|
if (o == null || getClass() != o.getClass()) return false; |
||||||
|
|
||||||
|
PersonEntity that = (PersonEntity) o; |
||||||
|
|
||||||
|
if (id != that.id) return false; |
||||||
|
if (firstName != null ? !firstName.equals(that.firstName) : that.firstName != null) return false; |
||||||
|
if (lastName != null ? !lastName.equals(that.lastName) : that.lastName != null) return false; |
||||||
|
if (email != null ? !email.equals(that.email) : that.email != null) return false; |
||||||
|
if (gender != null ? !gender.equals(that.gender) : that.gender != null) return false; |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int hashCode() { |
||||||
|
int result = (int) (id ^ (id >>> 32)); |
||||||
|
result = 31 * result + (firstName != null ? firstName.hashCode() : 0); |
||||||
|
result = 31 * result + (lastName != null ? lastName.hashCode() : 0); |
||||||
|
result = 31 * result + (email != null ? email.hashCode() : 0); |
||||||
|
result = 31 * result + (gender != null ? gender.hashCode() : 0); |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return "PersonEntity{" + |
||||||
|
"id=" + id + |
||||||
|
", firstName='" + firstName + '\'' + |
||||||
|
", lastName='" + lastName + '\'' + |
||||||
|
", email='" + email + '\'' + |
||||||
|
", gender='" + gender + '\'' + |
||||||
|
", domainEntitySet=" + domainEntitySet + |
||||||
|
'}'; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,63 @@ |
|||||||
|
package com.example.dev_j200_2.entities; |
||||||
|
|
||||||
|
import jakarta.persistence.*; |
||||||
|
|
||||||
|
@Entity |
||||||
|
@Table(name = "users", schema = "test_db", catalog = "") |
||||||
|
public class UsersEntity { |
||||||
|
private long id; |
||||||
|
private String username; |
||||||
|
private String userpass; |
||||||
|
|
||||||
|
@Id |
||||||
|
@Column(name = "id") |
||||||
|
public long getId() { |
||||||
|
return id; |
||||||
|
} |
||||||
|
|
||||||
|
public void setId(long id) { |
||||||
|
this.id = id; |
||||||
|
} |
||||||
|
|
||||||
|
@Basic |
||||||
|
@Column(name = "username") |
||||||
|
public String getUsername() { |
||||||
|
return username; |
||||||
|
} |
||||||
|
|
||||||
|
public void setUsername(String username) { |
||||||
|
this.username = username; |
||||||
|
} |
||||||
|
|
||||||
|
@Basic |
||||||
|
@Column(name = "userpass") |
||||||
|
public String getUserpass() { |
||||||
|
return userpass; |
||||||
|
} |
||||||
|
|
||||||
|
public void setUserpass(String userpass) { |
||||||
|
this.userpass = userpass; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean equals(Object o) { |
||||||
|
if (this == o) return true; |
||||||
|
if (o == null || getClass() != o.getClass()) return false; |
||||||
|
|
||||||
|
UsersEntity that = (UsersEntity) o; |
||||||
|
|
||||||
|
if (id != that.id) return false; |
||||||
|
if (username != null ? !username.equals(that.username) : that.username != null) return false; |
||||||
|
if (userpass != null ? !userpass.equals(that.userpass) : that.userpass != null) return false; |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int hashCode() { |
||||||
|
int result = (int) (id ^ (id >>> 32)); |
||||||
|
result = 31 * result + (username != null ? username.hashCode() : 0); |
||||||
|
result = 31 * result + (userpass != null ? userpass.hashCode() : 0); |
||||||
|
return result; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,76 @@ |
|||||||
|
package com.example.dev_j200_2.repo; |
||||||
|
|
||||||
|
import com.example.dev_j200_2.entities.DomainEntity; |
||||||
|
import com.example.dev_j200_2.entities.PersonEntity; |
||||||
|
import com.example.dev_j200_2.entities.UsersEntity; |
||||||
|
import jakarta.ejb.Singleton; |
||||||
|
import jakarta.persistence.EntityManager; |
||||||
|
import jakarta.persistence.PersistenceContext; |
||||||
|
import jakarta.persistence.criteria.CriteriaBuilder; |
||||||
|
import jakarta.persistence.criteria.CriteriaQuery; |
||||||
|
import jakarta.persistence.criteria.Root; |
||||||
|
import jakarta.persistence.metamodel.Metamodel; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Singleton |
||||||
|
public class AppRepository implements AppRepositoryI { |
||||||
|
@PersistenceContext |
||||||
|
private EntityManager em; |
||||||
|
|
||||||
|
@Override |
||||||
|
public <T> List<T> findAll(Class<T> clazz) { |
||||||
|
CriteriaBuilder cb = em.getCriteriaBuilder(); |
||||||
|
CriteriaQuery<T> cq = cb.createQuery(clazz); |
||||||
|
Metamodel m = em.getMetamodel(); |
||||||
|
Root<T> obj = cq.from(clazz); |
||||||
|
return em.createQuery(cq.select(obj)).getResultList(); |
||||||
|
} |
||||||
|
@Override |
||||||
|
public <T> T findById(Class<T> clazz, long id) { |
||||||
|
return em.find(clazz, id); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public <T> void delete(Class<T> clazz, long id) { |
||||||
|
T entity = em.find(clazz, id); |
||||||
|
em.remove(entity); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public <T> void save(T entity) { |
||||||
|
em.persist(entity); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public <T> void update(T entity) { |
||||||
|
em.merge(entity); |
||||||
|
em.flush(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<PersonEntity> findAllPerson() { |
||||||
|
CriteriaBuilder cb = em.getCriteriaBuilder(); |
||||||
|
CriteriaQuery<PersonEntity> cq = cb.createQuery(PersonEntity.class); |
||||||
|
Root<PersonEntity> root = cq.from(PersonEntity.class); |
||||||
|
cq.select(root); |
||||||
|
return em.createQuery(cq).getResultList(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<DomainEntity> findAllDomain() { |
||||||
|
return em.createNamedQuery("Domain.All", DomainEntity.class).getResultList(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public PersonEntity findPersonById(long id) { |
||||||
|
return em.find(PersonEntity.class, id); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public UsersEntity findUserById(long id) { |
||||||
|
return em.find(UsersEntity.class, id); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
package com.example.dev_j200_2.repo; |
||||||
|
|
||||||
|
import com.example.dev_j200_2.entities.DomainEntity; |
||||||
|
import com.example.dev_j200_2.entities.PersonEntity; |
||||||
|
import com.example.dev_j200_2.entities.UsersEntity; |
||||||
|
import jakarta.ejb.Local; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
@Local |
||||||
|
public interface AppRepositoryI { |
||||||
|
|
||||||
|
List<PersonEntity> findAllPerson(); |
||||||
|
List<DomainEntity> findAllDomain(); |
||||||
|
<T>List<T> findAll(Class<T> clazz); |
||||||
|
PersonEntity findPersonById(long id); |
||||||
|
UsersEntity findUserById(long id); |
||||||
|
<T>T findById(Class<T> clazz, long id); |
||||||
|
<T> void delete(Class<T> clazz, long id); |
||||||
|
<T> void save(T entity); |
||||||
|
<T> void update(T entity); |
||||||
|
} |
@ -0,0 +1,9 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
||||||
|
<persistence xmlns="https://jakarta.ee/xml/ns/persistence" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd" |
||||||
|
version="3.0"> |
||||||
|
<persistence-unit name="default"> |
||||||
|
<jta-data-source>java:/test_db</jta-data-source> |
||||||
|
</persistence-unit> |
||||||
|
</persistence> |
@ -0,0 +1,7 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd" |
||||||
|
version="5.0"> |
||||||
|
|
||||||
|
</web-app> |
@ -0,0 +1,20 @@ |
|||||||
|
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> |
||||||
|
<!DOCTYPE html> |
||||||
|
<html> |
||||||
|
<head> |
||||||
|
<title>JSP - Hello World</title> |
||||||
|
</head> |
||||||
|
<body align="center"> |
||||||
|
<h1><%= "Authorization" %> |
||||||
|
</h1> |
||||||
|
<br/> |
||||||
|
<a href="hello-servlet">Hello Servlet</a> |
||||||
|
<form action="hello-servlet" method="post" align="center"> |
||||||
|
<label>username</label><br> |
||||||
|
<input type="text" name="username" required><br><br> |
||||||
|
<label>password</label><br> |
||||||
|
<input type="password" name="password" required><br><br> |
||||||
|
<input type="submit" value="Sing in"> |
||||||
|
</form> |
||||||
|
</body> |
||||||
|
</html> |
@ -0,0 +1,27 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html lang="en"> |
||||||
|
<head> |
||||||
|
<meta charset="UTF-8"> |
||||||
|
<title>Title</title> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
<form action="ServletViewList" method="get" align="center"> |
||||||
|
<input type="text" name="filter"> |
||||||
|
<input type="submit" value="Filter"> |
||||||
|
</form> |
||||||
|
<table align="center" cellpadding="5" border="1" cellspacing="0"> |
||||||
|
<tr> |
||||||
|
<th>ID</th> |
||||||
|
<th>NAME</th> |
||||||
|
<th>SERIAL</th> |
||||||
|
<th>NUMBER</th> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td></td> |
||||||
|
<td></td> |
||||||
|
<td></td> |
||||||
|
<td></td> |
||||||
|
</tr> |
||||||
|
</table> |
||||||
|
</body> |
||||||
|
</html> |
@ -0,0 +1,9 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
||||||
|
<persistence xmlns="https://jakarta.ee/xml/ns/persistence" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd" |
||||||
|
version="3.0"> |
||||||
|
<persistence-unit name="default"> |
||||||
|
<jta-data-source>java:/test_db</jta-data-source> |
||||||
|
</persistence-unit> |
||||||
|
</persistence> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,5 @@ |
|||||||
|
Manifest-Version: 1.0 |
||||||
|
Created-By: IntelliJ IDEA |
||||||
|
Built-By: denis |
||||||
|
Build-Jdk: 11.0.18 |
||||||
|
|
@ -0,0 +1,9 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
||||||
|
<persistence xmlns="https://jakarta.ee/xml/ns/persistence" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd" |
||||||
|
version="3.0"> |
||||||
|
<persistence-unit name="default"> |
||||||
|
<jta-data-source>java:/test_db</jta-data-source> |
||||||
|
</persistence-unit> |
||||||
|
</persistence> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,7 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_5_0.xsd" |
||||||
|
version="5.0"> |
||||||
|
|
||||||
|
</web-app> |
@ -0,0 +1,20 @@ |
|||||||
|
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> |
||||||
|
<!DOCTYPE html> |
||||||
|
<html> |
||||||
|
<head> |
||||||
|
<title>JSP - Hello World</title> |
||||||
|
</head> |
||||||
|
<body align="center"> |
||||||
|
<h1><%= "Authorization" %> |
||||||
|
</h1> |
||||||
|
<br/> |
||||||
|
<a href="hello-servlet">Hello Servlet</a> |
||||||
|
<form action="hello-servlet" method="post" align="center"> |
||||||
|
<label>username</label><br> |
||||||
|
<input type="text" name="username" required><br><br> |
||||||
|
<label>password</label><br> |
||||||
|
<input type="password" name="password" required><br><br> |
||||||
|
<input type="submit" value="Sing in"> |
||||||
|
</form> |
||||||
|
</body> |
||||||
|
</html> |
@ -0,0 +1,27 @@ |
|||||||
|
<!DOCTYPE html> |
||||||
|
<html lang="en"> |
||||||
|
<head> |
||||||
|
<meta charset="UTF-8"> |
||||||
|
<title>Title</title> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
<form action="ServletViewList" method="get" align="center"> |
||||||
|
<input type="text" name="filter"> |
||||||
|
<input type="submit" value="Filter"> |
||||||
|
</form> |
||||||
|
<table align="center" cellpadding="5" border="1" cellspacing="0"> |
||||||
|
<tr> |
||||||
|
<th>ID</th> |
||||||
|
<th>NAME</th> |
||||||
|
<th>SERIAL</th> |
||||||
|
<th>NUMBER</th> |
||||||
|
</tr> |
||||||
|
<tr> |
||||||
|
<td></td> |
||||||
|
<td></td> |
||||||
|
<td></td> |
||||||
|
<td></td> |
||||||
|
</tr> |
||||||
|
</table> |
||||||
|
</body> |
||||||
|
</html> |
@ -0,0 +1,5 @@ |
|||||||
|
Manifest-Version: 1.0 |
||||||
|
Created-By: IntelliJ IDEA |
||||||
|
Built-By: denis |
||||||
|
Build-Jdk: 11.0.18 |
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue