View Javadoc
1   package org.argeo.activities;
2   
3   import java.util.Calendar;
4   import java.util.List;
5   
6   import javax.jcr.Node;
7   import javax.jcr.NodeIterator;
8   import javax.jcr.RepositoryException;
9   import javax.jcr.Session;
10  
11  import org.argeo.connect.AppService;
12  
13  /**
14   * Manage activity and tasks concepts in a Connect repository. Implementing
15   * applications should extend and/or override the canonical implementation in
16   * order to provide business specific behaviours.
17   * 
18   * The correct instance of this interface is usually acquired through the
19   * peopleService.
20   */
21  public interface ActivitiesService extends AppService {
22  
23  	/* ACTIVITIES */
24  
25  	/**
26  	 * Simply configures a simple activity using default manager (the current
27  	 * logged in user) and default date (now)
28  	 */
29  	public Node configureActivity(Node activity, String type, String title, String desc, List<Node> relatedTo)
30  			throws RepositoryException;
31  
32  	/**
33  	 * Creates a new simple activity using the default path
34  	 * 
35  	 * We use a distinct manager and activity date rather than JCR_CREATED and
36  	 * JCR_CREATED_BY fields because we cannot force these fields and this is
37  	 * problematic for instance when importing old activities
38  	 */
39  	public Node configureActivity(Node activity, String reporterId, String type, String title, String desc,
40  			List<Node> relatedTo, Calendar date) throws RepositoryException;
41  
42  	/**
43  	 * Returns the default activity English Label if defined.
44  	 * 
45  	 * It relies on the mixin of this node. If an activity Node is having more
46  	 * than one "activity type" mixin, the main type as returned by the
47  	 * {@link AppService#getMainNodeType(Node)} methods will be used.
48  	 */
49  	public String getActivityLabel(Node activity);
50  
51  	/**
52  	 * Retrieves a date to display depending on the node type.
53  	 * 
54  	 * @param activityNode
55  	 *            an activity or a task
56  	 * @return
57  	 */
58  	public Calendar getActivityRelevantDate(Node activityNode);
59  
60  	/* TASKS */
61  	/**
62  	 * Creates a new draft task with the minimum information
63  	 * 
64  	 * @param taskNodeType
65  	 */
66  	public Node configureTask(Node task, String taskNodeType, String title, String description, String assignedTo)
67  			throws RepositoryException;
68  
69  	/**
70  	 * Creates a new draft task with the given information.
71  	 * 
72  	 * @param session
73  	 * @param taskNodeType
74  	 * @param reporterId
75  	 * @param title
76  	 * @param description
77  	 * @param assignedTo
78  	 * @param relatedTo
79  	 * @param creationDate
80  	 * @param dueDate
81  	 * @param wakeUpDate
82  	 * @return
83  	 */
84  	public Node configureTask(Node task, String taskNodeType, String reporterId, String title, String description,
85  			String assignedTo, List<Node> relatedTo, Calendar creationDate, Calendar dueDate, Calendar wakeUpDate)
86  			throws RepositoryException;
87  
88  	public void setTaskDefaultStatus(Node taskNode, String taskNodeType) throws RepositoryException;
89  
90  	// public Node createPoll(Node parentNode, String reporterId, String
91  	// pollName, String title, String description,
92  	// String assignedTo, List<Node> relatedTo, Calendar creationDate, Calendar
93  	// dueDate, Calendar wakeUpDate)
94  	// throws RepositoryException;
95  
96  	/**
97  	 * Retrieves tasks assigned to one of the group that contain the username
98  	 * retrieved from the current session
99  	 */
100 	public NodeIterator getMyTasks(Session session, boolean onlyOpenTasks);
101 
102 	/**
103 	 * Retrieves tasks assigned to one of the group that contain this username
104 	 */
105 	public NodeIterator getTasksForUser(Session session, String username, boolean onlyOpenTasks);
106 
107 	/** Gets the display name of the assigned to group for this task */
108 	public String getAssignedToDisplayName(Node taskNode);
109 
110 	/**
111 	 * Updates the status of this task to the new passed status. It is also in
112 	 * charge of updating other task properties, typically after determining if
113 	 * the closed status of the task has changed.
114 	 * 
115 	 * It also enable to keep a cache of modified node if the update triggered
116 	 * modification or update on other nodes.
117 	 * 
118 	 * It will return true if anything has changed but *DOES NOT SAVE* the
119 	 * session
120 	 */
121 	public boolean updateStatus(String templateId, Node taskNode, String newStatus, List<String> modifiedPaths)
122 			throws RepositoryException;
123 
124 	/**
125 	 * Determines whether a task has been done. Application should override or
126 	 * extends this to provide specific behaviour
127 	 */
128 	public boolean isTaskDone(Node taskNode);
129 
130 	/**
131 	 * Determines whether is sleeping. Application should override or extends
132 	 * this to provide specific behaviour
133 	 */
134 	public boolean isTaskSleeping(Node taskNode);
135 
136 	/* MISCELLANEOUS */
137 }