package com.robocubs4205.cubscout.rest.v1;

import com.robocubs4205.cubscout.model.Robot;
import org.springframework.hateoas.mvc.IdentifiableResourceAssemblerSupport;

import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;

/**
 * Created by trevor on 2/18/17.
 */
public class RobotResourceAssembler extends IdentifiableResourceAssemblerSupport<Robot, RobotResource> {
    public RobotResourceAssembler() {
        super(RobotController.class, RobotResource.class);
    }

    @Override
    public RobotResource toResource(Robot entity) {
        RobotResource resource = createResource(entity);
        resource.setRobotId(entity.getId());
        resource.setNumber(entity.getNumber());
        resource.setYear(entity.getYear());
        resource.setName(entity.getName());
        resource.add(linkTo(TeamController.class).slash(entity.getTeam()).withRel("team"));
        resource.add(linkTo(RobotController.class).slash(entity).slash("matches")
                                                  .withRel("matches"));
        return resource;
    }
}

@@ -1034,24 +1034,116 @@
 matches%22));%0A
+        resource.add(linkTo(GameController.class).slash(entity.getGame()).withRel(%22game%22));%0A
         retu

add link to game to json robot resource