// 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/accounting/src/main/java/de/budgetfreak/accounting/service/AccountService.java
// @Service
// public class AccountService {
// 
//     private AccountRepository accountRepository;
//     private UserRepository userRepository;
// 
//     @Autowired
//     public AccountService(AccountRepository accountRepository, UserRepository userRepository) {
//         this.accountRepository = accountRepository;
//         this.userRepository = userRepository;
//     }
// 
//     /**
//      * Lists all accounts.
//      *
//      * @param userId The id of the user who's account we want to access.
//      */
//     public List<Account> list(long userId) {
//         return accountRepository.findByUserId(userId);
//     }
// 
//     /**
//      * Returns one account by id.
//      *
//      * @param id The id of the account.
//      */
//     public Account get(long id) {
//         return accountRepository.findOne(Example.of(new Account().setId(id))).orElse(null);
//     }
// 
//     /**
//      * Creates an account.
//      *
//      * @param userId      The user the account will belong to.
//      * @param description The description.
//      * @param onBudget    Whether the account will have an effect on the budget.
//      */
//     public Account create(long userId, String description, boolean onBudget) {
//         User user = userRepository.getOne(userId);
//         Account account = new Account(description, onBudget, user);
//         return accountRepository.saveAndFlush(account);
//     }
// }


import de.budgetfreak.accounting.domain.Account;
import de.budgetfreak.accounting.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.Resources;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
package de.budgetfreak.accounting.web;




/**
 * Controller for accessing accounts.
 */
@RestController
@RequestMapping("/users/{userId}/accounts")
public class AccountController {

// 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/accounting/src/main/java/de/budgetfreak/accounting/service/AccountService.java
// @Service
// public class AccountService {
// 
//     private AccountRepository accountRepository;
//     private UserRepository userRepository;
// 
//     @Autowired
//     public AccountService(AccountRepository accountRepository, UserRepository userRepository) {
//         this.accountRepository = accountRepository;
//         this.userRepository = userRepository;
//     }
// 
//     /**
//      * Lists all accounts.
//      *
//      * @param userId The id of the user who's account we want to access.
//      */
//     public List<Account> list(long userId) {
//         return accountRepository.findByUserId(userId);
//     }
// 
//     /**
//      * Returns one account by id.
//      *
//      * @param id The id of the account.
//      */
//     public Account get(long id) {
//         return accountRepository.findOne(Example.of(new Account().setId(id))).orElse(null);
//     }
// 
//     /**
//      * Creates an account.
//      *
//      * @param userId      The user the account will belong to.
//      * @param description The description.
//      * @param onBudget    Whether the account will have an effect on the budget.
//      */
//     public Account create(long userId, String description, boolean onBudget) {
//         User user = userRepository.getOne(userId);
//         Account account = new Account(description, onBudget, user);
//         return accountRepository.saveAndFlush(account);
//     }
// }


// Path: server/accounting/src/main/java/de/budgetfreak/accounting/web/AccountController.java
import de.budgetfreak.accounting.domain.Account;
import de.budgetfreak.accounting.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.Resources;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;

package de.budgetfreak.accounting.web;




/**
 * Controller for accessing accounts.
 */
@RestController
@RequestMapping("/users/{userId}/accounts")
public class AccountController {

    private AccountService accountService;