Newer
Older
stockManagement.pull / src / main / java / stockManagement / pull / Shipping.java
Shinji on 25 Jan 2023 1 KB パッケージの修正
package stockManagement.pull;

import java.util.*;
import javax.ws.rs.*;
import javax.ws.rs.client.*;
import javax.ws.rs.core.*;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.databind.ObjectMapper;

import pushPullRefactor.Getter;
import pushPullRefactor.Message;
import pushPullRefactor.PullReference;
import pushPullRefactor.Pushable;
import pushPullRefactor.Resource;
import pushPullRefactor.State;

import com.fasterxml.jackson.core.JsonProcessingException;


@Path("/shipping")
@Resource("shipping")
@Component
public class Shipping {
	private Client client = ClientBuilder.newClient();
	@PullReference("handling")
	@Pushable
	String handling = "/handling";
	@Produces(MediaType.APPLICATION_JSON)
	@GET
	@Getter
	public Map.Entry<String, Integer> getValue() {
		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());
	}
}