Newer
Older
algoLike.push / src / main / java / algoLike / push / ResultBySelectingA.java
package algoLike.push;

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 com.fasterxml.jackson.core.JsonProcessingException;

@Path("/resultBySelectingA")
@Component
public class ResultBySelectingA {
	private Client client = ClientBuilder.newClient();
	private Map.Entry<Boolean, Map.Entry<Integer, Integer>> value;
	@PUT
	public void selectAndAttackA(@FormParam("t") int t, @FormParam("g") int g, @FormParam("b") List<Map.Entry<Integer, Boolean>> b, @FormParam("a") int a) throws JsonProcessingException {
		this.value = new AbstractMap.SimpleEntry<>((b.get(t).getKey()==g),  new AbstractMap.SimpleEntry<>(t, a));
		Form form = new Form();
		form.param("resultBySelectingA", new ObjectMapper().writeValueAsString(this.value));
		Entity<Form> entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED);
		String result = client.target("http://localhost:8080").path("/handsA/resultBySelectingA").request().post(entity, String.class);
		form = new Form();
		form.param("resultBySelectingA", new ObjectMapper().writeValueAsString(this.value));
		entity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED);
		result = client.target("http://localhost:8080").path("/handsB/resultBySelectingA").request().post(entity, String.class);
	}
	@Produces(MediaType.APPLICATION_JSON)
	@GET
	public Map.Entry<Boolean, Map.Entry<Integer, Integer>> getValue() {
		return value;
	}
}