Skip to content
This repository was archived by the owner on Apr 6, 2018. It is now read-only.
Fabian Buch edited this page Jun 20, 2012 · 1 revision

JMite

Infrastructure

Simply declare jMite as dependency:


<dependency>
  <groupId>org.jmite</groupId>
  <artifactId>org.jmite</groupId>
  <version>0.1.0.RELEASE</version>

Setup Mite Client

Setting up a client instance of Mite is as easy as using the Builder class inside MiteClient and configuring it according to your needs. You essentially have to provide two things.

  1. The server name (typically your Mite account URL)
  2. Authentication data
    1. Username / password combination
    2. An API key (go to http://youraccount.mite.yo.lk/myself to get one)

So the code might look something like this.


Mite mite = new MiteClient.Builder("http://youraccount.mite.yo.lk")
  .withUsernameAndPassword("your@username.com","password").build();

Working with the client

Having achieved that you can pretty much navigate the resources as you would do via the URL. So retrieving all Services registered for your account would look like this:


List<Services> services = mite.services().all();

Service service = mite.services().get(4711);
service.setNote("My new note");
mite.services().save(service);

As you can see, getting a single Service can be done using the get method providing the id of the Service. Updating a new Service is just a matter of manipulating the retrieved instance and calling save on the Services resource. Creating new Service resources works the same way. Just provide a fresh instance to save().

TimeEntries and filters on them

Accessing all TimeEntries does not make much sense. Most often you want to filter TimeEntries by a specific project, time period or something like this. Hence the TimeEntries resources offers query() to return a TimeEntryQuery, that you configure as you like and call execute() then:


TimeEntryQuery query = mite.timeEntries().query();

List entries = query.withProject(4712).within(TimePeriod.THIS_MONTH).execute();

This query will return all entries for the given project within the current month. Time periods can be expressed via the TimePeriod enum, a start and end DateMidnight or a single DateMidnight to configure the query to return entries for the given single day.

Navigating between other resources and time entries works the same way. You create a new query, apply already retrieved resources to the appropriate role and execute the query.


TimeEntry entry = mite.timeEntries().get(4715);
Project project = mite.projects().get(4716);
TimeEntryQuery query = mite.timeEntries().query();

List entries = query.withCustomer(entry).execute();
List entries = query.with(project).execute();

The first query will return all entries of the customer that the reference entry was made for. The second query will return all entries for the project retrieved before.

Tracking time

To be implemented

Futher links