root/sandbox/nuxeo-api-sample/trunk/src/main/java/org/nuxeo/ecm/sample/workflow/WAPISample.java

Revision 25736, 2.7 kB (checked in by sfermigier, 1 year ago)

Indent properly.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 /*
2  * (C) Copyright 2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
3  *
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the GNU Lesser General Public License
6  * (LGPL) version 2.1 which accompanies this distribution, and is available at
7  * http://www.gnu.org/licenses/lgpl.html
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * Contributors:
15  *     Nuxeo - initial API and implementation
16  *
17  * $Id$
18  */
19
20 package org.nuxeo.ecm.sample.workflow;
21
22 import java.util.Date;
23
24 import javax.security.auth.login.LoginContext;
25
26 import org.nuxeo.ecm.platform.workflow.api.client.delegate.WAPIBusinessDelegate;
27 import org.nuxeo.ecm.platform.workflow.api.client.wfmc.WAPI;
28 import org.nuxeo.ecm.platform.workflow.api.client.wfmc.WMFilter;
29 import org.nuxeo.ecm.platform.workflow.api.client.wfmc.WMWorkItemIterator;
30 import org.nuxeo.ecm.platform.workflow.api.client.wfmc.impl.WMFilterImpl;
31 import org.nuxeo.ecm.platform.workflow.api.common.WorkflowConstants;
32 import org.nuxeo.ecm.sample.SampleApplication;
33 import org.nuxeo.runtime.api.Framework;
34
35 /**
36  *
37  * @author <a href="mailto:ja@nuxeo.com">Julien Anguenot</a>
38  */
39 public class WAPISample extends SampleApplication {
40
41     private static final String USERNAME = "Administrator";
42
43     private static final String PWD = "Administrator";
44
45     @Override
46     protected void runSample() throws Exception {
47         try {
48             LoginContext loginCtx = Framework.login(USERNAME, PWD);
49             loginCtx.login();
50
51             WAPI wapi = WAPIBusinessDelegate.getWAPI();
52
53             Date deadline = new Date();
54             WMFilter filter = new WMFilterImpl(
55                     WorkflowConstants.WORKFLOW_TASK_PROP_DUE_DATE, WMFilter.LT,
56                     deadline);
57
58             WMWorkItemIterator it = wapi.listWorkItems(filter);
59             System.out.println("Number of items where due date is strictly before now :"
60                     + it.size());
61
62             filter = new WMFilterImpl(
63                     WorkflowConstants.WORKFLOW_TASK_PROP_DUE_DATE, WMFilter.GT,
64                     deadline);
65             it = wapi.listWorkItems(filter);
66             System.out.println("Number of items where due date is strictly after now :"
67                     + it.size());
68
69             // loginCtx.logout();
70         } catch (Throwable t) {
71             t.printStackTrace();
72         }
73     }
74
75     public static void main(String[] args) {
76         // run my application!
77         new WAPISample().start(args);
78     }
79
80 }
Note: See TracBrowser for help on using the browser.