private static void createOverdueLoanForCopy(Library library, Copy copy, int position)
     throws IllegalLoanOperationException {
   Loan l = library.createAndAddLoan(getCustomer(library, position), copy);
   GregorianCalendar pickup = l.getPickupDate();
   pickup.add(GregorianCalendar.MONTH, -1);
   pickup.add(GregorianCalendar.DAY_OF_MONTH, -position % 15);
   l.setPickupDate(pickup);
 }
 private static void createLoansForCopy(Library library, Copy copy, int position, int count)
     throws IllegalLoanOperationException {
   // Create Loans in the past
   for (int i = count; i > 1; i--) {
     Loan l = library.createAndAddLoan(getCustomer(library, position + i), copy);
     GregorianCalendar pickup = l.getPickupDate();
     pickup.add(GregorianCalendar.MONTH, -i);
     pickup.add(GregorianCalendar.DAY_OF_MONTH, position % 10);
     l.setPickupDate(pickup);
     GregorianCalendar ret = (GregorianCalendar) pickup.clone();
     ret.add(GregorianCalendar.DAY_OF_YEAR, position % 10 + i * 2);
     l.returnCopy(ret);
   }
   // Create actual open loans
   if (position % 2 == 0) {
     Loan l = library.createAndAddLoan(getCustomer(library, position), copy);
     GregorianCalendar pickup = l.getPickupDate();
     pickup.add(GregorianCalendar.DAY_OF_MONTH, -position % 10);
     l.setPickupDate(pickup);
   }
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View root = inflater.inflate(R.layout.ausleihen_fragment_details, container, false);
    TextView priceContent = (TextView) root.findViewById(R.id.priceLarge);
    ;
    TextView manufacturerContent = (TextView) root.findViewById(R.id.manufacturerText);
    TextView stateContent = (TextView) root.findViewById(R.id.stateText);
    final TextView availabilityContent = (TextView) root.findViewById(R.id.availabilityText);

    Bundle args = getArguments();
    final Loan thisLoan = (Loan) args.getSerializable("ausleihen");
    priceContent.setText(thisLoan.getGadget().getPrice() + ".-");
    IToolbarSetter toolbar = (IToolbarSetter) getActivity();
    toolbar.setTitle(thisLoan.getGadget().getName());
    manufacturerContent.setText(thisLoan.getGadget().getManufacturer());
    stateContent.setText(thisLoan.getGadget().getCondition().name());
    DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
    availabilityContent.setText(
        dateFormat.format(thisLoan.getPickupDate().getTime() + 7 * 24 * 60 * 60 * 1000));

    return root;
  }
  //    @PostConstruct
  public void init() {

    System.out.println("PostConstruct method call...");

    User ulan = new User();
    ulan.setName("Ulan");

    userDAO.save(ulan);

    User carl = new User("Carl");
    userDAO.save(carl);

    //        System.out.println(ulan);

    List<User> userList = userDAO.getUserList();

    System.out.println("UserList:");

    for (User u : userList) {
      System.out.println(u);
    }

    Loan loan1 = new Loan();
    loan1.setAmount(300);
    loan1.setTerm(15);

    Loan loan2 = new Loan();
    loan2.setAmount(200);
    loan2.setTerm(10);

    Loan loan3 = new Loan();
    loan3.setAmount(400);
    loan3.setTerm(20);

    User user1 = userList.get(0);

    user1.addLoan(loan1);
    user1.addLoan(loan2);

    User user2 = userList.get(1);

    user2.addLoan(loan3);

    userDAO.save(user1);
    userDAO.save(user2);

    List<Loan> loanList = loanDAO.getLoanList();
    System.out.println("Printing loanList:");
    for (Loan loan : loanList) {
      System.out.println(loan);
    }

    System.out.println("Printing whole DB:");
    userList = userDAO.getUserList();
    for (User u : userList) {
      System.out.println(u);
      for (Loan loan : u.getLoanList()) {
        System.out.println(loan);
      }
    }

    System.out.println("Printing list for User with ID 1");
    user1 = userDAO.getById(1);
    for (Loan loan : user1.getLoanList()) {
      System.out.println(loan);
    }

    System.out.println("Printing list for User with ID 2");
    user2 = userDAO.getById(2);
    for (Loan loan : user2.getLoanList()) {
      System.out.println(loan);
    }
  }