1 package org.collectionspace.services.batch.nuxeo;
3 import java.util.ArrayList;
4 import java.util.HashMap;
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;
13 public class CreateAndLinkLoanOutBatchJob implements BatchInvocable {
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;
22 public CreateAndLinkLoanOutBatchJob() {
23 CreateAndLinkLoanOutBatchJob.setupClassStatics();
25 completionStatus = STATUS_UNSTARTED;
27 results = new InvocationResults();
31 private static void setupClassStatics() {
32 if(invocationModes == null ) {
33 invocationModes = new ArrayList<String>(1);
34 invocationModes.add(INVOCATION_MODE_SINGLE);
39 * @return a set of modes that this plugin can support on invocation. Must be non-empty.
41 public List<String> getSupportedInvocationModes() {
42 return CreateAndLinkLoanOutBatchJob.invocationModes;
46 * Sets the invocation context for the batch job. Called before run().
47 * @param context an instance of InvocationContext.
49 public void setInvocationContext(InvocationContext context) {
50 this.context = context;
54 * Sets the invocation context for the batch job. Called before run().
55 * @param context an instance of InvocationContext.
57 public void setResourceMap(ResourceMap resourceMap) {
61 * The main work logic of the batch job. Will be called after setContext.
64 completionStatus = STATUS_UNSTARTED;
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;
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.
79 public int getCompletionStatus() {
80 return completionStatus;
84 * @return information about the batch job actions and results
86 public InvocationResults getResults() {
87 if(completionStatus != STATUS_COMPLETE)
93 * @return a user-presentable note when an error occurs in batch processing. Will only
94 * be called if getCompletionStatus() returns STATUS_ERROR.
96 public String getErrorInfo() {