Task samples

Basics

Task fields description:

Field Type Description Mandatory

Id

Long

Internal task id.

It is automatically set by the application.

 Not applicable.

Owner

String

It contains the OpenKM user ID.

It is automatically set by the application.

Not applicable.

Subject

String

The topic of the task.

Yes.

Description

String

The description of the task.

No.

Start

Calendar

When the task might start.

Yes.

End

Calendar

When the task might end.

No.

Status

TaskStatus

The task status.

You administer the list of status values.

Yes.

Project

TaskProject

The project related with the task.

You administer the list of project values.

Yes.

Type

TaskType

The task type.

You administer the list of task type values.

 Yes.

Progress

Integer

The numeric progress status.

The range of allowed values is from 0 to 100, where 100% indicates a completed task.

 Yes.

RepeatGroup

Long

When a task is repeated over time it is a member of a group. The group is identified by a unique repeat group ID.

No.

ReminderStartValue

Integer

How many days before the task starts, the system might send an email notification to the user.

No.

ReminderEndValue

Integer

How many days before the task ends, the system might send an email notification to the user.

No.

ReminderStartUnit

String

Reminder start units.

Allowed values:

  • "m" for minutes.
  • "h" for hours.
  • "d" for days.

Mandatory when ReminderStartValue is greater than 0.

ReminderEndUnit

String

Reminder end units.

Allowed values:

  • "m" for minutes.
  • "h" for hours.
  • "d" for days.

Mandatory when ReminderEndValue is greater than 0.

Users

Set<String>

Collection of users assigned to the task.

No. But at least one user or role should be assigned.

Roles

Set<String>

Collection of roles assigned to the task.

No. But at least one user or role should be assigned.

Documents

Set<String>

List of UUIDs of the related documents.

No.

Folders

Set<String>

List of UUIDs of the related folders.

No.

Mails

Set<String>

List of UUIDs of the related mails.

No.

Records

Set<String>

List of UUIDs of the related records.

No.

On all methods, you'll see a parameter named "token". When accessing the application via SOAP, the login process returns a token, which is used to identify the user on all the exposed methods. By default, from the application execution context you must use the "null" value, which indicates the application must use the "user session".

In special cases, you might be "promoted as Administrator" using the "administrator token".

String systemToken = DbSessionManager.getInstance().getSystemToken();

Suggested code sample

First, you must create the webservice object:

OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

Then should login using the method "login". You can access the "login" method from webservice object "ws" as is shown below:

ws.login(user, password);

Once you are logged in with the webservices, the session is kept in the webservice object. Then you can use the other API methods.

At this point you can use all the Task methods from "task" class as is shown below:

ws.task.getAssigned(projectId, typeId, statusId, orderColumn, true, 0, 10, subject);

Methods

getAssigned

Description:

Method Return values Description

getAssigned(long projectId, long typeId, long statusId, String orderColumn, boolean orderAsc, int offset, int limit, Calendar from, Calendar to, String subject)

List<Task>

Retrieve a list of tasks assigned to a user, filtered and paginated.

Filter parameters description:

  • The projectId parameter must be a valid project id.
  • The typeId parameters must be a valid type id.
  • The statusId parameters must be a valid status id.
  • The orderColumn parameter must be a valid parameter of the TaskManagerTask class. Commonly used parameters are "subject", "start", "end", "progress", "owner".  More information at javadoc documentation.
  • The orderAsc parameter orders ascending or descending.
  • The 'from' date to filter (this parameter is optional)
  • The 'to' date to filter (this parameter is optional)
  • The subject parameter: the topic of the task.

The parameters "limit" and "offset" allow you to retrieve just a portion of the results of a query.

  • The parameter "limit" is used to limit the number of results returned.
  • The parameter "offset" specifies how many results to skip before starting to return results.

For example, if your query has 1000 results but you only want to return the first 10, you should use these values:

  • limit=10
  • offset=0

Now suppose you want to show the results from 11-20, you should use these values:

  • limit=10
  • offset=10

The parameters "from" and "to" are optional and allow you to retrieve just a portion of the results of a query.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.*;
import com.openkm.sdk4j.impl.OKMWebservices;

import java.util.Calendar;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);

            String orderColumn = "subject"; // A valid TaskManagerTask class parameter name used in HQL query
            Calendar from = Calendar.getInstance();
            from.set(from.get(Calendar.YEAR), Calendar.NOVEMBER, 1);

            Calendar to = Calendar.getInstance();
            to.set(from.get(Calendar.YEAR), Calendar.NOVEMBER, 30);

            long statusId = 1; // A valid task status id
            long projectId = 1; // A valid project id
            long typeId = 1; // A valid type id

            TaskList listAssigned = ws.task.getAssigned(projectId, typeId, statusId, orderColumn, true, 0, 10, from, to, "");
            for (Task task : listAssigned.getTasks()) {
                System.out.println(task);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getActive

Description:

Method Return values Description

getActive(long projectId, long typeId, long statusId, String orderColumn, boolean orderAsc, int offset, int limit, Calendar from, Calendar to, String subject)

List<Task>

Retrieve a list of active tasks assigned to a user, filtered and paginated.

Filter parameters description:

  • The projectId parameter must be a valid project id.
  • The typeId parameters must be a valid type id.
  • The statusId parameters must be a valid status id.
  • The orderColumn parameter must be a valid parameter of the TaskManagerTask class. Commonly used parameters are "subject", "start", "end", "progress", "owner".  More information at javadoc documentation.
  • The orderAsc parameter orders ascending or descending.
  • The 'from' date to filter (this parameter is optional)
  • The 'to' date to filter (this parameter is optional)
  • The subject parameter: the topic of the task.

The parameters "limit" and "offset" allow you to retrieve just a portion of the results of a query.

  • The parameter "limit" is used to limit the number of results returned.
  • The parameter "offset" specifies how many results to skip before starting to return results.

For example, if your query has 1000 results but you only want to return the first 10, you should use these values:

  • limit=10
  • offset=0

Now suppose you want to show the results from 11-20, you should use these values:

  • limit=10
  • offset=10

The parameters "from" and "to" are optional and allow you to retrieve just a portion of the results of a query.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.*;
import com.openkm.sdk4j.impl.OKMWebservices;

import java.util.Calendar;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);

            String orderColumn = "subject"; // A valid TaskManagerTask class parameter name used in HQL query
            Calendar from = Calendar.getInstance();
            from.set(from.get(Calendar.YEAR), Calendar.NOVEMBER, 1);

            Calendar to = Calendar.getInstance();
            to.set(from.get(Calendar.YEAR), Calendar.NOVEMBER, 30);

            long statusId = 1; // A valid task status id
            long projectId = 1; // A valid project id
            long typeId = 1; // A valid type id

            TaskList listAssigned = ws.task.getActive(projectId, typeId, statusId, orderColumn, true, 0, 10, from, to, "");
            for (Task task : listAssigned.getTasks()) {
                System.out.println(task);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getFinished

Description:

Method Return values Description

getFinished(long projectId, long typeId, long statusId, String orderColumn, boolean orderAsc, int offset, int limit, Calendar from, Calendar to, String subject)

List<Task>

Retrieve a list of finished tasks assigned to a user, filtered and paginated.

Filter parameters description:

  • The projectId parameter must be a valid project id.
  • The typeId parameters must be a valid type id.
  • The statusId parameters must be a valid status id.
  • The orderColumn parameter must be a valid parameter of the TaskManagerTask class. Commonly used parameters are "subject", "start", "end", "progress", "owner".  More information at javadoc documentation.
  • The orderAsc parameter orders ascending or descending.
  • The 'from' date to filter (this parameter is optional)
  • The 'to' date to filter (this parameter is optional)
  • The subject parameter: the topic of the task.

The parameters "limit" and "offset" allow you to retrieve just a portion of the results of a query.

  • The parameter "limit" is used to limit the number of results returned.
  • The parameter "offset" specifies how many results to skip before starting to return results.

For example, if your query has 1000 results but you only want to return the first 10, you should use these values:

  • limit=10
  • offset=0

Now suppose you want to show the results from 11-20, you should use these values:

  • limit=10
  • offset=10

The parameters "from" and "to" are optional and allow you to retrieve just a portion of the results of a query.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.*;
import com.openkm.sdk4j.impl.OKMWebservices;

import java.util.Calendar;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);

            String orderColumn = "subject"; // A valid TaskManagerTask class parameter name used in HQL query
            Calendar from = Calendar.getInstance();
            from.set(from.get(Calendar.YEAR), Calendar.NOVEMBER, 1);

            Calendar to = Calendar.getInstance();
            to.set(from.get(Calendar.YEAR), Calendar.NOVEMBER, 30);

            long statusId = 1; // A valid task status id
            long projectId = 1; // A valid project id
            long typeId = 1; // A valid type id

            TaskList listAssigned = ws.task.getFinished(projectId, typeId, statusId, orderColumn, true, 0, 10, from, to, "");
            for (Task task : listAssigned.getTasks()) {
                System.out.println(task);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getNotified

Description:

Method Return values Description

getNotified(long projectId, long typeId, long statusId, String orderColumn, boolean orderAsc, int offset, int limit, Calendar from, Calendar to, String subject)

List<Task>

Retrieve a list of notified tasks assigned to a user, filtered and paginated.

Filter parameters description:

  • The projectId parameter must be a valid project id.
  • The typeId parameters must be a valid type id.
  • The statusId parameters must be a valid status id.
  • The orderColumn parameter must be a valid parameter of the TaskManagerTask class. Commonly used parameters are "subject", "start", "end", "progress", "owner".  More information at javadoc documentation.
  • The orderAsc parameter orders ascending or descending.
  • The 'from' date to filter (this parameter is optional)
  • The 'to' date to filter (this parameter is optional)
  • The subject parameter: the topic of the task.

The parameters "limit" and "offset" allow you to retrieve just a portion of the results of a query.

  • The parameter "limit" is used to limit the number of results returned.
  • The parameter "offset" specifies how many results to skip before starting to return results.

For example, if your query has 1000 results but you only want to return the first 10, you should use these values:

  • limit=10
  • offset=0

Now suppose you want to show the results from 11-20, you should use these values:

  • limit=10
  • offset=10

The parameters "from" and "to" are optional and allow you to retrieve just a portion of the results of a query.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.*;
import com.openkm.sdk4j.impl.OKMWebservices;

import java.util.Calendar;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);

            String orderColumn = "subject"; // A valid TaskManagerTask class parameter name used in HQL query
            Calendar from = Calendar.getInstance();
            from.set(from.get(Calendar.YEAR), Calendar.NOVEMBER, 1);

            Calendar to = Calendar.getInstance();
            to.set(from.get(Calendar.YEAR), Calendar.NOVEMBER, 30);

            long statusId = 1; // A valid task status id
            long projectId = 1; // A valid project id
            long typeId = 1; // A valid type id

            TaskList listAssigned = ws.task.getNotified(projectId, typeId, statusId, orderColumn, true, 0, 10, from, to, "");
            for (Task task : listAssigned.getTasks()) {
                System.out.println(task);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getStatus

Description:

Method Return values Description

getStatus()

List<TaskStatus>

Retrieve a list of all the task statuses.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.TaskStatus;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            for (TaskStatus ts : ws.task.getStatus()) {
                System.out.println(ts);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getProjects

Description:

Method Return values Description

getProjects(boolean filterActive)

List<TaskProject>

Retrieve a list of all the task projects.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.TaskProject;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            for (TaskProject tp : ws.task.getTProjects(true)) {
                System.out.println(tp);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getTypes

Description:

Method Return values Description

getTypes(boolean filterActive)

List<TaskType>

Retrieve a list of all the task types.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.TaskType;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            for (TaskType tt : ws.task.getTypes(true)) {
                System.out.println(tt);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getAssignedCount

Description:

Method Return values Description

getAssignedCount(long statusId, long projectId, long typeId)

long

Returns the number of tasks assigned to a user.

Filter parameters description:

  • The statusId parameter must be a valid status id.
  • The projectId parameter must be a valid project id.
  • The typeId parameter must be a valid type id.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long projectId = 1; // A valid project id
            long typeId = 1; // A valid type id
            long statusId = 1; // A valid status id
            long total = ws.task.getAssignedCount(statusId, projectId, typeId);
            System.out.println(total);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getActiveCount

Description:

Method Return values Description

getActiveCount(long statusId, long projectId, long typeId)

Long

Returns the number of active tasks for a user.

Filter parameters description:

  • The statusId parameter must be a valid status id.
  • The projectId parameter must be a valid project id.
  • The typeId parameter must be a valid type id.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long projectId = 1; // A valid project id
            long typeId = 1; // A valid type id
            long statusId = 1; // A valid status id
            long total = ws.task.getActiveCount(statusId, projectId, typeId);
            System.out.println(total);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getFinishedCount

Description:

Method Return values Description

getFinishedCount(long statusId, long projectId, long typeId)

Long

Returns the number of finished tasks for a user.

Filter parameters description:

  • The statusId parameter must be a valid status id.
  • The projectId parameter must be a valid project id.
  • The typeId parameter must be a valid type id.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long projectId = 1; // A valid project id
            long typeId = 1; // A valid type id
            long statusId = 1; // A valid status id
            long total = ws.task.getFinishedCount(statusId, projectId, typeId);
            System.out.println(total);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getNotifiedCount

Description:

Method Return values Description

getNotifiedCount(long statusId, long projectId, long typeId)

Long

Returns the number of notified tasks assigned to a user.

Filter parameters description:

  • The statusId parameter must be a valid status id.
  • The projectId parameter must be a valid project id.
  • The typeId parameter must be a valid type id.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long projectId = 1; // A valid project id
            long typeId = 1; // A valid type id
            long statusId = 1; // A valid status id
            long total = ws.task.getNotifiedCount(statusId, projectId, typeId);
            System.out.println(total);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

create

Description:

Method Return values Description

create(String subject, String start, String end, String description, long statusId, long projectId,
            long typeId, String user, List<String> notificationUsers, List<String> externalUsers, List<String> relatedDocuments,
            List<String> relatedFolders, List<String> relatedRecords, List<String> relatedMails, String repeatExpression,
            String repeatExpression, String formatDate, int repeatTimes, String reminderStartUnit, int reminderStartValue,
            String reminderEndUnit, int reminderEndValue)

Task

Create a new task.

The repeatExpression parameters description:

The commands are executed by cron when the minute, hour, and month fields match the current time, and when at least one of the two day fields (day of month, or day of week) match the current time. The scheduler examines crontab entries once every minute. The time and date fields are:

 * * * * * command to execute
? ? ? ? ?
? ? ? ? ?
? ? ? ? ????? day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
? ? ? ?????????? month (1 - 12)
? ? ??????????????? day of month (1 - 31)
? ???????????????????? hour (0 - 23)
????????????????????????? min (0 - 59)

 

   

Example:

package com.openkm;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Task;
import com.openkm.sdk4j.impl.OKMWebservices;
import com.openkm.sdk4j.util.ISO8601;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            String subject = "task subject";

            Calendar calendar = Calendar.getInstance();
            String start = ISO8601.formatBasic(calendar);

            calendar.add(Calendar.DATE, 15);
            String end = ISO8601.formatBasic(calendar);

            String description = "description test";

            long statusId = 1; // A valid task status id
            long projectId = 1; // A valid project id
            long typeId = 1; // A valid type id

            List<String> notificationUsers = new ArrayList<>();
            notificationUsers.add("gnujavasergio");
            notificationUsers.add("sochoa");

            List<String> externalUsers = new ArrayList<>();
            externalUsers.add("gnu.java.sergio@gmail.com");

            List<String> relatedDocuments = new ArrayList<>();
            relatedDocuments.add("d701c503-87fc-4a9e-829e-478dc375eb83");
            relatedDocuments.add("f02053e3-2264-4040-bb84-67983a0208f7");

            List<String> relatedFolders = new ArrayList<>();
            relatedFolders.add("0a777b34-f518-4da7-9e58-8b1425e05add");
            relatedFolders.add("271cc3aa-218e-4574-8065-c34c704f4a20");

            List<String> relatedMails = new ArrayList<>();
            relatedMails.add("3ae1bb26-acdf-4463-a0c1-06cc62f55b95");
            relatedMails.add("c599be73-7831-4e93-be91-453baeda2b00");

            List<String> relatedRecords = new ArrayList<>();
            relatedRecords.add("96801b33-e92e-436b-8ed7-5d8dea904673");
            relatedRecords.add("23b50095-aa18-4d16-ae75-74b994a2f2b4");

            String currentDate = "31/04/2018";
            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
            calendar.setTime(sdf.parse(currentDate));

            String repeatExpression = "0 0 1 * *";

            calendar.add(Calendar.DATE, 1);
            String repeatUntil = ISO8601.formatBasic(calendar);

            // createTask
            Task newTask = ws.task.create(subject, start, end, description, statusId, projectId, typeId,
                    "okmAdmin", notificationUsers, externalUsers, relatedDocuments, relatedFolders, relatedRecords, relatedMails, repeatExpression, repeatUntil,
                    "dd-MM-yyyy", 10, "m", 5, "m", 10);
            System.out.println(newTask);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

update

Description:

Method Return values Description

update(long taskId, String subject, String start, String end, String description, long statusId,
            long projectId, long typeId, String user, List<String> notificationUsers, List<String> externalUsers,
            List<String> relatedDocuments, List<String> relatedFolders, List<String> relatedRecords, List<String> relatedMails,
            String owner, String repeatExpression, String repeatUntil, String formatDate, int repeatTimes, int progress,
            String reminderStartUnit, int reminderStartValue, String reminderEndUnit, int reminderEndValue)

Task

Update a task.

The repeatExpression parameters description:

The commands are executed by cron when the minute, hour, and month fields match the current time, and when at least one of the two day fields (day of month, or day of week) match the current time. The scheduler examines crontab entries once every minute. The time and date fields are:

 * * * * * command to execute
? ? ? ? ?
? ? ? ? ?
? ? ? ? ????? day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
? ? ? ?????????? month (1 - 12)
? ? ??????????????? day of month (1 - 31)
? ???????????????????? hour (0 - 23)
????????????????????????? min (0 - 59)

Example:

package com.openkm;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Task;
import com.openkm.sdk4j.impl.OKMWebservices;
import com.openkm.sdk4j.util.ISO8601;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            String subject = "update task subject";

            Calendar calendar = Calendar.getInstance();
            String start = ISO8601.formatBasic(calendar);

            calendar.add(Calendar.DATE, 15);
            String end = ISO8601.formatBasic(calendar);

            String description = "Update description test";

            long statusId = 1; // A valid task status id
            long projectId = 1; // A valid project id
            long typeId = 1; // A valid type id

            List<String> notificationUsers = new ArrayList<>();
            notificationUsers.add("gnujavasergio");
            notificationUsers.add("sochoa");

            List<String> externalUsers = new ArrayList<>();
            externalUsers.add("gnu.java.sergio@gmail.com");

            List<String> relatedDocuments = new ArrayList<>();
            relatedDocuments.add("d701c503-87fc-4a9e-829e-478dc375eb83");
            relatedDocuments.add("f02053e3-2264-4040-bb84-67983a0208f7");

            List<String> relatedFolders = new ArrayList<>();
            relatedFolders.add("0a777b34-f518-4da7-9e58-8b1425e05add");
            relatedFolders.add("271cc3aa-218e-4574-8065-c34c704f4a20");

            List<String> relatedMails = new ArrayList<>();
            relatedMails.add("3ae1bb26-acdf-4463-a0c1-06cc62f55b95");
            relatedMails.add("c599be73-7831-4e93-be91-453baeda2b00");

            List<String> relatedRecords = new ArrayList<>();
            relatedRecords.add("96801b33-e92e-436b-8ed7-5d8dea904673");
            relatedRecords.add("23b50095-aa18-4d16-ae75-74b994a2f2b4");

            String currentDate = "31/04/2018";
            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
            calendar.setTime(sdf.parse(currentDate));

            String repeatExpression = "0 0 1 * *";

            calendar.add(Calendar.DATE, 1);
            String repeatUntil = ISO8601.formatBasic(calendar);

            long taskId = 1;
            Task updateTask = ws.task.update(taskId, subject, start, end, description,
                    statusId, projectId, typeId, "okmAdmin", notificationUsers, externalUsers,
                    relatedDocuments, relatedFolders, relatedRecords, relatedMails,
                    "okmAdmin", repeatExpression, repeatUntil, "dd-MM-yyyy",
                    10, 10, "m", 5, "m", 10);
            System.out.println(updateTask);;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getTask

Description:

Method Return values Description

getTask(long taskId)

Task

Retrieve a task.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Task;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long taskId = 2;
            Task task = ws.task.getTask(taskId);
            System.out.println(task);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

delete

Description:

Method Return values Description

delete(long taskId)

void

Delete a task.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
    	String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long taskId = 2;
            ws.task.delete(taskId);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

createProject

Description:

Method Return values Description

createProject(String name, boolean active, String description)

TaskProject

Create a new task project.

The boolean parameter "active", indicates if your project is active or not.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.TaskProject;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            TaskProject tp = ws.task.createProject("Project one", true, "Description");
            System.out.println(tp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

updateProject

Description:

Method Return values Description

updateProject(long projectId, boolean active, String name, String description, )

TaskProject

Update a task project.

The boolean parameter "active", indicates if your project is active or not.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.TaskProject;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long projectId = 4; // A valid project id
            TaskProject tp = ws.task.getTaskProject(projectId);
            System.out.println(tp);
            tp = ws.task.updateProject(projectId, false, "cancelled", "Description");
            System.out.println(tp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

deleteProject

Description:

Method Return values Description

deleteTProject(long projectId)

void

Delete a task project.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long projectId = 5; // A valid project id
            ws.task.deleteProject(projectId);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getProject

Description:

Method Return values Description

getProject(long projectId)

TaskProject

Return a task project object by id.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.TaskProject;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long projectId = 1; // A valid project id
            TaskProject tp = ws.task.getProject(projectId);
            System.out.println(tp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getProjects

Description:

Method Return values Description

getProjects(boolean filterActive)

List<TaskProject>

Retrieve a list of all task projects.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.TaskProject;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            for (TaskProject tp : ws.task.getProjects(true)) {
                System.out.println(tp);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

createType

Description:

Method Return values Description

createType(String name, boolean active, String description)

TaskType

Create a new task type.

The boolean parameter "active" indicates whether your type is active or not.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.TaskType;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            TaskType tt = ws.task.createType("Type one", true, "Description");
            System.out.println(tt);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

updateType

Description:

Method Return values Description

updateType(long typeId, boolean active, String name, String description)

TaskType

Update a task type.

The boolean parameter "active" indicates whether your type is active or not.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.TaskType;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long typeId = 4; // A valid type id
            TaskType tp = ws.task.getTaskType(typeId);
            System.out.println(tp);
            tp = ws.task.updateType(typeId, false, "Type one", "Description");
            System.out.println(tp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

deleteType

Description:

Method Return values Description

deleteType(long typeId)

void

Delete a task type.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long typeId = 4; // A valid type id
            ws.task.deleteType(typeId);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getType

Description:

Method Return values Description

getType(long typeId)

TaskType

Return a task type object by id.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.TaskType;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long typeId = 1; // A valid type id
            TaskType tt = ws.task.getType(typeId);
            System.out.println(tt);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getTypes

Description:

Method Return values Description

getTypes(boolean filterActive)

List<TaskType>

Retrieve a list of all task types.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.TaskType;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            for (TaskType tt : ws.task.getTypes(true)) {
                System.out.println(tt);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

createStatus

Description:

Method Return values Description

createStatus(String name, boolean finish)

TaskStatus

Create a new task status.

Depending on your logic, several statuses can be ending statuses. For example, statuses named "closed" or "cancelled". The boolean parameter "finish" indicates whether your status is an "ending status".

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.TaskStatus;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            TaskStatus ts = ws.task.createStatus("cancelled", true);
            System.out.println(ts);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

updateStatus

Description:

Method Return values Description

updateStatus(long statusId, String name, boolean finish)

TaskStatus

Update a task status.

Depending on your logic, several statuses can be ending statuses. For example, statuses named "closed" or "cancelled". The boolean parameter "finish" indicates whether your status is an "ending status".

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.TaskStatus;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long statusId = 1; // A valid task id
            TaskStatus ts = ws.task.getTaskStatus(statusId);
            System.out.println(ts);
            ts = ws.task.updateStatus(statusId, "cancelled", true);
            System.out.println(ts);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

deleteStatus

Description:

Method Return values Description

deleteStatus(long statusId)

void

Delete a task status.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long statusId = 4; // A valid status id
            ws.task.deleteStatus(statusId);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getStatus

Description:

Method Return values Description

getStatus(long statusId)

TaskStatus

Return a task status object by id.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.TaskStatus;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long statusId = 1; // A valid status id
            TaskStatus ts = ws.task.getStatus(statusId);
            System.out.println(ts);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getStatus

Description:

Method Return values Description

getStatus()

List<TaskStatus>

Retrieve a list of all task statuses.

Example:

package com.openkm;

import com.openkm.api.OKMTask;
import com.openkm.bean.TaskStatus;
import com.openkm.util.ContextWrapper;

public class Test {

    public static void main(String[] args) {
        try {
            OKMTask okmTask = ContextWrapper.getContext().getBean(OKMTask.class);
            for (TaskStatus ts : okmTask.getStatus(null)) {
                System.out.println(ts);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

createNote

Description:

Method Return values Description

createNote(long taskId, String text)

TaskNote

Create a new note for a task.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.TaskNote;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long taskId = 1; // A valid task id
            TaskNote tn = ws.task.createNote(taskId, "New note");
            System.out.println(tn);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

updateNote

Description:

Method Return values Description

updateNote(long noteId, String text)

TaskNote

Update a note for a task.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.TaskNote;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long noteId = 1; // A valid note id
            TaskNote tn = ws.task.updateNote(noteId, "Note updated");
            System.out.println(tn);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

deleteNote

Description:

Method Return values Description

deleteNote(String token, long noteId)

void

Delete a note from a task.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long noteId = 1; // A valid note id
            ws.task.deleteNote(noteId);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getNotes

Description:

Method Return values Description

getNotes(long taskId)

List<TaskNote>

Retrieve a list of all notes for a task.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.TaskNote;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long taskId = 1; // A valid task id
            for (TaskNote tn : ws.task.getNotes(taskId)) {
                System.out.println(tn);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}