| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||||
| EOStoredProcedure |
|
| 1.4615384615384615;1.462 |
| 1 | /* |
|
| 2 | Wotonomy: OpenStep design patterns for pure Java applications. |
|
| 3 | Copyright (C) 2001 Michael Powers |
|
| 4 | ||
| 5 | This library is free software; you can redistribute it and/or |
|
| 6 | modify it under the terms of the GNU Lesser General Public |
|
| 7 | License as published by the Free Software Foundation; either |
|
| 8 | version 2.1 of the License, or (at your option) any later version. |
|
| 9 | ||
| 10 | This library is distributed in the hope that it will be useful, |
|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 13 | Lesser General Public License for more details. |
|
| 14 | ||
| 15 | You should have received a copy of the GNU Lesser General Public |
|
| 16 | License along with this library; if not, see http://www.gnu.org |
|
| 17 | */ |
|
| 18 | ||
| 19 | package net.wotonomy.access; |
|
| 20 | ||
| 21 | import net.wotonomy.foundation.NSArray; |
|
| 22 | import net.wotonomy.foundation.NSDictionary; |
|
| 23 | import net.wotonomy.foundation.NSMutableArray; |
|
| 24 | import net.wotonomy.foundation.NSMutableDictionary; |
|
| 25 | /** |
|
| 26 | * Represents a stored procedure in a database. |
|
| 27 | * |
|
| 28 | * @author ezamudio@nasoft.com |
|
| 29 | * @author $Author: cgruber $ |
|
| 30 | * @version $Revision: 894 $ |
|
| 31 | */ |
|
| 32 | public class EOStoredProcedure implements EOPropertyListEncoding { |
|
| 33 | ||
| 34 | protected String _name; |
|
| 35 | protected String _externalName; |
|
| 36 | protected EOModel _model; |
|
| 37 | 0 | protected NSArray _arguments = NSArray.EmptyArray; |
| 38 | 0 | protected NSDictionary _userInfo = NSDictionary.EmptyDictionary; |
| 39 | 0 | protected NSDictionary _internalInfo = NSDictionary.EmptyDictionary; |
| 40 | ||
| 41 | /** Creates a stored procedure from a property list. */ |
|
| 42 | public EOStoredProcedure(NSDictionary dict, Object obj) { |
|
| 43 | 0 | super(); |
| 44 | 0 | if (obj instanceof EOModel) |
| 45 | 0 | _model = (EOModel)obj; |
| 46 | 0 | NSArray a = (NSArray)dict.objectForKey("arguments"); |
| 47 | 0 | if (a != null) { |
| 48 | 0 | NSMutableArray args = new NSMutableArray(a.count()); |
| 49 | 0 | for (int i = 0; i < a.count(); i++) { |
| 50 | 0 | NSDictionary ad = (NSDictionary)a.objectAtIndex(i); |
| 51 | 0 | EOAttribute arg = new EOAttribute(ad, this); |
| 52 | 0 | args.addObject(arg); |
| 53 | } |
|
| 54 | 0 | _arguments = args; |
| 55 | } |
|
| 56 | 0 | setName((String)dict.objectForKey("name")); |
| 57 | 0 | setExternalName((String)dict.objectForKey("externalName")); |
| 58 | 0 | if (dict.objectForKey("userInfo") != null) |
| 59 | 0 | setUserInfo((NSDictionary)dict.objectForKey("userInfo")); |
| 60 | 0 | if (dict.objectForKey("internalInfo") != null) |
| 61 | 0 | _internalInfo = (NSDictionary)dict.objectForKey("internalInfo"); |
| 62 | 0 | } |
| 63 | ||
| 64 | public EOStoredProcedure(String withName) { |
|
| 65 | 0 | super(); |
| 66 | 0 | setName(withName); |
| 67 | 0 | } |
| 68 | ||
| 69 | public void setName(String value) { |
|
| 70 | 0 | _name = value; |
| 71 | 0 | } |
| 72 | public String name() { |
|
| 73 | 0 | return _name; |
| 74 | } |
|
| 75 | ||
| 76 | public void setExternalName(String value) { |
|
| 77 | 0 | _externalName = value; |
| 78 | 0 | } |
| 79 | public String externalName() { |
|
| 80 | 0 | return _externalName; |
| 81 | } |
|
| 82 | ||
| 83 | public void setArguments(NSArray value) { |
|
| 84 | 0 | _arguments = value; |
| 85 | 0 | } |
| 86 | public NSArray arguments() { |
|
| 87 | 0 | return _arguments; |
| 88 | } |
|
| 89 | ||
| 90 | public EOModel model() { |
|
| 91 | 0 | return _model; |
| 92 | } |
|
| 93 | ||
| 94 | public void setUserInfo(NSDictionary info) { |
|
| 95 | 0 | _userInfo = info; |
| 96 | 0 | } |
| 97 | public NSDictionary userInfo() { |
|
| 98 | 0 | return _userInfo; |
| 99 | } |
|
| 100 | ||
| 101 | public void awakeWithPropertyList(NSDictionary plist) { |
|
| 102 | 0 | } |
| 103 | ||
| 104 | public void encodeIntoPropertyList(NSMutableDictionary plist) { |
|
| 105 | 0 | plist.setObjectForKey(name(), "name"); |
| 106 | 0 | plist.setObjectForKey(externalName(), "externalName"); |
| 107 | 0 | NSMutableArray arr = new NSMutableArray(_arguments.count()); |
| 108 | 0 | NSMutableDictionary d = null; |
| 109 | 0 | for (int i = 0; i < _arguments.count(); i++) { |
| 110 | 0 | EOAttribute a = (EOAttribute)_arguments.objectAtIndex(i); |
| 111 | 0 | d = new NSMutableDictionary(); |
| 112 | 0 | a.encodeIntoPropertyList(d); |
| 113 | 0 | arr.addObject(d); |
| 114 | } |
|
| 115 | 0 | plist.setObjectForKey(arr, "arguments"); |
| 116 | 0 | } |
| 117 | ||
| 118 | } |
|
| 119 | /* |
|
| 120 | * $Log$ |
|
| 121 | * Revision 1.2 2006/02/16 16:47:14 cgruber |
|
| 122 | * Move some classes in to "internal" packages and re-work imports, etc. |
|
| 123 | * |
|
| 124 | * Also use UnsupportedOperationExceptions where appropriate, instead of WotonomyExceptions. |
|
| 125 | * |
|
| 126 | * Revision 1.1 2006/02/16 13:19:57 cgruber |
|
| 127 | * Check in all sources in eclipse-friendly maven-enabled packages. |
|
| 128 | * |
|
| 129 | * Revision 1.4 2003/08/11 19:38:27 chochos |
|
| 130 | * Can now read from a file and re-write to another file. |
|
| 131 | * |
|
| 132 | * Revision 1.3 2003/08/09 01:36:32 chochos |
|
| 133 | * implement EOPropertyListEncoding |
|
| 134 | * |
|
| 135 | * Revision 1.2 2003/08/08 02:14:43 chochos |
|
| 136 | * can create a stored procedure from a property list. main accessors are in place. |
|
| 137 | * |
|
| 138 | * Revision 1.1 2003/08/07 02:41:04 chochos |
|
| 139 | * these don't do much for now. |
|
| 140 | * |
|
| 141 | */ |