View Javadoc
1   /***
2    * License Agreement.
3    * 
4    * JSPA (POJO-SP)
5    * 
6    * Copyright (C) 2009 HRX Pty Ltd
7    * 
8    * This file is part of JSPA.
9    * 
10   * JSPA is free software: you can redistribute it and/or modify it under the
11   * terms of the GNU Lesser General Public License version 3 as published by the
12   * Free Software Foundation.
13   * 
14   * JSPA is distributed in the hope that it will be useful, but WITHOUT ANY
15   * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16   * A PARTICULAR PURPOSE. See the Lesser General Public License for more details.
17   * 
18   * You should have received a copy of the GNU Lesser General Public License
19   * along with JSPA. If not, see <http://www.gnu.org/licenses/>.
20   */
21  package com.hrx.rasp.util.dao.metadata;
22  
23  import java.util.HashSet;
24  import java.util.Set;
25  
26  import com.hrx.rasp.util.dao.ResultSetProcessor;
27  import com.hrx.rasp.util.dao.annotations.IN;
28  import com.hrx.rasp.util.dao.annotations.INOUT;
29  import com.hrx.rasp.util.dao.annotations.OUT;
30  import com.hrx.rasp.util.dao.operation.OperationType;
31  
32  /***
33   * @author dan.stoica <dan.stoica@acslink.net.au>
34   *
35   */
36  public class StoredProcPkMetaData implements StoredProcMetaData
37  {
38  
39  	private OperationType operation;
40  
41  	private final Set<StoredProcField<IN>> paramsIn = new HashSet<StoredProcField<IN>>();
42  	private final Set<StoredProcField<OUT>> paramsOut = new HashSet<StoredProcField<OUT>>();
43  	private final Set<StoredProcField<INOUT>> paramsInOUT = new HashSet<StoredProcField<INOUT>>();
44  
45  	private final Set<StoredProcField<?>> primaryKeyParameters = new HashSet<StoredProcField<?>>();
46  
47  	private Class<ResultSetProcessor<Object>> resultSetProcessorClass;
48  
49  	@Override
50  	public void putInOutParameter(StoredProcField<INOUT> spField)
51  	{
52  		this.paramsInOUT.add(spField);
53  		putPkParameter(spField);
54  	}
55  
56  	@Override
57  	public void putInParameter(StoredProcField<IN> spField)
58  	{
59  		this.paramsIn.add(spField);
60  		putPkParameter(spField);
61  	}
62  
63  	@Override
64  	public void putOutParameter(StoredProcField<OUT> spField)
65  	{
66  		this.paramsOut.add(spField);
67  		putPkParameter(spField);
68  	}
69  
70  	@Override
71  	public void putPkParameter(StoredProcField<?> spField)
72  	{
73  		this.primaryKeyParameters.add(spField);
74  	}
75  
76  	@Override
77  	public void setOperationType(OperationType operation)
78  	{
79  		this.operation = operation;
80  	}
81  
82  	@Override
83  	public OperationType getOperationType()
84  	{
85  		return operation;
86  	}
87  
88  	@Override
89  	public void clear()
90  	{
91  		this.primaryKeyParameters.clear();
92  	}
93  
94  	public int getArgCount()
95  	{
96  		return this.primaryKeyParameters.size();
97  	}
98  
99  	/***
100 	 * @return the resultSetProcessorClass
101 	 */
102 	public Class<ResultSetProcessor<Object>> getResultSetProcessorClass()
103 	{
104 		return (Class<ResultSetProcessor<Object>>) resultSetProcessorClass;
105 	}
106 
107 	/***
108 	 * @param resultSetProcessorClass
109 	 *            the resultSetProcessorClass to set
110 	 */
111 	public void setResultSetProcessorClass(Class<ResultSetProcessor<Object>> resultSetProcessorClass)
112 	{
113 		this.resultSetProcessorClass = resultSetProcessorClass;
114 	}
115 
116 	/***
117 	 * @return the paramsIn
118 	 */
119 	public Set<StoredProcField<IN>> getInParameters()
120 	{
121 		return paramsIn;
122 	}
123 
124 	/***
125 	 * @return the paramsOut
126 	 */
127 	public Set<StoredProcField<OUT>> getOutParameters()
128 	{
129 		return paramsOut;
130 	}
131 
132 	/***
133 	 * @return
134 	 */
135 	public Set<StoredProcField<INOUT>> getInOutParameters()
136 	{
137 		return paramsInOUT;
138 	}
139 
140 	public Set<StoredProcField<?>> getPrimaryKeyParameters()
141 	{
142 		return primaryKeyParameters;
143 	}
144 
145 }