taskadapter / redmine-java-api

Redmine Java API
Apache License 2.0
269 stars 162 forks source link

Add time entries manager #258

Closed albfan closed 8 years ago

albfan commented 8 years ago

I guess it is only add A manager on

https://github.com/taskadapter/redmine-java-api/blob/0d4e0c01d26f136ba75942a76b3050e89ee463d6/src/main/java/com/taskadapter/redmineapi/RedmineManager.java#L56

I can provide pull request.

Another option would be to allow third-party code to access to transport inside RedmineManager, as

transport.getObject(TimeEntry.class)

seems ready to be used

https://github.com/taskadapter/redmine-java-api/blob/dccf43b06f35b8edadb8ee09936dc35bf1da3217/src/main/java/com/taskadapter/redmineapi/internal/Transport.java#L113https://github.com/taskadapter/redmine-java-api/blob/dccf43b06f35b8edadb8ee09936dc35bf1da3217/src/main/java/com/taskadapter/redmineapi/internal/Transport.java#L113

alexeyOnGitHub commented 8 years ago

hi! can you please describe your use-cases? what operations do you want that class to support? what would be the expected params and return values? once agreed on requirements, we can extract/refactor code. does this make sense? :)

albfan commented 8 years ago

Sure. I'm revamping redminejavacli

https://albfan.github.io/RedmineJavaCLI/userguide/

and want to provide missing features, esential for daily use, and after provide some of them

Next step is to access to time entries to check your updates (in day, week, month)

But I don't have easy access to timeEntries manager or at least to Transport to make a low level call to getObject() and output timeentries, reports...

Example for all projects on last two weeks: http://www.redmine.org/time_entries.json?f[]=spent_on&f[]=user_id&f[]=&op[spent_on]=l2w&op[user_id]==&v[user_id][]=me

Example for project "foo": http://www.redmine.org/projects/foo/time_entries.json?f[]=spent_on&f[]=user_id&f[]=&op[spent_on]=l2w&op[user_id]==&v[user_id][]=me

See above link don't work on redmine.org (at least for me), but on my redmine install it does

{
    "time_entries": [
        {
        "id": 4311,
        "project": {
            "id": 10,
            "name": "Bar"
        },
        "issue": {
            "id": 3576
        },
        "user": {
            "id": 20,
            "name": "Alberto Fanjul"
        },
        "activity": {
            "id": 13,
            "name": "Pruebas"
        },
        "hours": 1.0,
        "comments": "",
        "spent_on": "2016-07-05",
        "created_on": "2016-07-05T13:34:17Z",
        "updated_on": "2016-07-05T13:34:17Z"
    },  {
        "id": 4301,
        "project": {
            "id": 28,
            "name": "Foo"
        },
        "issue": {
            "id": 3845
        },
        "user": {
            "id": 20,
            "name": "Alberto Fanjul"
        },
        "activity": {
            "id": 9,
            "name": "Desarrollo"
        },
        "hours": 6.0,
        "comments": "",
        "spent_on": "2016-07-05",
        "created_on": "2016-07-05T10:56:28Z",
        "updated_on": "2016-07-05T12:22:28Z"
    }, {
        "id": 4299,
        "project": {
            "id": 10,
            "name": "Bar"
        },
        "issue": {
            "id": 3576
        },
        "user": {
            "id": 20,
            "name": "Alberto Fanjul"
        },
        "activity": {
            "id": 9,
            "name": "Desarrollo"
        },
        "hours": 5.0,
        "comments": "",
        "spent_on": "2016-07-04",
        "created_on": "2016-07-04T14:53:27Z",
        "updated_on": "2016-07-04T14:53:27Z"
    },
        ... 
        {
        "id": 4298,
        "project": {
            "id": 28,
            "name": "Foo"
        },
        "issue": {
            "id": 3838
        },
        "user": {
            "id": 20,
            "name": "Alberto Fanjul"
        },
        "activity": {
            "id": 10,
            "name": "Análisis"
        },
        "hours": 2.0,
        "comments": "",
        "spent_on": "2016-07-04",
        "created_on": "2016-07-04T14:51:20Z",
        "updated_on": "2016-07-04T14:51:20Z"
    }],
    "total_count": 24,
    "offset": 0,
    "limit": 25
}

I want to mention I hacked your library using map with duplicates to perform such form params queries

https://github.com/albfan/RedmineJavaCLI/commit/2bc51901f2f8252525a2d2258593082979ba7122

So input is a Map from everything accepted on /time_entries/report and output is a list of TimeEntry objects.

if you don't have time for this I can start coding on a fork while you point out guidelines, high level code hints and everything not standard for your codebase on my proposal. I feel this can be working on monday (I would love to add this feature to my CLI as soon as possible) but in long term I don't want to depend on my own redmine-java-api fork.

alexeyOnGitHub commented 8 years ago

there are several methods in IssueManager that work with time entries. e.g. this one: https://github.com/taskadapter/redmine-java-api/blob/master/src/main/java/com/taskadapter/redmineapi/IssueManager.java#L252

why is that one not sufficient?

albfan commented 8 years ago

Opps! I did use

https://github.com/taskadapter/redmine-java-api/blob/master/src/main/java/com/taskadapter/redmineapi/IssueManager.java#L225

but never expect to find a method for time entries on IssueManager. Is that intentional?

I see it is from a no released version yet. My approach is to use https://jitpack.io

I'm using :

repositories {
  ...
  maven { url "https://jitpack.io" }
}
dependencies {
  compile 'com.github.taskadapter:redmine-java-api:26e81c'
  //compile 'com.github.taskadapter:redmine-java-api:master-SNAPSHOT' //this would develop on the edge

...

Is that ok? Any recommendations or plans to tag 2.7.0? I want my team to upgrade the cli without fuss

alexeyOnGitHub commented 8 years ago

sorry for the confusion. I added a usage sample to the README file today. time entries are related to issues and thus historically were managed by IssueManager. there was a one-off method for them. now that we have more methods related to time entries, it may be time to extact this into a new class indeed. I haven't seen https://jitpack.io/ before. looks like an interesting concept. I don't want to get into overhead of managing two parallel versions - 2.7.x and 3.0.x - I barely have enough time for one. :) so I will make this change in the master branch and it will go into 3.0.0.

the reason why 3.x is not released yet is because there is an old request pending to support updating empty/null fields. there are several possible approaches for that (feel free to read open issues and review couple sample implementations in branches). whatever is chosen, it will break backward compatibility, and it would make sense to release this as a big major update (3.0.0). but since I'm not actively working on this library these days, and there is no one else willing to design or otherwise help with this, it gets postponed...

alexeyOnGitHub commented 8 years ago

done

albfan commented 8 years ago

All sounds great.

The lifecycle management for this project rocks!. I will review it all and adopt some on mines.

Let's see if there's anything I can do/propose to release that 3.0.0 version