View Javadoc
1   package ca.uhn.fhir.rest.api;
2   
3   /*
4    * #%L
5    * HAPI FHIR - Core Library
6    * %%
7    * Copyright (C) 2014 University Health Network
8    * %%
9    * Licensed under the Apache License, Version 2.0 (the "License");
10   * you may not use this file except in compliance with the License.
11   * You may obtain a copy of the License at
12   * 
13   *      http://www.apache.org/licenses/LICENSE-2.0
14   * 
15   * Unless required by applicable law or agreed to in writing, software
16   * distributed under the License is distributed on an "AS IS" BASIS,
17   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18   * See the License for the specific language governing permissions and
19   * limitations under the License.
20   * #L%
21   */
22  
23  import ca.uhn.fhir.model.dstu.resource.OperationOutcome;
24  import ca.uhn.fhir.model.primitive.IdDt;
25  
26  public class MethodOutcome {
27  
28  	private IdDt myId;
29  	private OperationOutcome myOperationOutcome;
30  	private IdDt myVersionId;
31  	private Boolean myCreated;
32  
33  	/**
34  	 * Constructor
35  	 */
36  	public MethodOutcome() {
37  	}
38  
39  	/**
40  	 * Constructor
41  	 * 
42  	 * @param theId
43  	 *            The ID of the created/updated resource
44  	 */
45  	public MethodOutcome(IdDt theId) {
46  		myId = theId;
47  	}
48  
49  	/**
50  	 * Constructor
51  	 * 
52  	 * @param theId
53  	 *            The ID of the created/updated resource
54  	 * 
55  	 * @param theCreated
56  	 *            If not null, indicates whether the resource was created (as opposed to being updated). This is generally not needed, since the server can assume based on the method being called
57  	 *            whether the result was a creation or an update. However, it can be useful if you are implementing an update method that does a create if the ID doesn't already exist.
58  	 */
59  	public MethodOutcome(IdDt theId, Boolean theCreated) {
60  		myId = theId;
61  		myCreated = theCreated;
62  	}
63  
64  	/**
65  	 * Constructor
66  	 * 
67  	 * @param theId
68  	 *            The ID of the created/updated resource
69  	 * 
70  	 * @param theOperationOutcome
71  	 *            The operation outcome to return with the response (or null for none)
72  	 */
73  	public MethodOutcome(IdDt theId, OperationOutcome theOperationOutcome) {
74  		myId = theId;
75  		myOperationOutcome = theOperationOutcome;
76  	}
77  
78  	/**
79  	 * Constructor
80  	 * 
81  	 * @param theId
82  	 *            The ID of the created/updated resource
83  	 * 
84  	 * @param theOperationOutcome
85  	 *            The operation outcome to return with the response (or null for none)
86  	 * 
87  	 * @param theCreated
88  	 *            If not null, indicates whether the resource was created (as opposed to being updated). This is generally not needed, since the server can assume based on the method being called
89  	 *            whether the result was a creation or an update. However, it can be useful if you are implementing an update method that does a create if the ID doesn't already exist.
90  	 */
91  	public MethodOutcome(IdDt theId, OperationOutcome theOperationOutcome, Boolean theCreated) {
92  		myId = theId;
93  		myOperationOutcome = theOperationOutcome;
94  		myCreated = theCreated;
95  	}
96  
97  	/**
98  	 * @deprecated Use the constructor which accepts a single IdDt parameter, and include the logical ID and version ID in that IdDt instance
99  	 */
100 	public MethodOutcome(IdDt theId, IdDt theVersionId) {
101 		myId = theId;
102 		myVersionId = theVersionId;
103 	}
104 
105 	/**
106 	 * @deprecated Use the constructor which accepts a single IdDt parameter, and include the logical ID and version ID in that IdDt instance
107 	 */
108 	public MethodOutcome(IdDt theId, IdDt theVersionId, OperationOutcome theOperationOutcome) {
109 		myId = theId;
110 		myVersionId = theVersionId;
111 		myOperationOutcome = theOperationOutcome;
112 	}
113 
114 	public IdDt getId() {
115 		return myId;
116 	}
117 
118 	/**
119 	 * Returns the {@link OperationOutcome} resource to return to the client or <code>null</code> if none.
120 	 * 
121 	 * @return This method <b>will return null</b>, unlike many methods in the API.
122 	 */
123 	public OperationOutcome getOperationOutcome() {
124 		return myOperationOutcome;
125 	}
126 
127 	/**
128 	 * @deprecated {@link MethodOutcome#getId()} should return the complete ID including version if it is available
129 	 */
130 	public IdDt getVersionId() {
131 		return myVersionId;
132 	}
133 
134 	public Boolean getCreated() {
135 		return myCreated;
136 	}
137 
138 	/**
139 	 * If not null, indicates whether the resource was created (as opposed to being updated). This is generally not needed, since the server can assume based on the method being called whether the
140 	 * result was a creation or an update. However, it can be useful if you are implementing an update method that does a create if the ID doesn't already exist.
141 	 * 
142 	 * @param theCreated
143 	 *            If not null, indicates whether the resource was created (as opposed to being updated). This is generally not needed, since the server can assume based on the method being called
144 	 *            whether the result was a creation or an update. However, it can be useful if you are implementing an update method that does a create if the ID doesn't already exist.
145 	 */
146 	public void setCreated(Boolean theCreated) {
147 		myCreated = theCreated;
148 	}
149 
150 	/**
151 	 * @param theId
152 	 *            The ID of the created/updated resource
153 	 */
154 	public void setId(IdDt theId) {
155 		myId = theId;
156 	}
157 
158 	/**
159 	 * Sets the {@link OperationOutcome} resource to return to the client. Set to <code>null</code> (which is the default) if none.
160 	 */
161 	public void setOperationOutcome(OperationOutcome theOperationOutcome) {
162 		myOperationOutcome = theOperationOutcome;
163 	}
164 
165 	/**
166 	 * @deprecated Put the ID and version ID into the same IdDt instance and pass it to {@link #setId(IdDt)}
167 	 */
168 	public void setVersionId(IdDt theVersionId) {
169 		myVersionId = theVersionId;
170 	}
171 
172 }