]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
b0f77f4e3089133c324d07b7369871226a12d821
[tmp/jakarta-migration.git] /
1 package org.collectionspace.services.batch.nuxeo;
2
3 import java.util.ArrayList;
4 import java.util.HashMap;
5 import java.util.List;
6
7 import org.collectionspace.services.batch.BatchInvocable;
8 import org.collectionspace.services.common.ResourceBase;
9 import org.collectionspace.services.common.ResourceMap;
10 import org.collectionspace.services.common.invocable.InvocationContext;
11 import org.collectionspace.services.common.invocable.InvocationResults;
12
13 public class CreateAndLinkLoanOutBatchJob implements BatchInvocable {
14
15         private static ArrayList<String> invocationModes = null;
16         private InvocationContext context;
17         private int completionStatus;
18         private HashMap<String,ResourceBase> resourceMap;
19         private InvocationResults results;
20         private String errorInfo;
21         
22         public CreateAndLinkLoanOutBatchJob() {
23                 CreateAndLinkLoanOutBatchJob.setupClassStatics();
24                 context = null;
25                 completionStatus = STATUS_UNSTARTED;
26                 resourceMap = null;
27                 results = new InvocationResults();
28                 errorInfo = "";
29         }
30
31         private static void setupClassStatics() {
32                 if(invocationModes == null ) {
33                         invocationModes = new ArrayList<String>(1);
34                         invocationModes.add(INVOCATION_MODE_SINGLE);
35                 }
36         }
37
38         /**
39          * @return a set of modes that this plugin can support on invocation. Must be non-empty.
40          */
41         public List<String> getSupportedInvocationModes() {
42                 return CreateAndLinkLoanOutBatchJob.invocationModes;
43         }
44         
45         /**
46          * Sets the invocation context for the batch job. Called before run().
47          * @param context an instance of InvocationContext.
48          */
49         public void setInvocationContext(InvocationContext context) {
50                 this.context = context;
51         }
52
53         /**
54          * Sets the invocation context for the batch job. Called before run().
55          * @param context an instance of InvocationContext.
56          */
57         public void setResourceMap(ResourceMap resourceMap) {
58         }
59
60         /**
61          * The main work logic of the batch job. Will be called after setContext.
62          */
63         public void run() {
64                 completionStatus = STATUS_UNSTARTED;
65                 try {
66                         Thread.sleep(1000);
67                 } catch(Exception e) {}
68                 results.setPrimaryURICreated(null);
69                 results.setNumAffected(0);
70                 results.setUserNote("CreateAndLinkLoanOutBatchJob pretended to do work, and completed");
71                 completionStatus = STATUS_COMPLETE;
72         }
73
74         /**
75          * @return one of the STATUS_* constants, or a value from 1-99 to indicate progress.
76          * Implementations need not support partial completion (progress) values, and can transition
77          * from STATUS_MIN_PROGRESS to STATUS_COMPLETE.
78          */
79         public int getCompletionStatus() {
80                 return completionStatus;
81         }
82
83         /**
84          * @return information about the batch job actions and results
85          */
86         public InvocationResults getResults() {
87                 if(completionStatus != STATUS_COMPLETE)
88                         return null;
89                 return results;
90         }
91
92         /**
93          * @return a user-presentable note when an error occurs in batch processing. Will only
94          * be called if getCompletionStatus() returns STATUS_ERROR.
95          */
96         public String getErrorInfo() {
97                 return errorInfo;
98         }
99
100
101 }