mirror of
https://github.com/bbasaran/kessel-run.git
synced 2024-09-25 21:35:21 -04:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee1a604fbd | ||
|
|
2f0f24f3a7 | ||
|
|
147374738a |
+1
-1
@@ -10,7 +10,7 @@ import java.io.IOException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class JsonToPojoConcerterService {
|
public class JsonToPojoConverterService {
|
||||||
|
|
||||||
public void convertJsonToJavaClass(URL inputJsonUrl, File outputJavaClassDirectory, String packageName, String javaClassName)
|
public void convertJsonToJavaClass(URL inputJsonUrl, File outputJavaClassDirectory, String packageName, String javaClassName)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
@@ -1,16 +1,22 @@
|
|||||||
package org.misoenergy.hackday.kessel_run.service;
|
package org.misoenergy.hackday.kessel_run.service;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.misoenergy.hackday.kessel_run.model.StarWarsPojo;
|
import org.misoenergy.hackday.kessel_run.model.StarWarsPojo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
import reactor.util.function.Tuple2;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -20,7 +26,7 @@ public class StarWarsApiService {
|
|||||||
RestTemplate restTemplate;
|
RestTemplate restTemplate;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private JsonToPojoConcerterService jsonToPojoConcerterService;
|
private JsonToPojoConverterService jsonToPojoConcerterService;
|
||||||
|
|
||||||
private String url = "https://sw5eapi.azurewebsites.net/api/class";
|
private String url = "https://sw5eapi.azurewebsites.net/api/class";
|
||||||
|
|
||||||
@@ -64,20 +70,28 @@ public class StarWarsApiService {
|
|||||||
|
|
||||||
String packageName = "org.misoenergy.hackday.kessel_run.model";
|
String packageName = "org.misoenergy.hackday.kessel_run.model";
|
||||||
|
|
||||||
|
Map<String, File> pojoList = new HashMap<>();
|
||||||
|
|
||||||
String jsonPath = "src/main/resources/";
|
String jsonPath = "src/main/resources/";
|
||||||
File inputJson = new File(jsonPath + "starwarsjsonresponse.json");
|
File classJson = new File(jsonPath + "starwarsjsonresponse.json");
|
||||||
|
File equipmentJson = new File(jsonPath + "equipment.json");
|
||||||
|
String classClassName = "StarWarsPojo";
|
||||||
|
String equipmentClassName = "EquipmentPojo";
|
||||||
|
|
||||||
|
pojoList.put(classClassName, classJson);
|
||||||
|
pojoList.put(equipmentClassName, equipmentJson);
|
||||||
|
|
||||||
String outputPath = "src/main/resources/";
|
String outputPath = "src/main/resources/";
|
||||||
File outputJavaClassDirectory = new File(outputPath);
|
File outputJavaClassDirectory = new File(outputPath);
|
||||||
|
|
||||||
String javaClassName = "StarWarsPojo";
|
|
||||||
|
|
||||||
try {
|
pojoList.forEach((className, pojoJson) -> {
|
||||||
jsonToPojoConcerterService.convertJsonToJavaClass(inputJson.toURI()
|
try {
|
||||||
.toURL(), outputJavaClassDirectory, packageName, javaClassName ) ;
|
jsonToPojoConcerterService.convertJsonToJavaClass(pojoJson.toURI()
|
||||||
|
.toURL(), outputJavaClassDirectory, packageName, className);
|
||||||
}catch (Exception ex) {
|
} catch (Exception e) {
|
||||||
log.info("exception : {}" , ex.getMessage() );
|
log.info("exception : {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user