PULL型のものに変更
1 parent e32196a commit 39e1ffaab8cb519d9190a6e8298a26304dd1ba02
Shinji authored on 21 Jan 2023
Showing 2 changed files
View
155
src/main/java/stockManagement/pull/Handling.java
 
import pushPullRefactor.*;
 
import com.fasterxml.jackson.core.JsonProcessingException;
 
@Path("/handling")
@Component
@Resource("handling")
public class Handling {
@Cache("available")
private Map.Entry<String, Integer> available;
@Cache("request")
private Map.Entry<String, Integer> request;
@PushReference("shipping")
@Pullable("direct")
private String shipping = "/shipping";
@PushReference("stock")
private String stock = "/stock";
@State
private Map.Entry<String, Map.Entry<Integer, Integer>> value;
@Path("/available")
@PUT
@Message({"available", "shortage"})
@Message({})
public void updateAvailable(@FormParam("available") String available_json, @FormParam("shortage") String shortage_json) throws JsonProcessingException {
Map<String, Integer> shortage = new HashMap<>();
{
Map<String, Integer> i = new ObjectMapper().readValue(shortage_json, HashMap.class);
Map<String, Integer> i = new ObjectMapper().readValue(available_json, HashMap.class);
available = new AbstractMap.SimpleEntry<>(i.entrySet().iterator().next().getKey(), i.entrySet().iterator().next().getValue());
}
this.available = available;
Map.Entry<String, Map.Entry<Integer, Integer>> temp_if6;
int temp_get14;
Map.Entry<String, Map.Entry<Integer, Integer>> temp_if14;
int temp_get34;
if (shortage.get(available.getKey()) != null) {
temp_get14 = shortage.get(available.getKey());
temp_get34 = shortage.get(available.getKey());
} else {
temp_get14 = 0;
temp_get34 = 0;
}
if ((available.getValue()>=temp_get14)) {
int temp_get15;
if (shortage.get(available.getKey()) != null) {
temp_get15 = shortage.get(available.getKey());
if ((available.getValue()>=temp_get34)) {
int temp_get35;
if (shortage.get(available.getKey()) != null) {
temp_get35 = shortage.get(available.getKey());
} else {
temp_get35 = 0;
}
int temp_get36;
if (shortage.get(available.getKey()) != null) {
temp_get36 = shortage.get(available.getKey());
} else {
temp_get36 = 0;
}
temp_if14 = new AbstractMap.SimpleEntry<>(available.getKey(), new AbstractMap.SimpleEntry<>(temp_get35, (available.getValue()-temp_get36)));
} else {
temp_get15 = 0;
temp_if14 = new AbstractMap.SimpleEntry<>(available.getKey(), new AbstractMap.SimpleEntry<>(0, available.getValue()));
}
int temp_get16;
if (shortage.get(available.getKey()) != null) {
temp_get16 = shortage.get(available.getKey());
} else {
temp_get16 = 0;
}
temp_if6 = new AbstractMap.SimpleEntry<>(available.getKey(), new AbstractMap.SimpleEntry<>(temp_get15, (available.getValue()-temp_get16)));
} else {
temp_if6 = new AbstractMap.SimpleEntry<>(available.getKey(), new AbstractMap.SimpleEntry<>(0, available.getValue()));
}
this.value = temp_if6;
this.value = temp_if14;
Form form = new Form();
form.param("handling", new ObjectMapper().writeValueAsString(this.value));
Entity<Form> entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED);
String result = client.target("http://localhost:8080").path(shipping).request().put(entity, String.class);
form = new Form();
form.param("handling", new ObjectMapper().writeValueAsString(this.value));
entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED);
result = client.target("http://localhost:8080").path(stock).request().post(entity, String.class);
String result = client.target("http://localhost:8080").path("/stock").request().post(entity, String.class);
}
@Path("/request")
@PUT
@Message({"request", "stock"})
@Message({})
public void updateRequest(@FormParam("request") String request_json, @FormParam("stock") String stock_json) throws JsonProcessingException {
Map<String, Integer> stock = new HashMap<>();
{
Map<String, Integer> i = new ObjectMapper().readValue(stock_json, HashMap.class);
Map<String, Integer> i = new ObjectMapper().readValue(request_json, HashMap.class);
request = new AbstractMap.SimpleEntry<>(i.entrySet().iterator().next().getKey(), i.entrySet().iterator().next().getValue());
}
this.request = request;
Map.Entry<String, Map.Entry<Integer, Integer>> temp_if7;
int temp_get17;
Map.Entry<String, Map.Entry<Integer, Integer>> temp_if15;
int temp_get37;
if (stock.get(request.getKey()) != null) {
temp_get17 = stock.get(request.getKey());
temp_get37 = stock.get(request.getKey());
} else {
temp_get17 = 0;
temp_get37 = 0;
}
if ((temp_get17>=request.getValue())) {
int temp_get18;
if (stock.get(request.getKey()) != null) {
temp_get18 = stock.get(request.getKey());
if ((temp_get37>=request.getValue())) {
int temp_get38;
if (stock.get(request.getKey()) != null) {
temp_get38 = stock.get(request.getKey());
} else {
temp_get38 = 0;
}
temp_if15 = new AbstractMap.SimpleEntry<>(request.getKey(), new AbstractMap.SimpleEntry<>(request.getValue(), (temp_get38-request.getValue())));
} else {
temp_get18 = 0;
int temp_get39;
if (stock.get(request.getKey()) != null) {
temp_get39 = stock.get(request.getKey());
} else {
temp_get39 = 0;
}
temp_if15 = new AbstractMap.SimpleEntry<>(request.getKey(), new AbstractMap.SimpleEntry<>(0, temp_get39));
}
temp_if7 = new AbstractMap.SimpleEntry<>(request.getKey(), new AbstractMap.SimpleEntry<>(request.getValue(), (temp_get18-request.getValue())));
} else {
int temp_get19;
if (stock.get(request.getKey()) != null) {
temp_get19 = stock.get(request.getKey());
} else {
temp_get19 = 0;
}
temp_if7 = new AbstractMap.SimpleEntry<>(request.getKey(), new AbstractMap.SimpleEntry<>(0, temp_get19));
}
this.value = temp_if7;
this.value = temp_if15;
Form form = new Form();
form.param("handling", new ObjectMapper().writeValueAsString(this.value));
Entity<Form> entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED);
String result = client.target("http://localhost:8080").path(this.stock).request().post(entity, String.class);
form = new Form();
form.param("handling", new ObjectMapper().writeValueAsString(this.value));
entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED);
result = client.target("http://localhost:8080").path(shipping).request().put(entity, String.class);
String result = client.target("http://localhost:8080").path("/stock").request().post(entity, String.class);
}
 
@Produces(MediaType.APPLICATION_JSON)
@GET
@Getter
public Map.Entry<String, Map.Entry<Integer, Integer>> getValue() {
View
35
src/main/java/stockManagement/pull/Shipping.java
import pushPullRefactor.State;
 
import com.fasterxml.jackson.core.JsonProcessingException;
 
 
@Path("/shipping")
@Resource("shipping")
@Component
@Resource("shipping")
public class Shipping {
@State
private Map.Entry<String, Integer> value;
private Client client = ClientBuilder.newClient();
@PUT
@Message("handling")
public void updateHandling(@FormParam("handling") String handling_json) throws JsonProcessingException {
Map.Entry<String, Map.Entry<Integer, Integer>> handling;
{
Map<String, Map<String, Integer>> i = new ObjectMapper().readValue(handling_json, HashMap.class);
handling = new AbstractMap.SimpleEntry<>(i.entrySet().iterator().next().getKey(),
new AbstractMap.SimpleEntry<>(Integer.parseInt(i.entrySet().iterator().next().getValue().entrySet().iterator().next().getKey()), i.entrySet().iterator().next().getValue().entrySet().iterator().next().getValue()));
}
this.value = new AbstractMap.SimpleEntry<>(handling.getKey(), handling.getValue().getKey());
}
@PullReference("handling")
@Pushable
String handling = "/handling";
@Produces(MediaType.APPLICATION_JSON)
@GET
@Getter
public Map.Entry<String, Integer> getValue() {
return value;
Map<String, Map<String, Integer>> handling_json = client.target("http://localhost:8080").path(handling).request().get(HashMap.class);
Map.Entry<String, Map.Entry<Integer, Integer>> handling = new AbstractMap.SimpleEntry<>(handling_json.entrySet().iterator().next().getKey(), new AbstractMap.SimpleEntry<>(Integer.parseInt(handling_json.entrySet().iterator().next().getValue().entrySet().iterator().next().getKey()), handling_json.entrySet().iterator().next().getValue().entrySet().iterator().next().getValue()));
return new AbstractMap.SimpleEntry<>(handling.getKey(), handling.getValue().getKey());
}
}