Create the domain model

We're simulating a normal database driven web application with this example project, so lets create typical domain model classes. These won't actually get persisted in this example but the usage is exactly the same if they are. You can see the BandStand example in github for a fully worked database example.

Our domain model

We're going to use just two domain model classes - User and Meeting. Where User represents a user of the system who has a calendar of Meetings.

A couple of things you should take note of:

  • in this example we have the user's plaintext password available. If you only store a hash of the password in your real application thats ok.
  • we're storing the bytes of the calendar events in the icalData property, but its quite common to parse that data and store it in a structured form

I'll create these classes in the com.hellocaldav package:

 

package com.hellocaldav;

import java.util.List;

public class User {

    private String name;
    private String password;
    private List<Meeting> meetings;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public List<Meeting> getMeetings() {
        return meetings;
    }

    public void setMeetings(List<Meeting> meetings) {
        this.meetings = meetings;
    }
}

and the Meeting class...

 

package com.hellocaldav;

import java.util.Date;

public class Meeting {

    private long id;
    private String name;  // filename for the meeting. Must be unique within the user
    private Date modifiedDate;
    private byte[] icalData;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public Date getModifiedDate() {
        return modifiedDate;
    }

    public void setModifiedDate(Date modifiedDate) {
        this.modifiedDate = modifiedDate;
    }

    public byte[] getIcalData() {
        return icalData;
    }

    public void setIcalData(byte[] icalData) {
        this.icalData = icalData;
    }
}