// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java
// @Entity(name = "BF_ACCOUNT")
// public class Account {
// 
//     @Id
//     @GeneratedValue(strategy = GenerationType.IDENTITY)
//     @Column(name = "ID")
//     private Long id;
// 
//     @Column(name = "DESCRIPTION")
//     private String description;
// 
//     @Column(name = "ON_BUDGET")
//     private boolean onBudget;
// 
//     @ManyToOne(fetch = FetchType.LAZY)
//     @JoinColumn(name = "USER_ID")
//     private User user;
// 
//     public Account() {
//     }
// 
//     public Account(String description, boolean onBudget, User user) {
//         this.description = description;
//         this.onBudget = onBudget;
//         this.user = user;
//     }
// 
//     public Long getId() {
//         return id;
//     }
// 
//     public Account setId(Long id) {
//         this.id = id;
//         return this;
//     }
// 
//     public String getDescription() {
//         return description;
//     }
// 
//     public Account setDescription(String description) {
//         this.description = description;
//         return this;
//     }
// 
//     public boolean isOnBudget() {
//         return onBudget;
//     }
// 
//     public Account setOnBudget(boolean onBudget) {
//         this.onBudget = onBudget;
//         return this;
//     }
// 
//     public User getUser() {
//         return user;
//     }
// 
//     public Account setUser(User user) {
//         this.user = user;
//         return this;
//     }
// }
// 
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/web/UserController.java
// @RestController
// @RequestMapping("/users")
// public class UserController {
// 
//     private UserService userService;
//     private UserResourceAssembler userResourceAssembler;
// 
//     @InitBinder
//     protected void initBinder(WebDataBinder binder) {
//         // TODO Maybe define global validators?
//         binder.setValidator(new UserResourceValidator());
//     }
// 
// 
//     @Autowired
//     public UserController(UserService userService, UserResourceAssembler userResourceAssembler) {
//         this.userService = userService;
//         this.userResourceAssembler = userResourceAssembler;
//     }
// 
//     /**
//      * List all users in no given order.
//      */
//     @GetMapping
//     public Resources<UserResource> list() {
//         List<User> users = userService.list();
//         List<UserResource> resources = userResourceAssembler.toResources(users);
//         final Link selfRel = linkTo(methodOn(UserController.class).list()).withSelfRel();
//         return new Resources<>(resources, selfRel);
//     }
// 
//     /**
//      * Get one user.
//      */
//     @GetMapping("/{userId}")
//     public Resource<UserResource> get(@PathVariable("userId") long userId) {
//         User user = userService.get(userId);
//         final UserResource userResource = userResourceAssembler.toResource(user);
//         return new Resource<>(userResource);
//     }
// 
//     /**
//      * Create an user.
//      */
//     @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE)
//     public ResponseEntity<UserResource> create(@RequestBody @Valid UserResource userResource) {
//         User user = userService.create(userResource.getName(), userResource.getCurrency());
//         final UserResource createdUserResource = userResourceAssembler.toResource(user);
//         return new ResponseEntity<>(createdUserResource, HttpStatus.OK);
//     }
// }


import de.budgetfreak.accounting.domain.Account;
import de.budgetfreak.usermanagement.web.UserController;
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
import org.springframework.stereotype.Component;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
package de.budgetfreak.accounting.web;



/**
 * Assembler for {@link AccountResource}.
 */
@Component
public class AccountResourceAssembler extends ResourceAssemblerSupport<Account, AccountResource> {

    public AccountResourceAssembler() {
        super(AccountController.class, AccountResource.class);
    }

    @Override
    public AccountResource toResource(Account entity) {
        final AccountResource accountResource = new AccountResource(entity.getDescription(), entity.isOnBudget());
        accountResource.add(linkTo(methodOn(AccountController.class).get(entity.getUser().getId(), entity.getId())).withSelfRel());
// Path: server/accounting/src/main/java/de/budgetfreak/accounting/domain/Account.java
// @Entity(name = "BF_ACCOUNT")
// public class Account {
// 
//     @Id
//     @GeneratedValue(strategy = GenerationType.IDENTITY)
//     @Column(name = "ID")
//     private Long id;
// 
//     @Column(name = "DESCRIPTION")
//     private String description;
// 
//     @Column(name = "ON_BUDGET")
//     private boolean onBudget;
// 
//     @ManyToOne(fetch = FetchType.LAZY)
//     @JoinColumn(name = "USER_ID")
//     private User user;
// 
//     public Account() {
//     }
// 
//     public Account(String description, boolean onBudget, User user) {
//         this.description = description;
//         this.onBudget = onBudget;
//         this.user = user;
//     }
// 
//     public Long getId() {
//         return id;
//     }
// 
//     public Account setId(Long id) {
//         this.id = id;
//         return this;
//     }
// 
//     public String getDescription() {
//         return description;
//     }
// 
//     public Account setDescription(String description) {
//         this.description = description;
//         return this;
//     }
// 
//     public boolean isOnBudget() {
//         return onBudget;
//     }
// 
//     public Account setOnBudget(boolean onBudget) {
//         this.onBudget = onBudget;
//         return this;
//     }
// 
//     public User getUser() {
//         return user;
//     }
// 
//     public Account setUser(User user) {
//         this.user = user;
//         return this;
//     }
// }
// 
// Path: server/user-management/src/main/java/de/budgetfreak/usermanagement/web/UserController.java
// @RestController
// @RequestMapping("/users")
// public class UserController {
// 
//     private UserService userService;
//     private UserResourceAssembler userResourceAssembler;
// 
//     @InitBinder
//     protected void initBinder(WebDataBinder binder) {
//         // TODO Maybe define global validators?
//         binder.setValidator(new UserResourceValidator());
//     }
// 
// 
//     @Autowired
//     public UserController(UserService userService, UserResourceAssembler userResourceAssembler) {
//         this.userService = userService;
//         this.userResourceAssembler = userResourceAssembler;
//     }
// 
//     /**
//      * List all users in no given order.
//      */
//     @GetMapping
//     public Resources<UserResource> list() {
//         List<User> users = userService.list();
//         List<UserResource> resources = userResourceAssembler.toResources(users);
//         final Link selfRel = linkTo(methodOn(UserController.class).list()).withSelfRel();
//         return new Resources<>(resources, selfRel);
//     }
// 
//     /**
//      * Get one user.
//      */
//     @GetMapping("/{userId}")
//     public Resource<UserResource> get(@PathVariable("userId") long userId) {
//         User user = userService.get(userId);
//         final UserResource userResource = userResourceAssembler.toResource(user);
//         return new Resource<>(userResource);
//     }
// 
//     /**
//      * Create an user.
//      */
//     @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE)
//     public ResponseEntity<UserResource> create(@RequestBody @Valid UserResource userResource) {
//         User user = userService.create(userResource.getName(), userResource.getCurrency());
//         final UserResource createdUserResource = userResourceAssembler.toResource(user);
//         return new ResponseEntity<>(createdUserResource, HttpStatus.OK);
//     }
// }


// Path: server/accounting/src/main/java/de/budgetfreak/accounting/web/AccountResourceAssembler.java
import de.budgetfreak.accounting.domain.Account;
import de.budgetfreak.usermanagement.web.UserController;
import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
import org.springframework.stereotype.Component;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;

package de.budgetfreak.accounting.web;



/**
 * Assembler for {@link AccountResource}.
 */
@Component
public class AccountResourceAssembler extends ResourceAssemblerSupport<Account, AccountResource> {

    public AccountResourceAssembler() {
        super(AccountController.class, AccountResource.class);
    }

    @Override
    public AccountResource toResource(Account entity) {
        final AccountResource accountResource = new AccountResource(entity.getDescription(), entity.isOnBudget());
        accountResource.add(linkTo(methodOn(AccountController.class).get(entity.getUser().getId(), entity.getId())).withSelfRel());
        accountResource.add(linkTo(methodOn(UserController.class).get(entity.getUser().getId())).withRel("user"));