diff --git a/src/main/java/stockManagement/pull/Handling.java b/src/main/java/stockManagement/pull/Handling.java index 33c1eb3..524c521 100644 --- a/src/main/java/stockManagement/pull/Handling.java +++ b/src/main/java/stockManagement/pull/Handling.java @@ -10,7 +10,6 @@ import pushPullRefactor.*; import com.fasterxml.jackson.core.JsonProcessingException; - @Path("/handling") @Component @Resource("handling") @@ -20,18 +19,11 @@ private Map.Entry available; @Cache("request") private Map.Entry request; - @PushReference("shipping") - @Pullable("direct") - private String shipping = "/shipping"; - - @PushReference("stock") - private String stock = "/stock"; - @State private Map.Entry> value; @Path("/available") @PUT - @Message({"available", "shortage"}) + @Message({}) public void updateAvailable(@FormParam("available") String available_json, @FormParam("shortage") String shortage_json) throws JsonProcessingException { Map shortage = new HashMap<>(); { @@ -44,44 +36,39 @@ available = new AbstractMap.SimpleEntry<>(i.entrySet().iterator().next().getKey(), i.entrySet().iterator().next().getValue()); } this.available = available; - Map.Entry> temp_if6; - int temp_get14; + Map.Entry> 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
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 stock = new HashMap<>(); { @@ -94,40 +81,37 @@ request = new AbstractMap.SimpleEntry<>(i.entrySet().iterator().next().getKey(), i.entrySet().iterator().next().getValue()); } this.request = request; - Map.Entry> temp_if7; - int temp_get17; + Map.Entry> 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 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