001/* 002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * bstefanescu 018 * vpasquier 019 */ 020package org.nuxeo.ecm.automation; 021 022import java.io.Serializable; 023import java.util.ArrayList; 024import java.util.HashMap; 025import java.util.List; 026import java.util.Map; 027 028/** 029 * Describes an operation chain execution. 030 * 031 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 032 */ 033public class OperationChain implements Serializable { 034 035 private static final long serialVersionUID = 1L; 036 037 protected final String id; 038 039 // (via REST for example) 040 protected final List<OperationParameters> operations; 041 042 protected final Map<String, Object> chainParameters; 043 044 protected String description; 045 046 /** 047 * @since 7.1 048 */ 049 protected String[] aliases; 050 051 protected boolean isPublic; // whether this chain is visible to clients 052 053 public OperationChain(String id) { 054 this.id = id; 055 operations = new ArrayList<OperationParameters>(); 056 chainParameters = new HashMap<String, Object>(); 057 } 058 059 public OperationChain(String id, List<OperationParameters> operations) { 060 this.id = id; 061 this.operations = operations; 062 chainParameters = new HashMap<String, Object>(); 063 } 064 065 public OperationChain(String id, List<OperationParameters> operations, Map<String, Object> chainParameters) { 066 this.id = id; 067 this.operations = operations; 068 this.chainParameters = chainParameters; 069 } 070 071 public String getId() { 072 return id; 073 } 074 075 /** 076 * @since 7.1 077 */ 078 public String[] getAliases() { 079 return aliases; 080 } 081 082 public String getDescription() { 083 return description; 084 } 085 086 public void setDescription(String description) { 087 this.description = description; 088 } 089 090 /** 091 * @since 7.1 092 */ 093 public void setAliases(String[] aliases) { 094 this.aliases = aliases; 095 } 096 097 public boolean isPublic() { 098 return isPublic; 099 } 100 101 public void setPublic(boolean isPublic) { 102 this.isPublic = isPublic; 103 } 104 105 public List<OperationParameters> getOperations() { 106 return operations; 107 } 108 109 public void add(OperationParameters op) { 110 operations.add(op); 111 } 112 113 public OperationParameters add(String operationId) { 114 OperationParameters op = new OperationParameters(operationId); 115 operations.add(op); 116 return op; 117 } 118 119 /** 120 * @since 5.7.2 Adding chain parameters 121 */ 122 public void addChainParameters(Map<String, Object> chainParameter) { 123 chainParameters.putAll(chainParameter); 124 } 125 126 /** 127 * @since 5.7.2 Getting chain parameters 128 */ 129 public Map<String, Object> getChainParameters() { 130 return chainParameters; 131 } 132 133}