Промежуточный коммит

This commit is contained in:
WarL0ck 2017-12-06 12:43:08 +07:00
parent d9beeab2cd
commit bdbb585d68
23 changed files with 333 additions and 53 deletions

View File

@ -1,13 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.2">
<library name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.10">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-core/2.9.2/jackson-core-2.9.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-core/2.8.10/jackson-core-2.8.10.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-core/2.9.2/jackson-core-2.9.2-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-core/2.8.10/jackson-core-2.8.10-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-core/2.9.2/jackson-core-2.9.2-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-core/2.8.10/jackson-core-2.8.10-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -1,13 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.2">
<library name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.10">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-databind/2.9.2/jackson-databind-2.9.2.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-databind/2.8.10/jackson-databind-2.8.10.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-databind/2.9.2/jackson-databind-2.9.2-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-databind/2.8.10/jackson-databind-2.8.10-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-databind/2.9.2/jackson-databind-2.9.2-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-databind/2.8.10/jackson-databind-2.8.10-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-json:unknown">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/dataformat/jackson-dataformat-json/unknown/jackson-dataformat-json-unknown.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/dataformat/jackson-dataformat-json/unknown/jackson-dataformat-json-unknown-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/dataformat/jackson-dataformat-json/unknown/jackson-dataformat-json-unknown-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.atteo:evo-inflector:1.2.2">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/atteo/evo-inflector/1.2.2/evo-inflector-1.2.2.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/atteo/evo-inflector/1.2.2/evo-inflector-1.2.2-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/atteo/evo-inflector/1.2.2/evo-inflector-1.2.2-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.springframework.boot:spring-boot-starter-data-rest:1.5.9.RELEASE">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-data-rest/1.5.9.RELEASE/spring-boot-starter-data-rest-1.5.9.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-data-rest/1.5.9.RELEASE/spring-boot-starter-data-rest-1.5.9.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/boot/spring-boot-starter-data-rest/1.5.9.RELEASE/spring-boot-starter-data-rest-1.5.9.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.springframework.data:spring-data-commons:1.13.9.RELEASE">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/data/spring-data-commons/1.13.9.RELEASE/spring-data-commons-1.13.9.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/data/spring-data-commons/1.13.9.RELEASE/spring-data-commons-1.13.9.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/data/spring-data-commons/1.13.9.RELEASE/spring-data-commons-1.13.9.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.springframework.data:spring-data-rest-core:2.6.9.RELEASE">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/data/spring-data-rest-core/2.6.9.RELEASE/spring-data-rest-core-2.6.9.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/data/spring-data-rest-core/2.6.9.RELEASE/spring-data-rest-core-2.6.9.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/data/spring-data-rest-core/2.6.9.RELEASE/spring-data-rest-core-2.6.9.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.springframework.data:spring-data-rest-webmvc:2.6.9.RELEASE">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/data/spring-data-rest-webmvc/2.6.9.RELEASE/spring-data-rest-webmvc-2.6.9.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/data/spring-data-rest-webmvc/2.6.9.RELEASE/spring-data-rest-webmvc-2.6.9.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/data/spring-data-rest-webmvc/2.6.9.RELEASE/spring-data-rest-webmvc-2.6.9.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.springframework.hateoas:spring-hateoas:0.23.0.RELEASE">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/hateoas/spring-hateoas/0.23.0.RELEASE/spring-hateoas-0.23.0.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/hateoas/spring-hateoas/0.23.0.RELEASE/spring-hateoas-0.23.0.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/hateoas/spring-hateoas/0.23.0.RELEASE/spring-hateoas-0.23.0.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="Maven: org.springframework:spring-tx:4.3.13.RELEASE">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-tx/4.3.13.RELEASE/spring-tx-4.3.13.RELEASE.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-tx/4.3.13.RELEASE/spring-tx-4.3.13.RELEASE-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/springframework/spring-tx/4.3.13.RELEASE/spring-tx-4.3.13.RELEASE-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -1,4 +1,4 @@
#Rest server config
#Mon Dec 04 22:58:15 KRAT 2017
port=8080
#Tue Dec 05 21:32:53 KRAT 2017
port=8090
url=http\://localhost

17
pom.xml
View File

@ -101,23 +101,32 @@
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-json</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -11,9 +11,9 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.1.11" level="project" />
@ -21,22 +21,8 @@
<orderEntry type="library" name="Maven: org.slf4j:jcl-over-slf4j:1.7.25" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.25" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:log4j-over-slf4j:1.7.25" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.13.RELEASE" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.17" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:8.5.23" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-annotations-api:8.5.23" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:8.5.23" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:8.5.23" level="project" />
<orderEntry type="library" name="Maven: org.hibernate:hibernate-validator:5.3.6.Final" level="project" />
<orderEntry type="library" name="Maven: javax.validation:validation-api:1.1.0.Final" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.1.Final" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.3.4" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:4.3.13.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:1.5.9.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:1.5.9.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.5.9.RELEASE" level="project" />
@ -53,10 +39,33 @@
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.4.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:4.3.13.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.2" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:8.5.23" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat:tomcat-annotations-api:8.5.23" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:8.5.23" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:8.5.23" level="project" />
<orderEntry type="library" name="Maven: org.hibernate:hibernate-validator:5.3.6.Final" level="project" />
<orderEntry type="library" name="Maven: javax.validation:validation-api:1.1.0.Final" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.1.Final" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.3.4" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-rest:1.5.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-rest-webmvc:2.6.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-rest-core:2.6.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:4.3.13.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.hateoas:spring-hateoas:0.23.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:1.13.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.atteo:evo-inflector:1.2.2" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.10" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.10" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-json:unknown" level="project" />
</component>
</module>

View File

@ -79,4 +79,8 @@ public class ConfigController {
Stage stage = (Stage) cancel.getScene().getWindow();
stage.close();
}
public static String getConfigFile() {
return CONF_FILE;
}
}

View File

@ -5,6 +5,9 @@ public class EmailRecord {
private String name;
private String email;
public EmailRecord() {
}
public EmailRecord(long id, String name, String email) {
this.id = id;
this.name = name;

View File

@ -3,7 +3,9 @@ package ru.cft.task.restClient;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TextField;
import javafx.stage.Modality;
import javafx.stage.Stage;
@ -36,7 +38,7 @@ public class MainController {
System.exit(0);
}
private Stage showModal(String fxml, String title) {
private void showModal(String fxml, String title) {
Stage stage = null;
try {
Scene scene = new Scene(FXMLLoader.load(getClass().getResource(fxml)));
@ -47,36 +49,29 @@ public class MainController {
stage.setTitle(title);
stage.initOwner(mainStage);
stage.initModality(Modality.APPLICATION_MODAL);
return stage;
stage.showAndWait();
} catch (IOException e) {
Utils.showAlert("error", e.getMessage());
} finally {
return stage;
}
}
public void showServerConfig() {
Stage config = showModal("/config.fxml", srv_config.getText());
config.showAndWait();
showModal("/config.fxml", srv_config.getText());
}
public void createAction() {
Stage cr = showModal("/form.fxml", create.getText());
cr.showAndWait();
showModal("/form_create.fxml", create.getText());
}
public void readAction() {
Stage rd = showModal("/form.fxml", read.getText());
rd.showAndWait();
showModal("/form_read.fxml", read.getText());
}
public void updateAction() {
Stage upd = showModal("/form.fxml", update.getText());
upd.showAndWait();
showModal("/form_update.fxml", update.getText());
}
public void deleteAction() {
Stage dlt = showModal("/form.fxml", delete.getText());
dlt.showAndWait();
showModal("/form_delete.fxml", delete.getText());
}
}

View File

@ -4,6 +4,14 @@ import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import org.springframework.http.*;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class RestActionsController {
@FXML
@ -18,11 +26,81 @@ public class RestActionsController {
@FXML
private Button cancel;
@FXML
private Button doAction;
private String getRestServerUrl() {
Properties props = new Properties();
InputStream conf_file = null;
String url = "";
try {
conf_file = new FileInputStream(ConfigController.getConfigFile());
props.load(conf_file);
url = props.getProperty("url", "http://localhost");
url += ":" + props.getProperty("port", "8080");
} catch (IOException ex) {
Utils.showAlert("error", ex.getMessage());
} finally {
if (conf_file != null) {
try {
conf_file.close();
} catch (IOException ex) {
Utils.showAlert("error", ex.getMessage());
}
}
return url;
}
}
public void cancelAction() {
Stage stage = (Stage) cancel.getScene().getWindow();
stage.close();
}
public void createAction() {
EmailRecord emailRecord = new EmailRecord();
emailRecord.setName("Test");
emailRecord.setEmail("aaa");
RestTemplate restTemplate = new RestTemplate();
HttpEntity<EmailRecord> request = new HttpEntity<>(emailRecord);
try {
ResponseEntity<EmailRecord> response = restTemplate.exchange(getRestServerUrl(), HttpMethod.POST, request, EmailRecord.class);
System.out.println(response.getStatusCode());
if (response.getStatusCode() == HttpStatus.OK) {
EmailRecord er = response.getBody();
id.setText(String.valueOf(er.getId()));
}
} catch (RestClientException ex) {
Utils.showAlert("error", ex.getMessage());
}
}
public void readAction() {
HttpHeaders headers = new HttpHeaders();
headers.add("Accept", MediaType.APPLICATION_JSON_VALUE);
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set("id", id.getText());
headers.set("name", name.getText());
headers.set("email", email.getText());
RestTemplate restTemplate = new RestTemplate();
HttpEntity<EmailRecord> entity = new HttpEntity<>(headers);
try {
ResponseEntity<EmailRecord> result = restTemplate.exchange(getRestServerUrl(), HttpMethod.GET, entity, EmailRecord.class);
if (result.getStatusCode() == HttpStatus.OK) {
EmailRecord emailRecord = result.getBody();
id.setText(String.valueOf(emailRecord.getId()));
name.setText(emailRecord.getName());
email.setText(emailRecord.getEmail());
}
} catch (RestClientException ex) {
Utils.showAlert("error", ex.getMessage());
}
}
public void updateAction() {
}
public void deleteAction() {
}
}

View File

@ -0,0 +1,12 @@
package ru.cft.task.restClient;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.web.client.DefaultResponseErrorHandler;
import java.io.IOException;
public class RestErrorHandler extends DefaultResponseErrorHandler {
public void handleError(ClientHttpResponse response) throws IOException {
Utils.showAlert("error", response.getStatusText());
}
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane prefHeight="147.0" prefWidth="295.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ru.cft.task.restClient.RestActionsController">
<children>
<Label layoutX="15.0" layoutY="14.0" text="Идентификатор" />
<TextField fx:id="id" disable="true" editable="false" layoutX="111.0" layoutY="10.0" prefHeight="25.0" prefWidth="181.0" />
<Label layoutX="33.0" layoutY="49.0" text="Имя клиента" />
<Label layoutX="27.0" layoutY="83.0" text="Email клиента" />
<TextField fx:id="name" layoutX="111.0" layoutY="45.0" prefHeight="25.0" prefWidth="181.0" />
<TextField fx:id="email" layoutX="111.0" layoutY="79.0" prefHeight="25.0" prefWidth="181.0" />
<Button fx:id="cancel" layoutX="14.0" layoutY="118.0" mnemonicParsing="false" onAction="#cancelAction" text="Отмена" />
<Button fx:id="createBtn" layoutX="240.0" layoutY="118.0" mnemonicParsing="false" onAction="#createAction" text="Добавить" />
</children>
</AnchorPane>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane fx:id="deleteBtn" onDragDetected="#deleteAction" prefHeight="68.0" prefWidth="295.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ru.cft.task.restClient.RestActionsController">
<children>
<Label layoutX="15.0" layoutY="14.0" text="Идентификатор" />
<TextField fx:id="id" layoutX="111.0" layoutY="10.0" prefHeight="25.0" prefWidth="181.0" />
<Button fx:id="cancel" layoutX="15.0" layoutY="40.0" mnemonicParsing="false" onAction="#cancelAction" text="Отмена" />
<Button fx:id="doAction" layoutX="232.0" layoutY="40.0" mnemonicParsing="false" text="Удалить" />
</children>
</AnchorPane>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane prefHeight="147.0" prefWidth="295.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ru.cft.task.restClient.RestActionsController">
<children>
<Label layoutX="15.0" layoutY="14.0" text="Идентификатор" />
<TextField fx:id="id" layoutX="111.0" layoutY="10.0" prefHeight="25.0" prefWidth="181.0" />
<Label layoutX="33.0" layoutY="49.0" text="Имя клиента" />
<Label layoutX="27.0" layoutY="83.0" text="Email клиента" />
<TextField fx:id="name" layoutX="111.0" layoutY="45.0" prefHeight="25.0" prefWidth="181.0" />
<TextField fx:id="email" layoutX="111.0" layoutY="79.0" prefHeight="25.0" prefWidth="181.0" />
<Button fx:id="cancel" layoutX="14.0" layoutY="118.0" mnemonicParsing="false" onAction="#cancelAction" text="Отмена" />
<Button fx:id="readBtn" layoutX="240.0" layoutY="118.0" mnemonicParsing="false" onAction="#readAction" text="Найти" />
</children>
</AnchorPane>

View File

@ -8,12 +8,12 @@
<AnchorPane prefHeight="147.0" prefWidth="295.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ru.cft.task.restClient.RestActionsController">
<children>
<Label layoutX="15.0" layoutY="14.0" text="Идентификатор" />
<TextField layoutX="111.0" layoutY="10.0" prefHeight="25.0" prefWidth="181.0" />
<TextField fx:id="id" layoutX="111.0" layoutY="10.0" prefHeight="25.0" prefWidth="181.0" />
<Label layoutX="33.0" layoutY="49.0" text="Имя клиента" />
<Label layoutX="27.0" layoutY="83.0" text="Email клиента" />
<TextField layoutX="111.0" layoutY="45.0" prefHeight="25.0" prefWidth="181.0" />
<TextField layoutX="111.0" layoutY="79.0" prefHeight="25.0" prefWidth="181.0" />
<TextField fx:id="name" layoutX="111.0" layoutY="45.0" prefHeight="25.0" prefWidth="181.0" />
<TextField fx:id="email" layoutX="111.0" layoutY="79.0" prefHeight="25.0" prefWidth="181.0" />
<Button fx:id="cancel" layoutX="14.0" layoutY="118.0" mnemonicParsing="false" onAction="#cancelAction" text="Отмена" />
<Button fx:id="doAction" layoutX="240.0" layoutY="118.0" mnemonicParsing="false" text="Button" />
<Button fx:id="doAction" layoutX="240.0" layoutY="118.0" mnemonicParsing="false" onAction="#updateAction" text="Изменить" />
</children>
</AnchorPane>