commit 071f9656543dae87faf8a6914bc053a601e3f474 Author: travismccauley Date: Wed Jan 7 15:32:36 2004 +0000 Initial revision diff --git a/PaletteFunctions.js b/PaletteFunctions.js new file mode 100755 index 0000000..51b87c6 --- /dev/null +++ b/PaletteFunctions.js @@ -0,0 +1,178 @@ +// $Id: PaletteFunctions.js,v 1.1 2004/01/07 15:32:36 travismccauley Exp $ +// Requires: /net/sf/tapestry/html/PracticalBrowserSniffer.js + +function palette_clear_selections(element) +{ + var options = element.options; + + for (var i = 0; i < options.length; i++) + options[i].selected = false; +} + +function palette_select_all(element) +{ + var options = element.options; + + for (var i = 0; i < options.length; i++) + options[i].selected = true; +} + +function palette_sort(element, sorter) +{ + var options = element.options; + var list = new Array(); + var index = 0; + var isNavigator = (navigator.family == "nn4" || navigator.family == "gecko"); + + while (options.length > 0) + { + var option = options[0]; + + if (isNavigator) + { + // Can't transfer option in nn4, nn6 + + if (navigator.family == 'gecko') + var copy = document.createElement("OPTION"); + else + var copy = new Option(option.text, option.value); + + copy.text = option.text; + copy.value = option.value; + copy.selected = options.selected; + + list[index++] = copy; + } + else + list[index++] = option; + + + options[0] = null; + } + + list.sort(sorter); + + for (var i = 0; i < list.length; i++) + { + options[i] = list[i]; + } + + +} + +function palette_label_sorter(a, b) +{ + var a_text = a.text; + var b_text = b.text; + + if (a_text == b_text) + return 0; + + if (a_text < b.text) + return -1; + + return 1; +} + +function palette_sort_by_label(element) +{ + palette_sort(element, palette_label_sorter); +} + +function palette_value_sorter(a, b) +{ + var a_value = a.value; + var b_value = b.value; + + if (a_value == b_value) + return 0; + + if (a_value < b_value) + return -1; + + return 1; +} + +function palette_sort_by_value(element) +{ + palette_sort(element, palette_value_sorter); +} + +function palette_transfer_selections(source, target) +{ + var sourceOptions = source.options; + var targetOptions = target.options; + + var targetIndex = target.selectedIndex; + var offset = 0; + + palette_clear_selections(target); + + for (var i = 0; i < sourceOptions.length; i++) + { + var option = sourceOptions[i]; + + if (option.selected) + { + + if (navigator.family == 'nn4' || navigator.family == 'gecko') + { + // Can't share options between selects in NN4 + + var newOption = new Option(option.text, option.value, false, true); + + sourceOptions[i] = null; + + // Always added to end in NN4 + + targetOptions[targetOptions.length] = newOption; + } + else + { + sourceOptions.remove(i); + + if (targetIndex < 0) + targetOptions.add(option); + else + targetOptions.add(option, targetIndex + offset++); + } + + i--; + } + } + +} + +function palette_swap_options(options, selectedIndex, targetIndex) +{ + var option = options[selectedIndex]; + + // It's very hard to reorder options in NN4 + + if (navigator.family == 'nn4' || navigator.family == 'gecko') + { + var swap = options[targetIndex]; + + var hold = swap.text; + swap.text = option.text; + option.text = hold; + + hold = swap.value; + swap.value = option.value; + option.value = hold; + + hold = swap.selected; + swap.selected = option.selected; + option.selected = hold; + + // defaultSelected isn't relevant to the Palette + + return; + } + + // Sensible browsers ... + + options.remove(selectedIndex); + options.add(option, targetIndex); +} + diff --git a/PracticalBrowserSniffer.js b/PracticalBrowserSniffer.js new file mode 100755 index 0000000..e1a89e0 --- /dev/null +++ b/PracticalBrowserSniffer.js @@ -0,0 +1,160 @@ +// PracticalBrowserSniffer.js - Detect Browser +// Requires JavaScript 1.1 +/* +The contents of this file are subject to the Netscape Public +License Version 1.1 (the "License"); you may not use this file +except in compliance with the License. You may obtain a copy of +the License at http://www.mozilla.org/NPL/ + +Software distributed under the License is distributed on an "AS +IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +implied. See the License for the specific language governing +rights and limitations under the License. + +The Initial Developer of the Original Code is Bob Clary. + +Contributor(s): Bob Clary, Original Work, Copyright 1999-2000 + Bob Clary, Netscape Communications, Copyright 2001 + + +Note: + +Acquired from: http://developer.netscape.com/evangelism/tools/practical-browser-sniffing/ +Last update: July 17, 2001 + +*/ + +// work around bug in xpcdom Mozilla 0.9.1 +window.saveNavigator = window.navigator; + +// Handy functions +function noop() {} +function noerror() { return true; } + +function defaultOnError(msg, url, line) +{ + // customize this for your site + if (top.location.href.indexOf('_files/errors/') == -1) + top.location = '/evangelism/xbProjects/_files/errors/index.html?msg=' + escape(msg) + '&url=' + escape(url) + '&line=' + escape(line); +} + +// Display Error page... +// XXX: more work to be done here +// +function reportError(message) +{ + // customize this for your site + if (top.location.href.indexOf('_files/errors/') == -1) + top.location = '/evangelism/xbProjects/_files/errors/index.html?msg=' + escape(message); +} + +function pageRequires(cond, msg, redirectTo) +{ + if (!cond) + { + msg = 'This page requires ' + msg; + top.location = redirectTo + '?msg=' + escape(msg); + } + // return cond so can use in onclick handlers to exclude browsers + // from pages they do not support. + return cond; +} + +function detectBrowser() +{ + var oldOnError = window.onerror; + var element = null; + + window.onerror = defaultOnError; + + navigator.OS = ''; + navigator.version = 0; + navigator.org = ''; + navigator.family = ''; + + var platform; + if (typeof(window.navigator.platform) != 'undefined') + { + platform = window.navigator.platform.toLowerCase(); + if (platform.indexOf('win') != -1) + navigator.OS = 'win'; + else if (platform.indexOf('mac') != -1) + navigator.OS = 'mac'; + else if (platform.indexOf('unix') != -1 || platform.indexOf('linux') != -1 || platform.indexOf('sun') != -1) + navigator.OS = 'nix'; + } + + var i = 0; + var ua = window.navigator.userAgent.toLowerCase(); + + if (ua.indexOf('opera') != -1) + { + i = ua.indexOf('opera'); + navigator.family = 'opera'; + navigator.org = 'opera'; + navigator.version = parseFloat('0' + ua.substr(i+6), 10); + } + else if ((i = ua.indexOf('msie')) != -1) + { + navigator.org = 'microsoft'; + navigator.version = parseFloat('0' + ua.substr(i+5), 10); + + if (navigator.version < 4) + navigator.family = 'ie3'; + else + navigator.family = 'ie4' + } + else if (typeof(window.controllers) != 'undefined' && typeof(window.locationbar) != 'undefined') + { + i = ua.lastIndexOf('/') + navigator.version = parseFloat('0' + ua.substr(i+1), 10); + navigator.family = 'gecko'; + + if (ua.indexOf('netscape') != -1) + navigator.org = 'netscape'; + else if (ua.indexOf('compuserve') != -1) + navigator.org = 'compuserve'; + else + navigator.org = 'mozilla'; + } + else if ((ua.indexOf('mozilla') !=-1) && (ua.indexOf('spoofer')==-1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera')==-1)&& (ua.indexOf('webtv')==-1) && (ua.indexOf('hotjava')==-1)) + { + var is_major = parseFloat(navigator.appVersion); + + if (is_major < 4) + navigator.version = is_major; + else + { + i = ua.lastIndexOf('/') + navigator.version = parseFloat('0' + ua.substr(i+1), 10); + } + navigator.org = 'netscape'; + navigator.family = 'nn' + parseInt(navigator.appVersion); + } + else if ((i = ua.indexOf('aol')) != -1 ) + { + // aol + navigator.family = 'aol'; + navigator.org = 'aol'; + navigator.version = parseFloat('0' + ua.substr(i+4), 10); + } + + navigator.DOMCORE1 = (typeof(document.getElementsByTagName) != 'undefined' && typeof(document.createElement) != 'undefined'); + navigator.DOMCORE2 = (navigator.DOMCORE1 && typeof(document.getElementById) != 'undefined' && typeof(document.createElementNS) != 'undefined'); + navigator.DOMHTML = (navigator.DOMCORE1 && typeof(document.getElementById) != 'undefined'); + navigator.DOMCSS1 = ( (navigator.family == 'gecko') || (navigator.family == 'ie4') ); + + navigator.DOMCSS2 = false; + if (navigator.DOMCORE1) + { + element = document.createElement('p'); + navigator.DOMCSS2 = (typeof(element.style) == 'object'); + } + + navigator.DOMEVENTS = (typeof(document.createEvent) != 'undefined'); + + window.onerror = oldOnError; +} + +detectBrowser(); + diff --git a/WEB-INF/.DS_Store b/WEB-INF/.DS_Store new file mode 100755 index 0000000..d243e23 Binary files /dev/null and b/WEB-INF/.DS_Store differ diff --git a/WEB-INF/lib/LICENSE-commons-beanutils.txt b/WEB-INF/lib/LICENSE-commons-beanutils.txt new file mode 100755 index 0000000..55e6954 --- /dev/null +++ b/WEB-INF/lib/LICENSE-commons-beanutils.txt @@ -0,0 +1,60 @@ +/* + * $Header: /tmp/thdltools/Roster/WEB-INF/lib/LICENSE-commons-beanutils.txt,v 1.1 2004/01/07 15:32:47 travismccauley Exp $ + * $Revision: 1.1 $ + * $Date: 2004/01/07 15:32:47 $ + * + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ diff --git a/WEB-INF/lib/LICENSE-commons-collections.txt b/WEB-INF/lib/LICENSE-commons-collections.txt new file mode 100755 index 0000000..7b278d7 --- /dev/null +++ b/WEB-INF/lib/LICENSE-commons-collections.txt @@ -0,0 +1,60 @@ +/* + * $Header: /tmp/thdltools/Roster/WEB-INF/lib/LICENSE-commons-collections.txt,v 1.1 2004/01/07 15:32:47 travismccauley Exp $ + * $Revision: 1.1 $ + * $Date: 2004/01/07 15:32:47 $ + * + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ diff --git a/WEB-INF/lib/LICENSE-commons-fileupload.txt b/WEB-INF/lib/LICENSE-commons-fileupload.txt new file mode 100755 index 0000000..30756fb --- /dev/null +++ b/WEB-INF/lib/LICENSE-commons-fileupload.txt @@ -0,0 +1,60 @@ +/* + * $Header: /tmp/thdltools/Roster/WEB-INF/lib/LICENSE-commons-fileupload.txt,v 1.1 2004/01/07 15:32:47 travismccauley Exp $ + * $Revision: 1.1 $ + * $Date: 2004/01/07 15:32:47 $ + * + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ diff --git a/WEB-INF/lib/LICENSE.bsf.txt b/WEB-INF/lib/LICENSE.bsf.txt new file mode 100755 index 0000000..77ef125 --- /dev/null +++ b/WEB-INF/lib/LICENSE.bsf.txt @@ -0,0 +1,53 @@ + The Apache Software License, Version 1.1 + + Copyright (c) 2002 The Apache Software Foundation. All rights + reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + 3. The end-user documentation included with the redistribution, + if any, must include the following acknowledgment: + "This product includes software developed by the + Apache Software Foundation (http://www.apache.org/)." + Alternately, this acknowledgment may appear in the software itself, + if and wherever such third-party acknowledgments normally appear. + + 4. The names "BSF", "Apache", and "Apache Software Foundation" must + not be used to endorse or promote products derived from this + software without prior written permission. For written + permission, please contact apache@apache.org. + + 5. Products derived from this software may not be called "Apache", + nor may "Apache" appear in their name, without prior written + permission of the Apache Software Foundation. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + SUCH DAMAGE. + + This software consists of voluntary contributions made by many individuals + on behalf of the Apache Software Foundation and was originally created by + Sanjiva Weerawarana and others at International Business Machines + Corporation. For more information on the Apache Software Foundation, + please see . + + diff --git a/WEB-INF/lib/LICENSE.commons-digester.txt b/WEB-INF/lib/LICENSE.commons-digester.txt new file mode 100755 index 0000000..4b5ec97 --- /dev/null +++ b/WEB-INF/lib/LICENSE.commons-digester.txt @@ -0,0 +1,60 @@ +/* + * $Header: /tmp/thdltools/Roster/WEB-INF/lib/LICENSE.commons-digester.txt,v 1.1 2004/01/07 15:32:47 travismccauley Exp $ + * $Revision: 1.1 $ + * $Date: 2004/01/07 15:32:47 $ + * + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ diff --git a/WEB-INF/lib/LICENSE.commons-lang.txt b/WEB-INF/lib/LICENSE.commons-lang.txt new file mode 100755 index 0000000..2a15904 --- /dev/null +++ b/WEB-INF/lib/LICENSE.commons-lang.txt @@ -0,0 +1,60 @@ +/* + * $Header: /tmp/thdltools/Roster/WEB-INF/lib/LICENSE.commons-lang.txt,v 1.1 2004/01/07 15:32:47 travismccauley Exp $ + * $Revision: 1.1 $ + * $Date: 2004/01/07 15:32:47 $ + * + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ \ No newline at end of file diff --git a/WEB-INF/lib/LICENSE.commons-logging.txt b/WEB-INF/lib/LICENSE.commons-logging.txt new file mode 100755 index 0000000..6c5080c --- /dev/null +++ b/WEB-INF/lib/LICENSE.commons-logging.txt @@ -0,0 +1,60 @@ +/* + * $Header: /tmp/thdltools/Roster/WEB-INF/lib/LICENSE.commons-logging.txt,v 1.1 2004/01/07 15:32:47 travismccauley Exp $ + * $Revision: 1.1 $ + * $Date: 2004/01/07 15:32:47 $ + * + * ==================================================================== + * + * The Apache Software License, Version 1.1 + * + * Copyright (c) 1999-2001 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Commons", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ \ No newline at end of file diff --git a/WEB-INF/lib/LICENSE.jakarta-oro.txt b/WEB-INF/lib/LICENSE.jakarta-oro.txt new file mode 100755 index 0000000..9c63560 --- /dev/null +++ b/WEB-INF/lib/LICENSE.jakarta-oro.txt @@ -0,0 +1,56 @@ +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2000-2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation", "Jakarta-Oro" + * must not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * or "Jakarta-Oro", nor may "Apache" or "Jakarta-Oro" appear in their + * name, without prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + * Portions of this software are based upon software originally written + * by Daniel F. Savarese. We appreciate his contributions. + */ diff --git a/WEB-INF/lib/LICENSE.javassist.txt b/WEB-INF/lib/LICENSE.javassist.txt new file mode 100755 index 0000000..cb19a04 --- /dev/null +++ b/WEB-INF/lib/LICENSE.javassist.txt @@ -0,0 +1,478 @@ +MOZILLA PUBLIC LICENSE Version 1.1 + +-------------------------------------------------------------------------------- + +1. Definitions. + +1.0.1. "Commercial Use" means distribution or otherwise making the +Covered Code available to a third party. + +1.1. ''Contributor'' means each entity that creates or contributes to +the creation of Modifications. + +1.2. ''Contributor Version'' means the combination of the Original +Code, prior Modifications used by a Contributor, and the Modifications +made by that particular Contributor. + +1.3. ''Covered Code'' means the Original Code or Modifications or the +combination of the Original Code and Modifications, in each case +including portions thereof. + +1.4. ''Electronic Distribution Mechanism'' means a mechanism generally +accepted in the software development community for the electronic +transfer of data. + +1.5. ''Executable'' means Covered Code in any form other than Source +Code. + +1.6. ''Initial Developer'' means the individual or entity identified +as the Initial Developer in the Source Code notice required by Exhibit +A. + +1.7. ''Larger Work'' means a work which combines Covered Code or +portions thereof with code not governed by the terms of this License. + +1.8. ''License'' means this document. + +1.8.1. "Licensable" means having the right to grant, to the maximum +extent possible, whether at the time of the initial grant or +subsequently acquired, any and all of the rights conveyed herein. + +1.9. ''Modifications'' means any addition to or deletion from the +substance or structure of either the Original Code or any previous +Modifications. When Covered Code is released as a series of files, a +Modification is: + +A. Any addition to or deletion from the contents of a file containing +Original Code or previous Modifications. + +B. Any new file that contains any part of the Original Code or +previous Modifications. + + +1.10. ''Original Code'' means Source Code of computer software code +which is described in the Source Code notice required by Exhibit A as +Original Code, and which, at the time of its release under this +License is not already Covered Code governed by this License. + +1.10.1. "Patent Claims" means any patent claim(s), now owned or +hereafter acquired, including without limitation, method, process, and +apparatus claims, in any patent Licensable by grantor. + +1.11. ''Source Code'' means the preferred form of the Covered Code for +making modifications to it, including all modules it contains, plus +any associated interface definition files, scripts used to control +compilation and installation of an Executable, or source code +differential comparisons against either the Original Code or another +well known, available Covered Code of the Contributor's choice. The +Source Code can be in a compressed or archival form, provided the +appropriate decompression or de-archiving software is widely available +for no charge. + +1.12. "You'' (or "Your") means an individual or a legal entity +exercising rights under, and complying with all of the terms of, this +License or a future version of this License issued under Section +6.1. For legal entities, "You'' includes any entity which controls, is +controlled by, or is under common control with You. For purposes of +this definition, "control'' means (a) the power, direct or indirect, +to cause the direction or management of such entity, whether by +contract or otherwise, or (b) ownership of more than fifty percent +(50%) of the outstanding shares or beneficial ownership of such +entity. + +2. Source Code License. 1. The Initial Developer Grant. The Initial +Developer hereby grants You a world-wide, royalty-free, +non-exclusive license, subject to third party intellectual property +claims: (a) under intellectual property rights (other than patent or +trademark) Licensable by Initial Developer to use, reproduce, +modify, display, perform, sublicense and distribute the Original +Code (or portions thereof) with or without Modifications, and/or as +part of a Larger Work; and (b) under Patents Claims infringed by the +making, using or selling of Original Code, to make, have made, use, +practice, sell, and offer for sale, and/or otherwise dispose of the +Original Code (or portions thereof). + +(c) the licenses granted in this Section 2.1(a) and (b) are effective +on the date Initial Developer first distributes Original Code under +the terms of this License. + +(d) Notwithstanding Section 2.1(b) above, no patent license is granted: +1) for code that You delete from the Original Code; +2) separate from the Original Code; or +3) for infringements caused by: i) the modification of the Original Code +or ii) the combination of the Original Code with other software or +devices. + + +2.2. Contributor Grant. Subject to third party intellectual property +claims, each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license + +(a) under intellectual property rights (other than patent or +trademark) Licensable by Contributor, to use, reproduce, modify, +display, perform, sublicense and distribute the Modifications created +by such Contributor (or portions thereof) either on an unmodified +basis, with other Modifications, as Covered Code and/or as part of a +Larger Work; and + +(b) under Patent Claims infringed by the making, using, or selling of +Modifications made by that Contributor either alone and/or in +combination with its Contributor Version (or portions of such +combination), to make, use, sell, offer for sale, have made, and/or +otherwise dispose of: 1) Modifications made by that Contributor (or +portions thereof); and 2) the combination of Modifications made by +that Contributor with its Contributor Version (or portions of such +combination). + +(c) the licenses granted in Sections 2.2(a) and 2.2(b) are effective +on the date Contributor first makes Commercial Use of the Covered +Code. + +(d) Notwithstanding Section 2.2(b) above, no patent license is +granted: 1) for any code that Contributor has deleted from the +Contributor Version; 2) separate from the Contributor Version; 3) for +infringements caused by: i) third party modifications of Contributor +Version or ii) the combination of Modifications made by that +Contributor with other software (except as part of the Contributor +Version) or other devices; or 4) under Patent Claims infringed by +Covered Code in the absence of Modifications made by that Contributor. + + +3. Distribution Obligations. + +3.1. Application of License. + +The Modifications which You create or to which You contribute are +governed by the terms of this License, including without limitation +Section 2.2. The Source Code version of Covered Code may be +distributed only under the terms of this License or a future version +of this License released under Section 6.1, and You must include a +copy of this License with every copy of the Source Code You +distribute. You may not offer or impose any terms on any Source Code +version that alters or restricts the applicable version of this +License or the recipients' rights hereunder. However, You may include +an additional document offering the additional rights described in +Section 3.5. + +3.2. Availability of Source Code. + +Any Modification which You create or to which You contribute must be +made available in Source Code form under the terms of this License +either on the same media as an Executable version or via an accepted +Electronic Distribution Mechanism to anyone to whom you made an +Executable version available; and if made available via Electronic +Distribution Mechanism, must remain available for at least twelve (12) +months after the date it initially became available, or at least six +(6) months after a subsequent version of that particular Modification +has been made available to such recipients. You are responsible for +ensuring that the Source Code version remains available even if the +Electronic Distribution Mechanism is maintained by a third party. + +3.3. Description of Modifications. + +You must cause all Covered Code to which You contribute to contain a +file documenting the changes You made to create that Covered Code and +the date of any change. You must include a prominent statement that +the Modification is derived, directly or indirectly, from Original +Code provided by the Initial Developer and including the name of the +Initial Developer in (a) the Source Code, and (b) in any notice in an +Executable version or related documentation in which You describe the +origin or ownership of the Covered Code. + +3.4. Intellectual Property Matters + +(a) Third Party Claims. + +If Contributor has knowledge that a license under a third party's +intellectual property rights is required to exercise the rights +granted by such Contributor under Sections 2.1 or 2.2, Contributor +must include a text file with the Source Code distribution titled +"LEGAL'' which describes the claim and the party making the claim in +sufficient detail that a recipient will know whom to contact. If +Contributor obtains such knowledge after the Modification is made +available as described in Section 3.2, Contributor shall promptly +modify the LEGAL file in all copies Contributor makes available +thereafter and shall take other steps (such as notifying appropriate +mailing lists or newsgroups) reasonably calculated to inform those who +received the Covered Code that new knowledge has been obtained. + +(b) Contributor APIs. + +If Contributor's Modifications include an application programming +interface and Contributor has knowledge of patent licenses which are +reasonably necessary to implement that API, Contributor must also +include this information in the LEGAL file. + + +(c) Representations. + +Contributor represents that, except as disclosed pursuant to Section +3.4(a) above, Contributor believes that Contributor's Modifications +are Contributor's original creation(s) and/or Contributor has +sufficient rights to grant the rights conveyed by this License. + +3.5. Required Notices. + +You must duplicate the notice in Exhibit A in each file of the Source +Code. If it is not possible to put such notice in a particular Source +Code file due to its structure, then You must include such notice in a +location (such as a relevant directory) where a user would be likely +to look for such a notice. If You created one or more Modification(s) +You may add your name as a Contributor to the notice described in +Exhibit A. You must also duplicate this License in any documentation +for the Source Code where You describe recipients' rights or ownership +rights relating to Covered Code. You may choose to offer, and to +charge a fee for, warranty, support, indemnity or liability +obligations to one or more recipients of Covered Code. However, You +may do so only on Your own behalf, and not on behalf of the Initial +Developer or any Contributor. You must make it absolutely clear than +any such warranty, support, indemnity or liability obligation is +offered by You alone, and You hereby agree to indemnify the Initial +Developer and every Contributor for any liability incurred by the +Initial Developer or such Contributor as a result of warranty, +support, indemnity or liability terms You offer. + +3.6. Distribution of Executable Versions. + +You may distribute Covered Code in Executable form only if the +requirements of Section 3.1-3.5 have been met for that Covered Code, +and if You include a notice stating that the Source Code version of +the Covered Code is available under the terms of this License, +including a description of how and where You have fulfilled the +obligations of Section 3.2. The notice must be conspicuously included +in any notice in an Executable version, related documentation or +collateral in which You describe recipients' rights relating to the +Covered Code. You may distribute the Executable version of Covered +Code or ownership rights under a license of Your choice, which may +contain terms different from this License, provided that You are in +compliance with the terms of this License and that the license for the +Executable version does not attempt to limit or alter the recipient's +rights in the Source Code version from the rights set forth in this +License. If You distribute the Executable version under a different +license You must make it absolutely clear that any terms which differ +from this License are offered by You alone, not by the Initial +Developer or any Contributor. You hereby agree to indemnify the +Initial Developer and every Contributor for any liability incurred by +the Initial Developer or such Contributor as a result of any such +terms You offer. + +3.7. Larger Works. + +You may create a Larger Work by combining Covered Code with other code +not governed by the terms of this License and distribute the Larger +Work as a single product. In such a case, You must make sure the +requirements of this License are fulfilled for the Covered Code. + +4. Inability to Comply Due to Statute or Regulation. + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Code due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description +must be included in the LEGAL file described in Section 3.4 and must +be included with all distributions of the Source Code. Except to the +extent prohibited by statute or regulation, such description must be +sufficiently detailed for a recipient of ordinary skill to be able to +understand it. + +5. Application of this License. + +This License applies to code to which the Initial Developer has +attached the notice in Exhibit A and to related Covered Code. + +6. Versions of the License. + +6.1. New Versions. + +Netscape Communications Corporation (''Netscape'') may publish revised +and/or new versions of the License from time to time. Each version +will be given a distinguishing version number. + +6.2. Effect of New Versions. + +Once Covered Code has been published under a particular version of the +License, You may always continue to use it under the terms of that +version. You may also choose to use such Covered Code under the terms +of any subsequent version of the License published by Netscape. No one +other than Netscape has the right to modify the terms applicable to +Covered Code created under this License. + +6.3. Derivative Works. + +If You create or use a modified version of this License (which you may +only do in order to apply it to code which is not already Covered Code +governed by this License), You must (a) rename Your license so that +the phrases ''Mozilla'', ''MOZILLAPL'', ''MOZPL'', ''Netscape'', +"MPL", ''NPL'' or any confusingly similar phrase do not appear in your +license (except to note that your license differs from this License) +and (b) otherwise make it clear that Your version of the license +contains terms which differ from the Mozilla Public License and +Netscape Public License. (Filling in the name of the Initial +Developer, Original Code or Contributor in the notice described in +Exhibit A shall not of themselves be deemed to be modifications of +this License.) + +7. DISCLAIMER OF WARRANTY. + +COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS'' BASIS, +WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, +WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF +DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR +NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF +THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE +IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER +CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR +CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART +OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER +EXCEPT UNDER THIS DISCLAIMER. + +8. TERMINATION. + +8.1. This License and the rights granted hereunder will terminate +automatically if You fail to comply with terms herein and fail to cure +such breach within 30 days of becoming aware of the breach. All +sublicenses to the Covered Code which are properly granted shall +survive any termination of this License. Provisions which, by their +nature, must remain in effect beyond the termination of this License +shall survive. + +8.2. If You initiate litigation by asserting a patent infringement +claim (excluding declatory judgment actions) against Initial Developer +or a Contributor (the Initial Developer or Contributor against whom +You file such action is referred to as "Participant") alleging that: + +(a) such Participant's Contributor Version directly or indirectly +infringes any patent, then any and all rights granted by such +Participant to You under Sections 2.1 and/or 2.2 of this License +shall, upon 60 days notice from Participant terminate prospectively, +unless if within 60 days after receipt of notice You either: (i) agree +in writing to pay Participant a mutually agreeable reasonable royalty +for Your past and future use of Modifications made by such +Participant, or (ii) withdraw Your litigation claim with respect to +the Contributor Version against such Participant. If within 60 days +of notice, a reasonable royalty and payment arrangement are not +mutually agreed upon in writing by the parties or the litigation claim +is not withdrawn, the rights granted by Participant to You under +Sections 2.1 and/or 2.2 automatically terminate at the expiration of +the 60 day notice period specified above. + +(b) any software, hardware, or device, other than such Participant's +Contributor Version, directly or indirectly infringes any patent, then +any rights granted to You by such Participant under Sections 2.1(b) +and 2.2(b) are revoked effective as of the date You first made, used, +sold, distributed, or had made, Modifications made by that +Participant. + +8.3. If You assert a patent infringement claim against Participant +alleging that such Participant's Contributor Version directly or +indirectly infringes any patent where such claim is resolved (such as +by license or settlement) prior to the initiation of patent +infringement litigation, then the reasonable value of the licenses +granted by such Participant under Sections 2.1 or 2.2 shall be taken +into account in determining the amount or value of any payment or +license. + +8.4. In the event of termination under Sections 8.1 or 8.2 above, all +end user license agreements (excluding distributors and resellers) +which have been validly granted by You or any distributor hereunder +prior to termination shall survive termination. + +9. LIMITATION OF LIABILITY. + +UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT +(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL +DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, +OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR +ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY +CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, +WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER +COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN +INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF +LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY +RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW +PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE +EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO +THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. + +10. U.S. GOVERNMENT END USERS. + +The Covered Code is a ''commercial item,'' as that term is defined in +48 C.F.R. 2.101 (Oct. 1995), consisting of ''commercial computer +software'' and ''commercial computer software documentation,'' as such +terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 +C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), +all U.S. Government End Users acquire Covered Code with only those +rights set forth herein. + +11. MISCELLANEOUS. + +This License represents the complete agreement concerning subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. This License shall be governed by +California law provisions (except to the extent applicable law, if +any, provides otherwise), excluding its conflict-of-law +provisions. With respect to disputes in which at least one party is a +citizen of, or an entity chartered or registered to do business in the +United States of America, any litigation relating to this License +shall be subject to the jurisdiction of the Federal Courts of the +Northern District of California, with venue lying in Santa Clara +County, California, with the losing party responsible for costs, +including without limitation, court costs and reasonable attorneys' +fees and expenses. The application of the United Nations Convention on +Contracts for the International Sale of Goods is expressly +excluded. Any law or regulation which provides that the language of a +contract shall be construed against the drafter shall not apply to +this License. + +12. RESPONSIBILITY FOR CLAIMS. + +As between Initial Developer and the Contributors, each party is +responsible for claims and damages arising, directly or indirectly, +out of its utilization of rights under this License and You agree to +work with Initial Developer and Contributors to distribute such +responsibility on an equitable basis. Nothing herein is intended or +shall be deemed to constitute any admission of liability. + +13. MULTIPLE-LICENSED CODE. + +Initial Developer may designate portions of the Covered Code as +.Multiple-Licensed.. .Multiple-Licensed. means that the Initial +Developer permits you to utilize portions of the Covered Code under +Your choice of the MPL or the alternative licenses, if any, specified +by the Initial Developer in the file described in Exhibit A. + +EXHIBIT A -Mozilla Public License. + +The contents of this file are subject to the Mozilla Public License +Version 1.1 (the "License"); you may not use this file except in +compliance with the License. You may obtain a copy of the License at + +http://www.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +the License for the specific language governing rights and limitations +under the License. + +The Original Code is Javassist. + +The Initial Developer of the Original Code is Shigeru Chiba. Portions +created by the Initial Developer are + + Copyright (C) 1999-2003 Shigeru Chiba. All Rights Reserved. + +Contributor(s): ______________________________________. + +Alternatively, the contents of this file may be used under the terms +of the GNU Lesser General Public License Version 2.1 or later (the +"LGPL"), in which case the provisions of the LGPL are applicable +instead of those above. If you wish to allow use of your version of +this file only under the terms of the LGPL, and not to allow others to +use your version of this file under the terms of the MPL, indicate +your decision by deleting the provisions above and replace them with +the notice and other provisions required by the LGPL. If you do not +delete the provisions above, a recipient may use your version of this +file under the terms of either the MPL or the LGPL. + diff --git a/WEB-INF/lib/LICENSE.log4j.txt b/WEB-INF/lib/LICENSE.log4j.txt new file mode 100755 index 0000000..007db57 --- /dev/null +++ b/WEB-INF/lib/LICENSE.log4j.txt @@ -0,0 +1,48 @@ +/* + * ============================================================================ + * The Apache Software License, Version 1.1 + * ============================================================================ + * + * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modifica- + * tion, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "log4j" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation. For more information on the + * Apache Software Foundation, please see . + * + */ diff --git a/WEB-INF/lib/LICENSE.ognl.txt b/WEB-INF/lib/LICENSE.ognl.txt new file mode 100755 index 0000000..4b1db54 --- /dev/null +++ b/WEB-INF/lib/LICENSE.ognl.txt @@ -0,0 +1,103 @@ + + This directory contains an example ANTLR grammar for a little +language called OGNL (pronounced OGG-null), which stands for +Object-Graph Navigation Language. OGNL is an expression language for +setting and getting properties of Java objects, and can be used as is +or as a starting point for other projects. + +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +* * +* Copyright (c) 2002, Drew Davidson and Luke Blanshard * +* All rights reserved. * +* * +* Redistribution and use in source and binary forms, with or without * +* modification, are permitted provided that the following conditions are * +* met: * +* * +* Redistributions of source code must retain the above copyright notice, * +* this list of conditions and the following disclaimer. * +* Redistributions in binary form must reproduce the above copyright * +* notice, this list of conditions and the following disclaimer in the * +* documentation and/or other materials provided with the distribution. * +* Neither the name of the Drew Davidson nor the names of its contributors * +* may be used to endorse or promote products derived from this software * +* without specific prior written permission. * +* * +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * +* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * +* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * +* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * +* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * +* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF * +* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * +* DAMAGE. * +* * +* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + + +1. Overview +=========== + + As a tool and a code base, OGNL can be used as is or can be +cannibalized for its parts. Its possible uses and features include: + + * OGNL was first conceived as a mechanism for associating parts of + GUIs with model objects. A single expression is used both to pull + the appropriate value from the model for display by a widget, and + to push the newly edited value back into the model when editing is + complete. + + * OGNL's current syntax includes most of Java's operators and a few + of its own. It is probably close to powerful enough to be used by + a debugger or other system that requires run-time interpretation + of expressions. + + * OGNL has fully integrated support for arbitrary-precision math, as + embodied by the classes of the java.math package, meaning that + OGNL's arithmetic operators work on BigIntegers and BigDecimals as + well as the primitive types. While this is of marginal use (at + best) to OGNL as a GUI hooker-upper, it could be valuable in other + settings. + + +2. Building +=========== + + OGNL was designed for JDK 1.2 (now known as Java 2). It is possible +to modify the code to run under 1.1, though the extensive use of the +1.2 collections API makes this a bit painful. If you have the JDK 1.1 +version of the 1.2 collections, which was made available in the summer +of 1998 by the InfoBus group at Sun (and still available in June 1999 +at http://java.sun.com/beans/infobus), the job will be easier. + + If you have GNU make, the GNUmakefile provided will build the OGNL +package, run the test program, and use javadoc to produce API +documentation; all on NT, Win98 or Unix systems. Please see that +file for more information on what build targets are available. + + +3. Documentation +================ + + OGNL is documented in the accompanying file "package.html", which is +used by javadoc as the ognl package description. The best way to view +this is to generate javadoc (using "make doc" if you have GNU make), +and then open the generated file "index.html" in the javadoc-created +"doc" subdirectory, using your favorite HTML browser. The package +description will be below the lists of interfaces and classes. + + The accompanying test program, Test.java, can be thought of as +"practical documentation." + + +4. Feedback +=========== + + If you have any observations or complaints about OGNL or its +implementation or documentation, we would like to hear from you. You +can reach Luke Blanshard by email at luke@quiq.com, or Drew Davidson at +drew@ognl.org. diff --git a/WEB-INF/lib/bsf-2.3.0.jar b/WEB-INF/lib/bsf-2.3.0.jar new file mode 100755 index 0000000..caa4dea Binary files /dev/null and b/WEB-INF/lib/bsf-2.3.0.jar differ diff --git a/WEB-INF/lib/commons-beanutils-1.6.1.jar b/WEB-INF/lib/commons-beanutils-1.6.1.jar new file mode 100755 index 0000000..795655a Binary files /dev/null and b/WEB-INF/lib/commons-beanutils-1.6.1.jar differ diff --git a/WEB-INF/lib/commons-collections-2.1.jar b/WEB-INF/lib/commons-collections-2.1.jar new file mode 100755 index 0000000..f66c6d2 Binary files /dev/null and b/WEB-INF/lib/commons-collections-2.1.jar differ diff --git a/WEB-INF/lib/commons-configuration-1.0-dev.jar b/WEB-INF/lib/commons-configuration-1.0-dev.jar new file mode 100755 index 0000000..c0f1011 Binary files /dev/null and b/WEB-INF/lib/commons-configuration-1.0-dev.jar differ diff --git a/WEB-INF/lib/commons-dbcp-1.0-dev-20020806.jar b/WEB-INF/lib/commons-dbcp-1.0-dev-20020806.jar new file mode 100755 index 0000000..a599753 Binary files /dev/null and b/WEB-INF/lib/commons-dbcp-1.0-dev-20020806.jar differ diff --git a/WEB-INF/lib/commons-digester-1.5.jar b/WEB-INF/lib/commons-digester-1.5.jar new file mode 100755 index 0000000..c2a7d9d Binary files /dev/null and b/WEB-INF/lib/commons-digester-1.5.jar differ diff --git a/WEB-INF/lib/commons-fileupload-1.0.jar b/WEB-INF/lib/commons-fileupload-1.0.jar new file mode 100755 index 0000000..1ca4a9c Binary files /dev/null and b/WEB-INF/lib/commons-fileupload-1.0.jar differ diff --git a/WEB-INF/lib/commons-lang-1.0.jar b/WEB-INF/lib/commons-lang-1.0.jar new file mode 100755 index 0000000..43e515c Binary files /dev/null and b/WEB-INF/lib/commons-lang-1.0.jar differ diff --git a/WEB-INF/lib/commons-logging-1.0.2.jar b/WEB-INF/lib/commons-logging-1.0.2.jar new file mode 100755 index 0000000..aca1e41 Binary files /dev/null and b/WEB-INF/lib/commons-logging-1.0.2.jar differ diff --git a/WEB-INF/lib/commons-pool-1.0.jar b/WEB-INF/lib/commons-pool-1.0.jar new file mode 100755 index 0000000..4a155cf Binary files /dev/null and b/WEB-INF/lib/commons-pool-1.0.jar differ diff --git a/WEB-INF/lib/jakarta-oro-2.0.6.jar b/WEB-INF/lib/jakarta-oro-2.0.6.jar new file mode 100755 index 0000000..346504c Binary files /dev/null and b/WEB-INF/lib/jakarta-oro-2.0.6.jar differ diff --git a/WEB-INF/lib/javassist-2.5.1.jar b/WEB-INF/lib/javassist-2.5.1.jar new file mode 100755 index 0000000..08f65c1 Binary files /dev/null and b/WEB-INF/lib/javassist-2.5.1.jar differ diff --git a/WEB-INF/lib/jdbc-2.0.jar b/WEB-INF/lib/jdbc-2.0.jar new file mode 100755 index 0000000..ddafa13 Binary files /dev/null and b/WEB-INF/lib/jdbc-2.0.jar differ diff --git a/WEB-INF/lib/log4j-1.2.6.jar b/WEB-INF/lib/log4j-1.2.6.jar new file mode 100755 index 0000000..be4a917 Binary files /dev/null and b/WEB-INF/lib/log4j-1.2.6.jar differ diff --git a/WEB-INF/lib/mysql-driver.jar b/WEB-INF/lib/mysql-driver.jar new file mode 100755 index 0000000..eb3469d Binary files /dev/null and b/WEB-INF/lib/mysql-driver.jar differ diff --git a/WEB-INF/lib/ognl-2.5.1.jar b/WEB-INF/lib/ognl-2.5.1.jar new file mode 100755 index 0000000..07a4b74 Binary files /dev/null and b/WEB-INF/lib/ognl-2.5.1.jar differ diff --git a/WEB-INF/lib/stratum-1.0-b3.jar b/WEB-INF/lib/stratum-1.0-b3.jar new file mode 100755 index 0000000..1cd14ac Binary files /dev/null and b/WEB-INF/lib/stratum-1.0-b3.jar differ diff --git a/WEB-INF/lib/tapestry-3.0-beta-3.jar b/WEB-INF/lib/tapestry-3.0-beta-3.jar new file mode 100755 index 0000000..2646c6e Binary files /dev/null and b/WEB-INF/lib/tapestry-3.0-beta-3.jar differ diff --git a/WEB-INF/lib/tapestry-contrib-3.0-beta-3.jar b/WEB-INF/lib/tapestry-contrib-3.0-beta-3.jar new file mode 100755 index 0000000..47ace41 Binary files /dev/null and b/WEB-INF/lib/tapestry-contrib-3.0-beta-3.jar differ diff --git a/WEB-INF/lib/torque-3.0.jar b/WEB-INF/lib/torque-3.0.jar new file mode 100755 index 0000000..7d0d902 Binary files /dev/null and b/WEB-INF/lib/torque-3.0.jar differ diff --git a/WEB-INF/lib/village-2.0-dev-20021111.jar b/WEB-INF/lib/village-2.0-dev-20021111.jar new file mode 100755 index 0000000..af381f3 Binary files /dev/null and b/WEB-INF/lib/village-2.0-dev-20021111.jar differ diff --git a/WEB-INF/web.xml b/WEB-INF/web.xml new file mode 100755 index 0000000..e7a305d --- /dev/null +++ b/WEB-INF/web.xml @@ -0,0 +1,70 @@ + + + + Roster + + + + roster-application + + org.apache.tapestry.ApplicationServlet + + + org.apache.tapestry.application-specification + /org/thdl/roster/Roster.application + + + + org.apache.tapestry.disable-caching + true + + + + torque-properties-path + + /org/thdl/roster/roster-torque.properties + + + + roster-uploads-directory + + /Users/travis/webapps/roster/uploads/ + + + 0 + + + + + test-servlet + org.thdl.commons.TestServlet + 0 + + + + roster-application + /tapestry + + + + test-servlet + /test + + + + 120 + + + + + + + + roster.html + + + diff --git a/build.xml b/build.xml new file mode 100755 index 0000000..c72014a --- /dev/null +++ b/build.xml @@ -0,0 +1,167 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The THDL Roster Javadocs]]> + Copyright © 2003 THDL. All Rights Reserved.]]> + + + + + + + + + + + + + + + + + + + + + + diff --git a/images/.DS_Store b/images/.DS_Store new file mode 100755 index 0000000..5008ddf Binary files /dev/null and b/images/.DS_Store differ diff --git a/images/deselect_left.gif b/images/deselect_left.gif new file mode 100755 index 0000000..2940e01 Binary files /dev/null and b/images/deselect_left.gif differ diff --git a/images/deselect_left_off.gif b/images/deselect_left_off.gif new file mode 100755 index 0000000..84dc945 Binary files /dev/null and b/images/deselect_left_off.gif differ diff --git a/images/move_down.gif b/images/move_down.gif new file mode 100755 index 0000000..8fb0088 Binary files /dev/null and b/images/move_down.gif differ diff --git a/images/move_down_off.gif b/images/move_down_off.gif new file mode 100755 index 0000000..174baeb Binary files /dev/null and b/images/move_down_off.gif differ diff --git a/images/move_up.gif b/images/move_up.gif new file mode 100755 index 0000000..711c86a Binary files /dev/null and b/images/move_up.gif differ diff --git a/images/move_up_off.gif b/images/move_up_off.gif new file mode 100755 index 0000000..e23a43f Binary files /dev/null and b/images/move_up_off.gif differ diff --git a/images/select_right.gif b/images/select_right.gif new file mode 100755 index 0000000..74e90c3 Binary files /dev/null and b/images/select_right.gif differ diff --git a/images/select_right_off.gif b/images/select_right_off.gif new file mode 100755 index 0000000..452ce50 Binary files /dev/null and b/images/select_right_off.gif differ diff --git a/images/show-inspector.gif b/images/show-inspector.gif new file mode 100755 index 0000000..a1bd2ff Binary files /dev/null and b/images/show-inspector.gif differ diff --git a/images/transparent.gif b/images/transparent.gif new file mode 100755 index 0000000..20ab3e5 Binary files /dev/null and b/images/transparent.gif differ diff --git a/images/warning.gif b/images/warning.gif new file mode 100755 index 0000000..cef7f69 Binary files /dev/null and b/images/warning.gif differ diff --git a/images/workbench.gif b/images/workbench.gif new file mode 100755 index 0000000..6a2bee2 Binary files /dev/null and b/images/workbench.gif differ diff --git a/roster.css b/roster.css new file mode 100755 index 0000000..5e674fe --- /dev/null +++ b/roster.css @@ -0,0 +1,189 @@ +/* STYLE */ + +h2 { +text-transform: uppercase; +} + +.highlightBox +{ + clear: left; +} + +.highlightBox h2 +{ +text-transform: none; +} + +#status +{ +float: right; +text-align: right; +width: 50%; +} + +.viewOptions +{ +width: 34%; +border: solid 1px green; +} + +div.viewOptions select +{ +width: 18em; +} + +/* .nowrap +{ +display: inline; +border: solid 2px blue; +width: 60%; +} */ + +.titleCaption +{ +float:right;; +border: solid 1px yellow; +width: 45%; +} + +.options +{ +float:right;; +border: solid 1px green; +width: 19%; +} + +* +{ +font-family: 'Arial Unicode MS', 'Lucida Grande', Verdana, Helvetica, Arial, sans-serif !important; +} + +.warning +{ +color: red; +} + +.message +{ +color: #006666; +} + +.prominent +{ +font-size: 1.1em; +} + +.label +{ +font-weight: bold; +} + +.inline-help +{ +font-size: .9em; +color: #006666; +} +p.palette +{ +margin: 10px 10px 10px 10px; +padding-left: 10px; +border: 1px solid gray; +background-color: white; +} + +TABLE.palette TH +{ +font-weight: bold; +color: black; +background-color: silver; +border: 1px solid gray; +text-align: center; +} + +TABLE.palette SELECT +{ + font-weight: bold; + background-color: silver; + width: 200px; +} +TABLE.palette TD.controls +{ + text-align: center; +} +TABLE.palette TD.controls a:hover +{ + background-color:white; +} + +img +{ + border: 0 !important; +} +/* LAYOUT */ + +#columnCenter { +margin-left: 20px; +max-width: 1000px; +} + +#loginForm, #sendInfoForm, #newUserForm +{ +margin: 10px 10px 10px 10px; +padding: 10px 0 10px 0; +border: 1px solid silver; +} + +#wizard +{ +border-bottom: 2px solid black; +margin: 30px 20px 0px 20px; +padding: 0px; +z-index: 1; +padding-left: 10px +} + +#wizard li +{ +display: inline; +overflow: hidden; +list-style-type: none; +} + +#wizard li +{ +background-color: #E5E5E5; +font-weight: bold; +border: 2px solid black; +padding: 5px 5px 0px 5px; +margin: 0px 3px 0px 0px; +text-decoration: none; +} + +#wizard li.activeTab +{ +background-color: white; +border-bottom: 2px solid white; +} + +#wizard a:hover +{ +background-color: white; +} + + +#wizard h1, #wizard h2, #wizard h3 +{ +clear: left; +} + +#tabbedBody +{ +margin: 0px 20px 20px 20px; +background-color: white; +height: auto; +padding: 20px; +border: 2px solid black; +border-top: none; +z-index: 2; +} + diff --git a/roster.html b/roster.html new file mode 100755 index 0000000..07cdff0 --- /dev/null +++ b/roster.html @@ -0,0 +1,14 @@ + + + +Roster Home + + + +

Roster in Tapestry


+
Go to application
+Test Unicode
+ + + + diff --git a/schema/.DS_Store b/schema/.DS_Store new file mode 100755 index 0000000..5008ddf Binary files /dev/null and b/schema/.DS_Store differ diff --git a/schema/id-table-schema.xml b/schema/id-table-schema.xml new file mode 100755 index 0000000..afec5c5 --- /dev/null +++ b/schema/id-table-schema.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
diff --git a/schema/roster-schema.xml b/schema/roster-schema.xml new file mode 100755 index 0000000..8141e76 --- /dev/null +++ b/schema/roster-schema.xml @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100755 index 0000000..20b7034 Binary files /dev/null and b/src/.DS_Store differ diff --git a/src/java/.DS_Store b/src/java/.DS_Store new file mode 100755 index 0000000..68394d9 Binary files /dev/null and b/src/java/.DS_Store differ diff --git a/src/java/org/.DS_Store b/src/java/org/.DS_Store new file mode 100755 index 0000000..b3da765 Binary files /dev/null and b/src/java/org/.DS_Store differ diff --git a/src/java/org/thdl/.DS_Store b/src/java/org/thdl/.DS_Store new file mode 100755 index 0000000..0612f8d Binary files /dev/null and b/src/java/org/thdl/.DS_Store differ diff --git a/src/java/org/thdl/roster/.DS_Store b/src/java/org/thdl/roster/.DS_Store new file mode 100755 index 0000000..6b82c90 Binary files /dev/null and b/src/java/org/thdl/roster/.DS_Store differ diff --git a/src/java/org/thdl/roster/EntitySelectionModel.java b/src/java/org/thdl/roster/EntitySelectionModel.java new file mode 100755 index 0000000..9ee3a84 --- /dev/null +++ b/src/java/org/thdl/roster/EntitySelectionModel.java @@ -0,0 +1,154 @@ +package org.thdl.roster; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tapestry.ApplicationRuntimeException; +import org.apache.tapestry.form.IPropertySelectionModel; + +/** + * This class is used as a property selection model to select a primary key. We + * assume that the primary keys are integers, which makes it easy to translate + * between the various representations. + * + *@author Howard Lewis Ship + *@created March 13, 2003 + *@version $Id: EntitySelectionModel.java,v 1.5 2003/01/13 03:33:28 hlship + * Exp $ + */ + +public class EntitySelectionModel implements IPropertySelectionModel +{ + + private final static int LIST_SIZE = 20; + + private List entries = new ArrayList( LIST_SIZE ); + + + /** + * Description of the Method + * + *@param key Description of the Parameter + *@param label Description of the Parameter + */ + public void add( Integer key, String label ) + { + Entry entry; + + entry = new Entry( key, label ); + entries.add( entry ); + } + + + /** + * Gets the optionCount attribute of the EntitySelectionModel object + * + *@return The optionCount value + */ + public int getOptionCount() + { + return entries.size(); + } + + + /** + * Description of the Method + * + *@param index Description of the Parameter + *@return Description of the Return Value + */ + private Entry get( int index ) + { + return (Entry) entries.get( index ); + } + + + /** + * Gets the option attribute of the EntitySelectionModel object + * + *@param index Description of the Parameter + *@return The option value + */ + public Object getOption( int index ) + { + return get( index ).primaryKey; + } + + + /** + * Gets the label attribute of the EntitySelectionModel object + * + *@param index Description of the Parameter + *@return The label value + */ + public String getLabel( int index ) + { + return get( index ).label; + } + + + /** + * Gets the value attribute of the EntitySelectionModel object + * + *@param index Description of the Parameter + *@return The value value + */ + public String getValue( int index ) + { + Integer primaryKey; + + primaryKey = get( index ).primaryKey; + + if ( primaryKey == null ) + { + return ""; + } + + return primaryKey.toString(); + } + + + /** + * Description of the Method + * + *@param value Description of the Parameter + *@return Description of the Return Value + */ + public Object translateValue( String value ) + { + if ( value.equals( "" ) ) + { + return null; + } + + try + { + return new Integer( value ); + } + catch ( NumberFormatException e ) + { + throw new ApplicationRuntimeException( "Could not convert '" + value + "' to an Integer.", e ); + } + } + + + private static class Entry + { + Integer primaryKey; + String label; + + + /** + * Constructor for the Entry object + * + *@param primaryKey Description of the Parameter + *@param label Description of the Parameter + */ + Entry( Integer primaryKey, String label ) + { + this.primaryKey = primaryKey; + this.label = label; + } + + } +} diff --git a/src/java/org/thdl/roster/Global.java b/src/java/org/thdl/roster/Global.java new file mode 100755 index 0000000..59b47ad --- /dev/null +++ b/src/java/org/thdl/roster/Global.java @@ -0,0 +1,182 @@ +package org.thdl.roster; + +import java.util.*; +import java.text.*; +import org.apache.tapestry.*; +import org.apache.torque.*; +import org.apache.torque.util.*; +import org.apache.torque.om.*; +import org.thdl.roster.om.*; +import org.apache.commons.configuration.Configuration; +import org.apache.commons.configuration.BaseConfiguration; +import org.apache.commons.configuration.PropertiesConfiguration; + +public class Global +{ +//attributes + private List allPeople; + private List allOrganizations; + private List allProjects; + private List representedCountries; + private Configuration torqueConfig; +//accessors + public void setRepresentedCountries(List representedCountries) { + this.representedCountries = representedCountries; + } + public List getRepresentedCountries() { + if ( null == representedCountries ) + { + setRepresentedCountries( refreshRepresentedCountries() ); + } + return representedCountries; + } + public void setAllPeople(List allPeople) { + this.allPeople = allPeople; + } + public void setAllOrganizations(List allOrganizations) { + this.allOrganizations = allOrganizations; + } + public void setAllProjects(List allProjects) { + this.allProjects = allProjects; + } + public List getAllPeople() { + if (null == allPeople) + { + setAllPeople( refreshPeople() ); + } + return allPeople; + } + public List getAllOrganizations() { + if (null == allOrganizations) + { + setAllOrganizations( refreshOrganizations() ); + } + return allOrganizations; + } + public List getAllProjects() { + if (null == allProjects) + { + setAllProjects( refreshProjects() ); + } + return allProjects; + } + private void setTorqueConfig(Configuration torqueConfig) { + this.torqueConfig = torqueConfig; + } + public Configuration getTorqueConfig() throws ApplicationRuntimeException { + if (null== torqueConfig) + { + setTorqueConfig( fileConfig() ); + } + return torqueConfig; + } +//helpers + public List refreshPeople() + { + try + { + Criteria crit = new Criteria(); + crit.add( MemberPeer.MEMBER_TYPE, MemberPeer.CLASSKEY_PERSON ); + crit.addJoin( MemberPeer.PERSON_DATA_ID, PersonDataPeer.ID ); + crit.addAscendingOrderByColumn( PersonDataPeer.LASTNAME ); + List people = MemberPeer.doSelect( crit ); + return java.util.Collections.synchronizedList( people ); + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } + } + + public List refreshOrganizations() + { + try + { + Criteria crit = new Criteria(); + crit.add( MemberPeer.MEMBER_TYPE, MemberPeer.CLASSKEY_ORGANIZATION ); + crit.addJoin( MemberPeer.ORGANIZATION_DATA_ID, OrganizationDataPeer.ID ); + crit.addAscendingOrderByColumn( OrganizationDataPeer.NAME ); + List organizations = MemberPeer.doSelect( crit ); + return java.util.Collections.synchronizedList( organizations ); + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } + } + + public List refreshProjects() + { + try + { + Criteria crit = new Criteria(); + crit.add( MemberPeer.MEMBER_TYPE, MemberPeer.CLASSKEY_PROJECT ); + crit.addJoin( MemberPeer.PROJECT_DATA_ID, ProjectDataPeer.ID ); + crit.addAscendingOrderByColumn( ProjectDataPeer.NAME ); + List projects = MemberPeer.doSelect( crit ); + return java.util.Collections.synchronizedList( projects ); + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } + } + public List refreshRepresentedCountries() + { + try + { + String sql="SELECT DISTINCT Country.* FROM Country, Address WHERE Address.country_id = Country.id"; + List villageRecords = CountryPeer.executeQuery( sql ); + List countries = CountryPeer.populateObjects( villageRecords ); + return java.util.Collections.synchronizedList( countries ); + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } + } + + private Configuration fileConfig() + { + try { + java.io.InputStream stream = Torque.class.getClassLoader().getResourceAsStream("org/thdl/roster/roster-torque.properties"); + PropertiesConfiguration config = new PropertiesConfiguration(); + config.load( stream ); + return config; + } + catch ( Exception e ) + { + throw new ApplicationRuntimeException( e.toString(), e ); + } + } + +//constructors + public Global() throws Exception + { + try { + if (! Torque.isInit() ) + { + Torque.init( getTorqueConfig() ); + } + } + catch ( Exception e ) + { + throw new ApplicationRuntimeException( e.toString(), e ); + } + } + + //main + public static void main( String[] args ) + { + try { + Global glob = new Global(); + glob.setTorqueConfig( glob.fileConfig() ); + if (! Torque.isInit() ) + { + Torque.init( glob.getTorqueConfig() ); + } + } + catch( Exception e ) { e.printStackTrace(); } + } +} + diff --git a/src/java/org/thdl/roster/PaletteMergeTableProcessor.java b/src/java/org/thdl/roster/PaletteMergeTableProcessor.java new file mode 100755 index 0000000..61a2b9b --- /dev/null +++ b/src/java/org/thdl/roster/PaletteMergeTableProcessor.java @@ -0,0 +1,174 @@ +package org.thdl.roster; + +import java.util.*; +import java.text.*; +import org.apache.tapestry.*; +import org.apache.torque.*; +import org.apache.torque.util.*; +import org.apache.torque.om.*; +import org.thdl.roster.om.*; + +/** + * This is a utility class for processing input from Tapestry Palette Components. + * Palettes are user-sortable multiple-select javascript widgets. + * The data collected are stored in Torque OR Objects that represent rows of a basic merge table. + * This class works in conjunction with torque objects that implement the RosterMergeData interface. + * The merge table should also include field called "relevance" to store the user-specified sort order + * + *@author travis + *@created June 17, 2003 + */ +public class PaletteMergeTableProcessor +{ + /** + * This is the utility method that processes data from the Palette. The examples here all assume that merge data relationship is PersonData::PersonPersonTypes. + * + *@param flatDataIds This is a list of Integers which are primary keys of two-column flat data tables ( PersonType.id, PersonType.personType ) that are used in palette select boxes. + *@param torqueObjects This is a list of Torque Objects that represent rows of the Merge Table (e.g. PersonPersonType ) + *@param memberDataId This is an Integer primary key of the single MemberData (e.g. PersonData) parent for the multiple rows of merge data. + *@param template This is a prototype Torque merge data object passed in to make copies from. (e.g. PersonPersonType, or ProjectProjectType ). + *@exception TorqueException Description of the Exception + *@exception ApplicationRuntimeException Description of the Exception + */ + public static void processPalette( List flatDataIds, List torqueObjects, Integer memberDataId, RosterMergeData template ) throws TorqueException, ApplicationRuntimeException + { + //creative loop + ListIterator flatDataIdsIterator = null; + if ( null != flatDataIds ) + { + flatDataIdsIterator = flatDataIds.listIterator( 0 ); + } + + while ( null != flatDataIdsIterator && flatDataIdsIterator.hasNext() ) + { + Integer flatDataId = (Integer) flatDataIdsIterator.next(); + RosterMergeData torqueObject = null; + + ListIterator torqueObjectsIterator = torqueObjects.listIterator( 0 ); + while ( torqueObjectsIterator.hasNext() ) + { + RosterMergeData mergeData = (RosterMergeData) torqueObjectsIterator.next(); + Integer flat = (Integer) mergeData.getByPosition( 2 ); + if ( flatDataId.equals( flat ) ) + { + torqueObject = mergeData; + } + } + + if ( null == torqueObject ) + { + try + { + torqueObject = (RosterMergeData) template.getClass().newInstance(); + torqueObject.setByPosition( 2, flatDataId ); + torqueObject.setByPosition( 3, memberDataId ); + } + catch ( Exception e ) + { + throw new ApplicationRuntimeException( e.getMessage(), e ); + } + } + try + { + Integer relevance = new Integer( flatDataIdsIterator.previousIndex() ); + torqueObject.setByPosition( 4, relevance ); + torqueObject.save(); + } + catch ( Exception e ) + { + throw new ApplicationRuntimeException( e.getMessage(), e ); + } + } + //destructive loop + ListIterator torqueObjectsIterator = torqueObjects.listIterator( 0 ); + while ( torqueObjectsIterator.hasNext() ) + { + RosterMergeData mergeObject = (RosterMergeData) torqueObjectsIterator.next(); + boolean match = false; + + if ( null != flatDataIds ) + { + flatDataIdsIterator = flatDataIds.listIterator( 0 ); + while ( flatDataIdsIterator.hasNext() ) + { + Integer flatDataId = (Integer) flatDataIdsIterator.next(); + if ( flatDataId.equals( mergeObject.getByPosition( 2 ) ) ) + { + match = true; + break; + } + } + if ( match == false ) + { + try + { + mergeObject.remove(); + } + catch ( Exception e ) + { + throw new ApplicationRuntimeException( "destruction loop says: " + e.getMessage(), e ); + } + } + } + else + { + try + { + mergeObject.remove(); + } + catch ( Exception e ) + { + throw new ApplicationRuntimeException( "destruction loop says: " + e.getMessage(), e ); + } + } + } + } + +//main + + /** + * The main program for the PaletteMergeTableProcessor class + * + *@param args The command line arguments + */ + public static void main( String[] args ) + { + try + { + /* + * java.io.InputStream stream = Torque.class.getClassLoader().getResourceAsStream("org/thdl/roster/roster-torque.properties"); + * org.apache.commons.configuration.PropertiesConfiguration config = new org.apache.commons.configuration.PropertiesConfiguration(); + * config.load( stream ); + */ + Torque.init( "./roster-torque.properties" ); + + Member person = MemberPeer.retrieveByPK( new Integer( 1020 ) ); + List flatDataIds = new LinkedList(); + flatDataIds.add( new Integer( 1 ) ); + flatDataIds.add( new Integer( 2 ) ); + flatDataIds.add( new Integer( 3 ) ); + List torqueObjects = person.getPersonData().getPersonPersonTypes(); + Integer memberDataId = person.getPersonData().getId(); + PersonPersonType template = new PersonPersonType(); + //PaletteMergeTableProcessor.processPalette( flatDataIds, torqueObjects, memberDataId, template ); + + System.out.println( MemberPeer.executeQuery( "select count( id ) from PersonPersonType" ) ); + + /* + * flatDataIds = new LinkedList(); + * flatDataIds.add( new Integer( 4 ) ); + * flatDataIds.add( new Integer( 5 ) ); + * flatDataIds.add( new Integer( 6 ) ); + * torqueObjects = person.getPersonData().getPersonPersonTypes(); + * PaletteMergeTableProcessor.processPalette( flatDataIds, torqueObjects, memberDataId, template ); + * System.out.println( MemberPeer.executeQuery( "select count( id ) from PersonPersonType" ) ); + */ + } + catch ( Exception e ) + { + e.printStackTrace(); + } + } + +} + diff --git a/src/java/org/thdl/roster/Roster.application b/src/java/org/thdl/roster/Roster.application new file mode 100755 index 0000000..eb9712d --- /dev/null +++ b/src/java/org/thdl/roster/Roster.application @@ -0,0 +1,66 @@ + + + + + +org.thdl.roster.Visit +org.thdl.roster.Global +true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/RosterConstants.java b/src/java/org/thdl/roster/RosterConstants.java new file mode 100755 index 0000000..ca20d66 --- /dev/null +++ b/src/java/org/thdl/roster/RosterConstants.java @@ -0,0 +1,10 @@ +package org.thdl.roster; + +public class RosterConstants +{ + protected final static String DRIVER = "com.mysql.jdbc.Driver"; + protected final static String USER = "moojoo"; + protected final static String PASSWORD = "googoo"; + protected final static String URL = "jdbc:mysql://localhost/Roster"; +} + diff --git a/src/java/org/thdl/roster/RosterEngine.java b/src/java/org/thdl/roster/RosterEngine.java new file mode 100755 index 0000000..ce9117b --- /dev/null +++ b/src/java/org/thdl/roster/RosterEngine.java @@ -0,0 +1,43 @@ +package org.thdl.roster; + +import org.apache.tapestry.engine.BaseEngine; +import org.apache.tapestry.request.RequestContext; +import org.apache.tapestry.form.IPropertySelectionModel; +import org.apache.torque.*; +import org.apache.torque.util.Criteria; +import java.util.*; +import java.io.*; +import javax.servlet.ServletException; +import java.util.ResourceBundle; + +import org.apache.tapestry.IRequestCycle; +import org.apache.tapestry.ApplicationRuntimeException; +import org.apache.tapestry.form.EnumPropertySelectionModel; +import org.apache.tapestry.form.IPropertySelectionModel; +import org.apache.tapestry.form.StringPropertySelectionModel; +import org.apache.tapestry.html.BasePage; +import org.apache.tapestry.contrib.palette.SortMode; +import org.thdl.roster.Visit; +import org.thdl.roster.om.*; + +public class RosterEngine extends BaseEngine +{ + private static final String[] PAGE_NAMES = { "Home", "Search", "People", "Organizations", "Projects", "Login" }; + private static final String[] PERSON_WIZARD_PAGES= { "Contact", "Background", "Activities", "Works", "Uploads" }; + + public String[] getPageNames() + { + return PAGE_NAMES; + } + public String[] getPersonWizardPages() + { + return PERSON_WIZARD_PAGES; + } + public boolean service(RequestContext context) throws ServletException, IOException + { + context.getRequest().setCharacterEncoding("UTF-8"); + + return super.service(context); + } + +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/RosterQuery.java b/src/java/org/thdl/roster/RosterQuery.java new file mode 100755 index 0000000..9f62780 --- /dev/null +++ b/src/java/org/thdl/roster/RosterQuery.java @@ -0,0 +1,243 @@ +package org.thdl.roster; + +import java.util.*; +import org.thdl.roster.om.*; +import org.apache.torque.*; +import org.apache.torque.util.*; + +public class RosterQuery implements java.io.Serializable +{ +//attributes + //private RosterQueryAgent queryAgent; + private HashMap memberTypes; + /*private String memberType; */ + + private String name; + private String organizationalBase; + private String anywhere; + private List representedCountries; //stores a reference to Global.representedCountries + private HashMap countries; + private Country country; + private String sql; + private Integer selectedDiscipline; + private Integer selectedLanguage; + private Integer selectedCulturalArea; + private Integer selectedPersonType; + private Integer selectedProjectType; + private Integer selectedOrganizationType; + +//accessors + + public void setSelectedPersonType(Integer selectedPersonType) { + this.selectedPersonType = selectedPersonType; + } + + public void setSelectedProjectType(Integer selectedProjectType) { + this.selectedProjectType = selectedProjectType; + } + + public void setSelectedOrganizationType(Integer selectedOrganizationType) { + this.selectedOrganizationType = selectedOrganizationType; + } + + public Integer getSelectedPersonType() { + return selectedPersonType; + } + + public Integer getSelectedProjectType() { + return selectedProjectType; + } + + public Integer getSelectedOrganizationType() { + return selectedOrganizationType; + } + + public void setPeople(Boolean people) { + getMemberTypes().put( MemberPeer.CLASSKEY_PERSON, people ); + } + + public void setProjects(Boolean projects) { + getMemberTypes().put( MemberPeer.CLASSKEY_PROJECT, projects ); + } + + public void setOrganizations(Boolean organizations) { + getMemberTypes().put( MemberPeer.CLASSKEY_ORGANIZATION, organizations ); + } + + public Boolean getPeople() { + return (Boolean)getMemberTypes().get( MemberPeer.CLASSKEY_PERSON ); + } + + public Boolean getProjects() { + return (Boolean)getMemberTypes().get( MemberPeer.CLASSKEY_PROJECT ); + } + + public Boolean getOrganizations() { + return (Boolean)getMemberTypes().get( MemberPeer.CLASSKEY_ORGANIZATION ); + } + public void setOrganizationalBase(String organizationalBase) { + this.organizationalBase = organizationalBase; + } + + public String getOrganizationalBase() { + return organizationalBase; + } + + public void setAnywhere(String anywhere) { + this.anywhere = anywhere; + } + + public String getAnywhere() { + return anywhere; + } + + public void setSelectedCulturalArea(Integer selectedCulturalArea) { + this.selectedCulturalArea = selectedCulturalArea; + } + + public Integer getSelectedCulturalArea() { + return selectedCulturalArea; + } + + public void setSelectedLanguage(Integer selectedLanguage) { + this.selectedLanguage = selectedLanguage; + } + + public Integer getSelectedLanguage() { + return selectedLanguage; + } + + public void setSelectedDiscipline(Integer selectedDiscipline) { + this.selectedDiscipline = selectedDiscipline; + } + + public Integer getSelectedDiscipline() { + return selectedDiscipline; + } + + public void setRepresentedCountries(List representedCountries) { + this.representedCountries = representedCountries; + } + + public List getRepresentedCountries() { + return representedCountries; + } + + public void setSelectedCountry( Boolean selectedCountry ) { + getCountries().put( getCountry(), selectedCountry ); + } + + public Boolean getSelectedCountry() { + Country key = getCountry(); + Boolean selected = (Boolean)getCountries().get( key ); + return selected; + } + + public void setCountries(HashMap countries) { + this.countries = countries; + } + + public HashMap getCountries() { + if ( null == countries ) + { + refreshCountries(); + } + return countries; + } + +/* public void setSelectedMemberType(Boolean selectedMemberType) { + getMemberTypes().put( getMemberType(), selectedMemberType ); + } + + public Boolean getSelectedMemberType() { + String key = getMemberType(); + Boolean selected = (Boolean)getMemberTypes().get( key ); + return selected; + } +*/ + public void setMemberTypes(HashMap memberTypes) { + this.memberTypes = memberTypes; + } + + public HashMap getMemberTypes() { + return memberTypes; + } + +/* public void setMemberType(String memberType) { + this.memberType = memberType; + } + public String getMemberType() { + return memberType; + } + +*/ + + public void setName(String name) { + this.name = name; + } + + public void setCountry(Country country) { + this.country = country; + } + + public String getName() { + return name; + } + + public Country getCountry() { + return country; + } + + public void setSql(String sql) { + this.sql = sql; + } + + public String getSql() { + return sql; + } +//helpers + public void clear() + { + setCountries( null ); + setName( null ); + setOrganizationalBase( null ); + setAnywhere( null ); + setSql( null ); + setSelectedDiscipline( null ); + setSelectedLanguage( null ); + setSelectedCulturalArea( null ); + setSelectedPersonType( null ); + setSelectedProjectType( null ); + setSelectedOrganizationType( null ); + } + public void refreshCountries() + { + setCountries( new HashMap() ); + Iterator countries = getRepresentedCountries().iterator(); + while (countries.hasNext()) + { + getCountries().put( countries.next(), Boolean.TRUE ); + } + } + +// constructors + public RosterQuery() + { + setCountries( new HashMap() ); + setMemberTypes( new HashMap() ); + /* getMemberTypes().put( MemberPeer.CLASSKEY_PERSON, Boolean.TRUE ); + getMemberTypes().put( MemberPeer.CLASSKEY_PROJECT, Boolean.TRUE ); + getMemberTypes().put( MemberPeer.CLASSKEY_ORGANIZATION, Boolean.TRUE ); */ + setPeople( Boolean.TRUE ); + setProjects( Boolean.TRUE ); + setOrganizations( Boolean.TRUE ); + } + public RosterQuery( List representedCountries ) + { + this(); + setRepresentedCountries( representedCountries ); + refreshCountries(); + //setQueryAgent( new RosterQueryAgent() ); + } + +} diff --git a/src/java/org/thdl/roster/RosterQueryAgent.java b/src/java/org/thdl/roster/RosterQueryAgent.java new file mode 100755 index 0000000..2c85f29 --- /dev/null +++ b/src/java/org/thdl/roster/RosterQueryAgent.java @@ -0,0 +1,301 @@ +package org.thdl.roster; + +import java.util.*; +import org.apache.commons.configuration.*; + +import org.apache.tapestry.*; +import org.apache.tapestry.form.*; +import org.apache.torque.*; +import org.apache.torque.util.*; +import org.thdl.roster.*; +import org.thdl.roster.om.*; + +public class RosterQueryAgent + { + public String esc( String rawText ) throws TorqueException + { + return SqlExpression.quoteAndEscapeText( rawText, Torque.getDB( Torque.getDefaultDB() ) ); + } + + // Custom Query helpers + + public String buildQuery( RosterQuery query) throws TorqueException + { + StringBuffer sql = new StringBuffer() ; + sql.append( " \n\nSELECT DISTINCT Member.* FROM Member " ); + sql.append( " \nLEFT JOIN PersonData ON Member.person_data_id = PersonData.id " ); + sql.append( " \nLEFT JOIN ProjectData ON Member.project_data_id = ProjectData.id " ); + sql.append( " \nLEFT JOIN OrganizationData ON Member.organization_data_id = OrganizationData.id " ); + sql.append( " \nLEFT JOIN ContactInfo ON Member.contact_info_id = ContactInfo.id " ); + sql.append( " \nLEFT JOIN Address ON ContactInfo.address_id = Address.id " ); + sql.append( " \nLEFT JOIN Publication ON Member.publication_id = Publication.id " ); + sql.append( " \nLEFT JOIN ResearchInterest ON Member.research_interest_id = ResearchInterest.id " ); + sql.append( " \nLEFT JOIN ResearchInterestDiscipline ON ResearchInterest.id = ResearchInterestDiscipline.research_interest_id " ); + sql.append( " \nLEFT JOIN ResearchInterestCulturalArea ON ResearchInterest.id = ResearchInterestCulturalArea.research_interest_id " ); + sql.append( " \nLEFT JOIN ResearchInterestLanguage ON ResearchInterest.id = ResearchInterestLanguage.research_interest_id " ); + sql.append( " \nLEFT JOIN PersonPersonType ON PersonData.id = PersonPersonType.person_data_id " ); + sql.append( " \nLEFT JOIN ProjectProjectType ON ProjectData.id = ProjectProjectType.project_data_id " ); + sql.append( " \nLEFT JOIN OrganizationOrganizationType ON OrganizationData.id = OrganizationOrganizationType.organization_data_id " ); + sql.append( " \nWHERE Member.deleted = 'false' " ); + appendNames( sql, query ); + appendOrganizationalBase( sql, query ); + appendAnywhere( sql, query ); + appendMemberTypes( sql, query ); + appendCountries( sql, query ); + appendDiscipline( sql, query ); + appendLanguage( sql, query ); + appendCulturalArea( sql, query ); + sql.append( " \nORDER BY OrganizationData.name, ProjectData.name, PersonData.lastname" ); + return sql.toString(); + } + + public List executeQuery( String sql ) throws TorqueException + { + List villageRecords = MemberPeer.executeQuery( sql ); + List members = MemberPeer.populateObjects( villageRecords ); + return members; + } + + public void appendCulturalArea( StringBuffer sql, RosterQuery query ) + { + if ( null != query.getSelectedCulturalArea() ) + { + sql.append( " \nAND ResearchInterestCulturalArea.cultural_area_id = " ); + sql.append( query.getSelectedCulturalArea() ); + } + } + + public void appendLanguage( StringBuffer sql, RosterQuery query ) + { + if ( null != query.getSelectedLanguage() ) + { + sql.append( " \nAND ResearchInterestLanguage.language_id = " ); + sql.append( query.getSelectedLanguage() ); + } + } + + public void appendDiscipline( StringBuffer sql, RosterQuery query ) + { + if ( null != query.getSelectedDiscipline() ) + { + sql.append( " \nAND ResearchInterestDiscipline.discipline_id = " ); + sql.append( query.getSelectedDiscipline() ); + } + } + + public void appendCountries( StringBuffer sql, RosterQuery query ) throws TorqueException + { + Iterator countries = query.getCountries().keySet().iterator(); + while ( countries.hasNext() ) + { + Country key = (Country)countries.next(); + Boolean value = (Boolean) query.getCountries().get( key ); + if ( value.equals( Boolean.FALSE ) ) + { + sql.append( " \nAND " ); + sql.append( AddressPeer.COUNTRY_ID ); + sql.append( " <> " ); + sql.append( key.getId() ); + } + } + } + + public void appendNames( StringBuffer sql, RosterQuery query ) throws TorqueException + { + if ( null != query.getName() && ! query.getName().equals( "" ) ) + { + String name = "%" + query.getName() + "%"; + name = esc( name ); + sql.append( " \nAND " ); + sql.append( " ( " ); + sql.append( " ( " ); + sql.append( " PersonData.firstname LIKE " ); + sql.append( name ); + sql.append( " \nOR" ); + sql.append( " PersonData.lastname LIKE " ); + sql.append( name ); + sql.append( " ) " ); + sql.append( " \nOR" ); + sql.append( " ProjectData.name LIKE " ); + sql.append( name ); + sql.append( " \nOR" ); + sql.append( " OrganizationData.name LIKE " ); + sql.append( name ); + sql.append( " )" ); + } + } + + public void appendOrganizationalBase( StringBuffer sql, RosterQuery query ) throws TorqueException + { + if ( null != query.getOrganizationalBase() && ! query.getOrganizationalBase().equals( "" ) ) + { + String orgBase = "%" + query.getOrganizationalBase() + "%"; + orgBase = esc( orgBase ); + sql.append( " \nAND " ); + sql.append( " ( " ); + sql.append( " PersonData.parent_organization LIKE " ); + sql.append( orgBase ); + sql.append( " \nOR" ); + sql.append( " ProjectData.parent_organization LIKE " ); + sql.append( orgBase ); + sql.append( " \nOR" ); + sql.append( " OrganizationData.parent_organization LIKE " ); + sql.append( orgBase ); + sql.append( " )" ); + } + } + + public void appendAnywhere( StringBuffer sql, RosterQuery query ) throws TorqueException + { + if ( null != query.getAnywhere() && ! query.getAnywhere().equals( "" ) ) + { + String param = "%" + query.getAnywhere() + "%"; + param = esc( param ); + sql.append( " \nAND " ); + sql.append( " ( " ); + sql.append( " PersonData.firstname LIKE " + param); + sql.append( " \nOR PersonData.middlename LIKE " + param ); + sql.append( " \nOR PersonData.lastname LIKE " + param ); + sql.append( " \nOR PersonData.bio LIKE " + param ); + sql.append( " \nOR PersonData.history LIKE " + param ); + sql.append( " \nOR PersonData.parent_organization LIKE " + param ); + sql.append( " \nOR PersonData.school LIKE " + param ); + sql.append( " \nOR PersonData.department LIKE " + param ); + sql.append( " \nOR PersonData.program LIKE " + param ); + sql.append( " \nOR PersonData.advisor LIKE " + param ); + sql.append( " \nOR PersonData.other_backgrounds LIKE " + param ); + sql.append( " \nOR PersonData.organization LIKE " + param ); + sql.append( " \nOR PersonData.division LIKE " + param ); + sql.append( " \nOR PersonData.title LIKE " + param ); + sql.append( " \nOR PersonData.job_description LIKE " + param ); + + sql.append( " \nOR ProjectData.name LIKE " + param ); + sql.append( " \nOR ProjectData.parent_organization LIKE " + param ); + sql.append( " \nOR ProjectData.divisions LIKE " + param ); + sql.append( " \nOR ProjectData.people LIKE " + param ); + sql.append( " \nOR ProjectData.description LIKE " + param ); + sql.append( " \nOR ProjectData.history LIKE " + param ); + sql.append( " \nOR ProjectData.resources LIKE " + param ); + sql.append( " \nOR ProjectData.education_programs LIKE " + param ); + + sql.append( " \nOR OrganizationData.name LIKE " + param ); + sql.append( " \nOR OrganizationData.parent_organization LIKE " + param ); + sql.append( " \nOR OrganizationData.divisions LIKE " + param ); + sql.append( " \nOR OrganizationData.people LIKE " + param ); + sql.append( " \nOR OrganizationData.description LIKE " + param ); + sql.append( " \nOR OrganizationData.history LIKE " + param ); + sql.append( " \nOR OrganizationData.resources LIKE " + param ); + sql.append( " \nOR OrganizationData.education_programs LIKE " + param ); + + sql.append( " \nOR Publication.formal_publications LIKE " + param ); + sql.append( " \nOR Publication.works_in_progress LIKE " + param ); + sql.append( " \nOR Publication.projects LIKE " + param ); + + sql.append( " \nOR ResearchInterest.interests LIKE " + param ); + sql.append( " \nOR ResearchInterest.activities LIKE " + param ); + sql.append( " \nOR ResearchInterest.collaboration_interests LIKE " + param ); + + sql.append( " ) " ); + } + } + + public void appendMemberTypes( StringBuffer sql, RosterQuery query ) throws TorqueException + { + Iterator memTypes = query.getMemberTypes().keySet().iterator(); + LinkedList sqlParts = new LinkedList(); + StringBuffer sqlPartsConcat = new StringBuffer(); + while ( memTypes.hasNext() ) + { + String key = (String)memTypes.next(); + Boolean value = (Boolean) query.getMemberTypes().get( key ); + if ( value.equals( Boolean.TRUE ) ) + { + StringBuffer tempSql = new StringBuffer(); + tempSql.append( MemberPeer.MEMBER_TYPE ); + tempSql.append( " LIKE " ); + tempSql.append( esc( key ) ); + if ( key.equals( MemberPeer.CLASSKEY_PERSON ) && null != query.getSelectedPersonType() ) + { + tempSql.append( " AND " ); + tempSql.append( PersonPersonTypePeer.PERSON_TYPE_ID ); + tempSql.append( " = " ); + tempSql.append( query.getSelectedPersonType() ); + } + else if ( key.equals( MemberPeer.CLASSKEY_PROJECT ) && null != query.getSelectedProjectType() ) + { + tempSql.append( " AND " ); + tempSql.append( ProjectProjectTypePeer.PROJECT_TYPE_ID ); + tempSql.append( " = " ); + tempSql.append( query.getSelectedProjectType() ); + } + else if ( key.equals( MemberPeer.CLASSKEY_ORGANIZATION ) && null != query.getSelectedOrganizationType() ) + { + tempSql.append( " AND " ); + tempSql.append( OrganizationOrganizationTypePeer.ORGANIZATION_TYPE_ID ); + tempSql.append( " = " ); + tempSql.append( query.getSelectedOrganizationType() ); + } + sqlParts.add( tempSql.toString() ); + } + } + + ListIterator iterator = sqlParts.listIterator(); + int index = 0; + String pieceOfSql; + while ( iterator.hasNext() ) + { + Object object = iterator.next(); + pieceOfSql = (String) object; + if ( index > 0 ) + { + sqlPartsConcat.append( " \nOR " ); + } + else + { + sqlPartsConcat.append( "\n" ); + } + sqlPartsConcat.append( " ( " ); + sqlPartsConcat.append( pieceOfSql ); + sqlPartsConcat.append( " ) " ); + index++; + } + sql.append( " \nAND ( " ); + sql.append( sqlPartsConcat.toString() ); + sql.append( " \n) " ); + } + + public RosterQueryAgent() throws Exception + { + java.io.InputStream stream = Torque.class.getClassLoader().getResourceAsStream("org/thdl/roster/roster-torque.properties"); + PropertiesConfiguration config = new PropertiesConfiguration(); + config.load( stream ); + if ( ! Torque.isInit() ) + { + Torque.init( config ); + } + } + public RosterQueryAgent( Configuration config ) throws Exception + { + if ( ! Torque.isInit() ) + { + Torque.init( config ); + } + } +//main + public static void main(String[] args) + { + try + { + RosterQuery query = new RosterQuery(); + RosterQueryAgent agent = new RosterQueryAgent(); + String sql = agent.buildQuery( query ); + System.out.println( sql ); + System.out.println( agent.executeQuery( sql ) ); + } + catch (Exception te ) + { + te.printStackTrace(); + } + } +} + diff --git a/src/java/org/thdl/roster/RosterTest.java b/src/java/org/thdl/roster/RosterTest.java new file mode 100755 index 0000000..b9767af --- /dev/null +++ b/src/java/org/thdl/roster/RosterTest.java @@ -0,0 +1,38 @@ +package org.thdl.roster; + +import java.util.*; +import org.thdl.roster.om.*; +import org.apache.torque.*; +import org.apache.torque.util.*; +import java.text.*; +public class RosterTest +{ + public void doStuff() + { + try + { + String sql = "SELECT DISTINCT Member.* FROM Member, PersonData, ProjectData, OrganizationData, ContactInfo, Address, ResearchInterest, ResearchInterestDiscipline, ResearchInterestCulturalArea, ResearchInterestLanguage WHERE Member.deleted = 'false' AND ( ( Member.person_data_id = PersonData.id AND ( PersonData.firstname LIKE '%travis%' OR PersonData.lastname LIKE '%travis%' ) ) OR ( Member.project_data_id = ProjectData.id AND ProjectData.name LIKE '%travis%' ) OR ( Member.organization_data_id = OrganizationData.id AND OrganizationData.name LIKE '%travis%' ) ) AND Member.research_interest_id = ResearchInterest.id AND ResearchInterest.id = ResearchInterestDiscipline.research_interest_id AND ResearchInterestDiscipline.discipline_id = 5 AND Member.research_interest_id = ResearchInterest.id AND ResearchInterest.id = ResearchInterestLanguage.research_interest_id AND ResearchInterestLanguage.language_id = 2 AND Member.research_interest_id = ResearchInterest.id AND ResearchInterest.id = ResearchInterestCulturalArea.research_interest_id AND ResearchInterestCulturalArea.cultural_area_id = 1"; + List villageRecords = MemberPeer.executeQuery( sql.toString() ); + System.out.println ( villageRecords ); + List members = MemberPeer.populateObjects( villageRecords ); + System.out.println ( members ); + } + catch (TorqueException te) { + te.printStackTrace( ); + } + } + public static void main( String[] srgs ) + { + try { + if ( ! Torque.isInit() ) + { + Torque.init( "./roster-torque.properties" ); + } + RosterTest rt = new RosterTest(); + rt.doStuff(); + } + catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/src/java/org/thdl/roster/TokenMaker.java b/src/java/org/thdl/roster/TokenMaker.java new file mode 100755 index 0000000..792ca5c --- /dev/null +++ b/src/java/org/thdl/roster/TokenMaker.java @@ -0,0 +1,26 @@ +package org.thdl.roster; + +import java.security.MessageDigest; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +public class TokenMaker +{ + public static String make() throws java.security.NoSuchAlgorithmException + { + long systime = System.currentTimeMillis(); + byte[] time = new Long(systime).toString().getBytes(); + + MessageDigest md5 = MessageDigest.getInstance("MD5"); + md5.update(time); + return toHex( md5.digest() ); + //System.err.println("Unable to calculate MD5 Digests.\nCould not create unique token"); + } + public static String toHex(byte[] digest) + { + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < digest.length; i++) + buf.append( Integer.toHexString( (int)digest[i] & 0x00ff ) ); //param=BITWISE operation + return buf.toString(); + } +} diff --git a/src/java/org/thdl/roster/Visit.java b/src/java/org/thdl/roster/Visit.java new file mode 100755 index 0000000..e1d0a57 --- /dev/null +++ b/src/java/org/thdl/roster/Visit.java @@ -0,0 +1,75 @@ +package org.thdl.roster; + +import java.io.Serializable; +import org.thdl.roster.om.*; +import org.thdl.users.*; +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; + +public class Visit implements Serializable +{ +//attributes + private ThdlUser thdlUser; + private boolean authenticated = false; + private RosterMember member; + private String test; + private String token; +//accessors + public void setToken(String token) { + this.token = token; + } + public String getToken() { + return token; + } + public void setTest(String test) { + this.test = test; + } + public String getTest() { + return test; + } + public void setMember(RosterMember member) { + this.member = member; + } + public RosterMember getMember() { + return member; + } + public void setThdlUser(ThdlUser thdlUser) { + this.thdlUser = thdlUser; + } + + public ThdlUser getThdlUser() { + return thdlUser; + } + public void setAuthenticated(boolean authenticated) { + this.authenticated = authenticated; + } + public boolean isAuthenticated() { + return authenticated; + } + +//helpers + public String getSnapshot() throws TorqueException + { + StringBuffer snapshot = new StringBuffer(); + snapshot.append( getThdlUser() + " name: '" + getThdlUser().getFirstname() +"'"); + snapshot.append( "
" ); + snapshot.append( getMember() ); + snapshot.append( "
" ); + snapshot.append( isAuthenticated() ); + snapshot.append( "
" ); + Person p = (Person) getMember(); + if (null != p) + { + snapshot.append( p.getPersonData().getPersonTypeIdList() ); + snapshot.append( "
" ); + } + + return snapshot.toString(); + } +//constructors + public Visit() + { + setThdlUser( new ThdlUser() ); + setAuthenticated( false ); + } +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/.DS_Store b/src/java/org/thdl/roster/components/.DS_Store new file mode 100755 index 0000000..2747620 Binary files /dev/null and b/src/java/org/thdl/roster/components/.DS_Store differ diff --git a/src/java/org/thdl/roster/components/AbbreviatedInsert.html b/src/java/org/thdl/roster/components/AbbreviatedInsert.html new file mode 100755 index 0000000..50482d5 --- /dev/null +++ b/src/java/org/thdl/roster/components/AbbreviatedInsert.html @@ -0,0 +1,4 @@ + + + + diff --git a/src/java/org/thdl/roster/components/AbbreviatedInsert.java b/src/java/org/thdl/roster/components/AbbreviatedInsert.java new file mode 100755 index 0000000..45ed1d3 --- /dev/null +++ b/src/java/org/thdl/roster/components/AbbreviatedInsert.java @@ -0,0 +1,50 @@ +package org.thdl.roster.components; + +public class AbbreviatedInsert extends org.apache.tapestry.BaseComponent +{ +//attributes + private String value; + private Integer characterCount; + private boolean abbreviated; + //accessors + public void setValue(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public void setCharacterCount(Integer characterCount) { + this.characterCount = characterCount; + } + + public Integer getCharacterCount() { + return characterCount; + } + + public void setAbbreviated(boolean abbreviated) { + this.abbreviated = abbreviated; + } + + public boolean getAbbreviated() { + return abbreviated; + } + + public String getAbbreviatedValue() + { + String value = getValue(); + int count = getCharacterCount().intValue(); + if ( null != value && value.length() > count ) + { + value = value.substring( 0, count ) + "...."; + setAbbreviated( true ); + } + else + { + setAbbreviated( false ); + } + return value; + } +} + diff --git a/src/java/org/thdl/roster/components/AbbreviatedInsert.jwc b/src/java/org/thdl/roster/components/AbbreviatedInsert.jwc new file mode 100755 index 0000000..0acda53 --- /dev/null +++ b/src/java/org/thdl/roster/components/AbbreviatedInsert.jwc @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/components/AddressDisplay.html b/src/java/org/thdl/roster/components/AddressDisplay.html new file mode 100755 index 0000000..e2295d1 --- /dev/null +++ b/src/java/org/thdl/roster/components/AddressDisplay.html @@ -0,0 +1,17 @@ + + +
+ + + + + + + + Country: + + + + + + diff --git a/src/java/org/thdl/roster/components/AddressDisplay.java b/src/java/org/thdl/roster/components/AddressDisplay.java new file mode 100755 index 0000000..802619a --- /dev/null +++ b/src/java/org/thdl/roster/components/AddressDisplay.java @@ -0,0 +1,23 @@ +package org.thdl.roster.components; + +import org.apache.tapestry.BaseComponent; +import org.apache.tapestry.IPage; +import org.apache.tapestry.IRequestCycle; +import org.apache.tapestry.IComponent; +import org.thdl.roster.Visit; +import org.thdl.roster.om.Address; + +public class AddressDisplay extends BaseComponent +{ +//attributes + private Address addressBean; +//accessors + public void setAddressBean(Address addressBean) { + this.addressBean = addressBean; + } + public Address getAddressBean() throws org.apache.torque.TorqueException + { + return addressBean; + } +//synthetic attribute accessors +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/AddressDisplay.jwc b/src/java/org/thdl/roster/components/AddressDisplay.jwc new file mode 100755 index 0000000..b9f0e83 --- /dev/null +++ b/src/java/org/thdl/roster/components/AddressDisplay.jwc @@ -0,0 +1,34 @@ + + + + + + + + + Street + + + + + + City + + + + + + Region + + + + + + Postal Code + + + + + diff --git a/src/java/org/thdl/roster/components/Border.html b/src/java/org/thdl/roster/components/Border.html new file mode 100755 index 0000000..f80d374 --- /dev/null +++ b/src/java/org/thdl/roster/components/Border.html @@ -0,0 +1,73 @@ + + + + + + +THDL Community Roster + + + + + + + + +
+ + + +
+ +
+ +
+

+

Insert Message Here

+

Insert Warning Here

+ +
+ +
+
+

Options

+

+ +
+
+ Logout
+

+
+
+ +
+ + + + diff --git a/src/java/org/thdl/roster/components/Border.java b/src/java/org/thdl/roster/components/Border.java new file mode 100755 index 0000000..2a2c07e --- /dev/null +++ b/src/java/org/thdl/roster/components/Border.java @@ -0,0 +1,24 @@ +package org.thdl.roster.components; + +import org.apache.tapestry.BaseComponent; +import org.apache.tapestry.IPage; +import org.apache.tapestry.IRequestCycle; +import org.apache.tapestry.IComponent; +import org.thdl.roster.Visit; + +public class Border extends BaseComponent +{ +//attributes + private String pageName; +//accessors + public void setPageName(String value) { + pageName = value; + } + public String getPageName() { + return pageName; + } +//synthetic attribute accessors + public boolean getDisablePageLink() { + return pageName.equals( getPage().getPageName() ); + } +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/Border.jwc b/src/java/org/thdl/roster/components/Border.jwc new file mode 100755 index 0000000..69f2619 --- /dev/null +++ b/src/java/org/thdl/roster/components/Border.jwc @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + li + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/components/Century.html b/src/java/org/thdl/roster/components/Century.html new file mode 100755 index 0000000..155c4a3 --- /dev/null +++ b/src/java/org/thdl/roster/components/Century.html @@ -0,0 +1,2 @@ + + diff --git a/src/java/org/thdl/roster/components/Century.java b/src/java/org/thdl/roster/components/Century.java new file mode 100755 index 0000000..79d8675 --- /dev/null +++ b/src/java/org/thdl/roster/components/Century.java @@ -0,0 +1,43 @@ +package org.thdl.roster.components; + +import org.apache.tapestry.*; +import java.util.*; + +public class Century extends BaseComponent +{ +//attributes + private HashMap centuries; + private Integer century; +//accessors + public void setCentury(Integer century) { + this.century = century; + } + public Integer getCentury() { + return century; + } + private void setCenturies(HashMap centuries) { + this.centuries = centuries; + } + private HashMap getCenturies() { + return centuries; + } +//synthetic attribute accessors + public String getCenturyText() + { + String cent = (String)getCenturies().get( getCentury() ); + return cent; + } +//helper +//constructors + public Century() + { + HashMap map = new HashMap(); + String centuries[] = {"twenty-first", "twentieth", "nineteenth", "eighteenth", "seventeenth", "sixteenth", "fifteenth", "fourteenth", "thirteenth", "twelfth", "eleventh", "tenth", "ninth", "eighth", "seventh", "pre-seventh"}; + int centIntegers[] = {21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 0}; + for ( int i = 0; i < centuries.length; i++ ) + { + map.put( new Integer( centIntegers[i] ), centuries[i] ); + } + setCenturies( map ); + } +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/Century.jwc b/src/java/org/thdl/roster/components/Century.jwc new file mode 100755 index 0000000..e208b30 --- /dev/null +++ b/src/java/org/thdl/roster/components/Century.jwc @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/components/ConditionalInsert.html b/src/java/org/thdl/roster/components/ConditionalInsert.html new file mode 100755 index 0000000..833dd0d --- /dev/null +++ b/src/java/org/thdl/roster/components/ConditionalInsert.html @@ -0,0 +1,7 @@ + +: +
+ +
+
+ diff --git a/src/java/org/thdl/roster/components/ConditionalInsert.java b/src/java/org/thdl/roster/components/ConditionalInsert.java new file mode 100755 index 0000000..6612bc5 --- /dev/null +++ b/src/java/org/thdl/roster/components/ConditionalInsert.java @@ -0,0 +1,19 @@ +package org.thdl.roster.components; + +public class ConditionalInsert extends org.apache.tapestry.BaseComponent +{ +//attributes + private String value; +//accessors + public void setValue(String value) { + this.value = value; + } + public String getValue() { + return value; + } + public boolean isDisplayWorthy() + { + return ( getValue() != null && ! java.util.regex.Pattern.matches( "\\s*", getValue() ) ); + } +} + diff --git a/src/java/org/thdl/roster/components/ConditionalInsert.jwc b/src/java/org/thdl/roster/components/ConditionalInsert.jwc new file mode 100755 index 0000000..cf329fa --- /dev/null +++ b/src/java/org/thdl/roster/components/ConditionalInsert.jwc @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/components/CountryDisplay.html b/src/java/org/thdl/roster/components/CountryDisplay.html new file mode 100755 index 0000000..34bdc70 --- /dev/null +++ b/src/java/org/thdl/roster/components/CountryDisplay.html @@ -0,0 +1,11 @@ + + +
+ + +Country: + + + + + diff --git a/src/java/org/thdl/roster/components/CountryDisplay.java b/src/java/org/thdl/roster/components/CountryDisplay.java new file mode 100755 index 0000000..a4b26a1 --- /dev/null +++ b/src/java/org/thdl/roster/components/CountryDisplay.java @@ -0,0 +1,19 @@ +package org.thdl.roster.components; + +import org.apache.tapestry.*; +import org.thdl.roster.om.Country; + +public class CountryDisplay extends BaseComponent +{ +//attributes + private Country countryBean; +//accessors + public void setCountryBean(Country countryBean) { + this.countryBean = countryBean; + } + public Country getCountryBean() { + return countryBean; + } +//synthetic attribute accessors +//helper +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/CountryDisplay.jwc b/src/java/org/thdl/roster/components/CountryDisplay.jwc new file mode 100755 index 0000000..ab24dfb --- /dev/null +++ b/src/java/org/thdl/roster/components/CountryDisplay.jwc @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/components/CulturalAreaDisplay.html b/src/java/org/thdl/roster/components/CulturalAreaDisplay.html new file mode 100755 index 0000000..48b2035 --- /dev/null +++ b/src/java/org/thdl/roster/components/CulturalAreaDisplay.html @@ -0,0 +1 @@ +, \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/CulturalAreaDisplay.java b/src/java/org/thdl/roster/components/CulturalAreaDisplay.java new file mode 100755 index 0000000..2cb0913 --- /dev/null +++ b/src/java/org/thdl/roster/components/CulturalAreaDisplay.java @@ -0,0 +1,80 @@ +package org.thdl.roster.components; + +import java.util.*; + +import org.apache.tapestry.html.BasePage; +import org.apache.tapestry.*; +import org.apache.torque.util.Criteria; +import org.apache.torque.*; + +import org.thdl.roster.om.*; +import org.thdl.roster.*; + +public class CulturalAreaDisplay extends BaseComponent +{ +//attributes + private ResearchInterest researchInterest; + private String CulturalArea; + private int index; +//accessors + public void setResearchInterest(ResearchInterest researchInterest) { + this.researchInterest = researchInterest; + } + public ResearchInterest getResearchInterest() { + return researchInterest; + } + public void setCulturalArea(String CulturalArea) { + this.CulturalArea = CulturalArea; + } + public String getCulturalArea() { + return CulturalArea; + } + public void setIndex(int index) { + this.index = index; + } + public int getIndex() { + return index; + } +//synthetic properties + public List getCulturalAreaList() + { + LinkedList culturalAreaStrings = new LinkedList(); + try + { + Criteria crit = new Criteria(); + crit.add( ResearchInterestCulturalAreaPeer.RESEARCH_INTEREST_ID, getResearchInterest().getId() ); + crit.addAscendingOrderByColumn( ResearchInterestCulturalAreaPeer.RELEVANCE ); + List ridList = ResearchInterestCulturalAreaPeer.doSelect( crit ); + ListIterator looper = ridList.listIterator(); + while( looper.hasNext() ) + { + ResearchInterestCulturalArea rid = (ResearchInterestCulturalArea) looper.next(); + String culturalArea = rid.getCulturalArea().getCulturalArea(); + culturalAreaStrings.add( culturalArea ); + } + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } + return culturalAreaStrings; + } +//constructors + public CulturalAreaDisplay() + { + super(); + try + { + if ( ! Torque.isInit() ) + { + Global global = (Global) getPage().getGlobal(); + Torque.init( global.getTorqueConfig() ); + } + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } + + } +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/CulturalAreaDisplay.jwc b/src/java/org/thdl/roster/components/CulturalAreaDisplay.jwc new file mode 100755 index 0000000..4f9d781 --- /dev/null +++ b/src/java/org/thdl/roster/components/CulturalAreaDisplay.jwc @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/components/DateFormatter.html b/src/java/org/thdl/roster/components/DateFormatter.html new file mode 100755 index 0000000..ebe04cd --- /dev/null +++ b/src/java/org/thdl/roster/components/DateFormatter.html @@ -0,0 +1,2 @@ + + diff --git a/src/java/org/thdl/roster/components/DateFormatter.java b/src/java/org/thdl/roster/components/DateFormatter.java new file mode 100755 index 0000000..e3ba875 --- /dev/null +++ b/src/java/org/thdl/roster/components/DateFormatter.java @@ -0,0 +1,26 @@ +package org.thdl.roster.components; + +import org.apache.tapestry.*; +import java.text.*; +import java.util.*; + +public class DateFormatter extends BaseComponent +{ +//attributes + private Date date; +//accessors + public void setDate(Date date) { + this.date = date; + } + public Date getDate() { + return date; + } +//helpers + public String getFormattedDate() + { + String date = null; + if (null != getDate() ) + date = DateFormat.getDateInstance().format( getDate() ); + return date; + } +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/DateFormatter.jwc b/src/java/org/thdl/roster/components/DateFormatter.jwc new file mode 100755 index 0000000..b4ccb80 --- /dev/null +++ b/src/java/org/thdl/roster/components/DateFormatter.jwc @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/components/DisciplineDisplay.html b/src/java/org/thdl/roster/components/DisciplineDisplay.html new file mode 100755 index 0000000..08af184 --- /dev/null +++ b/src/java/org/thdl/roster/components/DisciplineDisplay.html @@ -0,0 +1 @@ +, \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/DisciplineDisplay.java b/src/java/org/thdl/roster/components/DisciplineDisplay.java new file mode 100755 index 0000000..cb96e13 --- /dev/null +++ b/src/java/org/thdl/roster/components/DisciplineDisplay.java @@ -0,0 +1,80 @@ +package org.thdl.roster.components; + +import java.util.*; + +import org.apache.tapestry.html.BasePage; +import org.apache.tapestry.*; +import org.apache.torque.util.Criteria; +import org.apache.torque.*; + +import org.thdl.roster.om.*; +import org.thdl.roster.*; + +public class DisciplineDisplay extends BaseComponent +{ +//attributes + private ResearchInterest researchInterest; + private String Discipline; + private int index; +//accessors + public void setResearchInterest(ResearchInterest researchInterest) { + this.researchInterest = researchInterest; + } + public ResearchInterest getResearchInterest() { + return researchInterest; + } + public void setDiscipline(String Discipline) { + this.Discipline = Discipline; + } + public String getDiscipline() { + return Discipline; + } + public void setIndex(int index) { + this.index = index; + } + public int getIndex() { + return index; + } +//synthetic properties + public List getDisciplineList() + { + LinkedList disciplineStrings = new LinkedList(); + try + { + Criteria crit = new Criteria(); + crit.add( ResearchInterestDisciplinePeer.RESEARCH_INTEREST_ID, getResearchInterest().getId() ); + crit.addAscendingOrderByColumn( ResearchInterestDisciplinePeer.RELEVANCE ); + List ridList = ResearchInterestDisciplinePeer.doSelect( crit ); + ListIterator looper = ridList.listIterator(); + while( looper.hasNext() ) + { + ResearchInterestDiscipline rid = (ResearchInterestDiscipline) looper.next(); + String discipline = rid.getDiscipline().getDiscipline(); + disciplineStrings.add( discipline ); + } + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } + return disciplineStrings; + } +//constructors + public DisciplineDisplay() + { + super(); + try + { + if ( ! Torque.isInit() ) + { + Global global = (Global) getPage().getGlobal(); + Torque.init( global.getTorqueConfig() ); + } + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } + + } +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/DisciplineDisplay.jwc b/src/java/org/thdl/roster/components/DisciplineDisplay.jwc new file mode 100755 index 0000000..217201e --- /dev/null +++ b/src/java/org/thdl/roster/components/DisciplineDisplay.jwc @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/components/DocumentDisplay.html b/src/java/org/thdl/roster/components/DocumentDisplay.html new file mode 100755 index 0000000..dd6a596 --- /dev/null +++ b/src/java/org/thdl/roster/components/DocumentDisplay.html @@ -0,0 +1,12 @@ + + +
    + + + +
\ No newline at end of file diff --git a/src/java/org/thdl/roster/components/DocumentDisplay.java b/src/java/org/thdl/roster/components/DocumentDisplay.java new file mode 100755 index 0000000..7113502 --- /dev/null +++ b/src/java/org/thdl/roster/components/DocumentDisplay.java @@ -0,0 +1,50 @@ +package org.thdl.roster.components; + +import java.util.*; + +import org.apache.tapestry.html.BasePage; +import org.apache.tapestry.*; +import org.apache.torque.util.Criteria; +import org.apache.torque.*; + +import org.thdl.roster.om.*; +import org.thdl.roster.*; + +public class DocumentDisplay extends BaseComponent +{ +//attributes + private Member member; + private Document document; +//accessors + public void setMember(Member member) { + this.member = member; + } + public void setDocument(Document document) { + this.document = document; + } + public Member getMember() { + return member; + } + public Document getDocument() { + return document; + } +//helpers +//constructors + public DocumentDisplay() + { + super(); + /* try + { + if ( ! Torque.isInit() ) + { + Global global = (Global) getPage().getGlobal(); + Torque.init( global.getTorqueConfig() ); + } + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } */ + + } +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/DocumentDisplay.jwc b/src/java/org/thdl/roster/components/DocumentDisplay.jwc new file mode 100755 index 0000000..4090536 --- /dev/null +++ b/src/java/org/thdl/roster/components/DocumentDisplay.jwc @@ -0,0 +1,22 @@ + + + + + + + + + + + li + + + + a + + + + diff --git a/src/java/org/thdl/roster/components/LanguageDisplay.html b/src/java/org/thdl/roster/components/LanguageDisplay.html new file mode 100755 index 0000000..247c69f --- /dev/null +++ b/src/java/org/thdl/roster/components/LanguageDisplay.html @@ -0,0 +1 @@ +, \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/LanguageDisplay.java b/src/java/org/thdl/roster/components/LanguageDisplay.java new file mode 100755 index 0000000..a2297ca --- /dev/null +++ b/src/java/org/thdl/roster/components/LanguageDisplay.java @@ -0,0 +1,80 @@ +package org.thdl.roster.components; + +import java.util.*; + +import org.apache.tapestry.html.BasePage; +import org.apache.tapestry.*; +import org.apache.torque.util.Criteria; +import org.apache.torque.*; + +import org.thdl.roster.om.*; +import org.thdl.roster.*; + +public class LanguageDisplay extends BaseComponent +{ +//attributes + private ResearchInterest researchInterest; + private String Language; + private int index; +//accessors + public void setResearchInterest(ResearchInterest researchInterest) { + this.researchInterest = researchInterest; + } + public ResearchInterest getResearchInterest() { + return researchInterest; + } + public void setLanguage(String Language) { + this.Language = Language; + } + public String getLanguage() { + return Language; + } + public void setIndex(int index) { + this.index = index; + } + public int getIndex() { + return index; + } +//synthetic properties + public List getLanguageList() + { + LinkedList languageStrings = new LinkedList(); + try + { + Criteria crit = new Criteria(); + crit.add( ResearchInterestLanguagePeer.RESEARCH_INTEREST_ID, getResearchInterest().getId() ); + crit.addAscendingOrderByColumn( ResearchInterestLanguagePeer.RELEVANCE ); + List ridList = ResearchInterestLanguagePeer.doSelect( crit ); + ListIterator looper = ridList.listIterator(); + while( looper.hasNext() ) + { + ResearchInterestLanguage rid = (ResearchInterestLanguage) looper.next(); + String language = rid.getLanguage().getLanguage(); + languageStrings.add( language ); + } + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } + return languageStrings; + } +//constructors + public LanguageDisplay() + { + super(); + try + { + if ( ! Torque.isInit() ) + { + Global global = (Global) getPage().getGlobal(); + Torque.init( global.getTorqueConfig() ); + } + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } + + } +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/LanguageDisplay.jwc b/src/java/org/thdl/roster/components/LanguageDisplay.jwc new file mode 100755 index 0000000..adc06f7 --- /dev/null +++ b/src/java/org/thdl/roster/components/LanguageDisplay.jwc @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/components/MemberTypeDisplay.html b/src/java/org/thdl/roster/components/MemberTypeDisplay.html new file mode 100755 index 0000000..32967c1 --- /dev/null +++ b/src/java/org/thdl/roster/components/MemberTypeDisplay.html @@ -0,0 +1 @@ +, \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/MemberTypeDisplay.java b/src/java/org/thdl/roster/components/MemberTypeDisplay.java new file mode 100755 index 0000000..068fbbd --- /dev/null +++ b/src/java/org/thdl/roster/components/MemberTypeDisplay.java @@ -0,0 +1,115 @@ +package org.thdl.roster.components; + +import java.util.*; + +import org.apache.tapestry.html.BasePage; +import org.apache.tapestry.*; +import org.apache.torque.util.Criteria; +import org.apache.torque.*; + +import org.thdl.roster.om.*; +import org.thdl.roster.*; + +public class MemberTypeDisplay extends BaseComponent +{ +//attributes + private Member member; + private String memberType; + private int index; +//accessors + public void setMember(Member member) { + this.member = member; + } + public Member getMember() { + return member; + } + public void setMemberType(String memberType) { + this.memberType = memberType; + } + public String getMemberType() { + return memberType; + } + public void setIndex(int index) { + this.index = index; + } + public int getIndex() { + return index; + } +//synthetic properties + public List getMemberTypeList() + { + LinkedList memberTypes = new LinkedList(); + try + { + List mmTypes = null; + Criteria crit = new Criteria(); + if ( member instanceof Person ) + { + crit.add( PersonPersonTypePeer.PERSON_DATA_ID, getMember().getMemberData().getId() ); + crit.addAscendingOrderByColumn( PersonPersonTypePeer.RELEVANCE ); + mmTypes = PersonPersonTypePeer.doSelect( crit ); + } + else if ( member instanceof Project ) + { + crit.add( ProjectProjectTypePeer.PROJECT_DATA_ID, getMember().getMemberData().getId() ); + crit.addAscendingOrderByColumn( ProjectProjectTypePeer.RELEVANCE ); + mmTypes = ProjectProjectTypePeer.doSelect( crit ); + } + else if ( member instanceof Organization ) + { + crit.add( OrganizationOrganizationTypePeer.ORGANIZATION_DATA_ID, getMember().getMemberData().getId() ); + crit.addAscendingOrderByColumn( OrganizationOrganizationTypePeer.RELEVANCE ); + mmTypes = OrganizationOrganizationTypePeer.doSelect( crit ); + } + + ListIterator looper = mmTypes.listIterator(); + while( looper.hasNext() ) + { + String displayText = null; + if ( member instanceof Person ) + { + PersonPersonType pt = (PersonPersonType) looper.next(); + displayText= pt.getPersonType().getPersonType(); + } + else if ( member instanceof Project ) + { + ProjectProjectType pt = (ProjectProjectType) looper.next(); + displayText= pt.getProjectType().getProjectType(); + } + else if ( member instanceof Organization ) + { + OrganizationOrganizationType ot = (OrganizationOrganizationType) looper.next(); + displayText= ot.getOrganizationType().getOrganizationType(); + } + memberTypes.add( displayText ); + } + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } + catch ( RosterMemberTypeException rmte ) + { + throw new ApplicationRuntimeException( rmte ); + } + return memberTypes; + } +//constructors + public MemberTypeDisplay() + { + super(); + try + { + if ( ! Torque.isInit() ) + { + Global global = (Global) getPage().getGlobal(); + Torque.init( global.getTorqueConfig() ); + } + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } + + } +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/MemberTypeDisplay.jwc b/src/java/org/thdl/roster/components/MemberTypeDisplay.jwc new file mode 100755 index 0000000..182a44a --- /dev/null +++ b/src/java/org/thdl/roster/components/MemberTypeDisplay.jwc @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/components/OrganizationDisplay.html b/src/java/org/thdl/roster/components/OrganizationDisplay.html new file mode 100755 index 0000000..0dd001d --- /dev/null +++ b/src/java/org/thdl/roster/components/OrganizationDisplay.html @@ -0,0 +1,34 @@ + + +
+ + +

+ Organization Types: + +
+ + + + +

+ +

Back to top

+

Background

+ +

+ + + + + + + + +

+ + +
+
+ + diff --git a/src/java/org/thdl/roster/components/OrganizationDisplay.java b/src/java/org/thdl/roster/components/OrganizationDisplay.java new file mode 100755 index 0000000..a017a0c --- /dev/null +++ b/src/java/org/thdl/roster/components/OrganizationDisplay.java @@ -0,0 +1,22 @@ +package org.thdl.roster.components; + +import org.apache.tapestry.BaseComponent; +import org.apache.tapestry.IPage; +import org.apache.tapestry.IRequestCycle; +import org.apache.tapestry.IComponent; +import org.thdl.roster.Visit; +import org.thdl.roster.om.*; + +public class OrganizationDisplay extends BaseComponent +{ +//attributes + private Organization organizationBean; +//accessors + public void setOrganizationBean(Organization organizationBean) { + this.organizationBean = organizationBean; + } + public Organization getOrganizationBean() { + return organizationBean; + } +//synthetic attribute accessors +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/OrganizationDisplay.jwc b/src/java/org/thdl/roster/components/OrganizationDisplay.jwc new file mode 100755 index 0000000..e8433ec --- /dev/null +++ b/src/java/org/thdl/roster/components/OrganizationDisplay.jwc @@ -0,0 +1,66 @@ + + + + + + + + + + + + + Parent Organization + + + + + + People + + + + + + Mailing List + + + + + + Overview + + + + + + Components + + + + + + History + + + + + + Education programs + + + + + + Resources + + + + + + + + + diff --git a/src/java/org/thdl/roster/components/PersonDisplay.html b/src/java/org/thdl/roster/components/PersonDisplay.html new file mode 100755 index 0000000..be25ece --- /dev/null +++ b/src/java/org/thdl/roster/components/PersonDisplay.html @@ -0,0 +1,44 @@ + + +
+ + +

+ Person Types: +
+ + + +

+ +

Back to top

+

Background

+

History

+

+ +

+ +

Current Position

+

+ + + + + +

+

Education Information

+

+ + + + + + + + +

+ +
+
+ + diff --git a/src/java/org/thdl/roster/components/PersonDisplay.java b/src/java/org/thdl/roster/components/PersonDisplay.java new file mode 100755 index 0000000..2ed3ee6 --- /dev/null +++ b/src/java/org/thdl/roster/components/PersonDisplay.java @@ -0,0 +1,22 @@ +package org.thdl.roster.components; + +import org.apache.tapestry.BaseComponent; +import org.apache.tapestry.IPage; +import org.apache.tapestry.IRequestCycle; +import org.apache.tapestry.IComponent; +import org.thdl.roster.Visit; +import org.thdl.roster.om.*; + +public class PersonDisplay extends BaseComponent +{ +//attributes + private Person personBean; +//accessors + public void setPersonBean(Person personBean) { + this.personBean = personBean; + } + public Person getPersonBean() { + return personBean; + } +//synthetic attribute accessors +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/PersonDisplay.jwc b/src/java/org/thdl/roster/components/PersonDisplay.jwc new file mode 100755 index 0000000..753d07e --- /dev/null +++ b/src/java/org/thdl/roster/components/PersonDisplay.jwc @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Overview Bio + + + + + + History + + + + + + Organizational Base + + + + + + School + + + + + + Department + + + + + + Program + + + + + + Advisor + + + + + + Highest Degree Earned + + + + + + Year Began + + + + + + Finished + + + + + + Other Backgrounds + + + + + + Organization + + + + + + Division + + + + + + Title + + + + + + Start Date + + + + + + Job Description + + + + + diff --git a/src/java/org/thdl/roster/components/PhoneDisplay.html b/src/java/org/thdl/roster/components/PhoneDisplay.html new file mode 100755 index 0000000..9c9ded4 --- /dev/null +++ b/src/java/org/thdl/roster/components/PhoneDisplay.html @@ -0,0 +1,16 @@ + + +
+ + + + + : + + + + + + + + diff --git a/src/java/org/thdl/roster/components/PhoneDisplay.java b/src/java/org/thdl/roster/components/PhoneDisplay.java new file mode 100755 index 0000000..da3ef23 --- /dev/null +++ b/src/java/org/thdl/roster/components/PhoneDisplay.java @@ -0,0 +1,27 @@ +package org.thdl.roster.components; + +import org.apache.tapestry.BaseComponent; +import org.apache.tapestry.IPage; +import org.apache.tapestry.IRequestCycle; +import org.apache.tapestry.IComponent; +import org.thdl.roster.Visit; +import org.thdl.roster.om.Phone; + +public class PhoneDisplay extends BaseComponent +{ +//attributes + private Phone phoneBean; +//accessors + public void setPhoneBean(Phone phoneBean) { + this.phoneBean = phoneBean; + } + public Phone getPhoneBean() { + return phoneBean; + } + public boolean isDisplayWorthy() + { + //return ( null != getPhoneBean().getCountryCode() && null != getPhoneBean().getAreaCode() && null != getPhoneBean().getNumber() ); + return ( null != getPhoneBean().getNumber() ); + } +//synthetic attribute accessors +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/PhoneDisplay.jwc b/src/java/org/thdl/roster/components/PhoneDisplay.jwc new file mode 100755 index 0000000..d3106c3 --- /dev/null +++ b/src/java/org/thdl/roster/components/PhoneDisplay.jwc @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/components/ProjectDisplay.html b/src/java/org/thdl/roster/components/ProjectDisplay.html new file mode 100755 index 0000000..23f632e --- /dev/null +++ b/src/java/org/thdl/roster/components/ProjectDisplay.html @@ -0,0 +1,31 @@ + + +
+ + +

+Project Types:
+ + + + +

+ +

Back to top

+

Background

+ +

+ + + + + + + + +

+ +
+
+ + diff --git a/src/java/org/thdl/roster/components/ProjectDisplay.java b/src/java/org/thdl/roster/components/ProjectDisplay.java new file mode 100755 index 0000000..16b0bcb --- /dev/null +++ b/src/java/org/thdl/roster/components/ProjectDisplay.java @@ -0,0 +1,22 @@ +package org.thdl.roster.components; + +import org.apache.tapestry.BaseComponent; +import org.apache.tapestry.IPage; +import org.apache.tapestry.IRequestCycle; +import org.apache.tapestry.IComponent; +import org.thdl.roster.Visit; +import org.thdl.roster.om.*; + +public class ProjectDisplay extends BaseComponent +{ +//attributes + private Project projectBean; +//accessors + public void setProjectBean(Project projectBean) { + this.projectBean = projectBean; + } + public Project getProjectBean() { + return projectBean; + } +//synthetic attribute accessors +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/ProjectDisplay.jwc b/src/java/org/thdl/roster/components/ProjectDisplay.jwc new file mode 100755 index 0000000..8f7495f --- /dev/null +++ b/src/java/org/thdl/roster/components/ProjectDisplay.jwc @@ -0,0 +1,66 @@ + + + + + + + + + + + + + Parent Organization + + + + + + People + + + + + + Mailing List + + + + + + Overview + + + + + + Components + + + + + + History + + + + + + Education programs + + + + + + Resources + + + + + + + + + diff --git a/src/java/org/thdl/roster/components/forms/.DS_Store b/src/java/org/thdl/roster/components/forms/.DS_Store new file mode 100755 index 0000000..5008ddf Binary files /dev/null and b/src/java/org/thdl/roster/components/forms/.DS_Store differ diff --git a/src/java/org/thdl/roster/components/forms/AddressFields.html b/src/java/org/thdl/roster/components/forms/AddressFields.html new file mode 100755 index 0000000..2676c0f --- /dev/null +++ b/src/java/org/thdl/roster/components/forms/AddressFields.html @@ -0,0 +1,25 @@ + + +
+ + + +Street Address: + +
+City: + +
+Region: + +
+Postal Code: + +
+ +Country:
+ + + + + diff --git a/src/java/org/thdl/roster/components/forms/AddressFields.java b/src/java/org/thdl/roster/components/forms/AddressFields.java new file mode 100755 index 0000000..be0e6be --- /dev/null +++ b/src/java/org/thdl/roster/components/forms/AddressFields.java @@ -0,0 +1,61 @@ +package org.thdl.roster.components.forms; + +import java.util.*; +import org.apache.torque.*; +import org.apache.tapestry.*; +import org.apache.tapestry.form.*; +import org.thdl.roster.*; +import org.thdl.roster.om.*; + + +public class AddressFields extends BaseComponent +{ +//attributes + private Address addressBean; + private IPropertySelectionModel countryModel; +//accessors + + public void setAddressBean(Address addressBean) { + this.addressBean = addressBean; + } + + public Address getAddressBean() throws org.apache.torque.TorqueException + { + return addressBean; + } + + public void setCountryModel(IPropertySelectionModel countryModel) { + this.countryModel = countryModel; + } + public IPropertySelectionModel getCountryModel() { + if ( null == countryModel ) + setCountryModel( buildCountryModel() ); + return countryModel; + } +//helpers + public IPropertySelectionModel buildCountryModel() + { + try + { + if ( ! Torque.isInit() ) + { + Global global = (Global) getPage().getGlobal(); + Torque.init( global.getTorqueConfig() ); + } + EntitySelectionModel countryModel = new EntitySelectionModel(); + LinkedList list = new LinkedList( CountryPeer.doSelectAll() ); + Country country; + ListIterator looper = list.listIterator( 0 ); + while ( looper.hasNext() ) + { + country = (Country) looper.next(); + countryModel.add( country.getId(), country.getCountry() ); + } + return countryModel; + } + catch (Exception te) { + throw new ApplicationRuntimeException( te.getMessage(), te ); + } + } +//synthetic attribute accessors +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/forms/AddressFields.jwc b/src/java/org/thdl/roster/components/forms/AddressFields.jwc new file mode 100755 index 0000000..a2c1bdd --- /dev/null +++ b/src/java/org/thdl/roster/components/forms/AddressFields.jwc @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/components/forms/OrganizationFields.html b/src/java/org/thdl/roster/components/forms/OrganizationFields.html new file mode 100755 index 0000000..0fae28c --- /dev/null +++ b/src/java/org/thdl/roster/components/forms/OrganizationFields.html @@ -0,0 +1,62 @@ + + +
+ + +

Organization Information

+ +

+Organization name: +
+ +
+Organizational Base: For Religious centers, please use the organizational base to indicate your religious affiliation separated by colons. First specify "Buddhist" or "Hindu". Then following a colon, specify sectarian identity. For Tibetan Buddhist Centers, use Geluk, Kagyu, Sakya, Nyingma, Bön, or Jonang. Thus "Buddhist:Kagyu", etc. +
+ +
+Mailing list: If you have a mailing list for updates on your organization/project, please describe it briefly and how to subscribe. +
+ +
+ +History: +
+ +
+ +Components: +This refers to primary components of the organization which also have a separate identity, and as such may have their own roster entry (such as a University and its library). +
+ +
--> +Education programs: +
+ +
+Resources: +
+ + +

+ + +
+
+ + diff --git a/src/java/org/thdl/roster/components/forms/OrganizationFields.java b/src/java/org/thdl/roster/components/forms/OrganizationFields.java new file mode 100755 index 0000000..cb558c4 --- /dev/null +++ b/src/java/org/thdl/roster/components/forms/OrganizationFields.java @@ -0,0 +1,22 @@ +package org.thdl.roster.components.forms; + +import org.apache.tapestry.BaseComponent; +import org.apache.tapestry.IPage; +import org.apache.tapestry.IRequestCycle; +import org.apache.tapestry.IComponent; +import org.thdl.roster.Visit; +import org.thdl.roster.om.*; + +public class OrganizationFields extends BaseComponent +{ +//attributes + private OrganizationData organizationDataBean; +//accessors + public void setOrganizationDataBean(OrganizationData organizationDataBean) { + this.organizationDataBean = organizationDataBean; + } + public OrganizationData getOrganizationDataBean() { + return organizationDataBean; + } +//synthetic attribute accessors +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/forms/OrganizationFields.jwc b/src/java/org/thdl/roster/components/forms/OrganizationFields.jwc new file mode 100755 index 0000000..2fd5ac6 --- /dev/null +++ b/src/java/org/thdl/roster/components/forms/OrganizationFields.jwc @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/components/forms/PersonFields.html b/src/java/org/thdl/roster/components/forms/PersonFields.html new file mode 100755 index 0000000..a417bda --- /dev/null +++ b/src/java/org/thdl/roster/components/forms/PersonFields.html @@ -0,0 +1,81 @@ + + +
+ + + +

Personal Information

+

+First name: + +
+Middle name: + +
+Last name: + +
+Overview bio: Please write this in the third person so others can use it for a quick biographical sketch, and limit it to 100 words.
+ +
+Further biographical details: +
+ +
+Organizational Base: +
+ +
+

+

Education Information

+

+School: + +
+Department: + +
+Program: + +
+Advisor: + +
+Higest degree earned: + +
+Year began: + +
+Year Finished: + +
+Other Backgrounds:
+ +
+

+ + +
+
+ + diff --git a/src/java/org/thdl/roster/components/forms/PersonFields.java b/src/java/org/thdl/roster/components/forms/PersonFields.java new file mode 100755 index 0000000..db8877c --- /dev/null +++ b/src/java/org/thdl/roster/components/forms/PersonFields.java @@ -0,0 +1,22 @@ +package org.thdl.roster.components.forms; + +import org.apache.tapestry.BaseComponent; +import org.apache.tapestry.IPage; +import org.apache.tapestry.IRequestCycle; +import org.apache.tapestry.IComponent; +import org.thdl.roster.Visit; +import org.thdl.roster.om.*; + +public class PersonFields extends BaseComponent +{ +//attributes + private PersonData personDataBean; +//accessors + public void setPersonDataBean(PersonData personDataBean) { + this.personDataBean = personDataBean; + } + public PersonData getPersonDataBean() { + return personDataBean; + } +//synthetic attribute accessors +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/forms/PersonFields.jwc b/src/java/org/thdl/roster/components/forms/PersonFields.jwc new file mode 100755 index 0000000..654b246 --- /dev/null +++ b/src/java/org/thdl/roster/components/forms/PersonFields.jwc @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/components/forms/PhoneFields.html b/src/java/org/thdl/roster/components/forms/PhoneFields.html new file mode 100755 index 0000000..97e1015 --- /dev/null +++ b/src/java/org/thdl/roster/components/forms/PhoneFields.html @@ -0,0 +1,11 @@ + + +
+ + + - - + + +
+ + diff --git a/src/java/org/thdl/roster/components/forms/PhoneFields.java b/src/java/org/thdl/roster/components/forms/PhoneFields.java new file mode 100755 index 0000000..f9021d2 --- /dev/null +++ b/src/java/org/thdl/roster/components/forms/PhoneFields.java @@ -0,0 +1,22 @@ +package org.thdl.roster.components.forms; + +import org.apache.tapestry.BaseComponent; +import org.apache.tapestry.IPage; +import org.apache.tapestry.IRequestCycle; +import org.apache.tapestry.IComponent; +import org.thdl.roster.Visit; +import org.thdl.roster.om.Phone; + +public class PhoneFields extends BaseComponent +{ +//attributes + private Phone phoneBean; +//accessors + public void setPhoneBean(Phone phoneBean) { + this.phoneBean = phoneBean; + } + public Phone getPhoneBean() { + return phoneBean; + } +//synthetic attribute accessors +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/forms/PhoneFields.jwc b/src/java/org/thdl/roster/components/forms/PhoneFields.jwc new file mode 100755 index 0000000..67c541a --- /dev/null +++ b/src/java/org/thdl/roster/components/forms/PhoneFields.jwc @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/components/forms/ProjectFields.html b/src/java/org/thdl/roster/components/forms/ProjectFields.html new file mode 100755 index 0000000..d369a2d --- /dev/null +++ b/src/java/org/thdl/roster/components/forms/ProjectFields.html @@ -0,0 +1,57 @@ + + +
+ + +

Project Information

+ +

+Project name: +
+ +
+Organizational Base: +
+ +
+Mailing list: +
+ +
+ + History: +
+ +
+ + Education programs: +
+ +
+Resources: +
+ + +

+ + +
+
+ + diff --git a/src/java/org/thdl/roster/components/forms/ProjectFields.java b/src/java/org/thdl/roster/components/forms/ProjectFields.java new file mode 100755 index 0000000..410062c --- /dev/null +++ b/src/java/org/thdl/roster/components/forms/ProjectFields.java @@ -0,0 +1,22 @@ +package org.thdl.roster.components.forms; + +import org.apache.tapestry.BaseComponent; +import org.apache.tapestry.IPage; +import org.apache.tapestry.IRequestCycle; +import org.apache.tapestry.IComponent; +import org.thdl.roster.Visit; +import org.thdl.roster.om.*; + +public class ProjectFields extends BaseComponent +{ +//attributes + private ProjectData projectDataBean; +//accessors + public void setProjectDataBean(ProjectData projectDataBean) { + this.projectDataBean = projectDataBean; + } + public ProjectData getProjectDataBean() { + return projectDataBean; + } +//synthetic attribute accessors +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/forms/ProjectFields.jwc b/src/java/org/thdl/roster/components/forms/ProjectFields.jwc new file mode 100755 index 0000000..9788e89 --- /dev/null +++ b/src/java/org/thdl/roster/components/forms/ProjectFields.jwc @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/components/forms/WizardTabs.html b/src/java/org/thdl/roster/components/forms/WizardTabs.html new file mode 100755 index 0000000..3255e78 --- /dev/null +++ b/src/java/org/thdl/roster/components/forms/WizardTabs.html @@ -0,0 +1,40 @@ +
+ +
    +
  • + +
  • +
+
+
+
+
diff --git a/src/java/org/thdl/roster/components/forms/WizardTabs.java b/src/java/org/thdl/roster/components/forms/WizardTabs.java new file mode 100755 index 0000000..523f713 --- /dev/null +++ b/src/java/org/thdl/roster/components/forms/WizardTabs.java @@ -0,0 +1,77 @@ +package org.thdl.roster.components.forms; + +import org.apache.tapestry.BaseComponent; +import org.apache.tapestry.IPage; +import org.apache.tapestry.IRequestCycle; +import org.apache.tapestry.IComponent; +import org.thdl.roster.Visit; + +public class WizardTabs extends BaseComponent +{ +//attributes + private String pageName; +//accessors + public void setPageName(String pageName) { + this.pageName = pageName; + } + public String getPageName() { + return pageName; + } + public String getHref() { + return "javascript:tabbedSubmit( '" + getPageName() + "' )"; + } + +/* private String[] pageNames; + private String[] pageLabels; + private int index; +//accessors + public void setPageNames(String[] pageNames) { + this.pageNames = pageNames; + } + public void setPageLabels(String[] pageLabels) { + this.pageLabels = pageLabels; + } + public String[] getPageNames() { + return pageNames; + } + public String[] getPageLabels() { + return pageLabels; + } + public String getPageName( int index ) { + return pageNames[ index ]; + } + public String getPageLabels( int index ) { + return pageLabels[ index ]; + } + public String getPageName() { + return pageNames[ getIndex() ]; + } + public String getPageLabels() { + return pageLabels[ getIndex() ]; + } + + public void setIndex(int index) { + this.index = index; + } + public int getIndex() { + return index; + } */ +//synthetic attribute accessors + + + public boolean getDisablePageLink() { + return getPageName().equals( getPage().getPageName() ); + } + public String getClassAttribute() { + String classAttribute = null; + if ( getDisablePageLink() ) + { + classAttribute="activeTab"; + } + else + { + classAttribute="tab"; + } + return classAttribute; + } +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/components/forms/WizardTabs.jwc b/src/java/org/thdl/roster/components/forms/WizardTabs.jwc new file mode 100755 index 0000000..b991252 --- /dev/null +++ b/src/java/org/thdl/roster/components/forms/WizardTabs.jwc @@ -0,0 +1,40 @@ + + + + + + + + + + + li + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/om/.DS_Store b/src/java/org/thdl/roster/om/.DS_Store new file mode 100755 index 0000000..5008ddf Binary files /dev/null and b/src/java/org/thdl/roster/om/.DS_Store differ diff --git a/src/java/org/thdl/roster/om/Address.java b/src/java/org/thdl/roster/om/Address.java new file mode 100755 index 0000000..29144cc --- /dev/null +++ b/src/java/org/thdl/roster/om/Address.java @@ -0,0 +1,26 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; +import org.apache.torque.*; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class Address + extends org.thdl.roster.om.BaseAddress + implements java.io.Serializable, Persistent +{ + public Address() throws TorqueException + { + super(); + setCountry( new Country() ); + } +} diff --git a/src/java/org/thdl/roster/om/AddressPeer.java b/src/java/org/thdl/roster/om/AddressPeer.java new file mode 100755 index 0000000..c6fad5d --- /dev/null +++ b/src/java/org/thdl/roster/om/AddressPeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class AddressPeer + extends org.thdl.roster.om.BaseAddressPeer +{ +} diff --git a/src/java/org/thdl/roster/om/BaseAddress.java b/src/java/org/thdl/roster/om/BaseAddress.java new file mode 100755 index 0000000..1c6e151 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseAddress.java @@ -0,0 +1,837 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to Address + */ +public abstract class BaseAddress extends BaseObject +{ + /** The Peer class */ + private static final AddressPeer peer = + new AddressPeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the address field + */ + private String address; + + /** + * The value for the city field + */ + private String city; + + /** + * The value for the region field + */ + private String region; + + /** + * The value for the zip field + */ + private String zip; + + /** + * The value for the country_id field + */ + private Integer country_id; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + + // update associated ContactInfo + if (collContactInfos != null) + { + for (int i = 0; i < collContactInfos.size(); i++) + { + ((ContactInfo) collContactInfos.get(i)) + .setAddressId(v); + } + } + } + + + /** + * Get the Address + * + * @return String + */ + public String getAddress() + { + return address; + } + + + /** + * Set the value of Address + * + * @param v new value + */ + public void setAddress(String v) + { + + + + if (!ObjectUtils.equals(this.address, v)) + { + this.address = v; + setModified(true); + } + + + } + + + /** + * Get the City + * + * @return String + */ + public String getCity() + { + return city; + } + + + /** + * Set the value of City + * + * @param v new value + */ + public void setCity(String v) + { + + + + if (!ObjectUtils.equals(this.city, v)) + { + this.city = v; + setModified(true); + } + + + } + + + /** + * Get the Region + * + * @return String + */ + public String getRegion() + { + return region; + } + + + /** + * Set the value of Region + * + * @param v new value + */ + public void setRegion(String v) + { + + + + if (!ObjectUtils.equals(this.region, v)) + { + this.region = v; + setModified(true); + } + + + } + + + /** + * Get the Zip + * + * @return String + */ + public String getZip() + { + return zip; + } + + + /** + * Set the value of Zip + * + * @param v new value + */ + public void setZip(String v) + { + + + + if (!ObjectUtils.equals(this.zip, v)) + { + this.zip = v; + setModified(true); + } + + + } + + + /** + * Get the CountryId + * + * @return Integer + */ + public Integer getCountryId() + { + return country_id; + } + + + /** + * Set the value of CountryId + * + * @param v new value + */ + public void setCountryId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.country_id, v)) + { + this.country_id = v; + setModified(true); + } + + + if (aCountry != null && !ObjectUtils.equals(aCountry.getId(), v)) + { + aCountry = null; + } + + } + + + + + + + + private Country aCountry; + + /** + * Declares an association between this object and a Country object + * + * @param v Country + * @throws TorqueException + */ + public void setCountry(Country v) throws TorqueException + { + if (v == null) + { + setCountryId((Integer)null); + } + else + { + setCountryId(v.getId()); + } + aCountry = v; + } + + + /** + * Get the associated Country object + * + * @return the associated Country object + * @throws TorqueException + */ + public Country getCountry() throws TorqueException + { + if (aCountry == null && (!ObjectUtils.equals(this.country_id, null))) + { + aCountry = CountryPeer.retrieveByPK(SimpleKey.keyFor(this.country_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + Country obj = CountryPeer.retrieveByPK(this.country_id); + obj.addAddresss(this); + */ + } + return aCountry; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setCountryKey(ObjectKey key) throws TorqueException + { + + setCountryId(new Integer(((NumberKey) key).intValue())); + } + + + + /** + * Collection to store aggregation of collContactInfos + */ + protected List collContactInfos; + + /** + * Temporary storage of collContactInfos to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initContactInfos() + { + if (collContactInfos == null) + { + collContactInfos = new ArrayList(); + } + } + + /** + * Method called to associate a ContactInfo object to this object + * through the ContactInfo foreign key attribute + * + * @param l ContactInfo + * @throws TorqueException + */ + public void addContactInfo(ContactInfo l) throws TorqueException + { + getContactInfos().add(l); + l.setAddress((Address) this); + } + + /** + * The criteria used to select the current contents of collContactInfos + */ + private Criteria lastContactInfosCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getContactInfos(new Criteria()) + * + * @throws TorqueException + */ + public List getContactInfos() throws TorqueException + { + if (collContactInfos == null) + { + collContactInfos = getContactInfos(new Criteria(10)); + } + return collContactInfos; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Address has previously + * been saved, it will retrieve related ContactInfos from storage. + * If this Address is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getContactInfos(Criteria criteria) throws TorqueException + { + if (collContactInfos == null) + { + if (isNew()) + { + collContactInfos = new ArrayList(); + } + else + { + criteria.add(ContactInfoPeer.ADDRESS_ID, getId() ); + collContactInfos = ContactInfoPeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ContactInfoPeer.ADDRESS_ID, getId()); + if (!lastContactInfosCriteria.equals(criteria)) + { + collContactInfos = ContactInfoPeer.doSelect(criteria); + } + } + } + lastContactInfosCriteria = criteria; + + return collContactInfos; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getContactInfos(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getContactInfos(Connection con) throws TorqueException + { + if (collContactInfos == null) + { + collContactInfos = getContactInfos(new Criteria(10), con); + } + return collContactInfos; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Address has previously + * been saved, it will retrieve related ContactInfos from storage. + * If this Address is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getContactInfos(Criteria criteria, Connection con) + throws TorqueException + { + if (collContactInfos == null) + { + if (isNew()) + { + collContactInfos = new ArrayList(); + } + else + { + criteria.add(ContactInfoPeer.ADDRESS_ID, getId()); + collContactInfos = ContactInfoPeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ContactInfoPeer.ADDRESS_ID, getId()); + if (!lastContactInfosCriteria.equals(criteria)) + { + collContactInfos = ContactInfoPeer.doSelect(criteria, con); + } + } + } + lastContactInfosCriteria = criteria; + + return collContactInfos; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("Address"); + fieldNames.add("City"); + fieldNames.add("Region"); + fieldNames.add("Zip"); + fieldNames.add("CountryId"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("Address")) + { + return getAddress(); + } + if (name.equals("City")) + { + return getCity(); + } + if (name.equals("Region")) + { + return getRegion(); + } + if (name.equals("Zip")) + { + return getZip(); + } + if (name.equals("CountryId")) + { + return getCountryId(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(AddressPeer.ID)) + { + return getId(); + } + if (name.equals(AddressPeer.ADDRESS)) + { + return getAddress(); + } + if (name.equals(AddressPeer.CITY)) + { + return getCity(); + } + if (name.equals(AddressPeer.REGION)) + { + return getRegion(); + } + if (name.equals(AddressPeer.ZIP)) + { + return getZip(); + } + if (name.equals(AddressPeer.COUNTRY_ID)) + { + return getCountryId(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getAddress(); + } + if (pos == 2) + { + return getCity(); + } + if (pos == 3) + { + return getRegion(); + } + if (pos == 4) + { + return getZip(); + } + if (pos == 5) + { + return getCountryId(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(AddressPeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + AddressPeer.doInsert((Address) this, con); + setNew(false); + } + else + { + AddressPeer.doUpdate((Address) this, con); + } + } + + + + if (collContactInfos != null) + { + for (int i = 0; i < collContactInfos.size(); i++) + { + ((ContactInfo) collContactInfos.get(i)).save(con); + } + } + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + throws TorqueException + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) throws TorqueException + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public Address copy() throws TorqueException + { + return copyInto(new Address()); + } + + protected Address copyInto(Address copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setAddress(address); + copyObj.setCity(city); + copyObj.setRegion(region); + copyObj.setZip(zip); + copyObj.setCountryId(country_id); + + copyObj.setNew(false); + + + List v = getContactInfos(); + for (int i = 0; i < v.size(); i++) + { + ContactInfo obj = (ContactInfo) v.get(i); + copyObj.addContactInfo(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public AddressPeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BaseAddressPeer.java b/src/java/org/thdl/roster/om/BaseAddressPeer.java new file mode 100755 index 0000000..393fc81 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseAddressPeer.java @@ -0,0 +1,880 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BaseAddressPeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "Address"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(AddressMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the ADDRESS field */ + public static final String ADDRESS; + /** the column name for the CITY field */ + public static final String CITY; + /** the column name for the REGION field */ + public static final String REGION; + /** the column name for the ZIP field */ + public static final String ZIP; + /** the column name for the COUNTRY_ID field */ + public static final String COUNTRY_ID; + + static + { + ID = "Address.ID"; + ADDRESS = "Address.ADDRESS"; + CITY = "Address.CITY"; + REGION = "Address.REGION"; + ZIP = "Address.ZIP"; + COUNTRY_ID = "Address.COUNTRY_ID"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(AddressMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 6; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.Address"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BaseAddressPeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(ADDRESS); + criteria.addSelectColumn(CITY); + criteria.addSelectColumn(REGION); + criteria.addSelectColumn(ZIP); + criteria.addSelectColumn(COUNTRY_ID); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Address row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + Address obj = (Address) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + Address obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setAddress(row.getValue(offset + 1).asString()); + obj.setCity(row.getValue(offset + 2).asString()); + obj.setRegion(row.getValue(offset + 3).asString()); + obj.setZip(row.getValue(offset + 4).asString()); + obj.setCountryId(row.getValue(offset + 5).asIntegerObj()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BaseAddressPeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(AddressPeer.row2Object(row, 1, + AddressPeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BaseAddressPeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BaseAddressPeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Address obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(Address obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Address obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Address obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Address) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(Address obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(Address) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Address obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(Address) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Address obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BaseAddressPeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( Address obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(ADDRESS, obj.getAddress()); + criteria.add(CITY, obj.getCity()); + criteria.add(REGION, obj.getRegion()); + criteria.add(ZIP, obj.getZip()); + criteria.add(COUNTRY_ID, obj.getCountryId()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Address retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Address retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + Address retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Address retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (Address)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + + + /** + * selects a collection of Address objects pre-filled with their + * Country objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in AddressPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinCountry(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + AddressPeer.addSelectColumns(c); + int offset = numColumns + 1; + CountryPeer.addSelectColumns(c); + + + c.addJoin(AddressPeer.COUNTRY_ID, + CountryPeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = AddressPeer.getOMClass(); + + Address obj1 = (Address) AddressPeer + .row2Object(row, 1, omClass); + + + omClass = CountryPeer.getOMClass(); + Country obj2 = (Country)CountryPeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + Address temp_obj1 = (Address)results.get(j); + Country temp_obj2 = (Country)temp_obj1.getCountry(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addAddress(obj1); + break; + } + } + if (newObject) + { + obj2.initAddresss(); + obj2.addAddress(obj1); + } + results.add(obj1); + } + return results; + } + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BaseContactInfo.java b/src/java/org/thdl/roster/om/BaseContactInfo.java new file mode 100755 index 0000000..679a388 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseContactInfo.java @@ -0,0 +1,1047 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to ContactInfo + */ +public abstract class BaseContactInfo extends BaseObject +{ + /** The Peer class */ + private static final ContactInfoPeer peer = + new ContactInfoPeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the contact_name field + */ + private String contact_name; + + /** + * The value for the email field + */ + private String email; + + /** + * The value for the website field + */ + private String website; + + /** + * The value for the phone field + */ + private Integer phone; + + /** + * The value for the fax field + */ + private Integer fax; + + /** + * The value for the address_id field + */ + private Integer address_id; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + + // update associated Member + if (collMembers != null) + { + for (int i = 0; i < collMembers.size(); i++) + { + ((Member) collMembers.get(i)) + .setContactInfoId(v); + } + } + } + + + /** + * Get the ContactName + * + * @return String + */ + public String getContactName() + { + return contact_name; + } + + + /** + * Set the value of ContactName + * + * @param v new value + */ + public void setContactName(String v) + { + + + + if (!ObjectUtils.equals(this.contact_name, v)) + { + this.contact_name = v; + setModified(true); + } + + + } + + + /** + * Get the Email + * + * @return String + */ + public String getEmail() + { + return email; + } + + + /** + * Set the value of Email + * + * @param v new value + */ + public void setEmail(String v) + { + + + + if (!ObjectUtils.equals(this.email, v)) + { + this.email = v; + setModified(true); + } + + + } + + + /** + * Get the Website + * + * @return String + */ + public String getWebsite() + { + return website; + } + + + /** + * Set the value of Website + * + * @param v new value + */ + public void setWebsite(String v) + { + + + + if (!ObjectUtils.equals(this.website, v)) + { + this.website = v; + setModified(true); + } + + + } + + + /** + * Get the Phone + * + * @return Integer + */ + public Integer getPhone() + { + return phone; + } + + + /** + * Set the value of Phone + * + * @param v new value + */ + public void setPhone(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.phone, v)) + { + this.phone = v; + setModified(true); + } + + + if (aPhoneRelatedByPhone != null && !ObjectUtils.equals(aPhoneRelatedByPhone.getId(), v)) + { + aPhoneRelatedByPhone = null; + } + + } + + + /** + * Get the Fax + * + * @return Integer + */ + public Integer getFax() + { + return fax; + } + + + /** + * Set the value of Fax + * + * @param v new value + */ + public void setFax(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.fax, v)) + { + this.fax = v; + setModified(true); + } + + + if (aPhoneRelatedByFax != null && !ObjectUtils.equals(aPhoneRelatedByFax.getId(), v)) + { + aPhoneRelatedByFax = null; + } + + } + + + /** + * Get the AddressId + * + * @return Integer + */ + public Integer getAddressId() + { + return address_id; + } + + + /** + * Set the value of AddressId + * + * @param v new value + */ + public void setAddressId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.address_id, v)) + { + this.address_id = v; + setModified(true); + } + + + if (aAddress != null && !ObjectUtils.equals(aAddress.getId(), v)) + { + aAddress = null; + } + + } + + + + + + + + private Address aAddress; + + /** + * Declares an association between this object and a Address object + * + * @param v Address + * @throws TorqueException + */ + public void setAddress(Address v) throws TorqueException + { + if (v == null) + { + setAddressId((Integer)null); + } + else + { + setAddressId(v.getId()); + } + aAddress = v; + } + + + /** + * Get the associated Address object + * + * @return the associated Address object + * @throws TorqueException + */ + public Address getAddress() throws TorqueException + { + if (aAddress == null && (!ObjectUtils.equals(this.address_id, null))) + { + aAddress = AddressPeer.retrieveByPK(SimpleKey.keyFor(this.address_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + Address obj = AddressPeer.retrieveByPK(this.address_id); + obj.addContactInfos(this); + */ + } + return aAddress; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setAddressKey(ObjectKey key) throws TorqueException + { + + setAddressId(new Integer(((NumberKey) key).intValue())); + } + + + + + private Phone aPhoneRelatedByPhone; + + /** + * Declares an association between this object and a Phone object + * + * @param v Phone + * @throws TorqueException + */ + public void setPhoneRelatedByPhone(Phone v) throws TorqueException + { + if (v == null) + { + setPhone((Integer)null); + } + else + { + setPhone(v.getId()); + } + aPhoneRelatedByPhone = v; + } + + + /** + * Get the associated Phone object + * + * @return the associated Phone object + * @throws TorqueException + */ + public Phone getPhoneRelatedByPhone() throws TorqueException + { + if (aPhoneRelatedByPhone == null && (!ObjectUtils.equals(this.phone, null))) + { + aPhoneRelatedByPhone = PhonePeer.retrieveByPK(SimpleKey.keyFor(this.phone)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + Phone obj = PhonePeer.retrieveByPK(this.phone); + obj.addContactInfosRelatedByPhone(this); + */ + } + return aPhoneRelatedByPhone; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setPhoneRelatedByPhoneKey(ObjectKey key) throws TorqueException + { + + setPhone(new Integer(((NumberKey) key).intValue())); + } + + + + + private Phone aPhoneRelatedByFax; + + /** + * Declares an association between this object and a Phone object + * + * @param v Phone + * @throws TorqueException + */ + public void setPhoneRelatedByFax(Phone v) throws TorqueException + { + if (v == null) + { + setFax((Integer)null); + } + else + { + setFax(v.getId()); + } + aPhoneRelatedByFax = v; + } + + + /** + * Get the associated Phone object + * + * @return the associated Phone object + * @throws TorqueException + */ + public Phone getPhoneRelatedByFax() throws TorqueException + { + if (aPhoneRelatedByFax == null && (!ObjectUtils.equals(this.fax, null))) + { + aPhoneRelatedByFax = PhonePeer.retrieveByPK(SimpleKey.keyFor(this.fax)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + Phone obj = PhonePeer.retrieveByPK(this.fax); + obj.addContactInfosRelatedByFax(this); + */ + } + return aPhoneRelatedByFax; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setPhoneRelatedByFaxKey(ObjectKey key) throws TorqueException + { + + setFax(new Integer(((NumberKey) key).intValue())); + } + + + + /** + * Collection to store aggregation of collMembers + */ + protected List collMembers; + + /** + * Temporary storage of collMembers to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initMembers() + { + if (collMembers == null) + { + collMembers = new ArrayList(); + } + } + + /** + * Method called to associate a Member object to this object + * through the Member foreign key attribute + * + * @param l Member + * @throws TorqueException + */ + public void addMember(Member l) throws TorqueException + { + getMembers().add(l); + l.setContactInfo((ContactInfo) this); + } + + /** + * The criteria used to select the current contents of collMembers + */ + private Criteria lastMembersCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getMembers(new Criteria()) + * + * @throws TorqueException + */ + public List getMembers() throws TorqueException + { + if (collMembers == null) + { + collMembers = getMembers(new Criteria(10)); + } + return collMembers; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this ContactInfo has previously + * been saved, it will retrieve related Members from storage. + * If this ContactInfo is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getMembers(Criteria criteria) throws TorqueException + { + if (collMembers == null) + { + if (isNew()) + { + collMembers = new ArrayList(); + } + else + { + criteria.add(MemberPeer.CONTACT_INFO_ID, getId() ); + collMembers = MemberPeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(MemberPeer.CONTACT_INFO_ID, getId()); + if (!lastMembersCriteria.equals(criteria)) + { + collMembers = MemberPeer.doSelect(criteria); + } + } + } + lastMembersCriteria = criteria; + + return collMembers; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getMembers(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getMembers(Connection con) throws TorqueException + { + if (collMembers == null) + { + collMembers = getMembers(new Criteria(10), con); + } + return collMembers; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this ContactInfo has previously + * been saved, it will retrieve related Members from storage. + * If this ContactInfo is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getMembers(Criteria criteria, Connection con) + throws TorqueException + { + if (collMembers == null) + { + if (isNew()) + { + collMembers = new ArrayList(); + } + else + { + criteria.add(MemberPeer.CONTACT_INFO_ID, getId()); + collMembers = MemberPeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(MemberPeer.CONTACT_INFO_ID, getId()); + if (!lastMembersCriteria.equals(criteria)) + { + collMembers = MemberPeer.doSelect(criteria, con); + } + } + } + lastMembersCriteria = criteria; + + return collMembers; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("ContactName"); + fieldNames.add("Email"); + fieldNames.add("Website"); + fieldNames.add("Phone"); + fieldNames.add("Fax"); + fieldNames.add("AddressId"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("ContactName")) + { + return getContactName(); + } + if (name.equals("Email")) + { + return getEmail(); + } + if (name.equals("Website")) + { + return getWebsite(); + } + if (name.equals("Phone")) + { + return getPhone(); + } + if (name.equals("Fax")) + { + return getFax(); + } + if (name.equals("AddressId")) + { + return getAddressId(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(ContactInfoPeer.ID)) + { + return getId(); + } + if (name.equals(ContactInfoPeer.CONTACT_NAME)) + { + return getContactName(); + } + if (name.equals(ContactInfoPeer.EMAIL)) + { + return getEmail(); + } + if (name.equals(ContactInfoPeer.WEBSITE)) + { + return getWebsite(); + } + if (name.equals(ContactInfoPeer.PHONE)) + { + return getPhone(); + } + if (name.equals(ContactInfoPeer.FAX)) + { + return getFax(); + } + if (name.equals(ContactInfoPeer.ADDRESS_ID)) + { + return getAddressId(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getContactName(); + } + if (pos == 2) + { + return getEmail(); + } + if (pos == 3) + { + return getWebsite(); + } + if (pos == 4) + { + return getPhone(); + } + if (pos == 5) + { + return getFax(); + } + if (pos == 6) + { + return getAddressId(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(ContactInfoPeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + ContactInfoPeer.doInsert((ContactInfo) this, con); + setNew(false); + } + else + { + ContactInfoPeer.doUpdate((ContactInfo) this, con); + } + } + + + + if (collMembers != null) + { + for (int i = 0; i < collMembers.size(); i++) + { + ((Member) collMembers.get(i)).save(con); + } + } + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + throws TorqueException + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) throws TorqueException + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public ContactInfo copy() throws TorqueException + { + return copyInto(new ContactInfo()); + } + + protected ContactInfo copyInto(ContactInfo copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setContactName(contact_name); + copyObj.setEmail(email); + copyObj.setWebsite(website); + copyObj.setPhone(phone); + copyObj.setFax(fax); + copyObj.setAddressId(address_id); + + copyObj.setNew(false); + + + List v = getMembers(); + for (int i = 0; i < v.size(); i++) + { + Member obj = (Member) v.get(i); + copyObj.addMember(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public ContactInfoPeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BaseContactInfoPeer.java b/src/java/org/thdl/roster/om/BaseContactInfoPeer.java new file mode 100755 index 0000000..5636265 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseContactInfoPeer.java @@ -0,0 +1,1310 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BaseContactInfoPeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "ContactInfo"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(ContactInfoMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the CONTACT_NAME field */ + public static final String CONTACT_NAME; + /** the column name for the EMAIL field */ + public static final String EMAIL; + /** the column name for the WEBSITE field */ + public static final String WEBSITE; + /** the column name for the PHONE field */ + public static final String PHONE; + /** the column name for the FAX field */ + public static final String FAX; + /** the column name for the ADDRESS_ID field */ + public static final String ADDRESS_ID; + + static + { + ID = "ContactInfo.ID"; + CONTACT_NAME = "ContactInfo.CONTACT_NAME"; + EMAIL = "ContactInfo.EMAIL"; + WEBSITE = "ContactInfo.WEBSITE"; + PHONE = "ContactInfo.PHONE"; + FAX = "ContactInfo.FAX"; + ADDRESS_ID = "ContactInfo.ADDRESS_ID"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(ContactInfoMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 7; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.ContactInfo"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BaseContactInfoPeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(CONTACT_NAME); + criteria.addSelectColumn(EMAIL); + criteria.addSelectColumn(WEBSITE); + criteria.addSelectColumn(PHONE); + criteria.addSelectColumn(FAX); + criteria.addSelectColumn(ADDRESS_ID); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ContactInfo row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + ContactInfo obj = (ContactInfo) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + ContactInfo obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setContactName(row.getValue(offset + 1).asString()); + obj.setEmail(row.getValue(offset + 2).asString()); + obj.setWebsite(row.getValue(offset + 3).asString()); + obj.setPhone(row.getValue(offset + 4).asIntegerObj()); + obj.setFax(row.getValue(offset + 5).asIntegerObj()); + obj.setAddressId(row.getValue(offset + 6).asIntegerObj()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BaseContactInfoPeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(ContactInfoPeer.row2Object(row, 1, + ContactInfoPeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BaseContactInfoPeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BaseContactInfoPeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(ContactInfo obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(ContactInfo obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(ContactInfo obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ContactInfo obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(ContactInfo) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(ContactInfo obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(ContactInfo) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(ContactInfo obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ContactInfo) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ContactInfo obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BaseContactInfoPeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( ContactInfo obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(CONTACT_NAME, obj.getContactName()); + criteria.add(EMAIL, obj.getEmail()); + criteria.add(WEBSITE, obj.getWebsite()); + criteria.add(PHONE, obj.getPhone()); + criteria.add(FAX, obj.getFax()); + criteria.add(ADDRESS_ID, obj.getAddressId()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ContactInfo retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ContactInfo retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + ContactInfo retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ContactInfo retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (ContactInfo)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + + + /** + * selects a collection of ContactInfo objects pre-filled with their + * Address objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in ContactInfoPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinAddress(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + ContactInfoPeer.addSelectColumns(c); + int offset = numColumns + 1; + AddressPeer.addSelectColumns(c); + + + c.addJoin(ContactInfoPeer.ADDRESS_ID, + AddressPeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = ContactInfoPeer.getOMClass(); + + ContactInfo obj1 = (ContactInfo) ContactInfoPeer + .row2Object(row, 1, omClass); + + + omClass = AddressPeer.getOMClass(); + Address obj2 = (Address)AddressPeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + ContactInfo temp_obj1 = (ContactInfo)results.get(j); + Address temp_obj2 = (Address)temp_obj1.getAddress(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addContactInfo(obj1); + break; + } + } + if (newObject) + { + obj2.initContactInfos(); + obj2.addContactInfo(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + + /** + * selects a collection of ContactInfo objects pre-filled with their + * Phone objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in ContactInfoPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinPhoneRelatedByPhone(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + ContactInfoPeer.addSelectColumns(c); + int offset = numColumns + 1; + PhonePeer.addSelectColumns(c); + + + c.addJoin(ContactInfoPeer.PHONE, + PhonePeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = ContactInfoPeer.getOMClass(); + + ContactInfo obj1 = (ContactInfo) ContactInfoPeer + .row2Object(row, 1, omClass); + + + omClass = PhonePeer.getOMClass(); + Phone obj2 = (Phone)PhonePeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + ContactInfo temp_obj1 = (ContactInfo)results.get(j); + Phone temp_obj2 = (Phone)temp_obj1.getPhoneRelatedByPhone(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addContactInfoRelatedByPhone(obj1); + break; + } + } + if (newObject) + { + obj2.initContactInfosRelatedByPhone(); + obj2.addContactInfoRelatedByPhone(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + + /** + * selects a collection of ContactInfo objects pre-filled with their + * Phone objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in ContactInfoPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinPhoneRelatedByFax(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + ContactInfoPeer.addSelectColumns(c); + int offset = numColumns + 1; + PhonePeer.addSelectColumns(c); + + + c.addJoin(ContactInfoPeer.FAX, + PhonePeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = ContactInfoPeer.getOMClass(); + + ContactInfo obj1 = (ContactInfo) ContactInfoPeer + .row2Object(row, 1, omClass); + + + omClass = PhonePeer.getOMClass(); + Phone obj2 = (Phone)PhonePeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + ContactInfo temp_obj1 = (ContactInfo)results.get(j); + Phone temp_obj2 = (Phone)temp_obj1.getPhoneRelatedByFax(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addContactInfoRelatedByFax(obj1); + break; + } + } + if (newObject) + { + obj2.initContactInfosRelatedByFax(); + obj2.addContactInfoRelatedByFax(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + + + + + /** + * selects a collection of ContactInfo objects pre-filled with + * all related objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in ContactInfoPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinAllExceptAddress(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to another value + // so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + addSelectColumns(c); + int offset2 = numColumns + 1; + + + PhonePeer.addSelectColumns(c); + int offset3 = offset2 + PhonePeer.numColumns; + + PhonePeer.addSelectColumns(c); + int offset4 = offset3 + PhonePeer.numColumns; + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record)rows.get(i); + + Class omClass = ContactInfoPeer.getOMClass(); + + ContactInfo obj1 = (ContactInfo)ContactInfoPeer + .row2Object(row, 1, omClass); + + + + + + + + omClass = PhonePeer.getOMClass(); + Phone obj2 = (Phone)PhonePeer + .row2Object( row, offset2, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + ContactInfo temp_obj1 = (ContactInfo)results.get(j); + Phone temp_obj2 = (Phone)temp_obj1.getPhoneRelatedByPhone(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addContactInfoRelatedByPhone(obj1); + break; + } + } + if (newObject) + { + obj2.initContactInfosRelatedByPhone(); + obj2.addContactInfoRelatedByPhone(obj1); + } + + + + + omClass = PhonePeer.getOMClass(); + Phone obj3 = (Phone)PhonePeer + .row2Object( row, offset3, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + ContactInfo temp_obj1 = (ContactInfo)results.get(j); + Phone temp_obj3 = (Phone)temp_obj1.getPhoneRelatedByFax(); + if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) + { + newObject = false; + temp_obj3.addContactInfoRelatedByFax(obj1); + break; + } + } + if (newObject) + { + obj3.initContactInfosRelatedByFax(); + obj3.addContactInfoRelatedByFax(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + /** + * selects a collection of ContactInfo objects pre-filled with + * all related objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in ContactInfoPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinAllExceptPhoneRelatedByPhone(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to another value + // so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + addSelectColumns(c); + int offset2 = numColumns + 1; + + AddressPeer.addSelectColumns(c); + int offset3 = offset2 + AddressPeer.numColumns; + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record)rows.get(i); + + Class omClass = ContactInfoPeer.getOMClass(); + + ContactInfo obj1 = (ContactInfo)ContactInfoPeer + .row2Object(row, 1, omClass); + + + + + + + omClass = AddressPeer.getOMClass(); + Address obj2 = (Address)AddressPeer + .row2Object( row, offset2, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + ContactInfo temp_obj1 = (ContactInfo)results.get(j); + Address temp_obj2 = (Address)temp_obj1.getAddress(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addContactInfo(obj1); + break; + } + } + if (newObject) + { + obj2.initContactInfos(); + obj2.addContactInfo(obj1); + } + + + results.add(obj1); + } + return results; + } + + + + + + /** + * selects a collection of ContactInfo objects pre-filled with + * all related objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in ContactInfoPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinAllExceptPhoneRelatedByFax(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to another value + // so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + addSelectColumns(c); + int offset2 = numColumns + 1; + + AddressPeer.addSelectColumns(c); + int offset3 = offset2 + AddressPeer.numColumns; + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record)rows.get(i); + + Class omClass = ContactInfoPeer.getOMClass(); + + ContactInfo obj1 = (ContactInfo)ContactInfoPeer + .row2Object(row, 1, omClass); + + + + + + + omClass = AddressPeer.getOMClass(); + Address obj2 = (Address)AddressPeer + .row2Object( row, offset2, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + ContactInfo temp_obj1 = (ContactInfo)results.get(j); + Address temp_obj2 = (Address)temp_obj1.getAddress(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addContactInfo(obj1); + break; + } + } + if (newObject) + { + obj2.initContactInfos(); + obj2.addContactInfo(obj1); + } + + + results.add(obj1); + } + return results; + } + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BaseCountry.java b/src/java/org/thdl/roster/om/BaseCountry.java new file mode 100755 index 0000000..7aa209f --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseCountry.java @@ -0,0 +1,553 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to Country + */ +public abstract class BaseCountry extends BaseObject +{ + /** The Peer class */ + private static final CountryPeer peer = + new CountryPeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the country field + */ + private String country; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + + // update associated Address + if (collAddresss != null) + { + for (int i = 0; i < collAddresss.size(); i++) + { + ((Address) collAddresss.get(i)) + .setCountryId(v); + } + } + } + + + /** + * Get the Country + * + * @return String + */ + public String getCountry() + { + return country; + } + + + /** + * Set the value of Country + * + * @param v new value + */ + public void setCountry(String v) + { + + + + if (!ObjectUtils.equals(this.country, v)) + { + this.country = v; + setModified(true); + } + + + } + + + + + + + /** + * Collection to store aggregation of collAddresss + */ + protected List collAddresss; + + /** + * Temporary storage of collAddresss to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initAddresss() + { + if (collAddresss == null) + { + collAddresss = new ArrayList(); + } + } + + /** + * Method called to associate a Address object to this object + * through the Address foreign key attribute + * + * @param l Address + * @throws TorqueException + */ + public void addAddress(Address l) throws TorqueException + { + getAddresss().add(l); + l.setCountry((Country) this); + } + + /** + * The criteria used to select the current contents of collAddresss + */ + private Criteria lastAddresssCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getAddresss(new Criteria()) + * + * @throws TorqueException + */ + public List getAddresss() throws TorqueException + { + if (collAddresss == null) + { + collAddresss = getAddresss(new Criteria(10)); + } + return collAddresss; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Country has previously + * been saved, it will retrieve related Addresss from storage. + * If this Country is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getAddresss(Criteria criteria) throws TorqueException + { + if (collAddresss == null) + { + if (isNew()) + { + collAddresss = new ArrayList(); + } + else + { + criteria.add(AddressPeer.COUNTRY_ID, getId() ); + collAddresss = AddressPeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(AddressPeer.COUNTRY_ID, getId()); + if (!lastAddresssCriteria.equals(criteria)) + { + collAddresss = AddressPeer.doSelect(criteria); + } + } + } + lastAddresssCriteria = criteria; + + return collAddresss; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getAddresss(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getAddresss(Connection con) throws TorqueException + { + if (collAddresss == null) + { + collAddresss = getAddresss(new Criteria(10), con); + } + return collAddresss; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Country has previously + * been saved, it will retrieve related Addresss from storage. + * If this Country is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getAddresss(Criteria criteria, Connection con) + throws TorqueException + { + if (collAddresss == null) + { + if (isNew()) + { + collAddresss = new ArrayList(); + } + else + { + criteria.add(AddressPeer.COUNTRY_ID, getId()); + collAddresss = AddressPeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(AddressPeer.COUNTRY_ID, getId()); + if (!lastAddresssCriteria.equals(criteria)) + { + collAddresss = AddressPeer.doSelect(criteria, con); + } + } + } + lastAddresssCriteria = criteria; + + return collAddresss; + } + + + + + + + + + + + + + + + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("Country"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("Country")) + { + return getCountry(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(CountryPeer.ID)) + { + return getId(); + } + if (name.equals(CountryPeer.COUNTRY)) + { + return getCountry(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getCountry(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(CountryPeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + CountryPeer.doInsert((Country) this, con); + setNew(false); + } + else + { + CountryPeer.doUpdate((Country) this, con); + } + } + + + + if (collAddresss != null) + { + for (int i = 0; i < collAddresss.size(); i++) + { + ((Address) collAddresss.get(i)).save(con); + } + } + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + throws TorqueException + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) throws TorqueException + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public Country copy() throws TorqueException + { + return copyInto(new Country()); + } + + protected Country copyInto(Country copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setCountry(country); + + copyObj.setNew(false); + + + List v = getAddresss(); + for (int i = 0; i < v.size(); i++) + { + Address obj = (Address) v.get(i); + copyObj.addAddress(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public CountryPeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BaseCountryPeer.java b/src/java/org/thdl/roster/om/BaseCountryPeer.java new file mode 100755 index 0000000..75ef06c --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseCountryPeer.java @@ -0,0 +1,778 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BaseCountryPeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "Country"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(CountryMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the COUNTRY field */ + public static final String COUNTRY; + + static + { + ID = "Country.ID"; + COUNTRY = "Country.COUNTRY"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(CountryMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 2; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.Country"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BaseCountryPeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(COUNTRY); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Country row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + Country obj = (Country) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + Country obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setCountry(row.getValue(offset + 1).asString()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BaseCountryPeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(CountryPeer.row2Object(row, 1, + CountryPeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BaseCountryPeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BaseCountryPeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Country obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(Country obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Country obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Country obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Country) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(Country obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(Country) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Country obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(Country) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Country obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BaseCountryPeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( Country obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(COUNTRY, obj.getCountry()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Country retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Country retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + Country retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Country retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (Country)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BaseCulturalArea.java b/src/java/org/thdl/roster/om/BaseCulturalArea.java new file mode 100755 index 0000000..f3e05aa --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseCulturalArea.java @@ -0,0 +1,561 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to CulturalArea + */ +public abstract class BaseCulturalArea extends BaseObject +{ + /** The Peer class */ + private static final CulturalAreaPeer peer = + new CulturalAreaPeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the cultural_area field + */ + private String cultural_area; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + + // update associated ResearchInterestCulturalArea + if (collResearchInterestCulturalAreas != null) + { + for (int i = 0; i < collResearchInterestCulturalAreas.size(); i++) + { + ((ResearchInterestCulturalArea) collResearchInterestCulturalAreas.get(i)) + .setCulturalAreaId(v); + } + } + } + + + /** + * Get the CulturalArea + * + * @return String + */ + public String getCulturalArea() + { + return cultural_area; + } + + + /** + * Set the value of CulturalArea + * + * @param v new value + */ + public void setCulturalArea(String v) + { + + + + if (!ObjectUtils.equals(this.cultural_area, v)) + { + this.cultural_area = v; + setModified(true); + } + + + } + + + + + + + /** + * Collection to store aggregation of collResearchInterestCulturalAreas + */ + protected List collResearchInterestCulturalAreas; + + /** + * Temporary storage of collResearchInterestCulturalAreas to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initResearchInterestCulturalAreas() + { + if (collResearchInterestCulturalAreas == null) + { + collResearchInterestCulturalAreas = new ArrayList(); + } + } + + /** + * Method called to associate a ResearchInterestCulturalArea object to this object + * through the ResearchInterestCulturalArea foreign key attribute + * + * @param l ResearchInterestCulturalArea + * @throws TorqueException + */ + public void addResearchInterestCulturalArea(ResearchInterestCulturalArea l) throws TorqueException + { + getResearchInterestCulturalAreas().add(l); + l.setCulturalArea((CulturalArea) this); + } + + /** + * The criteria used to select the current contents of collResearchInterestCulturalAreas + */ + private Criteria lastResearchInterestCulturalAreasCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getResearchInterestCulturalAreas(new Criteria()) + * + * @throws TorqueException + */ + public List getResearchInterestCulturalAreas() throws TorqueException + { + if (collResearchInterestCulturalAreas == null) + { + collResearchInterestCulturalAreas = getResearchInterestCulturalAreas(new Criteria(10)); + } + return collResearchInterestCulturalAreas; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CulturalArea has previously + * been saved, it will retrieve related ResearchInterestCulturalAreas from storage. + * If this CulturalArea is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getResearchInterestCulturalAreas(Criteria criteria) throws TorqueException + { + if (collResearchInterestCulturalAreas == null) + { + if (isNew()) + { + collResearchInterestCulturalAreas = new ArrayList(); + } + else + { + criteria.add(ResearchInterestCulturalAreaPeer.CULTURAL_AREA_ID, getId() ); + collResearchInterestCulturalAreas = ResearchInterestCulturalAreaPeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ResearchInterestCulturalAreaPeer.CULTURAL_AREA_ID, getId()); + if (!lastResearchInterestCulturalAreasCriteria.equals(criteria)) + { + collResearchInterestCulturalAreas = ResearchInterestCulturalAreaPeer.doSelect(criteria); + } + } + } + lastResearchInterestCulturalAreasCriteria = criteria; + + return collResearchInterestCulturalAreas; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getResearchInterestCulturalAreas(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getResearchInterestCulturalAreas(Connection con) throws TorqueException + { + if (collResearchInterestCulturalAreas == null) + { + collResearchInterestCulturalAreas = getResearchInterestCulturalAreas(new Criteria(10), con); + } + return collResearchInterestCulturalAreas; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this CulturalArea has previously + * been saved, it will retrieve related ResearchInterestCulturalAreas from storage. + * If this CulturalArea is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getResearchInterestCulturalAreas(Criteria criteria, Connection con) + throws TorqueException + { + if (collResearchInterestCulturalAreas == null) + { + if (isNew()) + { + collResearchInterestCulturalAreas = new ArrayList(); + } + else + { + criteria.add(ResearchInterestCulturalAreaPeer.CULTURAL_AREA_ID, getId()); + collResearchInterestCulturalAreas = ResearchInterestCulturalAreaPeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ResearchInterestCulturalAreaPeer.CULTURAL_AREA_ID, getId()); + if (!lastResearchInterestCulturalAreasCriteria.equals(criteria)) + { + collResearchInterestCulturalAreas = ResearchInterestCulturalAreaPeer.doSelect(criteria, con); + } + } + } + lastResearchInterestCulturalAreasCriteria = criteria; + + return collResearchInterestCulturalAreas; + } + + + + + + + + + + + + + + + + + + + + + + + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("CulturalArea"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("CulturalArea")) + { + return getCulturalArea(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(CulturalAreaPeer.ID)) + { + return getId(); + } + if (name.equals(CulturalAreaPeer.CULTURAL_AREA)) + { + return getCulturalArea(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getCulturalArea(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(CulturalAreaPeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + CulturalAreaPeer.doInsert((CulturalArea) this, con); + setNew(false); + } + else + { + CulturalAreaPeer.doUpdate((CulturalArea) this, con); + } + } + + + + if (collResearchInterestCulturalAreas != null) + { + for (int i = 0; i < collResearchInterestCulturalAreas.size(); i++) + { + ((ResearchInterestCulturalArea) collResearchInterestCulturalAreas.get(i)).save(con); + } + } + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + throws TorqueException + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) throws TorqueException + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public CulturalArea copy() throws TorqueException + { + return copyInto(new CulturalArea()); + } + + protected CulturalArea copyInto(CulturalArea copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setCulturalArea(cultural_area); + + copyObj.setNew(false); + + + List v = getResearchInterestCulturalAreas(); + for (int i = 0; i < v.size(); i++) + { + ResearchInterestCulturalArea obj = (ResearchInterestCulturalArea) v.get(i); + copyObj.addResearchInterestCulturalArea(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public CulturalAreaPeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BaseCulturalAreaPeer.java b/src/java/org/thdl/roster/om/BaseCulturalAreaPeer.java new file mode 100755 index 0000000..10c991a --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseCulturalAreaPeer.java @@ -0,0 +1,778 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BaseCulturalAreaPeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "CulturalArea"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(CulturalAreaMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the CULTURAL_AREA field */ + public static final String CULTURAL_AREA; + + static + { + ID = "CulturalArea.ID"; + CULTURAL_AREA = "CulturalArea.CULTURAL_AREA"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(CulturalAreaMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 2; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.CulturalArea"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BaseCulturalAreaPeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(CULTURAL_AREA); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static CulturalArea row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + CulturalArea obj = (CulturalArea) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + CulturalArea obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setCulturalArea(row.getValue(offset + 1).asString()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BaseCulturalAreaPeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(CulturalAreaPeer.row2Object(row, 1, + CulturalAreaPeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BaseCulturalAreaPeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BaseCulturalAreaPeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(CulturalArea obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(CulturalArea obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(CulturalArea obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(CulturalArea obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(CulturalArea) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(CulturalArea obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(CulturalArea) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(CulturalArea obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(CulturalArea) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(CulturalArea obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BaseCulturalAreaPeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( CulturalArea obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(CULTURAL_AREA, obj.getCulturalArea()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static CulturalArea retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static CulturalArea retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + CulturalArea retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static CulturalArea retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (CulturalArea)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BaseDiscipline.java b/src/java/org/thdl/roster/om/BaseDiscipline.java new file mode 100755 index 0000000..585c608 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseDiscipline.java @@ -0,0 +1,561 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to Discipline + */ +public abstract class BaseDiscipline extends BaseObject +{ + /** The Peer class */ + private static final DisciplinePeer peer = + new DisciplinePeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the discipline field + */ + private String discipline; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + + // update associated ResearchInterestDiscipline + if (collResearchInterestDisciplines != null) + { + for (int i = 0; i < collResearchInterestDisciplines.size(); i++) + { + ((ResearchInterestDiscipline) collResearchInterestDisciplines.get(i)) + .setDisciplineId(v); + } + } + } + + + /** + * Get the Discipline + * + * @return String + */ + public String getDiscipline() + { + return discipline; + } + + + /** + * Set the value of Discipline + * + * @param v new value + */ + public void setDiscipline(String v) + { + + + + if (!ObjectUtils.equals(this.discipline, v)) + { + this.discipline = v; + setModified(true); + } + + + } + + + + + + + /** + * Collection to store aggregation of collResearchInterestDisciplines + */ + protected List collResearchInterestDisciplines; + + /** + * Temporary storage of collResearchInterestDisciplines to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initResearchInterestDisciplines() + { + if (collResearchInterestDisciplines == null) + { + collResearchInterestDisciplines = new ArrayList(); + } + } + + /** + * Method called to associate a ResearchInterestDiscipline object to this object + * through the ResearchInterestDiscipline foreign key attribute + * + * @param l ResearchInterestDiscipline + * @throws TorqueException + */ + public void addResearchInterestDiscipline(ResearchInterestDiscipline l) throws TorqueException + { + getResearchInterestDisciplines().add(l); + l.setDiscipline((Discipline) this); + } + + /** + * The criteria used to select the current contents of collResearchInterestDisciplines + */ + private Criteria lastResearchInterestDisciplinesCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getResearchInterestDisciplines(new Criteria()) + * + * @throws TorqueException + */ + public List getResearchInterestDisciplines() throws TorqueException + { + if (collResearchInterestDisciplines == null) + { + collResearchInterestDisciplines = getResearchInterestDisciplines(new Criteria(10)); + } + return collResearchInterestDisciplines; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Discipline has previously + * been saved, it will retrieve related ResearchInterestDisciplines from storage. + * If this Discipline is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getResearchInterestDisciplines(Criteria criteria) throws TorqueException + { + if (collResearchInterestDisciplines == null) + { + if (isNew()) + { + collResearchInterestDisciplines = new ArrayList(); + } + else + { + criteria.add(ResearchInterestDisciplinePeer.DISCIPLINE_ID, getId() ); + collResearchInterestDisciplines = ResearchInterestDisciplinePeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ResearchInterestDisciplinePeer.DISCIPLINE_ID, getId()); + if (!lastResearchInterestDisciplinesCriteria.equals(criteria)) + { + collResearchInterestDisciplines = ResearchInterestDisciplinePeer.doSelect(criteria); + } + } + } + lastResearchInterestDisciplinesCriteria = criteria; + + return collResearchInterestDisciplines; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getResearchInterestDisciplines(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getResearchInterestDisciplines(Connection con) throws TorqueException + { + if (collResearchInterestDisciplines == null) + { + collResearchInterestDisciplines = getResearchInterestDisciplines(new Criteria(10), con); + } + return collResearchInterestDisciplines; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Discipline has previously + * been saved, it will retrieve related ResearchInterestDisciplines from storage. + * If this Discipline is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getResearchInterestDisciplines(Criteria criteria, Connection con) + throws TorqueException + { + if (collResearchInterestDisciplines == null) + { + if (isNew()) + { + collResearchInterestDisciplines = new ArrayList(); + } + else + { + criteria.add(ResearchInterestDisciplinePeer.DISCIPLINE_ID, getId()); + collResearchInterestDisciplines = ResearchInterestDisciplinePeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ResearchInterestDisciplinePeer.DISCIPLINE_ID, getId()); + if (!lastResearchInterestDisciplinesCriteria.equals(criteria)) + { + collResearchInterestDisciplines = ResearchInterestDisciplinePeer.doSelect(criteria, con); + } + } + } + lastResearchInterestDisciplinesCriteria = criteria; + + return collResearchInterestDisciplines; + } + + + + + + + + + + + + + + + + + + + + + + + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("Discipline"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("Discipline")) + { + return getDiscipline(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(DisciplinePeer.ID)) + { + return getId(); + } + if (name.equals(DisciplinePeer.DISCIPLINE)) + { + return getDiscipline(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getDiscipline(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(DisciplinePeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + DisciplinePeer.doInsert((Discipline) this, con); + setNew(false); + } + else + { + DisciplinePeer.doUpdate((Discipline) this, con); + } + } + + + + if (collResearchInterestDisciplines != null) + { + for (int i = 0; i < collResearchInterestDisciplines.size(); i++) + { + ((ResearchInterestDiscipline) collResearchInterestDisciplines.get(i)).save(con); + } + } + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + throws TorqueException + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) throws TorqueException + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public Discipline copy() throws TorqueException + { + return copyInto(new Discipline()); + } + + protected Discipline copyInto(Discipline copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setDiscipline(discipline); + + copyObj.setNew(false); + + + List v = getResearchInterestDisciplines(); + for (int i = 0; i < v.size(); i++) + { + ResearchInterestDiscipline obj = (ResearchInterestDiscipline) v.get(i); + copyObj.addResearchInterestDiscipline(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public DisciplinePeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BaseDisciplinePeer.java b/src/java/org/thdl/roster/om/BaseDisciplinePeer.java new file mode 100755 index 0000000..9f11392 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseDisciplinePeer.java @@ -0,0 +1,778 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BaseDisciplinePeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "Discipline"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(DisciplineMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the DISCIPLINE field */ + public static final String DISCIPLINE; + + static + { + ID = "Discipline.ID"; + DISCIPLINE = "Discipline.DISCIPLINE"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(DisciplineMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 2; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.Discipline"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BaseDisciplinePeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(DISCIPLINE); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Discipline row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + Discipline obj = (Discipline) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + Discipline obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setDiscipline(row.getValue(offset + 1).asString()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BaseDisciplinePeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(DisciplinePeer.row2Object(row, 1, + DisciplinePeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BaseDisciplinePeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BaseDisciplinePeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Discipline obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(Discipline obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Discipline obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Discipline obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Discipline) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(Discipline obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(Discipline) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Discipline obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(Discipline) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Discipline obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BaseDisciplinePeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( Discipline obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(DISCIPLINE, obj.getDiscipline()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Discipline retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Discipline retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + Discipline retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Discipline retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (Discipline)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BaseDocument.java b/src/java/org/thdl/roster/om/BaseDocument.java new file mode 100755 index 0000000..06c6735 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseDocument.java @@ -0,0 +1,734 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to Document + */ +public abstract class BaseDocument extends BaseObject +{ + /** The Peer class */ + private static final DocumentPeer peer = + new DocumentPeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the member_id field + */ + private Integer member_id; + + /** + * The value for the document_type_id field + */ + private Integer document_type_id; + + /** + * The value for the content_type field + */ + private String content_type; + + /** + * The value for the path field + */ + private String path; + + /** + * The value for the filename field + */ + private String filename; + + /** + * The value for the label field + */ + private String label; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + } + + + /** + * Get the MemberId + * + * @return Integer + */ + public Integer getMemberId() + { + return member_id; + } + + + /** + * Set the value of MemberId + * + * @param v new value + */ + public void setMemberId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.member_id, v)) + { + this.member_id = v; + setModified(true); + } + + + if (aMember != null && !ObjectUtils.equals(aMember.getId(), v)) + { + aMember = null; + } + + } + + + /** + * Get the DocumentTypeId + * + * @return Integer + */ + public Integer getDocumentTypeId() + { + return document_type_id; + } + + + /** + * Set the value of DocumentTypeId + * + * @param v new value + */ + public void setDocumentTypeId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.document_type_id, v)) + { + this.document_type_id = v; + setModified(true); + } + + + if (aDocumentType != null && !ObjectUtils.equals(aDocumentType.getId(), v)) + { + aDocumentType = null; + } + + } + + + /** + * Get the ContentType + * + * @return String + */ + public String getContentType() + { + return content_type; + } + + + /** + * Set the value of ContentType + * + * @param v new value + */ + public void setContentType(String v) + { + + + + if (!ObjectUtils.equals(this.content_type, v)) + { + this.content_type = v; + setModified(true); + } + + + } + + + /** + * Get the Path + * + * @return String + */ + public String getPath() + { + return path; + } + + + /** + * Set the value of Path + * + * @param v new value + */ + public void setPath(String v) + { + + + + if (!ObjectUtils.equals(this.path, v)) + { + this.path = v; + setModified(true); + } + + + } + + + /** + * Get the Filename + * + * @return String + */ + public String getFilename() + { + return filename; + } + + + /** + * Set the value of Filename + * + * @param v new value + */ + public void setFilename(String v) + { + + + + if (!ObjectUtils.equals(this.filename, v)) + { + this.filename = v; + setModified(true); + } + + + } + + + /** + * Get the Label + * + * @return String + */ + public String getLabel() + { + return label; + } + + + /** + * Set the value of Label + * + * @param v new value + */ + public void setLabel(String v) + { + + + + if (!ObjectUtils.equals(this.label, v)) + { + this.label = v; + setModified(true); + } + + + } + + + + + + + + private Member aMember; + + /** + * Declares an association between this object and a Member object + * + * @param v Member + * @throws TorqueException + */ + public void setMember(Member v) throws TorqueException + { + if (v == null) + { + setMemberId((Integer)null); + } + else + { + setMemberId(v.getId()); + } + aMember = v; + } + + + /** + * Get the associated Member object + * + * @return the associated Member object + * @throws TorqueException + */ + public Member getMember() throws TorqueException + { + if (aMember == null && (!ObjectUtils.equals(this.member_id, null))) + { + aMember = MemberPeer.retrieveByPK(SimpleKey.keyFor(this.member_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + Member obj = MemberPeer.retrieveByPK(this.member_id); + obj.addDocuments(this); + */ + } + return aMember; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setMemberKey(ObjectKey key) throws TorqueException + { + + setMemberId(new Integer(((NumberKey) key).intValue())); + } + + + + + private DocumentType aDocumentType; + + /** + * Declares an association between this object and a DocumentType object + * + * @param v DocumentType + * @throws TorqueException + */ + public void setDocumentType(DocumentType v) throws TorqueException + { + if (v == null) + { + setDocumentTypeId((Integer)null); + } + else + { + setDocumentTypeId(v.getId()); + } + aDocumentType = v; + } + + + /** + * Get the associated DocumentType object + * + * @return the associated DocumentType object + * @throws TorqueException + */ + public DocumentType getDocumentType() throws TorqueException + { + if (aDocumentType == null && (!ObjectUtils.equals(this.document_type_id, null))) + { + aDocumentType = DocumentTypePeer.retrieveByPK(SimpleKey.keyFor(this.document_type_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + DocumentType obj = DocumentTypePeer.retrieveByPK(this.document_type_id); + obj.addDocuments(this); + */ + } + return aDocumentType; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setDocumentTypeKey(ObjectKey key) throws TorqueException + { + + setDocumentTypeId(new Integer(((NumberKey) key).intValue())); + } + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("MemberId"); + fieldNames.add("DocumentTypeId"); + fieldNames.add("ContentType"); + fieldNames.add("Path"); + fieldNames.add("Filename"); + fieldNames.add("Label"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("MemberId")) + { + return getMemberId(); + } + if (name.equals("DocumentTypeId")) + { + return getDocumentTypeId(); + } + if (name.equals("ContentType")) + { + return getContentType(); + } + if (name.equals("Path")) + { + return getPath(); + } + if (name.equals("Filename")) + { + return getFilename(); + } + if (name.equals("Label")) + { + return getLabel(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(DocumentPeer.ID)) + { + return getId(); + } + if (name.equals(DocumentPeer.MEMBER_ID)) + { + return getMemberId(); + } + if (name.equals(DocumentPeer.DOCUMENT_TYPE_ID)) + { + return getDocumentTypeId(); + } + if (name.equals(DocumentPeer.CONTENT_TYPE)) + { + return getContentType(); + } + if (name.equals(DocumentPeer.PATH)) + { + return getPath(); + } + if (name.equals(DocumentPeer.FILENAME)) + { + return getFilename(); + } + if (name.equals(DocumentPeer.LABEL)) + { + return getLabel(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getMemberId(); + } + if (pos == 2) + { + return getDocumentTypeId(); + } + if (pos == 3) + { + return getContentType(); + } + if (pos == 4) + { + return getPath(); + } + if (pos == 5) + { + return getFilename(); + } + if (pos == 6) + { + return getLabel(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(DocumentPeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + DocumentPeer.doInsert((Document) this, con); + setNew(false); + } + else + { + DocumentPeer.doUpdate((Document) this, con); + } + } + + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public Document copy() throws TorqueException + { + return copyInto(new Document()); + } + + protected Document copyInto(Document copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setMemberId(member_id); + copyObj.setDocumentTypeId(document_type_id); + copyObj.setContentType(content_type); + copyObj.setPath(path); + copyObj.setFilename(filename); + copyObj.setLabel(label); + + copyObj.setNew(false); + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public DocumentPeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BaseDocumentPeer.java b/src/java/org/thdl/roster/om/BaseDocumentPeer.java new file mode 100755 index 0000000..70ac201 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseDocumentPeer.java @@ -0,0 +1,964 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BaseDocumentPeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "Document"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(DocumentMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the MEMBER_ID field */ + public static final String MEMBER_ID; + /** the column name for the DOCUMENT_TYPE_ID field */ + public static final String DOCUMENT_TYPE_ID; + /** the column name for the CONTENT_TYPE field */ + public static final String CONTENT_TYPE; + /** the column name for the PATH field */ + public static final String PATH; + /** the column name for the FILENAME field */ + public static final String FILENAME; + /** the column name for the LABEL field */ + public static final String LABEL; + + static + { + ID = "Document.ID"; + MEMBER_ID = "Document.MEMBER_ID"; + DOCUMENT_TYPE_ID = "Document.DOCUMENT_TYPE_ID"; + CONTENT_TYPE = "Document.CONTENT_TYPE"; + PATH = "Document.PATH"; + FILENAME = "Document.FILENAME"; + LABEL = "Document.LABEL"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(DocumentMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 7; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.Document"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BaseDocumentPeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(MEMBER_ID); + criteria.addSelectColumn(DOCUMENT_TYPE_ID); + criteria.addSelectColumn(CONTENT_TYPE); + criteria.addSelectColumn(PATH); + criteria.addSelectColumn(FILENAME); + criteria.addSelectColumn(LABEL); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Document row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + Document obj = (Document) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + Document obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setMemberId(row.getValue(offset + 1).asIntegerObj()); + obj.setDocumentTypeId(row.getValue(offset + 2).asIntegerObj()); + obj.setContentType(row.getValue(offset + 3).asString()); + obj.setPath(row.getValue(offset + 4).asString()); + obj.setFilename(row.getValue(offset + 5).asString()); + obj.setLabel(row.getValue(offset + 6).asString()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BaseDocumentPeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(DocumentPeer.row2Object(row, 1, + DocumentPeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BaseDocumentPeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BaseDocumentPeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Document obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(Document obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Document obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Document obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Document) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(Document obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(Document) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Document obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(Document) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Document obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BaseDocumentPeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( Document obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(MEMBER_ID, obj.getMemberId()); + criteria.add(DOCUMENT_TYPE_ID, obj.getDocumentTypeId()); + criteria.add(CONTENT_TYPE, obj.getContentType()); + criteria.add(PATH, obj.getPath()); + criteria.add(FILENAME, obj.getFilename()); + criteria.add(LABEL, obj.getLabel()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Document retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Document retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + Document retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Document retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (Document)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + + + /** + * selects a collection of Document objects pre-filled with their + * Member objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in DocumentPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinMember(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + DocumentPeer.addSelectColumns(c); + int offset = numColumns + 1; + MemberPeer.addSelectColumns(c); + + + c.addJoin(DocumentPeer.MEMBER_ID, + MemberPeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = DocumentPeer.getOMClass(); + + Document obj1 = (Document) DocumentPeer + .row2Object(row, 1, omClass); + + + omClass = MemberPeer.getOMClass(row, offset); + Member obj2 = (Member)MemberPeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + Document temp_obj1 = (Document)results.get(j); + Member temp_obj2 = (Member)temp_obj1.getMember(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addDocument(obj1); + break; + } + } + if (newObject) + { + obj2.initDocuments(); + obj2.addDocument(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + + /** + * selects a collection of Document objects pre-filled with their + * DocumentType objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in DocumentPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinDocumentType(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + DocumentPeer.addSelectColumns(c); + int offset = numColumns + 1; + DocumentTypePeer.addSelectColumns(c); + + + c.addJoin(DocumentPeer.DOCUMENT_TYPE_ID, + DocumentTypePeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = DocumentPeer.getOMClass(); + + Document obj1 = (Document) DocumentPeer + .row2Object(row, 1, omClass); + + + omClass = DocumentTypePeer.getOMClass(); + DocumentType obj2 = (DocumentType)DocumentTypePeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + Document temp_obj1 = (Document)results.get(j); + DocumentType temp_obj2 = (DocumentType)temp_obj1.getDocumentType(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addDocument(obj1); + break; + } + } + if (newObject) + { + obj2.initDocuments(); + obj2.addDocument(obj1); + } + results.add(obj1); + } + return results; + } + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BaseDocumentType.java b/src/java/org/thdl/roster/om/BaseDocumentType.java new file mode 100755 index 0000000..4ffbbf5 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseDocumentType.java @@ -0,0 +1,561 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to DocumentType + */ +public abstract class BaseDocumentType extends BaseObject +{ + /** The Peer class */ + private static final DocumentTypePeer peer = + new DocumentTypePeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the document_type field + */ + private String document_type; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + + // update associated Document + if (collDocuments != null) + { + for (int i = 0; i < collDocuments.size(); i++) + { + ((Document) collDocuments.get(i)) + .setDocumentTypeId(v); + } + } + } + + + /** + * Get the DocumentType + * + * @return String + */ + public String getDocumentType() + { + return document_type; + } + + + /** + * Set the value of DocumentType + * + * @param v new value + */ + public void setDocumentType(String v) + { + + + + if (!ObjectUtils.equals(this.document_type, v)) + { + this.document_type = v; + setModified(true); + } + + + } + + + + + + + /** + * Collection to store aggregation of collDocuments + */ + protected List collDocuments; + + /** + * Temporary storage of collDocuments to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initDocuments() + { + if (collDocuments == null) + { + collDocuments = new ArrayList(); + } + } + + /** + * Method called to associate a Document object to this object + * through the Document foreign key attribute + * + * @param l Document + * @throws TorqueException + */ + public void addDocument(Document l) throws TorqueException + { + getDocuments().add(l); + l.setDocumentType((DocumentType) this); + } + + /** + * The criteria used to select the current contents of collDocuments + */ + private Criteria lastDocumentsCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getDocuments(new Criteria()) + * + * @throws TorqueException + */ + public List getDocuments() throws TorqueException + { + if (collDocuments == null) + { + collDocuments = getDocuments(new Criteria(10)); + } + return collDocuments; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this DocumentType has previously + * been saved, it will retrieve related Documents from storage. + * If this DocumentType is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getDocuments(Criteria criteria) throws TorqueException + { + if (collDocuments == null) + { + if (isNew()) + { + collDocuments = new ArrayList(); + } + else + { + criteria.add(DocumentPeer.DOCUMENT_TYPE_ID, getId() ); + collDocuments = DocumentPeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(DocumentPeer.DOCUMENT_TYPE_ID, getId()); + if (!lastDocumentsCriteria.equals(criteria)) + { + collDocuments = DocumentPeer.doSelect(criteria); + } + } + } + lastDocumentsCriteria = criteria; + + return collDocuments; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getDocuments(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getDocuments(Connection con) throws TorqueException + { + if (collDocuments == null) + { + collDocuments = getDocuments(new Criteria(10), con); + } + return collDocuments; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this DocumentType has previously + * been saved, it will retrieve related Documents from storage. + * If this DocumentType is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getDocuments(Criteria criteria, Connection con) + throws TorqueException + { + if (collDocuments == null) + { + if (isNew()) + { + collDocuments = new ArrayList(); + } + else + { + criteria.add(DocumentPeer.DOCUMENT_TYPE_ID, getId()); + collDocuments = DocumentPeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(DocumentPeer.DOCUMENT_TYPE_ID, getId()); + if (!lastDocumentsCriteria.equals(criteria)) + { + collDocuments = DocumentPeer.doSelect(criteria, con); + } + } + } + lastDocumentsCriteria = criteria; + + return collDocuments; + } + + + + + + + + + + + + + + + + + + + + + + + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("DocumentType"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("DocumentType")) + { + return getDocumentType(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(DocumentTypePeer.ID)) + { + return getId(); + } + if (name.equals(DocumentTypePeer.DOCUMENT_TYPE)) + { + return getDocumentType(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getDocumentType(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(DocumentTypePeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + DocumentTypePeer.doInsert((DocumentType) this, con); + setNew(false); + } + else + { + DocumentTypePeer.doUpdate((DocumentType) this, con); + } + } + + + + if (collDocuments != null) + { + for (int i = 0; i < collDocuments.size(); i++) + { + ((Document) collDocuments.get(i)).save(con); + } + } + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + throws TorqueException + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) throws TorqueException + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public DocumentType copy() throws TorqueException + { + return copyInto(new DocumentType()); + } + + protected DocumentType copyInto(DocumentType copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setDocumentType(document_type); + + copyObj.setNew(false); + + + List v = getDocuments(); + for (int i = 0; i < v.size(); i++) + { + Document obj = (Document) v.get(i); + copyObj.addDocument(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public DocumentTypePeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BaseDocumentTypePeer.java b/src/java/org/thdl/roster/om/BaseDocumentTypePeer.java new file mode 100755 index 0000000..84c2ca0 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseDocumentTypePeer.java @@ -0,0 +1,778 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BaseDocumentTypePeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "DocumentType"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(DocumentTypeMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the DOCUMENT_TYPE field */ + public static final String DOCUMENT_TYPE; + + static + { + ID = "DocumentType.ID"; + DOCUMENT_TYPE = "DocumentType.DOCUMENT_TYPE"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(DocumentTypeMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 2; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.DocumentType"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BaseDocumentTypePeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(DOCUMENT_TYPE); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static DocumentType row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + DocumentType obj = (DocumentType) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + DocumentType obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setDocumentType(row.getValue(offset + 1).asString()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BaseDocumentTypePeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(DocumentTypePeer.row2Object(row, 1, + DocumentTypePeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BaseDocumentTypePeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BaseDocumentTypePeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(DocumentType obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(DocumentType obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(DocumentType obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(DocumentType obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(DocumentType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(DocumentType obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(DocumentType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(DocumentType obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(DocumentType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(DocumentType obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BaseDocumentTypePeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( DocumentType obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(DOCUMENT_TYPE, obj.getDocumentType()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static DocumentType retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static DocumentType retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + DocumentType retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static DocumentType retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (DocumentType)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BaseLanguage.java b/src/java/org/thdl/roster/om/BaseLanguage.java new file mode 100755 index 0000000..cd10562 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseLanguage.java @@ -0,0 +1,561 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to Language + */ +public abstract class BaseLanguage extends BaseObject +{ + /** The Peer class */ + private static final LanguagePeer peer = + new LanguagePeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the language field + */ + private String language; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + + // update associated ResearchInterestLanguage + if (collResearchInterestLanguages != null) + { + for (int i = 0; i < collResearchInterestLanguages.size(); i++) + { + ((ResearchInterestLanguage) collResearchInterestLanguages.get(i)) + .setLanguageId(v); + } + } + } + + + /** + * Get the Language + * + * @return String + */ + public String getLanguage() + { + return language; + } + + + /** + * Set the value of Language + * + * @param v new value + */ + public void setLanguage(String v) + { + + + + if (!ObjectUtils.equals(this.language, v)) + { + this.language = v; + setModified(true); + } + + + } + + + + + + + /** + * Collection to store aggregation of collResearchInterestLanguages + */ + protected List collResearchInterestLanguages; + + /** + * Temporary storage of collResearchInterestLanguages to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initResearchInterestLanguages() + { + if (collResearchInterestLanguages == null) + { + collResearchInterestLanguages = new ArrayList(); + } + } + + /** + * Method called to associate a ResearchInterestLanguage object to this object + * through the ResearchInterestLanguage foreign key attribute + * + * @param l ResearchInterestLanguage + * @throws TorqueException + */ + public void addResearchInterestLanguage(ResearchInterestLanguage l) throws TorqueException + { + getResearchInterestLanguages().add(l); + l.setLanguage((Language) this); + } + + /** + * The criteria used to select the current contents of collResearchInterestLanguages + */ + private Criteria lastResearchInterestLanguagesCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getResearchInterestLanguages(new Criteria()) + * + * @throws TorqueException + */ + public List getResearchInterestLanguages() throws TorqueException + { + if (collResearchInterestLanguages == null) + { + collResearchInterestLanguages = getResearchInterestLanguages(new Criteria(10)); + } + return collResearchInterestLanguages; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Language has previously + * been saved, it will retrieve related ResearchInterestLanguages from storage. + * If this Language is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getResearchInterestLanguages(Criteria criteria) throws TorqueException + { + if (collResearchInterestLanguages == null) + { + if (isNew()) + { + collResearchInterestLanguages = new ArrayList(); + } + else + { + criteria.add(ResearchInterestLanguagePeer.LANGUAGE_ID, getId() ); + collResearchInterestLanguages = ResearchInterestLanguagePeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ResearchInterestLanguagePeer.LANGUAGE_ID, getId()); + if (!lastResearchInterestLanguagesCriteria.equals(criteria)) + { + collResearchInterestLanguages = ResearchInterestLanguagePeer.doSelect(criteria); + } + } + } + lastResearchInterestLanguagesCriteria = criteria; + + return collResearchInterestLanguages; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getResearchInterestLanguages(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getResearchInterestLanguages(Connection con) throws TorqueException + { + if (collResearchInterestLanguages == null) + { + collResearchInterestLanguages = getResearchInterestLanguages(new Criteria(10), con); + } + return collResearchInterestLanguages; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Language has previously + * been saved, it will retrieve related ResearchInterestLanguages from storage. + * If this Language is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getResearchInterestLanguages(Criteria criteria, Connection con) + throws TorqueException + { + if (collResearchInterestLanguages == null) + { + if (isNew()) + { + collResearchInterestLanguages = new ArrayList(); + } + else + { + criteria.add(ResearchInterestLanguagePeer.LANGUAGE_ID, getId()); + collResearchInterestLanguages = ResearchInterestLanguagePeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ResearchInterestLanguagePeer.LANGUAGE_ID, getId()); + if (!lastResearchInterestLanguagesCriteria.equals(criteria)) + { + collResearchInterestLanguages = ResearchInterestLanguagePeer.doSelect(criteria, con); + } + } + } + lastResearchInterestLanguagesCriteria = criteria; + + return collResearchInterestLanguages; + } + + + + + + + + + + + + + + + + + + + + + + + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("Language"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("Language")) + { + return getLanguage(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(LanguagePeer.ID)) + { + return getId(); + } + if (name.equals(LanguagePeer.LANGUAGE)) + { + return getLanguage(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getLanguage(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(LanguagePeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + LanguagePeer.doInsert((Language) this, con); + setNew(false); + } + else + { + LanguagePeer.doUpdate((Language) this, con); + } + } + + + + if (collResearchInterestLanguages != null) + { + for (int i = 0; i < collResearchInterestLanguages.size(); i++) + { + ((ResearchInterestLanguage) collResearchInterestLanguages.get(i)).save(con); + } + } + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + throws TorqueException + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) throws TorqueException + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public Language copy() throws TorqueException + { + return copyInto(new Language()); + } + + protected Language copyInto(Language copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setLanguage(language); + + copyObj.setNew(false); + + + List v = getResearchInterestLanguages(); + for (int i = 0; i < v.size(); i++) + { + ResearchInterestLanguage obj = (ResearchInterestLanguage) v.get(i); + copyObj.addResearchInterestLanguage(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public LanguagePeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BaseLanguagePeer.java b/src/java/org/thdl/roster/om/BaseLanguagePeer.java new file mode 100755 index 0000000..dbbe50f --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseLanguagePeer.java @@ -0,0 +1,778 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BaseLanguagePeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "Language"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(LanguageMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the LANGUAGE field */ + public static final String LANGUAGE; + + static + { + ID = "Language.ID"; + LANGUAGE = "Language.LANGUAGE"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(LanguageMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 2; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.Language"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BaseLanguagePeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(LANGUAGE); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Language row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + Language obj = (Language) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + Language obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setLanguage(row.getValue(offset + 1).asString()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BaseLanguagePeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(LanguagePeer.row2Object(row, 1, + LanguagePeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BaseLanguagePeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BaseLanguagePeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Language obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(Language obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Language obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Language obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Language) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(Language obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(Language) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Language obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(Language) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Language obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BaseLanguagePeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( Language obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(LANGUAGE, obj.getLanguage()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Language retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Language retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + Language retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Language retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (Language)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BaseMember.java b/src/java/org/thdl/roster/om/BaseMember.java new file mode 100755 index 0000000..b09dbde --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseMember.java @@ -0,0 +1,1519 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + + + + + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to Member + */ +public abstract class BaseMember extends BaseObject +{ + /** The Peer class */ + private static final MemberPeer peer = + new MemberPeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the created_by field + */ + private Integer created_by; + + /** + * The value for the modified_by field + */ + private Integer modified_by; + + /** + * The value for the created_on field + */ + private Date created_on; + + /** + * The value for the modified_on field + */ + private Date modified_on; + + /** + * The value for the deleted field + */ + private String deleted; + + /** + * The value for the contact_info_id field + */ + private Integer contact_info_id; + + /** + * The value for the research_interest_id field + */ + private Integer research_interest_id; + + /** + * The value for the publication_id field + */ + private Integer publication_id; + + /** + * The value for the member_type field + */ + private String member_type; + + /** + * The value for the person_data_id field + */ + private Integer person_data_id; + + /** + * The value for the project_data_id field + */ + private Integer project_data_id; + + /** + * The value for the organization_data_id field + */ + private Integer organization_data_id; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + + // update associated Document + if (collDocuments != null) + { + for (int i = 0; i < collDocuments.size(); i++) + { + ((Document) collDocuments.get(i)) + .setMemberId(v); + } + } + } + + + /** + * Get the CreatedBy + * + * @return Integer + */ + public Integer getCreatedBy() + { + return created_by; + } + + + /** + * Set the value of CreatedBy + * + * @param v new value + */ + public void setCreatedBy(Integer v) + { + + + + if (!ObjectUtils.equals(this.created_by, v)) + { + this.created_by = v; + setModified(true); + } + + + } + + + /** + * Get the ModifiedBy + * + * @return Integer + */ + public Integer getModifiedBy() + { + return modified_by; + } + + + /** + * Set the value of ModifiedBy + * + * @param v new value + */ + public void setModifiedBy(Integer v) + { + + + + if (!ObjectUtils.equals(this.modified_by, v)) + { + this.modified_by = v; + setModified(true); + } + + + } + + + /** + * Get the CreatedOn + * + * @return Date + */ + public Date getCreatedOn() + { + return created_on; + } + + + /** + * Set the value of CreatedOn + * + * @param v new value + */ + public void setCreatedOn(Date v) + { + + + + if (!ObjectUtils.equals(this.created_on, v)) + { + this.created_on = v; + setModified(true); + } + + + } + + + /** + * Get the ModifiedOn + * + * @return Date + */ + public Date getModifiedOn() + { + return modified_on; + } + + + /** + * Set the value of ModifiedOn + * + * @param v new value + */ + public void setModifiedOn(Date v) + { + + + + if (!ObjectUtils.equals(this.modified_on, v)) + { + this.modified_on = v; + setModified(true); + } + + + } + + + /** + * Get the Deleted + * + * @return String + */ + public String getDeleted() + { + return deleted; + } + + + /** + * Set the value of Deleted + * + * @param v new value + */ + public void setDeleted(String v) + { + + + + if (!ObjectUtils.equals(this.deleted, v)) + { + this.deleted = v; + setModified(true); + } + + + } + + + /** + * Get the ContactInfoId + * + * @return Integer + */ + public Integer getContactInfoId() + { + return contact_info_id; + } + + + /** + * Set the value of ContactInfoId + * + * @param v new value + */ + public void setContactInfoId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.contact_info_id, v)) + { + this.contact_info_id = v; + setModified(true); + } + + + if (aContactInfo != null && !ObjectUtils.equals(aContactInfo.getId(), v)) + { + aContactInfo = null; + } + + } + + + /** + * Get the ResearchInterestId + * + * @return Integer + */ + public Integer getResearchInterestId() + { + return research_interest_id; + } + + + /** + * Set the value of ResearchInterestId + * + * @param v new value + */ + public void setResearchInterestId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.research_interest_id, v)) + { + this.research_interest_id = v; + setModified(true); + } + + + if (aResearchInterest != null && !ObjectUtils.equals(aResearchInterest.getId(), v)) + { + aResearchInterest = null; + } + + } + + + /** + * Get the PublicationId + * + * @return Integer + */ + public Integer getPublicationId() + { + return publication_id; + } + + + /** + * Set the value of PublicationId + * + * @param v new value + */ + public void setPublicationId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.publication_id, v)) + { + this.publication_id = v; + setModified(true); + } + + + if (aPublication != null && !ObjectUtils.equals(aPublication.getId(), v)) + { + aPublication = null; + } + + } + + + /** + * Get the MemberType + * + * @return String + */ + public String getMemberType() + { + return member_type; + } + + + /** + * Set the value of MemberType + * + * @param v new value + */ + public void setMemberType(String v) + { + + + + if (!ObjectUtils.equals(this.member_type, v)) + { + this.member_type = v; + setModified(true); + } + + + } + + + /** + * Get the PersonDataId + * + * @return Integer + */ + public Integer getPersonDataId() + { + return person_data_id; + } + + + /** + * Set the value of PersonDataId + * + * @param v new value + */ + public void setPersonDataId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.person_data_id, v)) + { + this.person_data_id = v; + setModified(true); + } + + + if (aPersonData != null && !ObjectUtils.equals(aPersonData.getId(), v)) + { + aPersonData = null; + } + + } + + + /** + * Get the ProjectDataId + * + * @return Integer + */ + public Integer getProjectDataId() + { + return project_data_id; + } + + + /** + * Set the value of ProjectDataId + * + * @param v new value + */ + public void setProjectDataId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.project_data_id, v)) + { + this.project_data_id = v; + setModified(true); + } + + + if (aProjectData != null && !ObjectUtils.equals(aProjectData.getId(), v)) + { + aProjectData = null; + } + + } + + + /** + * Get the OrganizationDataId + * + * @return Integer + */ + public Integer getOrganizationDataId() + { + return organization_data_id; + } + + + /** + * Set the value of OrganizationDataId + * + * @param v new value + */ + public void setOrganizationDataId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.organization_data_id, v)) + { + this.organization_data_id = v; + setModified(true); + } + + + if (aOrganizationData != null && !ObjectUtils.equals(aOrganizationData.getId(), v)) + { + aOrganizationData = null; + } + + } + + + + + + + + private ContactInfo aContactInfo; + + /** + * Declares an association between this object and a ContactInfo object + * + * @param v ContactInfo + * @throws TorqueException + */ + public void setContactInfo(ContactInfo v) throws TorqueException + { + if (v == null) + { + setContactInfoId((Integer)null); + } + else + { + setContactInfoId(v.getId()); + } + aContactInfo = v; + } + + + /** + * Get the associated ContactInfo object + * + * @return the associated ContactInfo object + * @throws TorqueException + */ + public ContactInfo getContactInfo() throws TorqueException + { + if (aContactInfo == null && (!ObjectUtils.equals(this.contact_info_id, null))) + { + aContactInfo = ContactInfoPeer.retrieveByPK(SimpleKey.keyFor(this.contact_info_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + ContactInfo obj = ContactInfoPeer.retrieveByPK(this.contact_info_id); + obj.addMembers(this); + */ + } + return aContactInfo; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setContactInfoKey(ObjectKey key) throws TorqueException + { + + setContactInfoId(new Integer(((NumberKey) key).intValue())); + } + + + + + private ResearchInterest aResearchInterest; + + /** + * Declares an association between this object and a ResearchInterest object + * + * @param v ResearchInterest + * @throws TorqueException + */ + public void setResearchInterest(ResearchInterest v) throws TorqueException + { + if (v == null) + { + setResearchInterestId((Integer)null); + } + else + { + setResearchInterestId(v.getId()); + } + aResearchInterest = v; + } + + + /** + * Get the associated ResearchInterest object + * + * @return the associated ResearchInterest object + * @throws TorqueException + */ + public ResearchInterest getResearchInterest() throws TorqueException + { + if (aResearchInterest == null && (!ObjectUtils.equals(this.research_interest_id, null))) + { + aResearchInterest = ResearchInterestPeer.retrieveByPK(SimpleKey.keyFor(this.research_interest_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + ResearchInterest obj = ResearchInterestPeer.retrieveByPK(this.research_interest_id); + obj.addMembers(this); + */ + } + return aResearchInterest; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setResearchInterestKey(ObjectKey key) throws TorqueException + { + + setResearchInterestId(new Integer(((NumberKey) key).intValue())); + } + + + + + private Publication aPublication; + + /** + * Declares an association between this object and a Publication object + * + * @param v Publication + * @throws TorqueException + */ + public void setPublication(Publication v) throws TorqueException + { + if (v == null) + { + setPublicationId((Integer)null); + } + else + { + setPublicationId(v.getId()); + } + aPublication = v; + } + + + /** + * Get the associated Publication object + * + * @return the associated Publication object + * @throws TorqueException + */ + public Publication getPublication() throws TorqueException + { + if (aPublication == null && (!ObjectUtils.equals(this.publication_id, null))) + { + aPublication = PublicationPeer.retrieveByPK(SimpleKey.keyFor(this.publication_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + Publication obj = PublicationPeer.retrieveByPK(this.publication_id); + obj.addMembers(this); + */ + } + return aPublication; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setPublicationKey(ObjectKey key) throws TorqueException + { + + setPublicationId(new Integer(((NumberKey) key).intValue())); + } + + + + + private PersonData aPersonData; + + /** + * Declares an association between this object and a PersonData object + * + * @param v PersonData + * @throws TorqueException + */ + public void setPersonData(PersonData v) throws TorqueException + { + if (v == null) + { + setPersonDataId((Integer)null); + } + else + { + setPersonDataId(v.getId()); + } + aPersonData = v; + } + + + /** + * Get the associated PersonData object + * + * @return the associated PersonData object + * @throws TorqueException + */ + public PersonData getPersonData() throws TorqueException + { + if (aPersonData == null && (!ObjectUtils.equals(this.person_data_id, null))) + { + aPersonData = PersonDataPeer.retrieveByPK(SimpleKey.keyFor(this.person_data_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + PersonData obj = PersonDataPeer.retrieveByPK(this.person_data_id); + obj.addMembers(this); + */ + } + return aPersonData; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setPersonDataKey(ObjectKey key) throws TorqueException + { + + setPersonDataId(new Integer(((NumberKey) key).intValue())); + } + + + + + private ProjectData aProjectData; + + /** + * Declares an association between this object and a ProjectData object + * + * @param v ProjectData + * @throws TorqueException + */ + public void setProjectData(ProjectData v) throws TorqueException + { + if (v == null) + { + setProjectDataId((Integer)null); + } + else + { + setProjectDataId(v.getId()); + } + aProjectData = v; + } + + + /** + * Get the associated ProjectData object + * + * @return the associated ProjectData object + * @throws TorqueException + */ + public ProjectData getProjectData() throws TorqueException + { + if (aProjectData == null && (!ObjectUtils.equals(this.project_data_id, null))) + { + aProjectData = ProjectDataPeer.retrieveByPK(SimpleKey.keyFor(this.project_data_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + ProjectData obj = ProjectDataPeer.retrieveByPK(this.project_data_id); + obj.addMembers(this); + */ + } + return aProjectData; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setProjectDataKey(ObjectKey key) throws TorqueException + { + + setProjectDataId(new Integer(((NumberKey) key).intValue())); + } + + + + + private OrganizationData aOrganizationData; + + /** + * Declares an association between this object and a OrganizationData object + * + * @param v OrganizationData + * @throws TorqueException + */ + public void setOrganizationData(OrganizationData v) throws TorqueException + { + if (v == null) + { + setOrganizationDataId((Integer)null); + } + else + { + setOrganizationDataId(v.getId()); + } + aOrganizationData = v; + } + + + /** + * Get the associated OrganizationData object + * + * @return the associated OrganizationData object + * @throws TorqueException + */ + public OrganizationData getOrganizationData() throws TorqueException + { + if (aOrganizationData == null && (!ObjectUtils.equals(this.organization_data_id, null))) + { + aOrganizationData = OrganizationDataPeer.retrieveByPK(SimpleKey.keyFor(this.organization_data_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + OrganizationData obj = OrganizationDataPeer.retrieveByPK(this.organization_data_id); + obj.addMembers(this); + */ + } + return aOrganizationData; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setOrganizationDataKey(ObjectKey key) throws TorqueException + { + + setOrganizationDataId(new Integer(((NumberKey) key).intValue())); + } + + + + /** + * Collection to store aggregation of collDocuments + */ + protected List collDocuments; + + /** + * Temporary storage of collDocuments to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initDocuments() + { + if (collDocuments == null) + { + collDocuments = new ArrayList(); + } + } + + /** + * Method called to associate a Document object to this object + * through the Document foreign key attribute + * + * @param l Document + * @throws TorqueException + */ + public void addDocument(Document l) throws TorqueException + { + getDocuments().add(l); + l.setMember((Member) this); + } + + /** + * The criteria used to select the current contents of collDocuments + */ + private Criteria lastDocumentsCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getDocuments(new Criteria()) + * + * @throws TorqueException + */ + public List getDocuments() throws TorqueException + { + if (collDocuments == null) + { + collDocuments = getDocuments(new Criteria(10)); + } + return collDocuments; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Member has previously + * been saved, it will retrieve related Documents from storage. + * If this Member is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getDocuments(Criteria criteria) throws TorqueException + { + if (collDocuments == null) + { + if (isNew()) + { + collDocuments = new ArrayList(); + } + else + { + criteria.add(DocumentPeer.MEMBER_ID, getId() ); + collDocuments = DocumentPeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(DocumentPeer.MEMBER_ID, getId()); + if (!lastDocumentsCriteria.equals(criteria)) + { + collDocuments = DocumentPeer.doSelect(criteria); + } + } + } + lastDocumentsCriteria = criteria; + + return collDocuments; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getDocuments(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getDocuments(Connection con) throws TorqueException + { + if (collDocuments == null) + { + collDocuments = getDocuments(new Criteria(10), con); + } + return collDocuments; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Member has previously + * been saved, it will retrieve related Documents from storage. + * If this Member is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getDocuments(Criteria criteria, Connection con) + throws TorqueException + { + if (collDocuments == null) + { + if (isNew()) + { + collDocuments = new ArrayList(); + } + else + { + criteria.add(DocumentPeer.MEMBER_ID, getId()); + collDocuments = DocumentPeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(DocumentPeer.MEMBER_ID, getId()); + if (!lastDocumentsCriteria.equals(criteria)) + { + collDocuments = DocumentPeer.doSelect(criteria, con); + } + } + } + lastDocumentsCriteria = criteria; + + return collDocuments; + } + + + + + + + + + + + + + + + + + + + + + + + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("CreatedBy"); + fieldNames.add("ModifiedBy"); + fieldNames.add("CreatedOn"); + fieldNames.add("ModifiedOn"); + fieldNames.add("Deleted"); + fieldNames.add("ContactInfoId"); + fieldNames.add("ResearchInterestId"); + fieldNames.add("PublicationId"); + fieldNames.add("MemberType"); + fieldNames.add("PersonDataId"); + fieldNames.add("ProjectDataId"); + fieldNames.add("OrganizationDataId"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("CreatedBy")) + { + return getCreatedBy(); + } + if (name.equals("ModifiedBy")) + { + return getModifiedBy(); + } + if (name.equals("CreatedOn")) + { + return getCreatedOn(); + } + if (name.equals("ModifiedOn")) + { + return getModifiedOn(); + } + if (name.equals("Deleted")) + { + return getDeleted(); + } + if (name.equals("ContactInfoId")) + { + return getContactInfoId(); + } + if (name.equals("ResearchInterestId")) + { + return getResearchInterestId(); + } + if (name.equals("PublicationId")) + { + return getPublicationId(); + } + if (name.equals("MemberType")) + { + return getMemberType(); + } + if (name.equals("PersonDataId")) + { + return getPersonDataId(); + } + if (name.equals("ProjectDataId")) + { + return getProjectDataId(); + } + if (name.equals("OrganizationDataId")) + { + return getOrganizationDataId(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(MemberPeer.ID)) + { + return getId(); + } + if (name.equals(MemberPeer.CREATED_BY)) + { + return getCreatedBy(); + } + if (name.equals(MemberPeer.MODIFIED_BY)) + { + return getModifiedBy(); + } + if (name.equals(MemberPeer.CREATED_ON)) + { + return getCreatedOn(); + } + if (name.equals(MemberPeer.MODIFIED_ON)) + { + return getModifiedOn(); + } + if (name.equals(MemberPeer.DELETED)) + { + return getDeleted(); + } + if (name.equals(MemberPeer.CONTACT_INFO_ID)) + { + return getContactInfoId(); + } + if (name.equals(MemberPeer.RESEARCH_INTEREST_ID)) + { + return getResearchInterestId(); + } + if (name.equals(MemberPeer.PUBLICATION_ID)) + { + return getPublicationId(); + } + if (name.equals(MemberPeer.MEMBER_TYPE)) + { + return getMemberType(); + } + if (name.equals(MemberPeer.PERSON_DATA_ID)) + { + return getPersonDataId(); + } + if (name.equals(MemberPeer.PROJECT_DATA_ID)) + { + return getProjectDataId(); + } + if (name.equals(MemberPeer.ORGANIZATION_DATA_ID)) + { + return getOrganizationDataId(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getCreatedBy(); + } + if (pos == 2) + { + return getModifiedBy(); + } + if (pos == 3) + { + return getCreatedOn(); + } + if (pos == 4) + { + return getModifiedOn(); + } + if (pos == 5) + { + return getDeleted(); + } + if (pos == 6) + { + return getContactInfoId(); + } + if (pos == 7) + { + return getResearchInterestId(); + } + if (pos == 8) + { + return getPublicationId(); + } + if (pos == 9) + { + return getMemberType(); + } + if (pos == 10) + { + return getPersonDataId(); + } + if (pos == 11) + { + return getProjectDataId(); + } + if (pos == 12) + { + return getOrganizationDataId(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(MemberPeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + MemberPeer.doInsert((Member) this, con); + setNew(false); + } + else + { + MemberPeer.doUpdate((Member) this, con); + } + } + + + + if (collDocuments != null) + { + for (int i = 0; i < collDocuments.size(); i++) + { + ((Document) collDocuments.get(i)).save(con); + } + } + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + throws TorqueException + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) throws TorqueException + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public Member copy() throws TorqueException + { + return copyInto(new Member()); + } + + protected Member copyInto(Member copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setCreatedBy(created_by); + copyObj.setModifiedBy(modified_by); + copyObj.setCreatedOn(created_on); + copyObj.setModifiedOn(modified_on); + copyObj.setDeleted(deleted); + copyObj.setContactInfoId(contact_info_id); + copyObj.setResearchInterestId(research_interest_id); + copyObj.setPublicationId(publication_id); + copyObj.setMemberType(member_type); + copyObj.setPersonDataId(person_data_id); + copyObj.setProjectDataId(project_data_id); + copyObj.setOrganizationDataId(organization_data_id); + + copyObj.setNew(false); + + + List v = getDocuments(); + for (int i = 0; i < v.size(); i++) + { + Document obj = (Document) v.get(i); + copyObj.addDocument(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public MemberPeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BaseMemberPeer.java b/src/java/org/thdl/roster/om/BaseMemberPeer.java new file mode 100755 index 0000000..ed8407a --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseMemberPeer.java @@ -0,0 +1,2533 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + + + + + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BaseMemberPeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "Member"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(MemberMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the CREATED_BY field */ + public static final String CREATED_BY; + /** the column name for the MODIFIED_BY field */ + public static final String MODIFIED_BY; + /** the column name for the CREATED_ON field */ + public static final String CREATED_ON; + /** the column name for the MODIFIED_ON field */ + public static final String MODIFIED_ON; + /** the column name for the DELETED field */ + public static final String DELETED; + /** the column name for the CONTACT_INFO_ID field */ + public static final String CONTACT_INFO_ID; + /** the column name for the RESEARCH_INTEREST_ID field */ + public static final String RESEARCH_INTEREST_ID; + /** the column name for the PUBLICATION_ID field */ + public static final String PUBLICATION_ID; + /** the column name for the MEMBER_TYPE field */ + public static final String MEMBER_TYPE; + /** the column name for the PERSON_DATA_ID field */ + public static final String PERSON_DATA_ID; + /** the column name for the PROJECT_DATA_ID field */ + public static final String PROJECT_DATA_ID; + /** the column name for the ORGANIZATION_DATA_ID field */ + public static final String ORGANIZATION_DATA_ID; + + static + { + ID = "Member.ID"; + CREATED_BY = "Member.CREATED_BY"; + MODIFIED_BY = "Member.MODIFIED_BY"; + CREATED_ON = "Member.CREATED_ON"; + MODIFIED_ON = "Member.MODIFIED_ON"; + DELETED = "Member.DELETED"; + CONTACT_INFO_ID = "Member.CONTACT_INFO_ID"; + RESEARCH_INTEREST_ID = "Member.RESEARCH_INTEREST_ID"; + PUBLICATION_ID = "Member.PUBLICATION_ID"; + MEMBER_TYPE = "Member.MEMBER_TYPE"; + PERSON_DATA_ID = "Member.PERSON_DATA_ID"; + PROJECT_DATA_ID = "Member.PROJECT_DATA_ID"; + ORGANIZATION_DATA_ID = "Member.ORGANIZATION_DATA_ID"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(MemberMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 13; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.Member"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + + + /** A key representing a particular subclass */ + public static final String CLASSKEY_PERSON = + "person"; + + /** A class that can be returned by this peer. */ + public static final String CLASSNAME_PERSON = + "org.thdl.roster.om.Person"; + + /** A class that can be returned by this peer. */ + public static final Class CLASS_PERSON = + initClass(CLASSNAME_PERSON); + /** A key representing a particular subclass */ + public static final String CLASSKEY_PROJECT = + "project"; + + /** A class that can be returned by this peer. */ + public static final String CLASSNAME_PROJECT = + "org.thdl.roster.om.Project"; + + /** A class that can be returned by this peer. */ + public static final Class CLASS_PROJECT = + initClass(CLASSNAME_PROJECT); + /** A key representing a particular subclass */ + public static final String CLASSKEY_ORGANIZATION = + "organization"; + + /** A class that can be returned by this peer. */ + public static final String CLASSNAME_ORGANIZATION = + "org.thdl.roster.om.Organization"; + + /** A class that can be returned by this peer. */ + public static final Class CLASS_ORGANIZATION = + initClass(CLASSNAME_ORGANIZATION); + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BaseMemberPeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(CREATED_BY); + criteria.addSelectColumn(MODIFIED_BY); + criteria.addSelectColumn(CREATED_ON); + criteria.addSelectColumn(MODIFIED_ON); + criteria.addSelectColumn(DELETED); + criteria.addSelectColumn(CONTACT_INFO_ID); + criteria.addSelectColumn(RESEARCH_INTEREST_ID); + criteria.addSelectColumn(PUBLICATION_ID); + criteria.addSelectColumn(MEMBER_TYPE); + criteria.addSelectColumn(PERSON_DATA_ID); + criteria.addSelectColumn(PROJECT_DATA_ID); + criteria.addSelectColumn(ORGANIZATION_DATA_ID); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Member row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + Member obj = (Member) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + Member obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setCreatedBy(row.getValue(offset + 1).asIntegerObj()); + obj.setModifiedBy(row.getValue(offset + 2).asIntegerObj()); + obj.setCreatedOn(row.getValue(offset + 3).asUtilDate()); + obj.setModifiedOn(row.getValue(offset + 4).asUtilDate()); + obj.setDeleted(row.getValue(offset + 5).asString()); + obj.setContactInfoId(row.getValue(offset + 6).asIntegerObj()); + obj.setResearchInterestId(row.getValue(offset + 7).asIntegerObj()); + obj.setPublicationId(row.getValue(offset + 8).asIntegerObj()); + obj.setMemberType(row.getValue(offset + 9).asString()); + obj.setPersonDataId(row.getValue(offset + 10).asIntegerObj()); + obj.setProjectDataId(row.getValue(offset + 11).asIntegerObj()); + obj.setOrganizationDataId(row.getValue(offset + 12).asIntegerObj()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BaseMemberPeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(MemberPeer.row2Object(row, 1, + MemberPeer.getOMClass(row, 1))); + } + return results; + } + + + /** + * The returned Class will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass(Record record, int offset) + throws TorqueException + { + Class c = null; + try + { + Class omClass = null; + String classKey = + record.getValue(offset - 1 + 10) + .asString(); + if (CLASSKEY_PERSON.equals(classKey)) + { + omClass = CLASS_PERSON; + } + else if (CLASSKEY_PROJECT.equals(classKey)) + { + omClass = CLASS_PROJECT; + } + else if (CLASSKEY_ORGANIZATION.equals(classKey)) + { + omClass = CLASS_ORGANIZATION; + } + else + { + omClass = getOMClass(); + } + c = omClass; + } + catch (Exception e) + { + throw new TorqueException(e); + } + return c; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BaseMemberPeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BaseMemberPeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Member obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(Member obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Member obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Member obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Member) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(Member obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(Member) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Member obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(Member) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Member obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BaseMemberPeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( Member obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(CREATED_BY, obj.getCreatedBy()); + criteria.add(MODIFIED_BY, obj.getModifiedBy()); + criteria.add(CREATED_ON, obj.getCreatedOn()); + criteria.add(MODIFIED_ON, obj.getModifiedOn()); + criteria.add(DELETED, obj.getDeleted()); + criteria.add(CONTACT_INFO_ID, obj.getContactInfoId()); + criteria.add(RESEARCH_INTEREST_ID, obj.getResearchInterestId()); + criteria.add(PUBLICATION_ID, obj.getPublicationId()); + criteria.add(MEMBER_TYPE, obj.getMemberType()); + criteria.add(PERSON_DATA_ID, obj.getPersonDataId()); + criteria.add(PROJECT_DATA_ID, obj.getProjectDataId()); + criteria.add(ORGANIZATION_DATA_ID, obj.getOrganizationDataId()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Member retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Member retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + Member retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Member retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (Member)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + + + /** + * selects a collection of Member objects pre-filled with their + * ContactInfo objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in MemberPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinContactInfo(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + MemberPeer.addSelectColumns(c); + int offset = numColumns + 1; + ContactInfoPeer.addSelectColumns(c); + + + c.addJoin(MemberPeer.CONTACT_INFO_ID, + ContactInfoPeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = MemberPeer.getOMClass(row, 1); + + Member obj1 = (Member) MemberPeer + .row2Object(row, 1, omClass); + + + omClass = ContactInfoPeer.getOMClass(); + ContactInfo obj2 = (ContactInfo)ContactInfoPeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + ContactInfo temp_obj2 = (ContactInfo)temp_obj1.getContactInfo(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addMember(obj1); + break; + } + } + if (newObject) + { + obj2.initMembers(); + obj2.addMember(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + + /** + * selects a collection of Member objects pre-filled with their + * ResearchInterest objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in MemberPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinResearchInterest(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + MemberPeer.addSelectColumns(c); + int offset = numColumns + 1; + ResearchInterestPeer.addSelectColumns(c); + + + c.addJoin(MemberPeer.RESEARCH_INTEREST_ID, + ResearchInterestPeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = MemberPeer.getOMClass(row, 1); + + Member obj1 = (Member) MemberPeer + .row2Object(row, 1, omClass); + + + omClass = ResearchInterestPeer.getOMClass(); + ResearchInterest obj2 = (ResearchInterest)ResearchInterestPeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + ResearchInterest temp_obj2 = (ResearchInterest)temp_obj1.getResearchInterest(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addMember(obj1); + break; + } + } + if (newObject) + { + obj2.initMembers(); + obj2.addMember(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + + /** + * selects a collection of Member objects pre-filled with their + * Publication objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in MemberPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinPublication(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + MemberPeer.addSelectColumns(c); + int offset = numColumns + 1; + PublicationPeer.addSelectColumns(c); + + + c.addJoin(MemberPeer.PUBLICATION_ID, + PublicationPeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = MemberPeer.getOMClass(row, 1); + + Member obj1 = (Member) MemberPeer + .row2Object(row, 1, omClass); + + + omClass = PublicationPeer.getOMClass(); + Publication obj2 = (Publication)PublicationPeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + Publication temp_obj2 = (Publication)temp_obj1.getPublication(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addMember(obj1); + break; + } + } + if (newObject) + { + obj2.initMembers(); + obj2.addMember(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + + /** + * selects a collection of Member objects pre-filled with their + * PersonData objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in MemberPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinPersonData(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + MemberPeer.addSelectColumns(c); + int offset = numColumns + 1; + PersonDataPeer.addSelectColumns(c); + + + c.addJoin(MemberPeer.PERSON_DATA_ID, + PersonDataPeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = MemberPeer.getOMClass(row, 1); + + Member obj1 = (Member) MemberPeer + .row2Object(row, 1, omClass); + + + omClass = PersonDataPeer.getOMClass(); + PersonData obj2 = (PersonData)PersonDataPeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + PersonData temp_obj2 = (PersonData)temp_obj1.getPersonData(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addMember(obj1); + break; + } + } + if (newObject) + { + obj2.initMembers(); + obj2.addMember(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + + /** + * selects a collection of Member objects pre-filled with their + * ProjectData objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in MemberPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinProjectData(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + MemberPeer.addSelectColumns(c); + int offset = numColumns + 1; + ProjectDataPeer.addSelectColumns(c); + + + c.addJoin(MemberPeer.PROJECT_DATA_ID, + ProjectDataPeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = MemberPeer.getOMClass(row, 1); + + Member obj1 = (Member) MemberPeer + .row2Object(row, 1, omClass); + + + omClass = ProjectDataPeer.getOMClass(); + ProjectData obj2 = (ProjectData)ProjectDataPeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + ProjectData temp_obj2 = (ProjectData)temp_obj1.getProjectData(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addMember(obj1); + break; + } + } + if (newObject) + { + obj2.initMembers(); + obj2.addMember(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + + /** + * selects a collection of Member objects pre-filled with their + * OrganizationData objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in MemberPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinOrganizationData(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + MemberPeer.addSelectColumns(c); + int offset = numColumns + 1; + OrganizationDataPeer.addSelectColumns(c); + + + c.addJoin(MemberPeer.ORGANIZATION_DATA_ID, + OrganizationDataPeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = MemberPeer.getOMClass(row, 1); + + Member obj1 = (Member) MemberPeer + .row2Object(row, 1, omClass); + + + omClass = OrganizationDataPeer.getOMClass(); + OrganizationData obj2 = (OrganizationData)OrganizationDataPeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + OrganizationData temp_obj2 = (OrganizationData)temp_obj1.getOrganizationData(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addMember(obj1); + break; + } + } + if (newObject) + { + obj2.initMembers(); + obj2.addMember(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + + + + + /** + * selects a collection of Member objects pre-filled with + * all related objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in MemberPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinAllExceptContactInfo(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to another value + // so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + addSelectColumns(c); + int offset2 = numColumns + 1; + + + ResearchInterestPeer.addSelectColumns(c); + int offset3 = offset2 + ResearchInterestPeer.numColumns; + + PublicationPeer.addSelectColumns(c); + int offset4 = offset3 + PublicationPeer.numColumns; + + PersonDataPeer.addSelectColumns(c); + int offset5 = offset4 + PersonDataPeer.numColumns; + + ProjectDataPeer.addSelectColumns(c); + int offset6 = offset5 + ProjectDataPeer.numColumns; + + OrganizationDataPeer.addSelectColumns(c); + int offset7 = offset6 + OrganizationDataPeer.numColumns; + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record)rows.get(i); + + Class omClass = MemberPeer.getOMClass(row, 1); + + Member obj1 = (Member)MemberPeer + .row2Object(row, 1, omClass); + + + + + + + + omClass = ResearchInterestPeer.getOMClass(); + ResearchInterest obj2 = (ResearchInterest)ResearchInterestPeer + .row2Object( row, offset2, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + ResearchInterest temp_obj2 = (ResearchInterest)temp_obj1.getResearchInterest(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addMember(obj1); + break; + } + } + if (newObject) + { + obj2.initMembers(); + obj2.addMember(obj1); + } + + + + + omClass = PublicationPeer.getOMClass(); + Publication obj3 = (Publication)PublicationPeer + .row2Object( row, offset3, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + Publication temp_obj3 = (Publication)temp_obj1.getPublication(); + if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) + { + newObject = false; + temp_obj3.addMember(obj1); + break; + } + } + if (newObject) + { + obj3.initMembers(); + obj3.addMember(obj1); + } + + + + + omClass = PersonDataPeer.getOMClass(); + PersonData obj4 = (PersonData)PersonDataPeer + .row2Object( row, offset4, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + PersonData temp_obj4 = (PersonData)temp_obj1.getPersonData(); + if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) + { + newObject = false; + temp_obj4.addMember(obj1); + break; + } + } + if (newObject) + { + obj4.initMembers(); + obj4.addMember(obj1); + } + + + + + omClass = ProjectDataPeer.getOMClass(); + ProjectData obj5 = (ProjectData)ProjectDataPeer + .row2Object( row, offset5, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + ProjectData temp_obj5 = (ProjectData)temp_obj1.getProjectData(); + if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) + { + newObject = false; + temp_obj5.addMember(obj1); + break; + } + } + if (newObject) + { + obj5.initMembers(); + obj5.addMember(obj1); + } + + + + + omClass = OrganizationDataPeer.getOMClass(); + OrganizationData obj6 = (OrganizationData)OrganizationDataPeer + .row2Object( row, offset6, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + OrganizationData temp_obj6 = (OrganizationData)temp_obj1.getOrganizationData(); + if (temp_obj6.getPrimaryKey().equals(obj6.getPrimaryKey())) + { + newObject = false; + temp_obj6.addMember(obj1); + break; + } + } + if (newObject) + { + obj6.initMembers(); + obj6.addMember(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + /** + * selects a collection of Member objects pre-filled with + * all related objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in MemberPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinAllExceptResearchInterest(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to another value + // so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + addSelectColumns(c); + int offset2 = numColumns + 1; + + ContactInfoPeer.addSelectColumns(c); + int offset3 = offset2 + ContactInfoPeer.numColumns; + + + PublicationPeer.addSelectColumns(c); + int offset4 = offset3 + PublicationPeer.numColumns; + + PersonDataPeer.addSelectColumns(c); + int offset5 = offset4 + PersonDataPeer.numColumns; + + ProjectDataPeer.addSelectColumns(c); + int offset6 = offset5 + ProjectDataPeer.numColumns; + + OrganizationDataPeer.addSelectColumns(c); + int offset7 = offset6 + OrganizationDataPeer.numColumns; + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record)rows.get(i); + + Class omClass = MemberPeer.getOMClass(row, 1); + + Member obj1 = (Member)MemberPeer + .row2Object(row, 1, omClass); + + + + + + + omClass = ContactInfoPeer.getOMClass(); + ContactInfo obj2 = (ContactInfo)ContactInfoPeer + .row2Object( row, offset2, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + ContactInfo temp_obj2 = (ContactInfo)temp_obj1.getContactInfo(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addMember(obj1); + break; + } + } + if (newObject) + { + obj2.initMembers(); + obj2.addMember(obj1); + } + + + + + + omClass = PublicationPeer.getOMClass(); + Publication obj3 = (Publication)PublicationPeer + .row2Object( row, offset3, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + Publication temp_obj3 = (Publication)temp_obj1.getPublication(); + if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) + { + newObject = false; + temp_obj3.addMember(obj1); + break; + } + } + if (newObject) + { + obj3.initMembers(); + obj3.addMember(obj1); + } + + + + + omClass = PersonDataPeer.getOMClass(); + PersonData obj4 = (PersonData)PersonDataPeer + .row2Object( row, offset4, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + PersonData temp_obj4 = (PersonData)temp_obj1.getPersonData(); + if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) + { + newObject = false; + temp_obj4.addMember(obj1); + break; + } + } + if (newObject) + { + obj4.initMembers(); + obj4.addMember(obj1); + } + + + + + omClass = ProjectDataPeer.getOMClass(); + ProjectData obj5 = (ProjectData)ProjectDataPeer + .row2Object( row, offset5, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + ProjectData temp_obj5 = (ProjectData)temp_obj1.getProjectData(); + if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) + { + newObject = false; + temp_obj5.addMember(obj1); + break; + } + } + if (newObject) + { + obj5.initMembers(); + obj5.addMember(obj1); + } + + + + + omClass = OrganizationDataPeer.getOMClass(); + OrganizationData obj6 = (OrganizationData)OrganizationDataPeer + .row2Object( row, offset6, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + OrganizationData temp_obj6 = (OrganizationData)temp_obj1.getOrganizationData(); + if (temp_obj6.getPrimaryKey().equals(obj6.getPrimaryKey())) + { + newObject = false; + temp_obj6.addMember(obj1); + break; + } + } + if (newObject) + { + obj6.initMembers(); + obj6.addMember(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + /** + * selects a collection of Member objects pre-filled with + * all related objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in MemberPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinAllExceptPublication(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to another value + // so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + addSelectColumns(c); + int offset2 = numColumns + 1; + + ContactInfoPeer.addSelectColumns(c); + int offset3 = offset2 + ContactInfoPeer.numColumns; + + ResearchInterestPeer.addSelectColumns(c); + int offset4 = offset3 + ResearchInterestPeer.numColumns; + + + PersonDataPeer.addSelectColumns(c); + int offset5 = offset4 + PersonDataPeer.numColumns; + + ProjectDataPeer.addSelectColumns(c); + int offset6 = offset5 + ProjectDataPeer.numColumns; + + OrganizationDataPeer.addSelectColumns(c); + int offset7 = offset6 + OrganizationDataPeer.numColumns; + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record)rows.get(i); + + Class omClass = MemberPeer.getOMClass(row, 1); + + Member obj1 = (Member)MemberPeer + .row2Object(row, 1, omClass); + + + + + + + omClass = ContactInfoPeer.getOMClass(); + ContactInfo obj2 = (ContactInfo)ContactInfoPeer + .row2Object( row, offset2, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + ContactInfo temp_obj2 = (ContactInfo)temp_obj1.getContactInfo(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addMember(obj1); + break; + } + } + if (newObject) + { + obj2.initMembers(); + obj2.addMember(obj1); + } + + + + + omClass = ResearchInterestPeer.getOMClass(); + ResearchInterest obj3 = (ResearchInterest)ResearchInterestPeer + .row2Object( row, offset3, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + ResearchInterest temp_obj3 = (ResearchInterest)temp_obj1.getResearchInterest(); + if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) + { + newObject = false; + temp_obj3.addMember(obj1); + break; + } + } + if (newObject) + { + obj3.initMembers(); + obj3.addMember(obj1); + } + + + + + + omClass = PersonDataPeer.getOMClass(); + PersonData obj4 = (PersonData)PersonDataPeer + .row2Object( row, offset4, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + PersonData temp_obj4 = (PersonData)temp_obj1.getPersonData(); + if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) + { + newObject = false; + temp_obj4.addMember(obj1); + break; + } + } + if (newObject) + { + obj4.initMembers(); + obj4.addMember(obj1); + } + + + + + omClass = ProjectDataPeer.getOMClass(); + ProjectData obj5 = (ProjectData)ProjectDataPeer + .row2Object( row, offset5, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + ProjectData temp_obj5 = (ProjectData)temp_obj1.getProjectData(); + if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) + { + newObject = false; + temp_obj5.addMember(obj1); + break; + } + } + if (newObject) + { + obj5.initMembers(); + obj5.addMember(obj1); + } + + + + + omClass = OrganizationDataPeer.getOMClass(); + OrganizationData obj6 = (OrganizationData)OrganizationDataPeer + .row2Object( row, offset6, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + OrganizationData temp_obj6 = (OrganizationData)temp_obj1.getOrganizationData(); + if (temp_obj6.getPrimaryKey().equals(obj6.getPrimaryKey())) + { + newObject = false; + temp_obj6.addMember(obj1); + break; + } + } + if (newObject) + { + obj6.initMembers(); + obj6.addMember(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + /** + * selects a collection of Member objects pre-filled with + * all related objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in MemberPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinAllExceptPersonData(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to another value + // so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + addSelectColumns(c); + int offset2 = numColumns + 1; + + ContactInfoPeer.addSelectColumns(c); + int offset3 = offset2 + ContactInfoPeer.numColumns; + + ResearchInterestPeer.addSelectColumns(c); + int offset4 = offset3 + ResearchInterestPeer.numColumns; + + PublicationPeer.addSelectColumns(c); + int offset5 = offset4 + PublicationPeer.numColumns; + + + ProjectDataPeer.addSelectColumns(c); + int offset6 = offset5 + ProjectDataPeer.numColumns; + + OrganizationDataPeer.addSelectColumns(c); + int offset7 = offset6 + OrganizationDataPeer.numColumns; + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record)rows.get(i); + + Class omClass = MemberPeer.getOMClass(row, 1); + + Member obj1 = (Member)MemberPeer + .row2Object(row, 1, omClass); + + + + + + + omClass = ContactInfoPeer.getOMClass(); + ContactInfo obj2 = (ContactInfo)ContactInfoPeer + .row2Object( row, offset2, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + ContactInfo temp_obj2 = (ContactInfo)temp_obj1.getContactInfo(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addMember(obj1); + break; + } + } + if (newObject) + { + obj2.initMembers(); + obj2.addMember(obj1); + } + + + + + omClass = ResearchInterestPeer.getOMClass(); + ResearchInterest obj3 = (ResearchInterest)ResearchInterestPeer + .row2Object( row, offset3, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + ResearchInterest temp_obj3 = (ResearchInterest)temp_obj1.getResearchInterest(); + if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) + { + newObject = false; + temp_obj3.addMember(obj1); + break; + } + } + if (newObject) + { + obj3.initMembers(); + obj3.addMember(obj1); + } + + + + + omClass = PublicationPeer.getOMClass(); + Publication obj4 = (Publication)PublicationPeer + .row2Object( row, offset4, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + Publication temp_obj4 = (Publication)temp_obj1.getPublication(); + if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) + { + newObject = false; + temp_obj4.addMember(obj1); + break; + } + } + if (newObject) + { + obj4.initMembers(); + obj4.addMember(obj1); + } + + + + + + omClass = ProjectDataPeer.getOMClass(); + ProjectData obj5 = (ProjectData)ProjectDataPeer + .row2Object( row, offset5, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + ProjectData temp_obj5 = (ProjectData)temp_obj1.getProjectData(); + if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) + { + newObject = false; + temp_obj5.addMember(obj1); + break; + } + } + if (newObject) + { + obj5.initMembers(); + obj5.addMember(obj1); + } + + + + + omClass = OrganizationDataPeer.getOMClass(); + OrganizationData obj6 = (OrganizationData)OrganizationDataPeer + .row2Object( row, offset6, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + OrganizationData temp_obj6 = (OrganizationData)temp_obj1.getOrganizationData(); + if (temp_obj6.getPrimaryKey().equals(obj6.getPrimaryKey())) + { + newObject = false; + temp_obj6.addMember(obj1); + break; + } + } + if (newObject) + { + obj6.initMembers(); + obj6.addMember(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + /** + * selects a collection of Member objects pre-filled with + * all related objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in MemberPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinAllExceptProjectData(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to another value + // so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + addSelectColumns(c); + int offset2 = numColumns + 1; + + ContactInfoPeer.addSelectColumns(c); + int offset3 = offset2 + ContactInfoPeer.numColumns; + + ResearchInterestPeer.addSelectColumns(c); + int offset4 = offset3 + ResearchInterestPeer.numColumns; + + PublicationPeer.addSelectColumns(c); + int offset5 = offset4 + PublicationPeer.numColumns; + + PersonDataPeer.addSelectColumns(c); + int offset6 = offset5 + PersonDataPeer.numColumns; + + + OrganizationDataPeer.addSelectColumns(c); + int offset7 = offset6 + OrganizationDataPeer.numColumns; + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record)rows.get(i); + + Class omClass = MemberPeer.getOMClass(row, 1); + + Member obj1 = (Member)MemberPeer + .row2Object(row, 1, omClass); + + + + + + + omClass = ContactInfoPeer.getOMClass(); + ContactInfo obj2 = (ContactInfo)ContactInfoPeer + .row2Object( row, offset2, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + ContactInfo temp_obj2 = (ContactInfo)temp_obj1.getContactInfo(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addMember(obj1); + break; + } + } + if (newObject) + { + obj2.initMembers(); + obj2.addMember(obj1); + } + + + + + omClass = ResearchInterestPeer.getOMClass(); + ResearchInterest obj3 = (ResearchInterest)ResearchInterestPeer + .row2Object( row, offset3, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + ResearchInterest temp_obj3 = (ResearchInterest)temp_obj1.getResearchInterest(); + if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) + { + newObject = false; + temp_obj3.addMember(obj1); + break; + } + } + if (newObject) + { + obj3.initMembers(); + obj3.addMember(obj1); + } + + + + + omClass = PublicationPeer.getOMClass(); + Publication obj4 = (Publication)PublicationPeer + .row2Object( row, offset4, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + Publication temp_obj4 = (Publication)temp_obj1.getPublication(); + if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) + { + newObject = false; + temp_obj4.addMember(obj1); + break; + } + } + if (newObject) + { + obj4.initMembers(); + obj4.addMember(obj1); + } + + + + + omClass = PersonDataPeer.getOMClass(); + PersonData obj5 = (PersonData)PersonDataPeer + .row2Object( row, offset5, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + PersonData temp_obj5 = (PersonData)temp_obj1.getPersonData(); + if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) + { + newObject = false; + temp_obj5.addMember(obj1); + break; + } + } + if (newObject) + { + obj5.initMembers(); + obj5.addMember(obj1); + } + + + + + + omClass = OrganizationDataPeer.getOMClass(); + OrganizationData obj6 = (OrganizationData)OrganizationDataPeer + .row2Object( row, offset6, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + OrganizationData temp_obj6 = (OrganizationData)temp_obj1.getOrganizationData(); + if (temp_obj6.getPrimaryKey().equals(obj6.getPrimaryKey())) + { + newObject = false; + temp_obj6.addMember(obj1); + break; + } + } + if (newObject) + { + obj6.initMembers(); + obj6.addMember(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + /** + * selects a collection of Member objects pre-filled with + * all related objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in MemberPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinAllExceptOrganizationData(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to another value + // so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + addSelectColumns(c); + int offset2 = numColumns + 1; + + ContactInfoPeer.addSelectColumns(c); + int offset3 = offset2 + ContactInfoPeer.numColumns; + + ResearchInterestPeer.addSelectColumns(c); + int offset4 = offset3 + ResearchInterestPeer.numColumns; + + PublicationPeer.addSelectColumns(c); + int offset5 = offset4 + PublicationPeer.numColumns; + + PersonDataPeer.addSelectColumns(c); + int offset6 = offset5 + PersonDataPeer.numColumns; + + ProjectDataPeer.addSelectColumns(c); + int offset7 = offset6 + ProjectDataPeer.numColumns; + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record)rows.get(i); + + Class omClass = MemberPeer.getOMClass(row, 1); + + Member obj1 = (Member)MemberPeer + .row2Object(row, 1, omClass); + + + + + + + omClass = ContactInfoPeer.getOMClass(); + ContactInfo obj2 = (ContactInfo)ContactInfoPeer + .row2Object( row, offset2, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + ContactInfo temp_obj2 = (ContactInfo)temp_obj1.getContactInfo(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addMember(obj1); + break; + } + } + if (newObject) + { + obj2.initMembers(); + obj2.addMember(obj1); + } + + + + + omClass = ResearchInterestPeer.getOMClass(); + ResearchInterest obj3 = (ResearchInterest)ResearchInterestPeer + .row2Object( row, offset3, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + ResearchInterest temp_obj3 = (ResearchInterest)temp_obj1.getResearchInterest(); + if (temp_obj3.getPrimaryKey().equals(obj3.getPrimaryKey())) + { + newObject = false; + temp_obj3.addMember(obj1); + break; + } + } + if (newObject) + { + obj3.initMembers(); + obj3.addMember(obj1); + } + + + + + omClass = PublicationPeer.getOMClass(); + Publication obj4 = (Publication)PublicationPeer + .row2Object( row, offset4, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + Publication temp_obj4 = (Publication)temp_obj1.getPublication(); + if (temp_obj4.getPrimaryKey().equals(obj4.getPrimaryKey())) + { + newObject = false; + temp_obj4.addMember(obj1); + break; + } + } + if (newObject) + { + obj4.initMembers(); + obj4.addMember(obj1); + } + + + + + omClass = PersonDataPeer.getOMClass(); + PersonData obj5 = (PersonData)PersonDataPeer + .row2Object( row, offset5, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + PersonData temp_obj5 = (PersonData)temp_obj1.getPersonData(); + if (temp_obj5.getPrimaryKey().equals(obj5.getPrimaryKey())) + { + newObject = false; + temp_obj5.addMember(obj1); + break; + } + } + if (newObject) + { + obj5.initMembers(); + obj5.addMember(obj1); + } + + + + + omClass = ProjectDataPeer.getOMClass(); + ProjectData obj6 = (ProjectData)ProjectDataPeer + .row2Object( row, offset6, omClass); + + newObject = true; + for (int j = 0; j < results.size(); j++) + { + Member temp_obj1 = (Member)results.get(j); + ProjectData temp_obj6 = (ProjectData)temp_obj1.getProjectData(); + if (temp_obj6.getPrimaryKey().equals(obj6.getPrimaryKey())) + { + newObject = false; + temp_obj6.addMember(obj1); + break; + } + } + if (newObject) + { + obj6.initMembers(); + obj6.addMember(obj1); + } + + results.add(obj1); + } + return results; + } + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BaseOrganizationData.java b/src/java/org/thdl/roster/om/BaseOrganizationData.java new file mode 100755 index 0000000..a057dc5 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseOrganizationData.java @@ -0,0 +1,1206 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to OrganizationData + */ +public abstract class BaseOrganizationData extends BaseObject +{ + /** The Peer class */ + private static final OrganizationDataPeer peer = + new OrganizationDataPeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the name field + */ + private String name; + + /** + * The value for the parent_organization field + */ + private String parent_organization; + + /** + * The value for the divisions field + */ + private String divisions; + + /** + * The value for the people field + */ + private String people; + + /** + * The value for the mailing_list field + */ + private String mailing_list; + + /** + * The value for the description field + */ + private String description; + + /** + * The value for the history field + */ + private String history; + + /** + * The value for the education_programs field + */ + private String education_programs; + + /** + * The value for the resources field + */ + private String resources; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + + // update associated Member + if (collMembers != null) + { + for (int i = 0; i < collMembers.size(); i++) + { + ((Member) collMembers.get(i)) + .setOrganizationDataId(v); + } + } + + // update associated OrganizationOrganizationType + if (collOrganizationOrganizationTypes != null) + { + for (int i = 0; i < collOrganizationOrganizationTypes.size(); i++) + { + ((OrganizationOrganizationType) collOrganizationOrganizationTypes.get(i)) + .setOrganizationDataId(v); + } + } + } + + + /** + * Get the Name + * + * @return String + */ + public String getName() + { + return name; + } + + + /** + * Set the value of Name + * + * @param v new value + */ + public void setName(String v) + { + + + + if (!ObjectUtils.equals(this.name, v)) + { + this.name = v; + setModified(true); + } + + + } + + + /** + * Get the ParentOrganization + * + * @return String + */ + public String getParentOrganization() + { + return parent_organization; + } + + + /** + * Set the value of ParentOrganization + * + * @param v new value + */ + public void setParentOrganization(String v) + { + + + + if (!ObjectUtils.equals(this.parent_organization, v)) + { + this.parent_organization = v; + setModified(true); + } + + + } + + + /** + * Get the Divisions + * + * @return String + */ + public String getDivisions() + { + return divisions; + } + + + /** + * Set the value of Divisions + * + * @param v new value + */ + public void setDivisions(String v) + { + + + + if (!ObjectUtils.equals(this.divisions, v)) + { + this.divisions = v; + setModified(true); + } + + + } + + + /** + * Get the People + * + * @return String + */ + public String getPeople() + { + return people; + } + + + /** + * Set the value of People + * + * @param v new value + */ + public void setPeople(String v) + { + + + + if (!ObjectUtils.equals(this.people, v)) + { + this.people = v; + setModified(true); + } + + + } + + + /** + * Get the MailingList + * + * @return String + */ + public String getMailingList() + { + return mailing_list; + } + + + /** + * Set the value of MailingList + * + * @param v new value + */ + public void setMailingList(String v) + { + + + + if (!ObjectUtils.equals(this.mailing_list, v)) + { + this.mailing_list = v; + setModified(true); + } + + + } + + + /** + * Get the Description + * + * @return String + */ + public String getDescription() + { + return description; + } + + + /** + * Set the value of Description + * + * @param v new value + */ + public void setDescription(String v) + { + + + + if (!ObjectUtils.equals(this.description, v)) + { + this.description = v; + setModified(true); + } + + + } + + + /** + * Get the History + * + * @return String + */ + public String getHistory() + { + return history; + } + + + /** + * Set the value of History + * + * @param v new value + */ + public void setHistory(String v) + { + + + + if (!ObjectUtils.equals(this.history, v)) + { + this.history = v; + setModified(true); + } + + + } + + + /** + * Get the EducationPrograms + * + * @return String + */ + public String getEducationPrograms() + { + return education_programs; + } + + + /** + * Set the value of EducationPrograms + * + * @param v new value + */ + public void setEducationPrograms(String v) + { + + + + if (!ObjectUtils.equals(this.education_programs, v)) + { + this.education_programs = v; + setModified(true); + } + + + } + + + /** + * Get the Resources + * + * @return String + */ + public String getResources() + { + return resources; + } + + + /** + * Set the value of Resources + * + * @param v new value + */ + public void setResources(String v) + { + + + + if (!ObjectUtils.equals(this.resources, v)) + { + this.resources = v; + setModified(true); + } + + + } + + + + + + + /** + * Collection to store aggregation of collMembers + */ + protected List collMembers; + + /** + * Temporary storage of collMembers to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initMembers() + { + if (collMembers == null) + { + collMembers = new ArrayList(); + } + } + + /** + * Method called to associate a Member object to this object + * through the Member foreign key attribute + * + * @param l Member + * @throws TorqueException + */ + public void addMember(Member l) throws TorqueException + { + getMembers().add(l); + l.setOrganizationData((OrganizationData) this); + } + + /** + * The criteria used to select the current contents of collMembers + */ + private Criteria lastMembersCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getMembers(new Criteria()) + * + * @throws TorqueException + */ + public List getMembers() throws TorqueException + { + if (collMembers == null) + { + collMembers = getMembers(new Criteria(10)); + } + return collMembers; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrganizationData has previously + * been saved, it will retrieve related Members from storage. + * If this OrganizationData is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getMembers(Criteria criteria) throws TorqueException + { + if (collMembers == null) + { + if (isNew()) + { + collMembers = new ArrayList(); + } + else + { + criteria.add(MemberPeer.ORGANIZATION_DATA_ID, getId() ); + collMembers = MemberPeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(MemberPeer.ORGANIZATION_DATA_ID, getId()); + if (!lastMembersCriteria.equals(criteria)) + { + collMembers = MemberPeer.doSelect(criteria); + } + } + } + lastMembersCriteria = criteria; + + return collMembers; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getMembers(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getMembers(Connection con) throws TorqueException + { + if (collMembers == null) + { + collMembers = getMembers(new Criteria(10), con); + } + return collMembers; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrganizationData has previously + * been saved, it will retrieve related Members from storage. + * If this OrganizationData is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getMembers(Criteria criteria, Connection con) + throws TorqueException + { + if (collMembers == null) + { + if (isNew()) + { + collMembers = new ArrayList(); + } + else + { + criteria.add(MemberPeer.ORGANIZATION_DATA_ID, getId()); + collMembers = MemberPeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(MemberPeer.ORGANIZATION_DATA_ID, getId()); + if (!lastMembersCriteria.equals(criteria)) + { + collMembers = MemberPeer.doSelect(criteria, con); + } + } + } + lastMembersCriteria = criteria; + + return collMembers; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /** + * Collection to store aggregation of collOrganizationOrganizationTypes + */ + protected List collOrganizationOrganizationTypes; + + /** + * Temporary storage of collOrganizationOrganizationTypes to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initOrganizationOrganizationTypes() + { + if (collOrganizationOrganizationTypes == null) + { + collOrganizationOrganizationTypes = new ArrayList(); + } + } + + /** + * Method called to associate a OrganizationOrganizationType object to this object + * through the OrganizationOrganizationType foreign key attribute + * + * @param l OrganizationOrganizationType + * @throws TorqueException + */ + public void addOrganizationOrganizationType(OrganizationOrganizationType l) throws TorqueException + { + getOrganizationOrganizationTypes().add(l); + l.setOrganizationData((OrganizationData) this); + } + + /** + * The criteria used to select the current contents of collOrganizationOrganizationTypes + */ + private Criteria lastOrganizationOrganizationTypesCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getOrganizationOrganizationTypes(new Criteria()) + * + * @throws TorqueException + */ + public List getOrganizationOrganizationTypes() throws TorqueException + { + if (collOrganizationOrganizationTypes == null) + { + collOrganizationOrganizationTypes = getOrganizationOrganizationTypes(new Criteria(10)); + } + return collOrganizationOrganizationTypes; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrganizationData has previously + * been saved, it will retrieve related OrganizationOrganizationTypes from storage. + * If this OrganizationData is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getOrganizationOrganizationTypes(Criteria criteria) throws TorqueException + { + if (collOrganizationOrganizationTypes == null) + { + if (isNew()) + { + collOrganizationOrganizationTypes = new ArrayList(); + } + else + { + criteria.add(OrganizationOrganizationTypePeer.ORGANIZATION_DATA_ID, getId() ); + collOrganizationOrganizationTypes = OrganizationOrganizationTypePeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(OrganizationOrganizationTypePeer.ORGANIZATION_DATA_ID, getId()); + if (!lastOrganizationOrganizationTypesCriteria.equals(criteria)) + { + collOrganizationOrganizationTypes = OrganizationOrganizationTypePeer.doSelect(criteria); + } + } + } + lastOrganizationOrganizationTypesCriteria = criteria; + + return collOrganizationOrganizationTypes; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getOrganizationOrganizationTypes(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getOrganizationOrganizationTypes(Connection con) throws TorqueException + { + if (collOrganizationOrganizationTypes == null) + { + collOrganizationOrganizationTypes = getOrganizationOrganizationTypes(new Criteria(10), con); + } + return collOrganizationOrganizationTypes; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrganizationData has previously + * been saved, it will retrieve related OrganizationOrganizationTypes from storage. + * If this OrganizationData is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getOrganizationOrganizationTypes(Criteria criteria, Connection con) + throws TorqueException + { + if (collOrganizationOrganizationTypes == null) + { + if (isNew()) + { + collOrganizationOrganizationTypes = new ArrayList(); + } + else + { + criteria.add(OrganizationOrganizationTypePeer.ORGANIZATION_DATA_ID, getId()); + collOrganizationOrganizationTypes = OrganizationOrganizationTypePeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(OrganizationOrganizationTypePeer.ORGANIZATION_DATA_ID, getId()); + if (!lastOrganizationOrganizationTypesCriteria.equals(criteria)) + { + collOrganizationOrganizationTypes = OrganizationOrganizationTypePeer.doSelect(criteria, con); + } + } + } + lastOrganizationOrganizationTypesCriteria = criteria; + + return collOrganizationOrganizationTypes; + } + + + + + + + + + + + + + + + + + + + + + + + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("Name"); + fieldNames.add("ParentOrganization"); + fieldNames.add("Divisions"); + fieldNames.add("People"); + fieldNames.add("MailingList"); + fieldNames.add("Description"); + fieldNames.add("History"); + fieldNames.add("EducationPrograms"); + fieldNames.add("Resources"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("Name")) + { + return getName(); + } + if (name.equals("ParentOrganization")) + { + return getParentOrganization(); + } + if (name.equals("Divisions")) + { + return getDivisions(); + } + if (name.equals("People")) + { + return getPeople(); + } + if (name.equals("MailingList")) + { + return getMailingList(); + } + if (name.equals("Description")) + { + return getDescription(); + } + if (name.equals("History")) + { + return getHistory(); + } + if (name.equals("EducationPrograms")) + { + return getEducationPrograms(); + } + if (name.equals("Resources")) + { + return getResources(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(OrganizationDataPeer.ID)) + { + return getId(); + } + if (name.equals(OrganizationDataPeer.NAME)) + { + return getName(); + } + if (name.equals(OrganizationDataPeer.PARENT_ORGANIZATION)) + { + return getParentOrganization(); + } + if (name.equals(OrganizationDataPeer.DIVISIONS)) + { + return getDivisions(); + } + if (name.equals(OrganizationDataPeer.PEOPLE)) + { + return getPeople(); + } + if (name.equals(OrganizationDataPeer.MAILING_LIST)) + { + return getMailingList(); + } + if (name.equals(OrganizationDataPeer.DESCRIPTION)) + { + return getDescription(); + } + if (name.equals(OrganizationDataPeer.HISTORY)) + { + return getHistory(); + } + if (name.equals(OrganizationDataPeer.EDUCATION_PROGRAMS)) + { + return getEducationPrograms(); + } + if (name.equals(OrganizationDataPeer.RESOURCES)) + { + return getResources(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getName(); + } + if (pos == 2) + { + return getParentOrganization(); + } + if (pos == 3) + { + return getDivisions(); + } + if (pos == 4) + { + return getPeople(); + } + if (pos == 5) + { + return getMailingList(); + } + if (pos == 6) + { + return getDescription(); + } + if (pos == 7) + { + return getHistory(); + } + if (pos == 8) + { + return getEducationPrograms(); + } + if (pos == 9) + { + return getResources(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(OrganizationDataPeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + OrganizationDataPeer.doInsert((OrganizationData) this, con); + setNew(false); + } + else + { + OrganizationDataPeer.doUpdate((OrganizationData) this, con); + } + } + + + + if (collMembers != null) + { + for (int i = 0; i < collMembers.size(); i++) + { + ((Member) collMembers.get(i)).save(con); + } + } + + + if (collOrganizationOrganizationTypes != null) + { + for (int i = 0; i < collOrganizationOrganizationTypes.size(); i++) + { + ((OrganizationOrganizationType) collOrganizationOrganizationTypes.get(i)).save(con); + } + } + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + throws TorqueException + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) throws TorqueException + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public OrganizationData copy() throws TorqueException + { + return copyInto(new OrganizationData()); + } + + protected OrganizationData copyInto(OrganizationData copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setName(name); + copyObj.setParentOrganization(parent_organization); + copyObj.setDivisions(divisions); + copyObj.setPeople(people); + copyObj.setMailingList(mailing_list); + copyObj.setDescription(description); + copyObj.setHistory(history); + copyObj.setEducationPrograms(education_programs); + copyObj.setResources(resources); + + copyObj.setNew(false); + + + List v = getMembers(); + for (int i = 0; i < v.size(); i++) + { + Member obj = (Member) v.get(i); + copyObj.addMember(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + + + v = getOrganizationOrganizationTypes(); + for (int i = 0; i < v.size(); i++) + { + OrganizationOrganizationType obj = (OrganizationOrganizationType) v.get(i); + copyObj.addOrganizationOrganizationType(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public OrganizationDataPeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BaseOrganizationDataPeer.java b/src/java/org/thdl/roster/om/BaseOrganizationDataPeer.java new file mode 100755 index 0000000..45b681c --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseOrganizationDataPeer.java @@ -0,0 +1,826 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BaseOrganizationDataPeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "OrganizationData"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(OrganizationDataMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the NAME field */ + public static final String NAME; + /** the column name for the PARENT_ORGANIZATION field */ + public static final String PARENT_ORGANIZATION; + /** the column name for the DIVISIONS field */ + public static final String DIVISIONS; + /** the column name for the PEOPLE field */ + public static final String PEOPLE; + /** the column name for the MAILING_LIST field */ + public static final String MAILING_LIST; + /** the column name for the DESCRIPTION field */ + public static final String DESCRIPTION; + /** the column name for the HISTORY field */ + public static final String HISTORY; + /** the column name for the EDUCATION_PROGRAMS field */ + public static final String EDUCATION_PROGRAMS; + /** the column name for the RESOURCES field */ + public static final String RESOURCES; + + static + { + ID = "OrganizationData.ID"; + NAME = "OrganizationData.NAME"; + PARENT_ORGANIZATION = "OrganizationData.PARENT_ORGANIZATION"; + DIVISIONS = "OrganizationData.DIVISIONS"; + PEOPLE = "OrganizationData.PEOPLE"; + MAILING_LIST = "OrganizationData.MAILING_LIST"; + DESCRIPTION = "OrganizationData.DESCRIPTION"; + HISTORY = "OrganizationData.HISTORY"; + EDUCATION_PROGRAMS = "OrganizationData.EDUCATION_PROGRAMS"; + RESOURCES = "OrganizationData.RESOURCES"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(OrganizationDataMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 10; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.OrganizationData"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BaseOrganizationDataPeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(NAME); + criteria.addSelectColumn(PARENT_ORGANIZATION); + criteria.addSelectColumn(DIVISIONS); + criteria.addSelectColumn(PEOPLE); + criteria.addSelectColumn(MAILING_LIST); + criteria.addSelectColumn(DESCRIPTION); + criteria.addSelectColumn(HISTORY); + criteria.addSelectColumn(EDUCATION_PROGRAMS); + criteria.addSelectColumn(RESOURCES); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static OrganizationData row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + OrganizationData obj = (OrganizationData) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + OrganizationData obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setName(row.getValue(offset + 1).asString()); + obj.setParentOrganization(row.getValue(offset + 2).asString()); + obj.setDivisions(row.getValue(offset + 3).asString()); + obj.setPeople(row.getValue(offset + 4).asString()); + obj.setMailingList(row.getValue(offset + 5).asString()); + obj.setDescription(row.getValue(offset + 6).asString()); + obj.setHistory(row.getValue(offset + 7).asString()); + obj.setEducationPrograms(row.getValue(offset + 8).asString()); + obj.setResources(row.getValue(offset + 9).asString()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BaseOrganizationDataPeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(OrganizationDataPeer.row2Object(row, 1, + OrganizationDataPeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BaseOrganizationDataPeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BaseOrganizationDataPeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(OrganizationData obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(OrganizationData obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(OrganizationData obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(OrganizationData obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(OrganizationData) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(OrganizationData obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(OrganizationData) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(OrganizationData obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(OrganizationData) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(OrganizationData obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BaseOrganizationDataPeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( OrganizationData obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(NAME, obj.getName()); + criteria.add(PARENT_ORGANIZATION, obj.getParentOrganization()); + criteria.add(DIVISIONS, obj.getDivisions()); + criteria.add(PEOPLE, obj.getPeople()); + criteria.add(MAILING_LIST, obj.getMailingList()); + criteria.add(DESCRIPTION, obj.getDescription()); + criteria.add(HISTORY, obj.getHistory()); + criteria.add(EDUCATION_PROGRAMS, obj.getEducationPrograms()); + criteria.add(RESOURCES, obj.getResources()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static OrganizationData retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static OrganizationData retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + OrganizationData retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static OrganizationData retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (OrganizationData)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BaseOrganizationOrganizationType.java b/src/java/org/thdl/roster/om/BaseOrganizationOrganizationType.java new file mode 100755 index 0000000..571c591 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseOrganizationOrganizationType.java @@ -0,0 +1,584 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to OrganizationOrganizationType + */ +public abstract class BaseOrganizationOrganizationType extends BaseObject +{ + /** The Peer class */ + private static final OrganizationOrganizationTypePeer peer = + new OrganizationOrganizationTypePeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the organization_type_id field + */ + private Integer organization_type_id; + + /** + * The value for the organization_data_id field + */ + private Integer organization_data_id; + + /** + * The value for the relevance field + */ + private Integer relevance; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + } + + + /** + * Get the OrganizationTypeId + * + * @return Integer + */ + public Integer getOrganizationTypeId() + { + return organization_type_id; + } + + + /** + * Set the value of OrganizationTypeId + * + * @param v new value + */ + public void setOrganizationTypeId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.organization_type_id, v)) + { + this.organization_type_id = v; + setModified(true); + } + + + if (aOrganizationType != null && !ObjectUtils.equals(aOrganizationType.getId(), v)) + { + aOrganizationType = null; + } + + } + + + /** + * Get the OrganizationDataId + * + * @return Integer + */ + public Integer getOrganizationDataId() + { + return organization_data_id; + } + + + /** + * Set the value of OrganizationDataId + * + * @param v new value + */ + public void setOrganizationDataId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.organization_data_id, v)) + { + this.organization_data_id = v; + setModified(true); + } + + + if (aOrganizationData != null && !ObjectUtils.equals(aOrganizationData.getId(), v)) + { + aOrganizationData = null; + } + + } + + + /** + * Get the Relevance + * + * @return Integer + */ + public Integer getRelevance() + { + return relevance; + } + + + /** + * Set the value of Relevance + * + * @param v new value + */ + public void setRelevance(Integer v) + { + + + + if (!ObjectUtils.equals(this.relevance, v)) + { + this.relevance = v; + setModified(true); + } + + + } + + + + + + + + private OrganizationData aOrganizationData; + + /** + * Declares an association between this object and a OrganizationData object + * + * @param v OrganizationData + * @throws TorqueException + */ + public void setOrganizationData(OrganizationData v) throws TorqueException + { + if (v == null) + { + setOrganizationDataId((Integer)null); + } + else + { + setOrganizationDataId(v.getId()); + } + aOrganizationData = v; + } + + + /** + * Get the associated OrganizationData object + * + * @return the associated OrganizationData object + * @throws TorqueException + */ + public OrganizationData getOrganizationData() throws TorqueException + { + if (aOrganizationData == null && (!ObjectUtils.equals(this.organization_data_id, null))) + { + aOrganizationData = OrganizationDataPeer.retrieveByPK(SimpleKey.keyFor(this.organization_data_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + OrganizationData obj = OrganizationDataPeer.retrieveByPK(this.organization_data_id); + obj.addOrganizationOrganizationTypes(this); + */ + } + return aOrganizationData; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setOrganizationDataKey(ObjectKey key) throws TorqueException + { + + setOrganizationDataId(new Integer(((NumberKey) key).intValue())); + } + + + + + private OrganizationType aOrganizationType; + + /** + * Declares an association between this object and a OrganizationType object + * + * @param v OrganizationType + * @throws TorqueException + */ + public void setOrganizationType(OrganizationType v) throws TorqueException + { + if (v == null) + { + setOrganizationTypeId((Integer)null); + } + else + { + setOrganizationTypeId(v.getId()); + } + aOrganizationType = v; + } + + + /** + * Get the associated OrganizationType object + * + * @return the associated OrganizationType object + * @throws TorqueException + */ + public OrganizationType getOrganizationType() throws TorqueException + { + if (aOrganizationType == null && (!ObjectUtils.equals(this.organization_type_id, null))) + { + aOrganizationType = OrganizationTypePeer.retrieveByPK(SimpleKey.keyFor(this.organization_type_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + OrganizationType obj = OrganizationTypePeer.retrieveByPK(this.organization_type_id); + obj.addOrganizationOrganizationTypes(this); + */ + } + return aOrganizationType; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setOrganizationTypeKey(ObjectKey key) throws TorqueException + { + + setOrganizationTypeId(new Integer(((NumberKey) key).intValue())); + } + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("OrganizationTypeId"); + fieldNames.add("OrganizationDataId"); + fieldNames.add("Relevance"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("OrganizationTypeId")) + { + return getOrganizationTypeId(); + } + if (name.equals("OrganizationDataId")) + { + return getOrganizationDataId(); + } + if (name.equals("Relevance")) + { + return getRelevance(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(OrganizationOrganizationTypePeer.ID)) + { + return getId(); + } + if (name.equals(OrganizationOrganizationTypePeer.ORGANIZATION_TYPE_ID)) + { + return getOrganizationTypeId(); + } + if (name.equals(OrganizationOrganizationTypePeer.ORGANIZATION_DATA_ID)) + { + return getOrganizationDataId(); + } + if (name.equals(OrganizationOrganizationTypePeer.RELEVANCE)) + { + return getRelevance(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getOrganizationTypeId(); + } + if (pos == 2) + { + return getOrganizationDataId(); + } + if (pos == 3) + { + return getRelevance(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(OrganizationOrganizationTypePeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + OrganizationOrganizationTypePeer.doInsert((OrganizationOrganizationType) this, con); + setNew(false); + } + else + { + OrganizationOrganizationTypePeer.doUpdate((OrganizationOrganizationType) this, con); + } + } + + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public OrganizationOrganizationType copy() throws TorqueException + { + return copyInto(new OrganizationOrganizationType()); + } + + protected OrganizationOrganizationType copyInto(OrganizationOrganizationType copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setOrganizationTypeId(organization_type_id); + copyObj.setOrganizationDataId(organization_data_id); + copyObj.setRelevance(relevance); + + copyObj.setNew(false); + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public OrganizationOrganizationTypePeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BaseOrganizationOrganizationTypePeer.java b/src/java/org/thdl/roster/om/BaseOrganizationOrganizationTypePeer.java new file mode 100755 index 0000000..8a7521b --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseOrganizationOrganizationTypePeer.java @@ -0,0 +1,946 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BaseOrganizationOrganizationTypePeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "OrganizationOrganizationType"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(OrganizationOrganizationTypeMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the ORGANIZATION_TYPE_ID field */ + public static final String ORGANIZATION_TYPE_ID; + /** the column name for the ORGANIZATION_DATA_ID field */ + public static final String ORGANIZATION_DATA_ID; + /** the column name for the RELEVANCE field */ + public static final String RELEVANCE; + + static + { + ID = "OrganizationOrganizationType.ID"; + ORGANIZATION_TYPE_ID = "OrganizationOrganizationType.ORGANIZATION_TYPE_ID"; + ORGANIZATION_DATA_ID = "OrganizationOrganizationType.ORGANIZATION_DATA_ID"; + RELEVANCE = "OrganizationOrganizationType.RELEVANCE"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(OrganizationOrganizationTypeMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 4; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.OrganizationOrganizationType"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BaseOrganizationOrganizationTypePeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(ORGANIZATION_TYPE_ID); + criteria.addSelectColumn(ORGANIZATION_DATA_ID); + criteria.addSelectColumn(RELEVANCE); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static OrganizationOrganizationType row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + OrganizationOrganizationType obj = (OrganizationOrganizationType) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + OrganizationOrganizationType obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setOrganizationTypeId(row.getValue(offset + 1).asIntegerObj()); + obj.setOrganizationDataId(row.getValue(offset + 2).asIntegerObj()); + obj.setRelevance(row.getValue(offset + 3).asIntegerObj()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BaseOrganizationOrganizationTypePeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(OrganizationOrganizationTypePeer.row2Object(row, 1, + OrganizationOrganizationTypePeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BaseOrganizationOrganizationTypePeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BaseOrganizationOrganizationTypePeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(OrganizationOrganizationType obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(OrganizationOrganizationType obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(OrganizationOrganizationType obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(OrganizationOrganizationType obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(OrganizationOrganizationType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(OrganizationOrganizationType obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(OrganizationOrganizationType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(OrganizationOrganizationType obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(OrganizationOrganizationType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(OrganizationOrganizationType obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BaseOrganizationOrganizationTypePeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( OrganizationOrganizationType obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(ORGANIZATION_TYPE_ID, obj.getOrganizationTypeId()); + criteria.add(ORGANIZATION_DATA_ID, obj.getOrganizationDataId()); + criteria.add(RELEVANCE, obj.getRelevance()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static OrganizationOrganizationType retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static OrganizationOrganizationType retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + OrganizationOrganizationType retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static OrganizationOrganizationType retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (OrganizationOrganizationType)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + + + /** + * selects a collection of OrganizationOrganizationType objects pre-filled with their + * OrganizationData objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrganizationOrganizationTypePeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinOrganizationData(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + OrganizationOrganizationTypePeer.addSelectColumns(c); + int offset = numColumns + 1; + OrganizationDataPeer.addSelectColumns(c); + + + c.addJoin(OrganizationOrganizationTypePeer.ORGANIZATION_DATA_ID, + OrganizationDataPeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = OrganizationOrganizationTypePeer.getOMClass(); + + OrganizationOrganizationType obj1 = (OrganizationOrganizationType) OrganizationOrganizationTypePeer + .row2Object(row, 1, omClass); + + + omClass = OrganizationDataPeer.getOMClass(); + OrganizationData obj2 = (OrganizationData)OrganizationDataPeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + OrganizationOrganizationType temp_obj1 = (OrganizationOrganizationType)results.get(j); + OrganizationData temp_obj2 = (OrganizationData)temp_obj1.getOrganizationData(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addOrganizationOrganizationType(obj1); + break; + } + } + if (newObject) + { + obj2.initOrganizationOrganizationTypes(); + obj2.addOrganizationOrganizationType(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + + /** + * selects a collection of OrganizationOrganizationType objects pre-filled with their + * OrganizationType objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in OrganizationOrganizationTypePeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinOrganizationType(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + OrganizationOrganizationTypePeer.addSelectColumns(c); + int offset = numColumns + 1; + OrganizationTypePeer.addSelectColumns(c); + + + c.addJoin(OrganizationOrganizationTypePeer.ORGANIZATION_TYPE_ID, + OrganizationTypePeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = OrganizationOrganizationTypePeer.getOMClass(); + + OrganizationOrganizationType obj1 = (OrganizationOrganizationType) OrganizationOrganizationTypePeer + .row2Object(row, 1, omClass); + + + omClass = OrganizationTypePeer.getOMClass(); + OrganizationType obj2 = (OrganizationType)OrganizationTypePeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + OrganizationOrganizationType temp_obj1 = (OrganizationOrganizationType)results.get(j); + OrganizationType temp_obj2 = (OrganizationType)temp_obj1.getOrganizationType(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addOrganizationOrganizationType(obj1); + break; + } + } + if (newObject) + { + obj2.initOrganizationOrganizationTypes(); + obj2.addOrganizationOrganizationType(obj1); + } + results.add(obj1); + } + return results; + } + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BaseOrganizationType.java b/src/java/org/thdl/roster/om/BaseOrganizationType.java new file mode 100755 index 0000000..1b488e5 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseOrganizationType.java @@ -0,0 +1,561 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to OrganizationType + */ +public abstract class BaseOrganizationType extends BaseObject +{ + /** The Peer class */ + private static final OrganizationTypePeer peer = + new OrganizationTypePeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the organization_type field + */ + private String organization_type; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + + // update associated OrganizationOrganizationType + if (collOrganizationOrganizationTypes != null) + { + for (int i = 0; i < collOrganizationOrganizationTypes.size(); i++) + { + ((OrganizationOrganizationType) collOrganizationOrganizationTypes.get(i)) + .setOrganizationTypeId(v); + } + } + } + + + /** + * Get the OrganizationType + * + * @return String + */ + public String getOrganizationType() + { + return organization_type; + } + + + /** + * Set the value of OrganizationType + * + * @param v new value + */ + public void setOrganizationType(String v) + { + + + + if (!ObjectUtils.equals(this.organization_type, v)) + { + this.organization_type = v; + setModified(true); + } + + + } + + + + + + + /** + * Collection to store aggregation of collOrganizationOrganizationTypes + */ + protected List collOrganizationOrganizationTypes; + + /** + * Temporary storage of collOrganizationOrganizationTypes to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initOrganizationOrganizationTypes() + { + if (collOrganizationOrganizationTypes == null) + { + collOrganizationOrganizationTypes = new ArrayList(); + } + } + + /** + * Method called to associate a OrganizationOrganizationType object to this object + * through the OrganizationOrganizationType foreign key attribute + * + * @param l OrganizationOrganizationType + * @throws TorqueException + */ + public void addOrganizationOrganizationType(OrganizationOrganizationType l) throws TorqueException + { + getOrganizationOrganizationTypes().add(l); + l.setOrganizationType((OrganizationType) this); + } + + /** + * The criteria used to select the current contents of collOrganizationOrganizationTypes + */ + private Criteria lastOrganizationOrganizationTypesCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getOrganizationOrganizationTypes(new Criteria()) + * + * @throws TorqueException + */ + public List getOrganizationOrganizationTypes() throws TorqueException + { + if (collOrganizationOrganizationTypes == null) + { + collOrganizationOrganizationTypes = getOrganizationOrganizationTypes(new Criteria(10)); + } + return collOrganizationOrganizationTypes; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrganizationType has previously + * been saved, it will retrieve related OrganizationOrganizationTypes from storage. + * If this OrganizationType is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getOrganizationOrganizationTypes(Criteria criteria) throws TorqueException + { + if (collOrganizationOrganizationTypes == null) + { + if (isNew()) + { + collOrganizationOrganizationTypes = new ArrayList(); + } + else + { + criteria.add(OrganizationOrganizationTypePeer.ORGANIZATION_TYPE_ID, getId() ); + collOrganizationOrganizationTypes = OrganizationOrganizationTypePeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(OrganizationOrganizationTypePeer.ORGANIZATION_TYPE_ID, getId()); + if (!lastOrganizationOrganizationTypesCriteria.equals(criteria)) + { + collOrganizationOrganizationTypes = OrganizationOrganizationTypePeer.doSelect(criteria); + } + } + } + lastOrganizationOrganizationTypesCriteria = criteria; + + return collOrganizationOrganizationTypes; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getOrganizationOrganizationTypes(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getOrganizationOrganizationTypes(Connection con) throws TorqueException + { + if (collOrganizationOrganizationTypes == null) + { + collOrganizationOrganizationTypes = getOrganizationOrganizationTypes(new Criteria(10), con); + } + return collOrganizationOrganizationTypes; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this OrganizationType has previously + * been saved, it will retrieve related OrganizationOrganizationTypes from storage. + * If this OrganizationType is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getOrganizationOrganizationTypes(Criteria criteria, Connection con) + throws TorqueException + { + if (collOrganizationOrganizationTypes == null) + { + if (isNew()) + { + collOrganizationOrganizationTypes = new ArrayList(); + } + else + { + criteria.add(OrganizationOrganizationTypePeer.ORGANIZATION_TYPE_ID, getId()); + collOrganizationOrganizationTypes = OrganizationOrganizationTypePeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(OrganizationOrganizationTypePeer.ORGANIZATION_TYPE_ID, getId()); + if (!lastOrganizationOrganizationTypesCriteria.equals(criteria)) + { + collOrganizationOrganizationTypes = OrganizationOrganizationTypePeer.doSelect(criteria, con); + } + } + } + lastOrganizationOrganizationTypesCriteria = criteria; + + return collOrganizationOrganizationTypes; + } + + + + + + + + + + + + + + + + + + + + + + + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("OrganizationType"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("OrganizationType")) + { + return getOrganizationType(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(OrganizationTypePeer.ID)) + { + return getId(); + } + if (name.equals(OrganizationTypePeer.ORGANIZATION_TYPE)) + { + return getOrganizationType(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getOrganizationType(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(OrganizationTypePeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + OrganizationTypePeer.doInsert((OrganizationType) this, con); + setNew(false); + } + else + { + OrganizationTypePeer.doUpdate((OrganizationType) this, con); + } + } + + + + if (collOrganizationOrganizationTypes != null) + { + for (int i = 0; i < collOrganizationOrganizationTypes.size(); i++) + { + ((OrganizationOrganizationType) collOrganizationOrganizationTypes.get(i)).save(con); + } + } + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + throws TorqueException + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) throws TorqueException + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public OrganizationType copy() throws TorqueException + { + return copyInto(new OrganizationType()); + } + + protected OrganizationType copyInto(OrganizationType copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setOrganizationType(organization_type); + + copyObj.setNew(false); + + + List v = getOrganizationOrganizationTypes(); + for (int i = 0; i < v.size(); i++) + { + OrganizationOrganizationType obj = (OrganizationOrganizationType) v.get(i); + copyObj.addOrganizationOrganizationType(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public OrganizationTypePeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BaseOrganizationTypePeer.java b/src/java/org/thdl/roster/om/BaseOrganizationTypePeer.java new file mode 100755 index 0000000..9b315b0 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseOrganizationTypePeer.java @@ -0,0 +1,778 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BaseOrganizationTypePeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "OrganizationType"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(OrganizationTypeMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the ORGANIZATION_TYPE field */ + public static final String ORGANIZATION_TYPE; + + static + { + ID = "OrganizationType.ID"; + ORGANIZATION_TYPE = "OrganizationType.ORGANIZATION_TYPE"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(OrganizationTypeMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 2; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.OrganizationType"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BaseOrganizationTypePeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(ORGANIZATION_TYPE); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static OrganizationType row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + OrganizationType obj = (OrganizationType) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + OrganizationType obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setOrganizationType(row.getValue(offset + 1).asString()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BaseOrganizationTypePeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(OrganizationTypePeer.row2Object(row, 1, + OrganizationTypePeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BaseOrganizationTypePeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BaseOrganizationTypePeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(OrganizationType obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(OrganizationType obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(OrganizationType obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(OrganizationType obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(OrganizationType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(OrganizationType obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(OrganizationType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(OrganizationType obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(OrganizationType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(OrganizationType obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BaseOrganizationTypePeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( OrganizationType obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(ORGANIZATION_TYPE, obj.getOrganizationType()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static OrganizationType retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static OrganizationType retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + OrganizationType retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static OrganizationType retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (OrganizationType)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BasePersonData.java b/src/java/org/thdl/roster/om/BasePersonData.java new file mode 100755 index 0000000..2aa2791 --- /dev/null +++ b/src/java/org/thdl/roster/om/BasePersonData.java @@ -0,0 +1,1756 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to PersonData + */ +public abstract class BasePersonData extends BaseObject +{ + /** The Peer class */ + private static final PersonDataPeer peer = + new PersonDataPeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the thdl_user_id field + */ + private Integer thdl_user_id; + + /** + * The value for the firstname field + */ + private String firstname; + + /** + * The value for the middlename field + */ + private String middlename; + + /** + * The value for the lastname field + */ + private String lastname; + + /** + * The value for the bio field + */ + private String bio; + + /** + * The value for the history field + */ + private String history; + + /** + * The value for the parent_organization field + */ + private String parent_organization; + + /** + * The value for the school field + */ + private String school; + + /** + * The value for the department field + */ + private String department; + + /** + * The value for the program field + */ + private String program; + + /** + * The value for the advisor field + */ + private String advisor; + + /** + * The value for the highest_degree field + */ + private String highest_degree; + + /** + * The value for the year_began field + */ + private Integer year_began; + + /** + * The value for the year_finished field + */ + private Integer year_finished; + + /** + * The value for the other_backgrounds field + */ + private String other_backgrounds; + + /** + * The value for the organization field + */ + private String organization; + + /** + * The value for the division field + */ + private String division; + + /** + * The value for the title field + */ + private String title; + + /** + * The value for the start_date field + */ + private Integer start_date; + + /** + * The value for the job_description field + */ + private String job_description; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + + // update associated Member + if (collMembers != null) + { + for (int i = 0; i < collMembers.size(); i++) + { + ((Member) collMembers.get(i)) + .setPersonDataId(v); + } + } + + // update associated PersonPersonType + if (collPersonPersonTypes != null) + { + for (int i = 0; i < collPersonPersonTypes.size(); i++) + { + ((PersonPersonType) collPersonPersonTypes.get(i)) + .setPersonDataId(v); + } + } + } + + + /** + * Get the ThdlUserId + * + * @return Integer + */ + public Integer getThdlUserId() + { + return thdl_user_id; + } + + + /** + * Set the value of ThdlUserId + * + * @param v new value + */ + public void setThdlUserId(Integer v) + { + + + + if (!ObjectUtils.equals(this.thdl_user_id, v)) + { + this.thdl_user_id = v; + setModified(true); + } + + + } + + + /** + * Get the Firstname + * + * @return String + */ + public String getFirstname() + { + return firstname; + } + + + /** + * Set the value of Firstname + * + * @param v new value + */ + public void setFirstname(String v) + { + + + + if (!ObjectUtils.equals(this.firstname, v)) + { + this.firstname = v; + setModified(true); + } + + + } + + + /** + * Get the Middlename + * + * @return String + */ + public String getMiddlename() + { + return middlename; + } + + + /** + * Set the value of Middlename + * + * @param v new value + */ + public void setMiddlename(String v) + { + + + + if (!ObjectUtils.equals(this.middlename, v)) + { + this.middlename = v; + setModified(true); + } + + + } + + + /** + * Get the Lastname + * + * @return String + */ + public String getLastname() + { + return lastname; + } + + + /** + * Set the value of Lastname + * + * @param v new value + */ + public void setLastname(String v) + { + + + + if (!ObjectUtils.equals(this.lastname, v)) + { + this.lastname = v; + setModified(true); + } + + + } + + + /** + * Get the Bio + * + * @return String + */ + public String getBio() + { + return bio; + } + + + /** + * Set the value of Bio + * + * @param v new value + */ + public void setBio(String v) + { + + + + if (!ObjectUtils.equals(this.bio, v)) + { + this.bio = v; + setModified(true); + } + + + } + + + /** + * Get the History + * + * @return String + */ + public String getHistory() + { + return history; + } + + + /** + * Set the value of History + * + * @param v new value + */ + public void setHistory(String v) + { + + + + if (!ObjectUtils.equals(this.history, v)) + { + this.history = v; + setModified(true); + } + + + } + + + /** + * Get the ParentOrganization + * + * @return String + */ + public String getParentOrganization() + { + return parent_organization; + } + + + /** + * Set the value of ParentOrganization + * + * @param v new value + */ + public void setParentOrganization(String v) + { + + + + if (!ObjectUtils.equals(this.parent_organization, v)) + { + this.parent_organization = v; + setModified(true); + } + + + } + + + /** + * Get the School + * + * @return String + */ + public String getSchool() + { + return school; + } + + + /** + * Set the value of School + * + * @param v new value + */ + public void setSchool(String v) + { + + + + if (!ObjectUtils.equals(this.school, v)) + { + this.school = v; + setModified(true); + } + + + } + + + /** + * Get the Department + * + * @return String + */ + public String getDepartment() + { + return department; + } + + + /** + * Set the value of Department + * + * @param v new value + */ + public void setDepartment(String v) + { + + + + if (!ObjectUtils.equals(this.department, v)) + { + this.department = v; + setModified(true); + } + + + } + + + /** + * Get the Program + * + * @return String + */ + public String getProgram() + { + return program; + } + + + /** + * Set the value of Program + * + * @param v new value + */ + public void setProgram(String v) + { + + + + if (!ObjectUtils.equals(this.program, v)) + { + this.program = v; + setModified(true); + } + + + } + + + /** + * Get the Advisor + * + * @return String + */ + public String getAdvisor() + { + return advisor; + } + + + /** + * Set the value of Advisor + * + * @param v new value + */ + public void setAdvisor(String v) + { + + + + if (!ObjectUtils.equals(this.advisor, v)) + { + this.advisor = v; + setModified(true); + } + + + } + + + /** + * Get the HighestDegree + * + * @return String + */ + public String getHighestDegree() + { + return highest_degree; + } + + + /** + * Set the value of HighestDegree + * + * @param v new value + */ + public void setHighestDegree(String v) + { + + + + if (!ObjectUtils.equals(this.highest_degree, v)) + { + this.highest_degree = v; + setModified(true); + } + + + } + + + /** + * Get the YearBegan + * + * @return Integer + */ + public Integer getYearBegan() + { + return year_began; + } + + + /** + * Set the value of YearBegan + * + * @param v new value + */ + public void setYearBegan(Integer v) + { + + + + if (!ObjectUtils.equals(this.year_began, v)) + { + this.year_began = v; + setModified(true); + } + + + } + + + /** + * Get the YearFinished + * + * @return Integer + */ + public Integer getYearFinished() + { + return year_finished; + } + + + /** + * Set the value of YearFinished + * + * @param v new value + */ + public void setYearFinished(Integer v) + { + + + + if (!ObjectUtils.equals(this.year_finished, v)) + { + this.year_finished = v; + setModified(true); + } + + + } + + + /** + * Get the OtherBackgrounds + * + * @return String + */ + public String getOtherBackgrounds() + { + return other_backgrounds; + } + + + /** + * Set the value of OtherBackgrounds + * + * @param v new value + */ + public void setOtherBackgrounds(String v) + { + + + + if (!ObjectUtils.equals(this.other_backgrounds, v)) + { + this.other_backgrounds = v; + setModified(true); + } + + + } + + + /** + * Get the Organization + * + * @return String + */ + public String getOrganization() + { + return organization; + } + + + /** + * Set the value of Organization + * + * @param v new value + */ + public void setOrganization(String v) + { + + + + if (!ObjectUtils.equals(this.organization, v)) + { + this.organization = v; + setModified(true); + } + + + } + + + /** + * Get the Division + * + * @return String + */ + public String getDivision() + { + return division; + } + + + /** + * Set the value of Division + * + * @param v new value + */ + public void setDivision(String v) + { + + + + if (!ObjectUtils.equals(this.division, v)) + { + this.division = v; + setModified(true); + } + + + } + + + /** + * Get the Title + * + * @return String + */ + public String getTitle() + { + return title; + } + + + /** + * Set the value of Title + * + * @param v new value + */ + public void setTitle(String v) + { + + + + if (!ObjectUtils.equals(this.title, v)) + { + this.title = v; + setModified(true); + } + + + } + + + /** + * Get the StartDate + * + * @return Integer + */ + public Integer getStartDate() + { + return start_date; + } + + + /** + * Set the value of StartDate + * + * @param v new value + */ + public void setStartDate(Integer v) + { + + + + if (!ObjectUtils.equals(this.start_date, v)) + { + this.start_date = v; + setModified(true); + } + + + } + + + /** + * Get the JobDescription + * + * @return String + */ + public String getJobDescription() + { + return job_description; + } + + + /** + * Set the value of JobDescription + * + * @param v new value + */ + public void setJobDescription(String v) + { + + + + if (!ObjectUtils.equals(this.job_description, v)) + { + this.job_description = v; + setModified(true); + } + + + } + + + + + + + /** + * Collection to store aggregation of collMembers + */ + protected List collMembers; + + /** + * Temporary storage of collMembers to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initMembers() + { + if (collMembers == null) + { + collMembers = new ArrayList(); + } + } + + /** + * Method called to associate a Member object to this object + * through the Member foreign key attribute + * + * @param l Member + * @throws TorqueException + */ + public void addMember(Member l) throws TorqueException + { + getMembers().add(l); + l.setPersonData((PersonData) this); + } + + /** + * The criteria used to select the current contents of collMembers + */ + private Criteria lastMembersCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getMembers(new Criteria()) + * + * @throws TorqueException + */ + public List getMembers() throws TorqueException + { + if (collMembers == null) + { + collMembers = getMembers(new Criteria(10)); + } + return collMembers; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this PersonData has previously + * been saved, it will retrieve related Members from storage. + * If this PersonData is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getMembers(Criteria criteria) throws TorqueException + { + if (collMembers == null) + { + if (isNew()) + { + collMembers = new ArrayList(); + } + else + { + criteria.add(MemberPeer.PERSON_DATA_ID, getId() ); + collMembers = MemberPeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(MemberPeer.PERSON_DATA_ID, getId()); + if (!lastMembersCriteria.equals(criteria)) + { + collMembers = MemberPeer.doSelect(criteria); + } + } + } + lastMembersCriteria = criteria; + + return collMembers; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getMembers(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getMembers(Connection con) throws TorqueException + { + if (collMembers == null) + { + collMembers = getMembers(new Criteria(10), con); + } + return collMembers; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this PersonData has previously + * been saved, it will retrieve related Members from storage. + * If this PersonData is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getMembers(Criteria criteria, Connection con) + throws TorqueException + { + if (collMembers == null) + { + if (isNew()) + { + collMembers = new ArrayList(); + } + else + { + criteria.add(MemberPeer.PERSON_DATA_ID, getId()); + collMembers = MemberPeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(MemberPeer.PERSON_DATA_ID, getId()); + if (!lastMembersCriteria.equals(criteria)) + { + collMembers = MemberPeer.doSelect(criteria, con); + } + } + } + lastMembersCriteria = criteria; + + return collMembers; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /** + * Collection to store aggregation of collPersonPersonTypes + */ + protected List collPersonPersonTypes; + + /** + * Temporary storage of collPersonPersonTypes to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initPersonPersonTypes() + { + if (collPersonPersonTypes == null) + { + collPersonPersonTypes = new ArrayList(); + } + } + + /** + * Method called to associate a PersonPersonType object to this object + * through the PersonPersonType foreign key attribute + * + * @param l PersonPersonType + * @throws TorqueException + */ + public void addPersonPersonType(PersonPersonType l) throws TorqueException + { + getPersonPersonTypes().add(l); + l.setPersonData((PersonData) this); + } + + /** + * The criteria used to select the current contents of collPersonPersonTypes + */ + private Criteria lastPersonPersonTypesCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getPersonPersonTypes(new Criteria()) + * + * @throws TorqueException + */ + public List getPersonPersonTypes() throws TorqueException + { + if (collPersonPersonTypes == null) + { + collPersonPersonTypes = getPersonPersonTypes(new Criteria(10)); + } + return collPersonPersonTypes; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this PersonData has previously + * been saved, it will retrieve related PersonPersonTypes from storage. + * If this PersonData is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getPersonPersonTypes(Criteria criteria) throws TorqueException + { + if (collPersonPersonTypes == null) + { + if (isNew()) + { + collPersonPersonTypes = new ArrayList(); + } + else + { + criteria.add(PersonPersonTypePeer.PERSON_DATA_ID, getId() ); + collPersonPersonTypes = PersonPersonTypePeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(PersonPersonTypePeer.PERSON_DATA_ID, getId()); + if (!lastPersonPersonTypesCriteria.equals(criteria)) + { + collPersonPersonTypes = PersonPersonTypePeer.doSelect(criteria); + } + } + } + lastPersonPersonTypesCriteria = criteria; + + return collPersonPersonTypes; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getPersonPersonTypes(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getPersonPersonTypes(Connection con) throws TorqueException + { + if (collPersonPersonTypes == null) + { + collPersonPersonTypes = getPersonPersonTypes(new Criteria(10), con); + } + return collPersonPersonTypes; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this PersonData has previously + * been saved, it will retrieve related PersonPersonTypes from storage. + * If this PersonData is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getPersonPersonTypes(Criteria criteria, Connection con) + throws TorqueException + { + if (collPersonPersonTypes == null) + { + if (isNew()) + { + collPersonPersonTypes = new ArrayList(); + } + else + { + criteria.add(PersonPersonTypePeer.PERSON_DATA_ID, getId()); + collPersonPersonTypes = PersonPersonTypePeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(PersonPersonTypePeer.PERSON_DATA_ID, getId()); + if (!lastPersonPersonTypesCriteria.equals(criteria)) + { + collPersonPersonTypes = PersonPersonTypePeer.doSelect(criteria, con); + } + } + } + lastPersonPersonTypesCriteria = criteria; + + return collPersonPersonTypes; + } + + + + + + + + + + + + + + + + + + + + + + + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("ThdlUserId"); + fieldNames.add("Firstname"); + fieldNames.add("Middlename"); + fieldNames.add("Lastname"); + fieldNames.add("Bio"); + fieldNames.add("History"); + fieldNames.add("ParentOrganization"); + fieldNames.add("School"); + fieldNames.add("Department"); + fieldNames.add("Program"); + fieldNames.add("Advisor"); + fieldNames.add("HighestDegree"); + fieldNames.add("YearBegan"); + fieldNames.add("YearFinished"); + fieldNames.add("OtherBackgrounds"); + fieldNames.add("Organization"); + fieldNames.add("Division"); + fieldNames.add("Title"); + fieldNames.add("StartDate"); + fieldNames.add("JobDescription"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("ThdlUserId")) + { + return getThdlUserId(); + } + if (name.equals("Firstname")) + { + return getFirstname(); + } + if (name.equals("Middlename")) + { + return getMiddlename(); + } + if (name.equals("Lastname")) + { + return getLastname(); + } + if (name.equals("Bio")) + { + return getBio(); + } + if (name.equals("History")) + { + return getHistory(); + } + if (name.equals("ParentOrganization")) + { + return getParentOrganization(); + } + if (name.equals("School")) + { + return getSchool(); + } + if (name.equals("Department")) + { + return getDepartment(); + } + if (name.equals("Program")) + { + return getProgram(); + } + if (name.equals("Advisor")) + { + return getAdvisor(); + } + if (name.equals("HighestDegree")) + { + return getHighestDegree(); + } + if (name.equals("YearBegan")) + { + return getYearBegan(); + } + if (name.equals("YearFinished")) + { + return getYearFinished(); + } + if (name.equals("OtherBackgrounds")) + { + return getOtherBackgrounds(); + } + if (name.equals("Organization")) + { + return getOrganization(); + } + if (name.equals("Division")) + { + return getDivision(); + } + if (name.equals("Title")) + { + return getTitle(); + } + if (name.equals("StartDate")) + { + return getStartDate(); + } + if (name.equals("JobDescription")) + { + return getJobDescription(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(PersonDataPeer.ID)) + { + return getId(); + } + if (name.equals(PersonDataPeer.THDL_USER_ID)) + { + return getThdlUserId(); + } + if (name.equals(PersonDataPeer.FIRSTNAME)) + { + return getFirstname(); + } + if (name.equals(PersonDataPeer.MIDDLENAME)) + { + return getMiddlename(); + } + if (name.equals(PersonDataPeer.LASTNAME)) + { + return getLastname(); + } + if (name.equals(PersonDataPeer.BIO)) + { + return getBio(); + } + if (name.equals(PersonDataPeer.HISTORY)) + { + return getHistory(); + } + if (name.equals(PersonDataPeer.PARENT_ORGANIZATION)) + { + return getParentOrganization(); + } + if (name.equals(PersonDataPeer.SCHOOL)) + { + return getSchool(); + } + if (name.equals(PersonDataPeer.DEPARTMENT)) + { + return getDepartment(); + } + if (name.equals(PersonDataPeer.PROGRAM)) + { + return getProgram(); + } + if (name.equals(PersonDataPeer.ADVISOR)) + { + return getAdvisor(); + } + if (name.equals(PersonDataPeer.HIGHEST_DEGREE)) + { + return getHighestDegree(); + } + if (name.equals(PersonDataPeer.YEAR_BEGAN)) + { + return getYearBegan(); + } + if (name.equals(PersonDataPeer.YEAR_FINISHED)) + { + return getYearFinished(); + } + if (name.equals(PersonDataPeer.OTHER_BACKGROUNDS)) + { + return getOtherBackgrounds(); + } + if (name.equals(PersonDataPeer.ORGANIZATION)) + { + return getOrganization(); + } + if (name.equals(PersonDataPeer.DIVISION)) + { + return getDivision(); + } + if (name.equals(PersonDataPeer.TITLE)) + { + return getTitle(); + } + if (name.equals(PersonDataPeer.START_DATE)) + { + return getStartDate(); + } + if (name.equals(PersonDataPeer.JOB_DESCRIPTION)) + { + return getJobDescription(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getThdlUserId(); + } + if (pos == 2) + { + return getFirstname(); + } + if (pos == 3) + { + return getMiddlename(); + } + if (pos == 4) + { + return getLastname(); + } + if (pos == 5) + { + return getBio(); + } + if (pos == 6) + { + return getHistory(); + } + if (pos == 7) + { + return getParentOrganization(); + } + if (pos == 8) + { + return getSchool(); + } + if (pos == 9) + { + return getDepartment(); + } + if (pos == 10) + { + return getProgram(); + } + if (pos == 11) + { + return getAdvisor(); + } + if (pos == 12) + { + return getHighestDegree(); + } + if (pos == 13) + { + return getYearBegan(); + } + if (pos == 14) + { + return getYearFinished(); + } + if (pos == 15) + { + return getOtherBackgrounds(); + } + if (pos == 16) + { + return getOrganization(); + } + if (pos == 17) + { + return getDivision(); + } + if (pos == 18) + { + return getTitle(); + } + if (pos == 19) + { + return getStartDate(); + } + if (pos == 20) + { + return getJobDescription(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(PersonDataPeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + PersonDataPeer.doInsert((PersonData) this, con); + setNew(false); + } + else + { + PersonDataPeer.doUpdate((PersonData) this, con); + } + } + + + + if (collMembers != null) + { + for (int i = 0; i < collMembers.size(); i++) + { + ((Member) collMembers.get(i)).save(con); + } + } + + + if (collPersonPersonTypes != null) + { + for (int i = 0; i < collPersonPersonTypes.size(); i++) + { + ((PersonPersonType) collPersonPersonTypes.get(i)).save(con); + } + } + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + throws TorqueException + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) throws TorqueException + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public PersonData copy() throws TorqueException + { + return copyInto(new PersonData()); + } + + protected PersonData copyInto(PersonData copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setThdlUserId(thdl_user_id); + copyObj.setFirstname(firstname); + copyObj.setMiddlename(middlename); + copyObj.setLastname(lastname); + copyObj.setBio(bio); + copyObj.setHistory(history); + copyObj.setParentOrganization(parent_organization); + copyObj.setSchool(school); + copyObj.setDepartment(department); + copyObj.setProgram(program); + copyObj.setAdvisor(advisor); + copyObj.setHighestDegree(highest_degree); + copyObj.setYearBegan(year_began); + copyObj.setYearFinished(year_finished); + copyObj.setOtherBackgrounds(other_backgrounds); + copyObj.setOrganization(organization); + copyObj.setDivision(division); + copyObj.setTitle(title); + copyObj.setStartDate(start_date); + copyObj.setJobDescription(job_description); + + copyObj.setNew(false); + + + List v = getMembers(); + for (int i = 0; i < v.size(); i++) + { + Member obj = (Member) v.get(i); + copyObj.addMember(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + + + v = getPersonPersonTypes(); + for (int i = 0; i < v.size(); i++) + { + PersonPersonType obj = (PersonPersonType) v.get(i); + copyObj.addPersonPersonType(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public PersonDataPeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BasePersonDataPeer.java b/src/java/org/thdl/roster/om/BasePersonDataPeer.java new file mode 100755 index 0000000..f700236 --- /dev/null +++ b/src/java/org/thdl/roster/om/BasePersonDataPeer.java @@ -0,0 +1,892 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BasePersonDataPeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "PersonData"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(PersonDataMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the THDL_USER_ID field */ + public static final String THDL_USER_ID; + /** the column name for the FIRSTNAME field */ + public static final String FIRSTNAME; + /** the column name for the MIDDLENAME field */ + public static final String MIDDLENAME; + /** the column name for the LASTNAME field */ + public static final String LASTNAME; + /** the column name for the BIO field */ + public static final String BIO; + /** the column name for the HISTORY field */ + public static final String HISTORY; + /** the column name for the PARENT_ORGANIZATION field */ + public static final String PARENT_ORGANIZATION; + /** the column name for the SCHOOL field */ + public static final String SCHOOL; + /** the column name for the DEPARTMENT field */ + public static final String DEPARTMENT; + /** the column name for the PROGRAM field */ + public static final String PROGRAM; + /** the column name for the ADVISOR field */ + public static final String ADVISOR; + /** the column name for the HIGHEST_DEGREE field */ + public static final String HIGHEST_DEGREE; + /** the column name for the YEAR_BEGAN field */ + public static final String YEAR_BEGAN; + /** the column name for the YEAR_FINISHED field */ + public static final String YEAR_FINISHED; + /** the column name for the OTHER_BACKGROUNDS field */ + public static final String OTHER_BACKGROUNDS; + /** the column name for the ORGANIZATION field */ + public static final String ORGANIZATION; + /** the column name for the DIVISION field */ + public static final String DIVISION; + /** the column name for the TITLE field */ + public static final String TITLE; + /** the column name for the START_DATE field */ + public static final String START_DATE; + /** the column name for the JOB_DESCRIPTION field */ + public static final String JOB_DESCRIPTION; + + static + { + ID = "PersonData.ID"; + THDL_USER_ID = "PersonData.THDL_USER_ID"; + FIRSTNAME = "PersonData.FIRSTNAME"; + MIDDLENAME = "PersonData.MIDDLENAME"; + LASTNAME = "PersonData.LASTNAME"; + BIO = "PersonData.BIO"; + HISTORY = "PersonData.HISTORY"; + PARENT_ORGANIZATION = "PersonData.PARENT_ORGANIZATION"; + SCHOOL = "PersonData.SCHOOL"; + DEPARTMENT = "PersonData.DEPARTMENT"; + PROGRAM = "PersonData.PROGRAM"; + ADVISOR = "PersonData.ADVISOR"; + HIGHEST_DEGREE = "PersonData.HIGHEST_DEGREE"; + YEAR_BEGAN = "PersonData.YEAR_BEGAN"; + YEAR_FINISHED = "PersonData.YEAR_FINISHED"; + OTHER_BACKGROUNDS = "PersonData.OTHER_BACKGROUNDS"; + ORGANIZATION = "PersonData.ORGANIZATION"; + DIVISION = "PersonData.DIVISION"; + TITLE = "PersonData.TITLE"; + START_DATE = "PersonData.START_DATE"; + JOB_DESCRIPTION = "PersonData.JOB_DESCRIPTION"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(PersonDataMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 21; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.PersonData"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BasePersonDataPeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(THDL_USER_ID); + criteria.addSelectColumn(FIRSTNAME); + criteria.addSelectColumn(MIDDLENAME); + criteria.addSelectColumn(LASTNAME); + criteria.addSelectColumn(BIO); + criteria.addSelectColumn(HISTORY); + criteria.addSelectColumn(PARENT_ORGANIZATION); + criteria.addSelectColumn(SCHOOL); + criteria.addSelectColumn(DEPARTMENT); + criteria.addSelectColumn(PROGRAM); + criteria.addSelectColumn(ADVISOR); + criteria.addSelectColumn(HIGHEST_DEGREE); + criteria.addSelectColumn(YEAR_BEGAN); + criteria.addSelectColumn(YEAR_FINISHED); + criteria.addSelectColumn(OTHER_BACKGROUNDS); + criteria.addSelectColumn(ORGANIZATION); + criteria.addSelectColumn(DIVISION); + criteria.addSelectColumn(TITLE); + criteria.addSelectColumn(START_DATE); + criteria.addSelectColumn(JOB_DESCRIPTION); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static PersonData row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + PersonData obj = (PersonData) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + PersonData obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setThdlUserId(row.getValue(offset + 1).asIntegerObj()); + obj.setFirstname(row.getValue(offset + 2).asString()); + obj.setMiddlename(row.getValue(offset + 3).asString()); + obj.setLastname(row.getValue(offset + 4).asString()); + obj.setBio(row.getValue(offset + 5).asString()); + obj.setHistory(row.getValue(offset + 6).asString()); + obj.setParentOrganization(row.getValue(offset + 7).asString()); + obj.setSchool(row.getValue(offset + 8).asString()); + obj.setDepartment(row.getValue(offset + 9).asString()); + obj.setProgram(row.getValue(offset + 10).asString()); + obj.setAdvisor(row.getValue(offset + 11).asString()); + obj.setHighestDegree(row.getValue(offset + 12).asString()); + obj.setYearBegan(row.getValue(offset + 13).asIntegerObj()); + obj.setYearFinished(row.getValue(offset + 14).asIntegerObj()); + obj.setOtherBackgrounds(row.getValue(offset + 15).asString()); + obj.setOrganization(row.getValue(offset + 16).asString()); + obj.setDivision(row.getValue(offset + 17).asString()); + obj.setTitle(row.getValue(offset + 18).asString()); + obj.setStartDate(row.getValue(offset + 19).asIntegerObj()); + obj.setJobDescription(row.getValue(offset + 20).asString()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BasePersonDataPeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(PersonDataPeer.row2Object(row, 1, + PersonDataPeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BasePersonDataPeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BasePersonDataPeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(PersonData obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(PersonData obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(PersonData obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(PersonData obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(PersonData) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(PersonData obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(PersonData) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(PersonData obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(PersonData) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(PersonData obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BasePersonDataPeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( PersonData obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(THDL_USER_ID, obj.getThdlUserId()); + criteria.add(FIRSTNAME, obj.getFirstname()); + criteria.add(MIDDLENAME, obj.getMiddlename()); + criteria.add(LASTNAME, obj.getLastname()); + criteria.add(BIO, obj.getBio()); + criteria.add(HISTORY, obj.getHistory()); + criteria.add(PARENT_ORGANIZATION, obj.getParentOrganization()); + criteria.add(SCHOOL, obj.getSchool()); + criteria.add(DEPARTMENT, obj.getDepartment()); + criteria.add(PROGRAM, obj.getProgram()); + criteria.add(ADVISOR, obj.getAdvisor()); + criteria.add(HIGHEST_DEGREE, obj.getHighestDegree()); + criteria.add(YEAR_BEGAN, obj.getYearBegan()); + criteria.add(YEAR_FINISHED, obj.getYearFinished()); + criteria.add(OTHER_BACKGROUNDS, obj.getOtherBackgrounds()); + criteria.add(ORGANIZATION, obj.getOrganization()); + criteria.add(DIVISION, obj.getDivision()); + criteria.add(TITLE, obj.getTitle()); + criteria.add(START_DATE, obj.getStartDate()); + criteria.add(JOB_DESCRIPTION, obj.getJobDescription()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static PersonData retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static PersonData retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + PersonData retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static PersonData retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (PersonData)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BasePersonPersonType.java b/src/java/org/thdl/roster/om/BasePersonPersonType.java new file mode 100755 index 0000000..68b66ae --- /dev/null +++ b/src/java/org/thdl/roster/om/BasePersonPersonType.java @@ -0,0 +1,584 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to PersonPersonType + */ +public abstract class BasePersonPersonType extends BaseObject +{ + /** The Peer class */ + private static final PersonPersonTypePeer peer = + new PersonPersonTypePeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the person_type_id field + */ + private Integer person_type_id; + + /** + * The value for the person_data_id field + */ + private Integer person_data_id; + + /** + * The value for the relevance field + */ + private Integer relevance; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + } + + + /** + * Get the PersonTypeId + * + * @return Integer + */ + public Integer getPersonTypeId() + { + return person_type_id; + } + + + /** + * Set the value of PersonTypeId + * + * @param v new value + */ + public void setPersonTypeId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.person_type_id, v)) + { + this.person_type_id = v; + setModified(true); + } + + + if (aPersonType != null && !ObjectUtils.equals(aPersonType.getId(), v)) + { + aPersonType = null; + } + + } + + + /** + * Get the PersonDataId + * + * @return Integer + */ + public Integer getPersonDataId() + { + return person_data_id; + } + + + /** + * Set the value of PersonDataId + * + * @param v new value + */ + public void setPersonDataId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.person_data_id, v)) + { + this.person_data_id = v; + setModified(true); + } + + + if (aPersonData != null && !ObjectUtils.equals(aPersonData.getId(), v)) + { + aPersonData = null; + } + + } + + + /** + * Get the Relevance + * + * @return Integer + */ + public Integer getRelevance() + { + return relevance; + } + + + /** + * Set the value of Relevance + * + * @param v new value + */ + public void setRelevance(Integer v) + { + + + + if (!ObjectUtils.equals(this.relevance, v)) + { + this.relevance = v; + setModified(true); + } + + + } + + + + + + + + private PersonData aPersonData; + + /** + * Declares an association between this object and a PersonData object + * + * @param v PersonData + * @throws TorqueException + */ + public void setPersonData(PersonData v) throws TorqueException + { + if (v == null) + { + setPersonDataId((Integer)null); + } + else + { + setPersonDataId(v.getId()); + } + aPersonData = v; + } + + + /** + * Get the associated PersonData object + * + * @return the associated PersonData object + * @throws TorqueException + */ + public PersonData getPersonData() throws TorqueException + { + if (aPersonData == null && (!ObjectUtils.equals(this.person_data_id, null))) + { + aPersonData = PersonDataPeer.retrieveByPK(SimpleKey.keyFor(this.person_data_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + PersonData obj = PersonDataPeer.retrieveByPK(this.person_data_id); + obj.addPersonPersonTypes(this); + */ + } + return aPersonData; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setPersonDataKey(ObjectKey key) throws TorqueException + { + + setPersonDataId(new Integer(((NumberKey) key).intValue())); + } + + + + + private PersonType aPersonType; + + /** + * Declares an association between this object and a PersonType object + * + * @param v PersonType + * @throws TorqueException + */ + public void setPersonType(PersonType v) throws TorqueException + { + if (v == null) + { + setPersonTypeId((Integer)null); + } + else + { + setPersonTypeId(v.getId()); + } + aPersonType = v; + } + + + /** + * Get the associated PersonType object + * + * @return the associated PersonType object + * @throws TorqueException + */ + public PersonType getPersonType() throws TorqueException + { + if (aPersonType == null && (!ObjectUtils.equals(this.person_type_id, null))) + { + aPersonType = PersonTypePeer.retrieveByPK(SimpleKey.keyFor(this.person_type_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + PersonType obj = PersonTypePeer.retrieveByPK(this.person_type_id); + obj.addPersonPersonTypes(this); + */ + } + return aPersonType; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setPersonTypeKey(ObjectKey key) throws TorqueException + { + + setPersonTypeId(new Integer(((NumberKey) key).intValue())); + } + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("PersonTypeId"); + fieldNames.add("PersonDataId"); + fieldNames.add("Relevance"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("PersonTypeId")) + { + return getPersonTypeId(); + } + if (name.equals("PersonDataId")) + { + return getPersonDataId(); + } + if (name.equals("Relevance")) + { + return getRelevance(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(PersonPersonTypePeer.ID)) + { + return getId(); + } + if (name.equals(PersonPersonTypePeer.PERSON_TYPE_ID)) + { + return getPersonTypeId(); + } + if (name.equals(PersonPersonTypePeer.PERSON_DATA_ID)) + { + return getPersonDataId(); + } + if (name.equals(PersonPersonTypePeer.RELEVANCE)) + { + return getRelevance(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getPersonTypeId(); + } + if (pos == 2) + { + return getPersonDataId(); + } + if (pos == 3) + { + return getRelevance(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(PersonPersonTypePeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + PersonPersonTypePeer.doInsert((PersonPersonType) this, con); + setNew(false); + } + else + { + PersonPersonTypePeer.doUpdate((PersonPersonType) this, con); + } + } + + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public PersonPersonType copy() throws TorqueException + { + return copyInto(new PersonPersonType()); + } + + protected PersonPersonType copyInto(PersonPersonType copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setPersonTypeId(person_type_id); + copyObj.setPersonDataId(person_data_id); + copyObj.setRelevance(relevance); + + copyObj.setNew(false); + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public PersonPersonTypePeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BasePersonPersonTypePeer.java b/src/java/org/thdl/roster/om/BasePersonPersonTypePeer.java new file mode 100755 index 0000000..31e64a3 --- /dev/null +++ b/src/java/org/thdl/roster/om/BasePersonPersonTypePeer.java @@ -0,0 +1,946 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BasePersonPersonTypePeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "PersonPersonType"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(PersonPersonTypeMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the PERSON_TYPE_ID field */ + public static final String PERSON_TYPE_ID; + /** the column name for the PERSON_DATA_ID field */ + public static final String PERSON_DATA_ID; + /** the column name for the RELEVANCE field */ + public static final String RELEVANCE; + + static + { + ID = "PersonPersonType.ID"; + PERSON_TYPE_ID = "PersonPersonType.PERSON_TYPE_ID"; + PERSON_DATA_ID = "PersonPersonType.PERSON_DATA_ID"; + RELEVANCE = "PersonPersonType.RELEVANCE"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(PersonPersonTypeMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 4; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.PersonPersonType"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BasePersonPersonTypePeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(PERSON_TYPE_ID); + criteria.addSelectColumn(PERSON_DATA_ID); + criteria.addSelectColumn(RELEVANCE); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static PersonPersonType row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + PersonPersonType obj = (PersonPersonType) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + PersonPersonType obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setPersonTypeId(row.getValue(offset + 1).asIntegerObj()); + obj.setPersonDataId(row.getValue(offset + 2).asIntegerObj()); + obj.setRelevance(row.getValue(offset + 3).asIntegerObj()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BasePersonPersonTypePeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(PersonPersonTypePeer.row2Object(row, 1, + PersonPersonTypePeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BasePersonPersonTypePeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BasePersonPersonTypePeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(PersonPersonType obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(PersonPersonType obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(PersonPersonType obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(PersonPersonType obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(PersonPersonType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(PersonPersonType obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(PersonPersonType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(PersonPersonType obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(PersonPersonType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(PersonPersonType obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BasePersonPersonTypePeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( PersonPersonType obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(PERSON_TYPE_ID, obj.getPersonTypeId()); + criteria.add(PERSON_DATA_ID, obj.getPersonDataId()); + criteria.add(RELEVANCE, obj.getRelevance()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static PersonPersonType retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static PersonPersonType retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + PersonPersonType retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static PersonPersonType retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (PersonPersonType)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + + + /** + * selects a collection of PersonPersonType objects pre-filled with their + * PersonData objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in PersonPersonTypePeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinPersonData(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + PersonPersonTypePeer.addSelectColumns(c); + int offset = numColumns + 1; + PersonDataPeer.addSelectColumns(c); + + + c.addJoin(PersonPersonTypePeer.PERSON_DATA_ID, + PersonDataPeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = PersonPersonTypePeer.getOMClass(); + + PersonPersonType obj1 = (PersonPersonType) PersonPersonTypePeer + .row2Object(row, 1, omClass); + + + omClass = PersonDataPeer.getOMClass(); + PersonData obj2 = (PersonData)PersonDataPeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + PersonPersonType temp_obj1 = (PersonPersonType)results.get(j); + PersonData temp_obj2 = (PersonData)temp_obj1.getPersonData(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addPersonPersonType(obj1); + break; + } + } + if (newObject) + { + obj2.initPersonPersonTypes(); + obj2.addPersonPersonType(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + + /** + * selects a collection of PersonPersonType objects pre-filled with their + * PersonType objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in PersonPersonTypePeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinPersonType(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + PersonPersonTypePeer.addSelectColumns(c); + int offset = numColumns + 1; + PersonTypePeer.addSelectColumns(c); + + + c.addJoin(PersonPersonTypePeer.PERSON_TYPE_ID, + PersonTypePeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = PersonPersonTypePeer.getOMClass(); + + PersonPersonType obj1 = (PersonPersonType) PersonPersonTypePeer + .row2Object(row, 1, omClass); + + + omClass = PersonTypePeer.getOMClass(); + PersonType obj2 = (PersonType)PersonTypePeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + PersonPersonType temp_obj1 = (PersonPersonType)results.get(j); + PersonType temp_obj2 = (PersonType)temp_obj1.getPersonType(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addPersonPersonType(obj1); + break; + } + } + if (newObject) + { + obj2.initPersonPersonTypes(); + obj2.addPersonPersonType(obj1); + } + results.add(obj1); + } + return results; + } + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BasePersonType.java b/src/java/org/thdl/roster/om/BasePersonType.java new file mode 100755 index 0000000..67202da --- /dev/null +++ b/src/java/org/thdl/roster/om/BasePersonType.java @@ -0,0 +1,561 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to PersonType + */ +public abstract class BasePersonType extends BaseObject +{ + /** The Peer class */ + private static final PersonTypePeer peer = + new PersonTypePeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the person_type field + */ + private String person_type; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + + // update associated PersonPersonType + if (collPersonPersonTypes != null) + { + for (int i = 0; i < collPersonPersonTypes.size(); i++) + { + ((PersonPersonType) collPersonPersonTypes.get(i)) + .setPersonTypeId(v); + } + } + } + + + /** + * Get the PersonType + * + * @return String + */ + public String getPersonType() + { + return person_type; + } + + + /** + * Set the value of PersonType + * + * @param v new value + */ + public void setPersonType(String v) + { + + + + if (!ObjectUtils.equals(this.person_type, v)) + { + this.person_type = v; + setModified(true); + } + + + } + + + + + + + /** + * Collection to store aggregation of collPersonPersonTypes + */ + protected List collPersonPersonTypes; + + /** + * Temporary storage of collPersonPersonTypes to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initPersonPersonTypes() + { + if (collPersonPersonTypes == null) + { + collPersonPersonTypes = new ArrayList(); + } + } + + /** + * Method called to associate a PersonPersonType object to this object + * through the PersonPersonType foreign key attribute + * + * @param l PersonPersonType + * @throws TorqueException + */ + public void addPersonPersonType(PersonPersonType l) throws TorqueException + { + getPersonPersonTypes().add(l); + l.setPersonType((PersonType) this); + } + + /** + * The criteria used to select the current contents of collPersonPersonTypes + */ + private Criteria lastPersonPersonTypesCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getPersonPersonTypes(new Criteria()) + * + * @throws TorqueException + */ + public List getPersonPersonTypes() throws TorqueException + { + if (collPersonPersonTypes == null) + { + collPersonPersonTypes = getPersonPersonTypes(new Criteria(10)); + } + return collPersonPersonTypes; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this PersonType has previously + * been saved, it will retrieve related PersonPersonTypes from storage. + * If this PersonType is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getPersonPersonTypes(Criteria criteria) throws TorqueException + { + if (collPersonPersonTypes == null) + { + if (isNew()) + { + collPersonPersonTypes = new ArrayList(); + } + else + { + criteria.add(PersonPersonTypePeer.PERSON_TYPE_ID, getId() ); + collPersonPersonTypes = PersonPersonTypePeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(PersonPersonTypePeer.PERSON_TYPE_ID, getId()); + if (!lastPersonPersonTypesCriteria.equals(criteria)) + { + collPersonPersonTypes = PersonPersonTypePeer.doSelect(criteria); + } + } + } + lastPersonPersonTypesCriteria = criteria; + + return collPersonPersonTypes; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getPersonPersonTypes(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getPersonPersonTypes(Connection con) throws TorqueException + { + if (collPersonPersonTypes == null) + { + collPersonPersonTypes = getPersonPersonTypes(new Criteria(10), con); + } + return collPersonPersonTypes; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this PersonType has previously + * been saved, it will retrieve related PersonPersonTypes from storage. + * If this PersonType is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getPersonPersonTypes(Criteria criteria, Connection con) + throws TorqueException + { + if (collPersonPersonTypes == null) + { + if (isNew()) + { + collPersonPersonTypes = new ArrayList(); + } + else + { + criteria.add(PersonPersonTypePeer.PERSON_TYPE_ID, getId()); + collPersonPersonTypes = PersonPersonTypePeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(PersonPersonTypePeer.PERSON_TYPE_ID, getId()); + if (!lastPersonPersonTypesCriteria.equals(criteria)) + { + collPersonPersonTypes = PersonPersonTypePeer.doSelect(criteria, con); + } + } + } + lastPersonPersonTypesCriteria = criteria; + + return collPersonPersonTypes; + } + + + + + + + + + + + + + + + + + + + + + + + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("PersonType"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("PersonType")) + { + return getPersonType(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(PersonTypePeer.ID)) + { + return getId(); + } + if (name.equals(PersonTypePeer.PERSON_TYPE)) + { + return getPersonType(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getPersonType(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(PersonTypePeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + PersonTypePeer.doInsert((PersonType) this, con); + setNew(false); + } + else + { + PersonTypePeer.doUpdate((PersonType) this, con); + } + } + + + + if (collPersonPersonTypes != null) + { + for (int i = 0; i < collPersonPersonTypes.size(); i++) + { + ((PersonPersonType) collPersonPersonTypes.get(i)).save(con); + } + } + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + throws TorqueException + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) throws TorqueException + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public PersonType copy() throws TorqueException + { + return copyInto(new PersonType()); + } + + protected PersonType copyInto(PersonType copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setPersonType(person_type); + + copyObj.setNew(false); + + + List v = getPersonPersonTypes(); + for (int i = 0; i < v.size(); i++) + { + PersonPersonType obj = (PersonPersonType) v.get(i); + copyObj.addPersonPersonType(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public PersonTypePeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BasePersonTypePeer.java b/src/java/org/thdl/roster/om/BasePersonTypePeer.java new file mode 100755 index 0000000..b48199e --- /dev/null +++ b/src/java/org/thdl/roster/om/BasePersonTypePeer.java @@ -0,0 +1,778 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BasePersonTypePeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "PersonType"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(PersonTypeMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the PERSON_TYPE field */ + public static final String PERSON_TYPE; + + static + { + ID = "PersonType.ID"; + PERSON_TYPE = "PersonType.PERSON_TYPE"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(PersonTypeMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 2; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.PersonType"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BasePersonTypePeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(PERSON_TYPE); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static PersonType row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + PersonType obj = (PersonType) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + PersonType obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setPersonType(row.getValue(offset + 1).asString()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BasePersonTypePeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(PersonTypePeer.row2Object(row, 1, + PersonTypePeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BasePersonTypePeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BasePersonTypePeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(PersonType obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(PersonType obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(PersonType obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(PersonType obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(PersonType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(PersonType obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(PersonType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(PersonType obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(PersonType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(PersonType obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BasePersonTypePeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( PersonType obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(PERSON_TYPE, obj.getPersonType()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static PersonType retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static PersonType retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + PersonType retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static PersonType retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (PersonType)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BasePhone.java b/src/java/org/thdl/roster/om/BasePhone.java new file mode 100755 index 0000000..20d8201 --- /dev/null +++ b/src/java/org/thdl/roster/om/BasePhone.java @@ -0,0 +1,890 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to Phone + */ +public abstract class BasePhone extends BaseObject +{ + /** The Peer class */ + private static final PhonePeer peer = + new PhonePeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the country_code field + */ + private Integer country_code; + + /** + * The value for the area_code field + */ + private Integer area_code; + + /** + * The value for the number field + */ + private Integer number; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + + // update associated ContactInfo + if (collContactInfosRelatedByPhone != null) + { + for (int i = 0; i < collContactInfosRelatedByPhone.size(); i++) + { + ((ContactInfo) collContactInfosRelatedByPhone.get(i)) + .setPhone(v); + } + } + + // update associated ContactInfo + if (collContactInfosRelatedByFax != null) + { + for (int i = 0; i < collContactInfosRelatedByFax.size(); i++) + { + ((ContactInfo) collContactInfosRelatedByFax.get(i)) + .setFax(v); + } + } + } + + + /** + * Get the CountryCode + * + * @return Integer + */ + public Integer getCountryCode() + { + return country_code; + } + + + /** + * Set the value of CountryCode + * + * @param v new value + */ + public void setCountryCode(Integer v) + { + + + + if (!ObjectUtils.equals(this.country_code, v)) + { + this.country_code = v; + setModified(true); + } + + + } + + + /** + * Get the AreaCode + * + * @return Integer + */ + public Integer getAreaCode() + { + return area_code; + } + + + /** + * Set the value of AreaCode + * + * @param v new value + */ + public void setAreaCode(Integer v) + { + + + + if (!ObjectUtils.equals(this.area_code, v)) + { + this.area_code = v; + setModified(true); + } + + + } + + + /** + * Get the Number + * + * @return Integer + */ + public Integer getNumber() + { + return number; + } + + + /** + * Set the value of Number + * + * @param v new value + */ + public void setNumber(Integer v) + { + + + + if (!ObjectUtils.equals(this.number, v)) + { + this.number = v; + setModified(true); + } + + + } + + + + + + + /** + * Collection to store aggregation of collContactInfosRelatedByPhone + */ + protected List collContactInfosRelatedByPhone; + + /** + * Temporary storage of collContactInfosRelatedByPhone to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initContactInfosRelatedByPhone() + { + if (collContactInfosRelatedByPhone == null) + { + collContactInfosRelatedByPhone = new ArrayList(); + } + } + + /** + * Method called to associate a ContactInfo object to this object + * through the ContactInfo foreign key attribute + * + * @param l ContactInfo + * @throws TorqueException + */ + public void addContactInfoRelatedByPhone(ContactInfo l) throws TorqueException + { + getContactInfosRelatedByPhone().add(l); + l.setPhoneRelatedByPhone((Phone) this); + } + + /** + * The criteria used to select the current contents of collContactInfosRelatedByPhone + */ + private Criteria lastContactInfosRelatedByPhoneCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getContactInfosRelatedByPhone(new Criteria()) + * + * @throws TorqueException + */ + public List getContactInfosRelatedByPhone() throws TorqueException + { + if (collContactInfosRelatedByPhone == null) + { + collContactInfosRelatedByPhone = getContactInfosRelatedByPhone(new Criteria(10)); + } + return collContactInfosRelatedByPhone; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Phone has previously + * been saved, it will retrieve related ContactInfosRelatedByPhone from storage. + * If this Phone is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getContactInfosRelatedByPhone(Criteria criteria) throws TorqueException + { + if (collContactInfosRelatedByPhone == null) + { + if (isNew()) + { + collContactInfosRelatedByPhone = new ArrayList(); + } + else + { + criteria.add(ContactInfoPeer.PHONE, getId() ); + collContactInfosRelatedByPhone = ContactInfoPeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ContactInfoPeer.PHONE, getId()); + if (!lastContactInfosRelatedByPhoneCriteria.equals(criteria)) + { + collContactInfosRelatedByPhone = ContactInfoPeer.doSelect(criteria); + } + } + } + lastContactInfosRelatedByPhoneCriteria = criteria; + + return collContactInfosRelatedByPhone; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getContactInfosRelatedByPhone(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getContactInfosRelatedByPhone(Connection con) throws TorqueException + { + if (collContactInfosRelatedByPhone == null) + { + collContactInfosRelatedByPhone = getContactInfosRelatedByPhone(new Criteria(10), con); + } + return collContactInfosRelatedByPhone; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Phone has previously + * been saved, it will retrieve related ContactInfosRelatedByPhone from storage. + * If this Phone is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getContactInfosRelatedByPhone(Criteria criteria, Connection con) + throws TorqueException + { + if (collContactInfosRelatedByPhone == null) + { + if (isNew()) + { + collContactInfosRelatedByPhone = new ArrayList(); + } + else + { + criteria.add(ContactInfoPeer.PHONE, getId()); + collContactInfosRelatedByPhone = ContactInfoPeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ContactInfoPeer.PHONE, getId()); + if (!lastContactInfosRelatedByPhoneCriteria.equals(criteria)) + { + collContactInfosRelatedByPhone = ContactInfoPeer.doSelect(criteria, con); + } + } + } + lastContactInfosRelatedByPhoneCriteria = criteria; + + return collContactInfosRelatedByPhone; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /** + * Collection to store aggregation of collContactInfosRelatedByFax + */ + protected List collContactInfosRelatedByFax; + + /** + * Temporary storage of collContactInfosRelatedByFax to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initContactInfosRelatedByFax() + { + if (collContactInfosRelatedByFax == null) + { + collContactInfosRelatedByFax = new ArrayList(); + } + } + + /** + * Method called to associate a ContactInfo object to this object + * through the ContactInfo foreign key attribute + * + * @param l ContactInfo + * @throws TorqueException + */ + public void addContactInfoRelatedByFax(ContactInfo l) throws TorqueException + { + getContactInfosRelatedByFax().add(l); + l.setPhoneRelatedByFax((Phone) this); + } + + /** + * The criteria used to select the current contents of collContactInfosRelatedByFax + */ + private Criteria lastContactInfosRelatedByFaxCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getContactInfosRelatedByFax(new Criteria()) + * + * @throws TorqueException + */ + public List getContactInfosRelatedByFax() throws TorqueException + { + if (collContactInfosRelatedByFax == null) + { + collContactInfosRelatedByFax = getContactInfosRelatedByFax(new Criteria(10)); + } + return collContactInfosRelatedByFax; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Phone has previously + * been saved, it will retrieve related ContactInfosRelatedByFax from storage. + * If this Phone is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getContactInfosRelatedByFax(Criteria criteria) throws TorqueException + { + if (collContactInfosRelatedByFax == null) + { + if (isNew()) + { + collContactInfosRelatedByFax = new ArrayList(); + } + else + { + criteria.add(ContactInfoPeer.FAX, getId() ); + collContactInfosRelatedByFax = ContactInfoPeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ContactInfoPeer.FAX, getId()); + if (!lastContactInfosRelatedByFaxCriteria.equals(criteria)) + { + collContactInfosRelatedByFax = ContactInfoPeer.doSelect(criteria); + } + } + } + lastContactInfosRelatedByFaxCriteria = criteria; + + return collContactInfosRelatedByFax; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getContactInfosRelatedByFax(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getContactInfosRelatedByFax(Connection con) throws TorqueException + { + if (collContactInfosRelatedByFax == null) + { + collContactInfosRelatedByFax = getContactInfosRelatedByFax(new Criteria(10), con); + } + return collContactInfosRelatedByFax; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Phone has previously + * been saved, it will retrieve related ContactInfosRelatedByFax from storage. + * If this Phone is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getContactInfosRelatedByFax(Criteria criteria, Connection con) + throws TorqueException + { + if (collContactInfosRelatedByFax == null) + { + if (isNew()) + { + collContactInfosRelatedByFax = new ArrayList(); + } + else + { + criteria.add(ContactInfoPeer.FAX, getId()); + collContactInfosRelatedByFax = ContactInfoPeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ContactInfoPeer.FAX, getId()); + if (!lastContactInfosRelatedByFaxCriteria.equals(criteria)) + { + collContactInfosRelatedByFax = ContactInfoPeer.doSelect(criteria, con); + } + } + } + lastContactInfosRelatedByFaxCriteria = criteria; + + return collContactInfosRelatedByFax; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("CountryCode"); + fieldNames.add("AreaCode"); + fieldNames.add("Number"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("CountryCode")) + { + return getCountryCode(); + } + if (name.equals("AreaCode")) + { + return getAreaCode(); + } + if (name.equals("Number")) + { + return getNumber(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(PhonePeer.ID)) + { + return getId(); + } + if (name.equals(PhonePeer.COUNTRY_CODE)) + { + return getCountryCode(); + } + if (name.equals(PhonePeer.AREA_CODE)) + { + return getAreaCode(); + } + if (name.equals(PhonePeer.NUMBER)) + { + return getNumber(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getCountryCode(); + } + if (pos == 2) + { + return getAreaCode(); + } + if (pos == 3) + { + return getNumber(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(PhonePeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + PhonePeer.doInsert((Phone) this, con); + setNew(false); + } + else + { + PhonePeer.doUpdate((Phone) this, con); + } + } + + + + if (collContactInfosRelatedByPhone != null) + { + for (int i = 0; i < collContactInfosRelatedByPhone.size(); i++) + { + ((ContactInfo) collContactInfosRelatedByPhone.get(i)).save(con); + } + } + + + if (collContactInfosRelatedByFax != null) + { + for (int i = 0; i < collContactInfosRelatedByFax.size(); i++) + { + ((ContactInfo) collContactInfosRelatedByFax.get(i)).save(con); + } + } + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + throws TorqueException + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) throws TorqueException + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public Phone copy() throws TorqueException + { + return copyInto(new Phone()); + } + + protected Phone copyInto(Phone copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setCountryCode(country_code); + copyObj.setAreaCode(area_code); + copyObj.setNumber(number); + + copyObj.setNew(false); + + + List v = getContactInfosRelatedByPhone(); + for (int i = 0; i < v.size(); i++) + { + ContactInfo obj = (ContactInfo) v.get(i); + copyObj.addContactInfoRelatedByPhone(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + + + v = getContactInfosRelatedByFax(); + for (int i = 0; i < v.size(); i++) + { + ContactInfo obj = (ContactInfo) v.get(i); + copyObj.addContactInfoRelatedByFax(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public PhonePeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BasePhonePeer.java b/src/java/org/thdl/roster/om/BasePhonePeer.java new file mode 100755 index 0000000..1090992 --- /dev/null +++ b/src/java/org/thdl/roster/om/BasePhonePeer.java @@ -0,0 +1,790 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BasePhonePeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "Phone"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(PhoneMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the COUNTRY_CODE field */ + public static final String COUNTRY_CODE; + /** the column name for the AREA_CODE field */ + public static final String AREA_CODE; + /** the column name for the NUMBER field */ + public static final String NUMBER; + + static + { + ID = "Phone.ID"; + COUNTRY_CODE = "Phone.COUNTRY_CODE"; + AREA_CODE = "Phone.AREA_CODE"; + NUMBER = "Phone.NUMBER"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(PhoneMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 4; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.Phone"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BasePhonePeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(COUNTRY_CODE); + criteria.addSelectColumn(AREA_CODE); + criteria.addSelectColumn(NUMBER); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Phone row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + Phone obj = (Phone) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + Phone obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setCountryCode(row.getValue(offset + 1).asIntegerObj()); + obj.setAreaCode(row.getValue(offset + 2).asIntegerObj()); + obj.setNumber(row.getValue(offset + 3).asIntegerObj()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BasePhonePeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(PhonePeer.row2Object(row, 1, + PhonePeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BasePhonePeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BasePhonePeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Phone obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(Phone obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Phone obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Phone obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Phone) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(Phone obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(Phone) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Phone obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(Phone) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Phone obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BasePhonePeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( Phone obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(COUNTRY_CODE, obj.getCountryCode()); + criteria.add(AREA_CODE, obj.getAreaCode()); + criteria.add(NUMBER, obj.getNumber()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Phone retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Phone retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + Phone retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Phone retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (Phone)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BaseProjectData.java b/src/java/org/thdl/roster/om/BaseProjectData.java new file mode 100755 index 0000000..017c110 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseProjectData.java @@ -0,0 +1,1206 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to ProjectData + */ +public abstract class BaseProjectData extends BaseObject +{ + /** The Peer class */ + private static final ProjectDataPeer peer = + new ProjectDataPeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the name field + */ + private String name; + + /** + * The value for the parent_organization field + */ + private String parent_organization; + + /** + * The value for the divisions field + */ + private String divisions; + + /** + * The value for the people field + */ + private String people; + + /** + * The value for the mailing_list field + */ + private String mailing_list; + + /** + * The value for the description field + */ + private String description; + + /** + * The value for the history field + */ + private String history; + + /** + * The value for the education_programs field + */ + private String education_programs; + + /** + * The value for the resources field + */ + private String resources; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + + // update associated Member + if (collMembers != null) + { + for (int i = 0; i < collMembers.size(); i++) + { + ((Member) collMembers.get(i)) + .setProjectDataId(v); + } + } + + // update associated ProjectProjectType + if (collProjectProjectTypes != null) + { + for (int i = 0; i < collProjectProjectTypes.size(); i++) + { + ((ProjectProjectType) collProjectProjectTypes.get(i)) + .setProjectDataId(v); + } + } + } + + + /** + * Get the Name + * + * @return String + */ + public String getName() + { + return name; + } + + + /** + * Set the value of Name + * + * @param v new value + */ + public void setName(String v) + { + + + + if (!ObjectUtils.equals(this.name, v)) + { + this.name = v; + setModified(true); + } + + + } + + + /** + * Get the ParentOrganization + * + * @return String + */ + public String getParentOrganization() + { + return parent_organization; + } + + + /** + * Set the value of ParentOrganization + * + * @param v new value + */ + public void setParentOrganization(String v) + { + + + + if (!ObjectUtils.equals(this.parent_organization, v)) + { + this.parent_organization = v; + setModified(true); + } + + + } + + + /** + * Get the Divisions + * + * @return String + */ + public String getDivisions() + { + return divisions; + } + + + /** + * Set the value of Divisions + * + * @param v new value + */ + public void setDivisions(String v) + { + + + + if (!ObjectUtils.equals(this.divisions, v)) + { + this.divisions = v; + setModified(true); + } + + + } + + + /** + * Get the People + * + * @return String + */ + public String getPeople() + { + return people; + } + + + /** + * Set the value of People + * + * @param v new value + */ + public void setPeople(String v) + { + + + + if (!ObjectUtils.equals(this.people, v)) + { + this.people = v; + setModified(true); + } + + + } + + + /** + * Get the MailingList + * + * @return String + */ + public String getMailingList() + { + return mailing_list; + } + + + /** + * Set the value of MailingList + * + * @param v new value + */ + public void setMailingList(String v) + { + + + + if (!ObjectUtils.equals(this.mailing_list, v)) + { + this.mailing_list = v; + setModified(true); + } + + + } + + + /** + * Get the Description + * + * @return String + */ + public String getDescription() + { + return description; + } + + + /** + * Set the value of Description + * + * @param v new value + */ + public void setDescription(String v) + { + + + + if (!ObjectUtils.equals(this.description, v)) + { + this.description = v; + setModified(true); + } + + + } + + + /** + * Get the History + * + * @return String + */ + public String getHistory() + { + return history; + } + + + /** + * Set the value of History + * + * @param v new value + */ + public void setHistory(String v) + { + + + + if (!ObjectUtils.equals(this.history, v)) + { + this.history = v; + setModified(true); + } + + + } + + + /** + * Get the EducationPrograms + * + * @return String + */ + public String getEducationPrograms() + { + return education_programs; + } + + + /** + * Set the value of EducationPrograms + * + * @param v new value + */ + public void setEducationPrograms(String v) + { + + + + if (!ObjectUtils.equals(this.education_programs, v)) + { + this.education_programs = v; + setModified(true); + } + + + } + + + /** + * Get the Resources + * + * @return String + */ + public String getResources() + { + return resources; + } + + + /** + * Set the value of Resources + * + * @param v new value + */ + public void setResources(String v) + { + + + + if (!ObjectUtils.equals(this.resources, v)) + { + this.resources = v; + setModified(true); + } + + + } + + + + + + + /** + * Collection to store aggregation of collMembers + */ + protected List collMembers; + + /** + * Temporary storage of collMembers to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initMembers() + { + if (collMembers == null) + { + collMembers = new ArrayList(); + } + } + + /** + * Method called to associate a Member object to this object + * through the Member foreign key attribute + * + * @param l Member + * @throws TorqueException + */ + public void addMember(Member l) throws TorqueException + { + getMembers().add(l); + l.setProjectData((ProjectData) this); + } + + /** + * The criteria used to select the current contents of collMembers + */ + private Criteria lastMembersCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getMembers(new Criteria()) + * + * @throws TorqueException + */ + public List getMembers() throws TorqueException + { + if (collMembers == null) + { + collMembers = getMembers(new Criteria(10)); + } + return collMembers; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this ProjectData has previously + * been saved, it will retrieve related Members from storage. + * If this ProjectData is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getMembers(Criteria criteria) throws TorqueException + { + if (collMembers == null) + { + if (isNew()) + { + collMembers = new ArrayList(); + } + else + { + criteria.add(MemberPeer.PROJECT_DATA_ID, getId() ); + collMembers = MemberPeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(MemberPeer.PROJECT_DATA_ID, getId()); + if (!lastMembersCriteria.equals(criteria)) + { + collMembers = MemberPeer.doSelect(criteria); + } + } + } + lastMembersCriteria = criteria; + + return collMembers; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getMembers(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getMembers(Connection con) throws TorqueException + { + if (collMembers == null) + { + collMembers = getMembers(new Criteria(10), con); + } + return collMembers; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this ProjectData has previously + * been saved, it will retrieve related Members from storage. + * If this ProjectData is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getMembers(Criteria criteria, Connection con) + throws TorqueException + { + if (collMembers == null) + { + if (isNew()) + { + collMembers = new ArrayList(); + } + else + { + criteria.add(MemberPeer.PROJECT_DATA_ID, getId()); + collMembers = MemberPeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(MemberPeer.PROJECT_DATA_ID, getId()); + if (!lastMembersCriteria.equals(criteria)) + { + collMembers = MemberPeer.doSelect(criteria, con); + } + } + } + lastMembersCriteria = criteria; + + return collMembers; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /** + * Collection to store aggregation of collProjectProjectTypes + */ + protected List collProjectProjectTypes; + + /** + * Temporary storage of collProjectProjectTypes to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initProjectProjectTypes() + { + if (collProjectProjectTypes == null) + { + collProjectProjectTypes = new ArrayList(); + } + } + + /** + * Method called to associate a ProjectProjectType object to this object + * through the ProjectProjectType foreign key attribute + * + * @param l ProjectProjectType + * @throws TorqueException + */ + public void addProjectProjectType(ProjectProjectType l) throws TorqueException + { + getProjectProjectTypes().add(l); + l.setProjectData((ProjectData) this); + } + + /** + * The criteria used to select the current contents of collProjectProjectTypes + */ + private Criteria lastProjectProjectTypesCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getProjectProjectTypes(new Criteria()) + * + * @throws TorqueException + */ + public List getProjectProjectTypes() throws TorqueException + { + if (collProjectProjectTypes == null) + { + collProjectProjectTypes = getProjectProjectTypes(new Criteria(10)); + } + return collProjectProjectTypes; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this ProjectData has previously + * been saved, it will retrieve related ProjectProjectTypes from storage. + * If this ProjectData is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getProjectProjectTypes(Criteria criteria) throws TorqueException + { + if (collProjectProjectTypes == null) + { + if (isNew()) + { + collProjectProjectTypes = new ArrayList(); + } + else + { + criteria.add(ProjectProjectTypePeer.PROJECT_DATA_ID, getId() ); + collProjectProjectTypes = ProjectProjectTypePeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ProjectProjectTypePeer.PROJECT_DATA_ID, getId()); + if (!lastProjectProjectTypesCriteria.equals(criteria)) + { + collProjectProjectTypes = ProjectProjectTypePeer.doSelect(criteria); + } + } + } + lastProjectProjectTypesCriteria = criteria; + + return collProjectProjectTypes; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getProjectProjectTypes(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getProjectProjectTypes(Connection con) throws TorqueException + { + if (collProjectProjectTypes == null) + { + collProjectProjectTypes = getProjectProjectTypes(new Criteria(10), con); + } + return collProjectProjectTypes; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this ProjectData has previously + * been saved, it will retrieve related ProjectProjectTypes from storage. + * If this ProjectData is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getProjectProjectTypes(Criteria criteria, Connection con) + throws TorqueException + { + if (collProjectProjectTypes == null) + { + if (isNew()) + { + collProjectProjectTypes = new ArrayList(); + } + else + { + criteria.add(ProjectProjectTypePeer.PROJECT_DATA_ID, getId()); + collProjectProjectTypes = ProjectProjectTypePeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ProjectProjectTypePeer.PROJECT_DATA_ID, getId()); + if (!lastProjectProjectTypesCriteria.equals(criteria)) + { + collProjectProjectTypes = ProjectProjectTypePeer.doSelect(criteria, con); + } + } + } + lastProjectProjectTypesCriteria = criteria; + + return collProjectProjectTypes; + } + + + + + + + + + + + + + + + + + + + + + + + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("Name"); + fieldNames.add("ParentOrganization"); + fieldNames.add("Divisions"); + fieldNames.add("People"); + fieldNames.add("MailingList"); + fieldNames.add("Description"); + fieldNames.add("History"); + fieldNames.add("EducationPrograms"); + fieldNames.add("Resources"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("Name")) + { + return getName(); + } + if (name.equals("ParentOrganization")) + { + return getParentOrganization(); + } + if (name.equals("Divisions")) + { + return getDivisions(); + } + if (name.equals("People")) + { + return getPeople(); + } + if (name.equals("MailingList")) + { + return getMailingList(); + } + if (name.equals("Description")) + { + return getDescription(); + } + if (name.equals("History")) + { + return getHistory(); + } + if (name.equals("EducationPrograms")) + { + return getEducationPrograms(); + } + if (name.equals("Resources")) + { + return getResources(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(ProjectDataPeer.ID)) + { + return getId(); + } + if (name.equals(ProjectDataPeer.NAME)) + { + return getName(); + } + if (name.equals(ProjectDataPeer.PARENT_ORGANIZATION)) + { + return getParentOrganization(); + } + if (name.equals(ProjectDataPeer.DIVISIONS)) + { + return getDivisions(); + } + if (name.equals(ProjectDataPeer.PEOPLE)) + { + return getPeople(); + } + if (name.equals(ProjectDataPeer.MAILING_LIST)) + { + return getMailingList(); + } + if (name.equals(ProjectDataPeer.DESCRIPTION)) + { + return getDescription(); + } + if (name.equals(ProjectDataPeer.HISTORY)) + { + return getHistory(); + } + if (name.equals(ProjectDataPeer.EDUCATION_PROGRAMS)) + { + return getEducationPrograms(); + } + if (name.equals(ProjectDataPeer.RESOURCES)) + { + return getResources(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getName(); + } + if (pos == 2) + { + return getParentOrganization(); + } + if (pos == 3) + { + return getDivisions(); + } + if (pos == 4) + { + return getPeople(); + } + if (pos == 5) + { + return getMailingList(); + } + if (pos == 6) + { + return getDescription(); + } + if (pos == 7) + { + return getHistory(); + } + if (pos == 8) + { + return getEducationPrograms(); + } + if (pos == 9) + { + return getResources(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(ProjectDataPeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + ProjectDataPeer.doInsert((ProjectData) this, con); + setNew(false); + } + else + { + ProjectDataPeer.doUpdate((ProjectData) this, con); + } + } + + + + if (collMembers != null) + { + for (int i = 0; i < collMembers.size(); i++) + { + ((Member) collMembers.get(i)).save(con); + } + } + + + if (collProjectProjectTypes != null) + { + for (int i = 0; i < collProjectProjectTypes.size(); i++) + { + ((ProjectProjectType) collProjectProjectTypes.get(i)).save(con); + } + } + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + throws TorqueException + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) throws TorqueException + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public ProjectData copy() throws TorqueException + { + return copyInto(new ProjectData()); + } + + protected ProjectData copyInto(ProjectData copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setName(name); + copyObj.setParentOrganization(parent_organization); + copyObj.setDivisions(divisions); + copyObj.setPeople(people); + copyObj.setMailingList(mailing_list); + copyObj.setDescription(description); + copyObj.setHistory(history); + copyObj.setEducationPrograms(education_programs); + copyObj.setResources(resources); + + copyObj.setNew(false); + + + List v = getMembers(); + for (int i = 0; i < v.size(); i++) + { + Member obj = (Member) v.get(i); + copyObj.addMember(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + + + v = getProjectProjectTypes(); + for (int i = 0; i < v.size(); i++) + { + ProjectProjectType obj = (ProjectProjectType) v.get(i); + copyObj.addProjectProjectType(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public ProjectDataPeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BaseProjectDataPeer.java b/src/java/org/thdl/roster/om/BaseProjectDataPeer.java new file mode 100755 index 0000000..caef8ff --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseProjectDataPeer.java @@ -0,0 +1,826 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BaseProjectDataPeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "ProjectData"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(ProjectDataMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the NAME field */ + public static final String NAME; + /** the column name for the PARENT_ORGANIZATION field */ + public static final String PARENT_ORGANIZATION; + /** the column name for the DIVISIONS field */ + public static final String DIVISIONS; + /** the column name for the PEOPLE field */ + public static final String PEOPLE; + /** the column name for the MAILING_LIST field */ + public static final String MAILING_LIST; + /** the column name for the DESCRIPTION field */ + public static final String DESCRIPTION; + /** the column name for the HISTORY field */ + public static final String HISTORY; + /** the column name for the EDUCATION_PROGRAMS field */ + public static final String EDUCATION_PROGRAMS; + /** the column name for the RESOURCES field */ + public static final String RESOURCES; + + static + { + ID = "ProjectData.ID"; + NAME = "ProjectData.NAME"; + PARENT_ORGANIZATION = "ProjectData.PARENT_ORGANIZATION"; + DIVISIONS = "ProjectData.DIVISIONS"; + PEOPLE = "ProjectData.PEOPLE"; + MAILING_LIST = "ProjectData.MAILING_LIST"; + DESCRIPTION = "ProjectData.DESCRIPTION"; + HISTORY = "ProjectData.HISTORY"; + EDUCATION_PROGRAMS = "ProjectData.EDUCATION_PROGRAMS"; + RESOURCES = "ProjectData.RESOURCES"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(ProjectDataMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 10; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.ProjectData"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BaseProjectDataPeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(NAME); + criteria.addSelectColumn(PARENT_ORGANIZATION); + criteria.addSelectColumn(DIVISIONS); + criteria.addSelectColumn(PEOPLE); + criteria.addSelectColumn(MAILING_LIST); + criteria.addSelectColumn(DESCRIPTION); + criteria.addSelectColumn(HISTORY); + criteria.addSelectColumn(EDUCATION_PROGRAMS); + criteria.addSelectColumn(RESOURCES); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ProjectData row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + ProjectData obj = (ProjectData) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + ProjectData obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setName(row.getValue(offset + 1).asString()); + obj.setParentOrganization(row.getValue(offset + 2).asString()); + obj.setDivisions(row.getValue(offset + 3).asString()); + obj.setPeople(row.getValue(offset + 4).asString()); + obj.setMailingList(row.getValue(offset + 5).asString()); + obj.setDescription(row.getValue(offset + 6).asString()); + obj.setHistory(row.getValue(offset + 7).asString()); + obj.setEducationPrograms(row.getValue(offset + 8).asString()); + obj.setResources(row.getValue(offset + 9).asString()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BaseProjectDataPeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(ProjectDataPeer.row2Object(row, 1, + ProjectDataPeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BaseProjectDataPeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BaseProjectDataPeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(ProjectData obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(ProjectData obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(ProjectData obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ProjectData obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(ProjectData) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(ProjectData obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(ProjectData) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(ProjectData obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ProjectData) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ProjectData obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BaseProjectDataPeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( ProjectData obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(NAME, obj.getName()); + criteria.add(PARENT_ORGANIZATION, obj.getParentOrganization()); + criteria.add(DIVISIONS, obj.getDivisions()); + criteria.add(PEOPLE, obj.getPeople()); + criteria.add(MAILING_LIST, obj.getMailingList()); + criteria.add(DESCRIPTION, obj.getDescription()); + criteria.add(HISTORY, obj.getHistory()); + criteria.add(EDUCATION_PROGRAMS, obj.getEducationPrograms()); + criteria.add(RESOURCES, obj.getResources()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ProjectData retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ProjectData retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + ProjectData retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ProjectData retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (ProjectData)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BaseProjectProjectType.java b/src/java/org/thdl/roster/om/BaseProjectProjectType.java new file mode 100755 index 0000000..10b5afb --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseProjectProjectType.java @@ -0,0 +1,584 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to ProjectProjectType + */ +public abstract class BaseProjectProjectType extends BaseObject +{ + /** The Peer class */ + private static final ProjectProjectTypePeer peer = + new ProjectProjectTypePeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the project_type_id field + */ + private Integer project_type_id; + + /** + * The value for the project_data_id field + */ + private Integer project_data_id; + + /** + * The value for the relevance field + */ + private Integer relevance; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + } + + + /** + * Get the ProjectTypeId + * + * @return Integer + */ + public Integer getProjectTypeId() + { + return project_type_id; + } + + + /** + * Set the value of ProjectTypeId + * + * @param v new value + */ + public void setProjectTypeId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.project_type_id, v)) + { + this.project_type_id = v; + setModified(true); + } + + + if (aProjectType != null && !ObjectUtils.equals(aProjectType.getId(), v)) + { + aProjectType = null; + } + + } + + + /** + * Get the ProjectDataId + * + * @return Integer + */ + public Integer getProjectDataId() + { + return project_data_id; + } + + + /** + * Set the value of ProjectDataId + * + * @param v new value + */ + public void setProjectDataId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.project_data_id, v)) + { + this.project_data_id = v; + setModified(true); + } + + + if (aProjectData != null && !ObjectUtils.equals(aProjectData.getId(), v)) + { + aProjectData = null; + } + + } + + + /** + * Get the Relevance + * + * @return Integer + */ + public Integer getRelevance() + { + return relevance; + } + + + /** + * Set the value of Relevance + * + * @param v new value + */ + public void setRelevance(Integer v) + { + + + + if (!ObjectUtils.equals(this.relevance, v)) + { + this.relevance = v; + setModified(true); + } + + + } + + + + + + + + private ProjectData aProjectData; + + /** + * Declares an association between this object and a ProjectData object + * + * @param v ProjectData + * @throws TorqueException + */ + public void setProjectData(ProjectData v) throws TorqueException + { + if (v == null) + { + setProjectDataId((Integer)null); + } + else + { + setProjectDataId(v.getId()); + } + aProjectData = v; + } + + + /** + * Get the associated ProjectData object + * + * @return the associated ProjectData object + * @throws TorqueException + */ + public ProjectData getProjectData() throws TorqueException + { + if (aProjectData == null && (!ObjectUtils.equals(this.project_data_id, null))) + { + aProjectData = ProjectDataPeer.retrieveByPK(SimpleKey.keyFor(this.project_data_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + ProjectData obj = ProjectDataPeer.retrieveByPK(this.project_data_id); + obj.addProjectProjectTypes(this); + */ + } + return aProjectData; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setProjectDataKey(ObjectKey key) throws TorqueException + { + + setProjectDataId(new Integer(((NumberKey) key).intValue())); + } + + + + + private ProjectType aProjectType; + + /** + * Declares an association between this object and a ProjectType object + * + * @param v ProjectType + * @throws TorqueException + */ + public void setProjectType(ProjectType v) throws TorqueException + { + if (v == null) + { + setProjectTypeId((Integer)null); + } + else + { + setProjectTypeId(v.getId()); + } + aProjectType = v; + } + + + /** + * Get the associated ProjectType object + * + * @return the associated ProjectType object + * @throws TorqueException + */ + public ProjectType getProjectType() throws TorqueException + { + if (aProjectType == null && (!ObjectUtils.equals(this.project_type_id, null))) + { + aProjectType = ProjectTypePeer.retrieveByPK(SimpleKey.keyFor(this.project_type_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + ProjectType obj = ProjectTypePeer.retrieveByPK(this.project_type_id); + obj.addProjectProjectTypes(this); + */ + } + return aProjectType; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setProjectTypeKey(ObjectKey key) throws TorqueException + { + + setProjectTypeId(new Integer(((NumberKey) key).intValue())); + } + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("ProjectTypeId"); + fieldNames.add("ProjectDataId"); + fieldNames.add("Relevance"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("ProjectTypeId")) + { + return getProjectTypeId(); + } + if (name.equals("ProjectDataId")) + { + return getProjectDataId(); + } + if (name.equals("Relevance")) + { + return getRelevance(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(ProjectProjectTypePeer.ID)) + { + return getId(); + } + if (name.equals(ProjectProjectTypePeer.PROJECT_TYPE_ID)) + { + return getProjectTypeId(); + } + if (name.equals(ProjectProjectTypePeer.PROJECT_DATA_ID)) + { + return getProjectDataId(); + } + if (name.equals(ProjectProjectTypePeer.RELEVANCE)) + { + return getRelevance(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getProjectTypeId(); + } + if (pos == 2) + { + return getProjectDataId(); + } + if (pos == 3) + { + return getRelevance(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(ProjectProjectTypePeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + ProjectProjectTypePeer.doInsert((ProjectProjectType) this, con); + setNew(false); + } + else + { + ProjectProjectTypePeer.doUpdate((ProjectProjectType) this, con); + } + } + + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public ProjectProjectType copy() throws TorqueException + { + return copyInto(new ProjectProjectType()); + } + + protected ProjectProjectType copyInto(ProjectProjectType copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setProjectTypeId(project_type_id); + copyObj.setProjectDataId(project_data_id); + copyObj.setRelevance(relevance); + + copyObj.setNew(false); + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public ProjectProjectTypePeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BaseProjectProjectTypePeer.java b/src/java/org/thdl/roster/om/BaseProjectProjectTypePeer.java new file mode 100755 index 0000000..373f023 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseProjectProjectTypePeer.java @@ -0,0 +1,946 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BaseProjectProjectTypePeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "ProjectProjectType"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(ProjectProjectTypeMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the PROJECT_TYPE_ID field */ + public static final String PROJECT_TYPE_ID; + /** the column name for the PROJECT_DATA_ID field */ + public static final String PROJECT_DATA_ID; + /** the column name for the RELEVANCE field */ + public static final String RELEVANCE; + + static + { + ID = "ProjectProjectType.ID"; + PROJECT_TYPE_ID = "ProjectProjectType.PROJECT_TYPE_ID"; + PROJECT_DATA_ID = "ProjectProjectType.PROJECT_DATA_ID"; + RELEVANCE = "ProjectProjectType.RELEVANCE"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(ProjectProjectTypeMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 4; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.ProjectProjectType"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BaseProjectProjectTypePeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(PROJECT_TYPE_ID); + criteria.addSelectColumn(PROJECT_DATA_ID); + criteria.addSelectColumn(RELEVANCE); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ProjectProjectType row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + ProjectProjectType obj = (ProjectProjectType) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + ProjectProjectType obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setProjectTypeId(row.getValue(offset + 1).asIntegerObj()); + obj.setProjectDataId(row.getValue(offset + 2).asIntegerObj()); + obj.setRelevance(row.getValue(offset + 3).asIntegerObj()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BaseProjectProjectTypePeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(ProjectProjectTypePeer.row2Object(row, 1, + ProjectProjectTypePeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BaseProjectProjectTypePeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BaseProjectProjectTypePeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(ProjectProjectType obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(ProjectProjectType obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(ProjectProjectType obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ProjectProjectType obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(ProjectProjectType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(ProjectProjectType obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(ProjectProjectType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(ProjectProjectType obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ProjectProjectType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ProjectProjectType obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BaseProjectProjectTypePeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( ProjectProjectType obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(PROJECT_TYPE_ID, obj.getProjectTypeId()); + criteria.add(PROJECT_DATA_ID, obj.getProjectDataId()); + criteria.add(RELEVANCE, obj.getRelevance()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ProjectProjectType retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ProjectProjectType retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + ProjectProjectType retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ProjectProjectType retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (ProjectProjectType)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + + + /** + * selects a collection of ProjectProjectType objects pre-filled with their + * ProjectData objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in ProjectProjectTypePeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinProjectData(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + ProjectProjectTypePeer.addSelectColumns(c); + int offset = numColumns + 1; + ProjectDataPeer.addSelectColumns(c); + + + c.addJoin(ProjectProjectTypePeer.PROJECT_DATA_ID, + ProjectDataPeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = ProjectProjectTypePeer.getOMClass(); + + ProjectProjectType obj1 = (ProjectProjectType) ProjectProjectTypePeer + .row2Object(row, 1, omClass); + + + omClass = ProjectDataPeer.getOMClass(); + ProjectData obj2 = (ProjectData)ProjectDataPeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + ProjectProjectType temp_obj1 = (ProjectProjectType)results.get(j); + ProjectData temp_obj2 = (ProjectData)temp_obj1.getProjectData(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addProjectProjectType(obj1); + break; + } + } + if (newObject) + { + obj2.initProjectProjectTypes(); + obj2.addProjectProjectType(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + + /** + * selects a collection of ProjectProjectType objects pre-filled with their + * ProjectType objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in ProjectProjectTypePeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinProjectType(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + ProjectProjectTypePeer.addSelectColumns(c); + int offset = numColumns + 1; + ProjectTypePeer.addSelectColumns(c); + + + c.addJoin(ProjectProjectTypePeer.PROJECT_TYPE_ID, + ProjectTypePeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = ProjectProjectTypePeer.getOMClass(); + + ProjectProjectType obj1 = (ProjectProjectType) ProjectProjectTypePeer + .row2Object(row, 1, omClass); + + + omClass = ProjectTypePeer.getOMClass(); + ProjectType obj2 = (ProjectType)ProjectTypePeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + ProjectProjectType temp_obj1 = (ProjectProjectType)results.get(j); + ProjectType temp_obj2 = (ProjectType)temp_obj1.getProjectType(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addProjectProjectType(obj1); + break; + } + } + if (newObject) + { + obj2.initProjectProjectTypes(); + obj2.addProjectProjectType(obj1); + } + results.add(obj1); + } + return results; + } + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BaseProjectType.java b/src/java/org/thdl/roster/om/BaseProjectType.java new file mode 100755 index 0000000..e18f3ee --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseProjectType.java @@ -0,0 +1,561 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to ProjectType + */ +public abstract class BaseProjectType extends BaseObject +{ + /** The Peer class */ + private static final ProjectTypePeer peer = + new ProjectTypePeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the project_type field + */ + private String project_type; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + + // update associated ProjectProjectType + if (collProjectProjectTypes != null) + { + for (int i = 0; i < collProjectProjectTypes.size(); i++) + { + ((ProjectProjectType) collProjectProjectTypes.get(i)) + .setProjectTypeId(v); + } + } + } + + + /** + * Get the ProjectType + * + * @return String + */ + public String getProjectType() + { + return project_type; + } + + + /** + * Set the value of ProjectType + * + * @param v new value + */ + public void setProjectType(String v) + { + + + + if (!ObjectUtils.equals(this.project_type, v)) + { + this.project_type = v; + setModified(true); + } + + + } + + + + + + + /** + * Collection to store aggregation of collProjectProjectTypes + */ + protected List collProjectProjectTypes; + + /** + * Temporary storage of collProjectProjectTypes to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initProjectProjectTypes() + { + if (collProjectProjectTypes == null) + { + collProjectProjectTypes = new ArrayList(); + } + } + + /** + * Method called to associate a ProjectProjectType object to this object + * through the ProjectProjectType foreign key attribute + * + * @param l ProjectProjectType + * @throws TorqueException + */ + public void addProjectProjectType(ProjectProjectType l) throws TorqueException + { + getProjectProjectTypes().add(l); + l.setProjectType((ProjectType) this); + } + + /** + * The criteria used to select the current contents of collProjectProjectTypes + */ + private Criteria lastProjectProjectTypesCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getProjectProjectTypes(new Criteria()) + * + * @throws TorqueException + */ + public List getProjectProjectTypes() throws TorqueException + { + if (collProjectProjectTypes == null) + { + collProjectProjectTypes = getProjectProjectTypes(new Criteria(10)); + } + return collProjectProjectTypes; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this ProjectType has previously + * been saved, it will retrieve related ProjectProjectTypes from storage. + * If this ProjectType is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getProjectProjectTypes(Criteria criteria) throws TorqueException + { + if (collProjectProjectTypes == null) + { + if (isNew()) + { + collProjectProjectTypes = new ArrayList(); + } + else + { + criteria.add(ProjectProjectTypePeer.PROJECT_TYPE_ID, getId() ); + collProjectProjectTypes = ProjectProjectTypePeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ProjectProjectTypePeer.PROJECT_TYPE_ID, getId()); + if (!lastProjectProjectTypesCriteria.equals(criteria)) + { + collProjectProjectTypes = ProjectProjectTypePeer.doSelect(criteria); + } + } + } + lastProjectProjectTypesCriteria = criteria; + + return collProjectProjectTypes; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getProjectProjectTypes(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getProjectProjectTypes(Connection con) throws TorqueException + { + if (collProjectProjectTypes == null) + { + collProjectProjectTypes = getProjectProjectTypes(new Criteria(10), con); + } + return collProjectProjectTypes; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this ProjectType has previously + * been saved, it will retrieve related ProjectProjectTypes from storage. + * If this ProjectType is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getProjectProjectTypes(Criteria criteria, Connection con) + throws TorqueException + { + if (collProjectProjectTypes == null) + { + if (isNew()) + { + collProjectProjectTypes = new ArrayList(); + } + else + { + criteria.add(ProjectProjectTypePeer.PROJECT_TYPE_ID, getId()); + collProjectProjectTypes = ProjectProjectTypePeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ProjectProjectTypePeer.PROJECT_TYPE_ID, getId()); + if (!lastProjectProjectTypesCriteria.equals(criteria)) + { + collProjectProjectTypes = ProjectProjectTypePeer.doSelect(criteria, con); + } + } + } + lastProjectProjectTypesCriteria = criteria; + + return collProjectProjectTypes; + } + + + + + + + + + + + + + + + + + + + + + + + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("ProjectType"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("ProjectType")) + { + return getProjectType(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(ProjectTypePeer.ID)) + { + return getId(); + } + if (name.equals(ProjectTypePeer.PROJECT_TYPE)) + { + return getProjectType(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getProjectType(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(ProjectTypePeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + ProjectTypePeer.doInsert((ProjectType) this, con); + setNew(false); + } + else + { + ProjectTypePeer.doUpdate((ProjectType) this, con); + } + } + + + + if (collProjectProjectTypes != null) + { + for (int i = 0; i < collProjectProjectTypes.size(); i++) + { + ((ProjectProjectType) collProjectProjectTypes.get(i)).save(con); + } + } + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + throws TorqueException + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) throws TorqueException + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public ProjectType copy() throws TorqueException + { + return copyInto(new ProjectType()); + } + + protected ProjectType copyInto(ProjectType copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setProjectType(project_type); + + copyObj.setNew(false); + + + List v = getProjectProjectTypes(); + for (int i = 0; i < v.size(); i++) + { + ProjectProjectType obj = (ProjectProjectType) v.get(i); + copyObj.addProjectProjectType(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public ProjectTypePeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BaseProjectTypePeer.java b/src/java/org/thdl/roster/om/BaseProjectTypePeer.java new file mode 100755 index 0000000..4c71a83 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseProjectTypePeer.java @@ -0,0 +1,778 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BaseProjectTypePeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "ProjectType"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(ProjectTypeMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the PROJECT_TYPE field */ + public static final String PROJECT_TYPE; + + static + { + ID = "ProjectType.ID"; + PROJECT_TYPE = "ProjectType.PROJECT_TYPE"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(ProjectTypeMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 2; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.ProjectType"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BaseProjectTypePeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(PROJECT_TYPE); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ProjectType row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + ProjectType obj = (ProjectType) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + ProjectType obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setProjectType(row.getValue(offset + 1).asString()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BaseProjectTypePeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(ProjectTypePeer.row2Object(row, 1, + ProjectTypePeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BaseProjectTypePeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BaseProjectTypePeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(ProjectType obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(ProjectType obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(ProjectType obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ProjectType obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(ProjectType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(ProjectType obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(ProjectType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(ProjectType obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ProjectType) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ProjectType obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BaseProjectTypePeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( ProjectType obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(PROJECT_TYPE, obj.getProjectType()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ProjectType retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ProjectType retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + ProjectType retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ProjectType retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (ProjectType)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BasePublication.java b/src/java/org/thdl/roster/om/BasePublication.java new file mode 100755 index 0000000..db38636 --- /dev/null +++ b/src/java/org/thdl/roster/om/BasePublication.java @@ -0,0 +1,693 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to Publication + */ +public abstract class BasePublication extends BaseObject +{ + /** The Peer class */ + private static final PublicationPeer peer = + new PublicationPeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the formal_publications field + */ + private String formal_publications; + + /** + * The value for the works_in_progress field + */ + private String works_in_progress; + + /** + * The value for the projects field + */ + private String projects; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + + // update associated Member + if (collMembers != null) + { + for (int i = 0; i < collMembers.size(); i++) + { + ((Member) collMembers.get(i)) + .setPublicationId(v); + } + } + } + + + /** + * Get the FormalPublications + * + * @return String + */ + public String getFormalPublications() + { + return formal_publications; + } + + + /** + * Set the value of FormalPublications + * + * @param v new value + */ + public void setFormalPublications(String v) + { + + + + if (!ObjectUtils.equals(this.formal_publications, v)) + { + this.formal_publications = v; + setModified(true); + } + + + } + + + /** + * Get the WorksInProgress + * + * @return String + */ + public String getWorksInProgress() + { + return works_in_progress; + } + + + /** + * Set the value of WorksInProgress + * + * @param v new value + */ + public void setWorksInProgress(String v) + { + + + + if (!ObjectUtils.equals(this.works_in_progress, v)) + { + this.works_in_progress = v; + setModified(true); + } + + + } + + + /** + * Get the Projects + * + * @return String + */ + public String getProjects() + { + return projects; + } + + + /** + * Set the value of Projects + * + * @param v new value + */ + public void setProjects(String v) + { + + + + if (!ObjectUtils.equals(this.projects, v)) + { + this.projects = v; + setModified(true); + } + + + } + + + + + + + /** + * Collection to store aggregation of collMembers + */ + protected List collMembers; + + /** + * Temporary storage of collMembers to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initMembers() + { + if (collMembers == null) + { + collMembers = new ArrayList(); + } + } + + /** + * Method called to associate a Member object to this object + * through the Member foreign key attribute + * + * @param l Member + * @throws TorqueException + */ + public void addMember(Member l) throws TorqueException + { + getMembers().add(l); + l.setPublication((Publication) this); + } + + /** + * The criteria used to select the current contents of collMembers + */ + private Criteria lastMembersCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getMembers(new Criteria()) + * + * @throws TorqueException + */ + public List getMembers() throws TorqueException + { + if (collMembers == null) + { + collMembers = getMembers(new Criteria(10)); + } + return collMembers; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Publication has previously + * been saved, it will retrieve related Members from storage. + * If this Publication is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getMembers(Criteria criteria) throws TorqueException + { + if (collMembers == null) + { + if (isNew()) + { + collMembers = new ArrayList(); + } + else + { + criteria.add(MemberPeer.PUBLICATION_ID, getId() ); + collMembers = MemberPeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(MemberPeer.PUBLICATION_ID, getId()); + if (!lastMembersCriteria.equals(criteria)) + { + collMembers = MemberPeer.doSelect(criteria); + } + } + } + lastMembersCriteria = criteria; + + return collMembers; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getMembers(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getMembers(Connection con) throws TorqueException + { + if (collMembers == null) + { + collMembers = getMembers(new Criteria(10), con); + } + return collMembers; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Publication has previously + * been saved, it will retrieve related Members from storage. + * If this Publication is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getMembers(Criteria criteria, Connection con) + throws TorqueException + { + if (collMembers == null) + { + if (isNew()) + { + collMembers = new ArrayList(); + } + else + { + criteria.add(MemberPeer.PUBLICATION_ID, getId()); + collMembers = MemberPeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(MemberPeer.PUBLICATION_ID, getId()); + if (!lastMembersCriteria.equals(criteria)) + { + collMembers = MemberPeer.doSelect(criteria, con); + } + } + } + lastMembersCriteria = criteria; + + return collMembers; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("FormalPublications"); + fieldNames.add("WorksInProgress"); + fieldNames.add("Projects"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("FormalPublications")) + { + return getFormalPublications(); + } + if (name.equals("WorksInProgress")) + { + return getWorksInProgress(); + } + if (name.equals("Projects")) + { + return getProjects(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(PublicationPeer.ID)) + { + return getId(); + } + if (name.equals(PublicationPeer.FORMAL_PUBLICATIONS)) + { + return getFormalPublications(); + } + if (name.equals(PublicationPeer.WORKS_IN_PROGRESS)) + { + return getWorksInProgress(); + } + if (name.equals(PublicationPeer.PROJECTS)) + { + return getProjects(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getFormalPublications(); + } + if (pos == 2) + { + return getWorksInProgress(); + } + if (pos == 3) + { + return getProjects(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(PublicationPeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + PublicationPeer.doInsert((Publication) this, con); + setNew(false); + } + else + { + PublicationPeer.doUpdate((Publication) this, con); + } + } + + + + if (collMembers != null) + { + for (int i = 0; i < collMembers.size(); i++) + { + ((Member) collMembers.get(i)).save(con); + } + } + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + throws TorqueException + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) throws TorqueException + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public Publication copy() throws TorqueException + { + return copyInto(new Publication()); + } + + protected Publication copyInto(Publication copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setFormalPublications(formal_publications); + copyObj.setWorksInProgress(works_in_progress); + copyObj.setProjects(projects); + + copyObj.setNew(false); + + + List v = getMembers(); + for (int i = 0; i < v.size(); i++) + { + Member obj = (Member) v.get(i); + copyObj.addMember(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public PublicationPeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BasePublicationPeer.java b/src/java/org/thdl/roster/om/BasePublicationPeer.java new file mode 100755 index 0000000..bdd5cad --- /dev/null +++ b/src/java/org/thdl/roster/om/BasePublicationPeer.java @@ -0,0 +1,790 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BasePublicationPeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "Publication"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(PublicationMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the FORMAL_PUBLICATIONS field */ + public static final String FORMAL_PUBLICATIONS; + /** the column name for the WORKS_IN_PROGRESS field */ + public static final String WORKS_IN_PROGRESS; + /** the column name for the PROJECTS field */ + public static final String PROJECTS; + + static + { + ID = "Publication.ID"; + FORMAL_PUBLICATIONS = "Publication.FORMAL_PUBLICATIONS"; + WORKS_IN_PROGRESS = "Publication.WORKS_IN_PROGRESS"; + PROJECTS = "Publication.PROJECTS"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(PublicationMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 4; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.Publication"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BasePublicationPeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(FORMAL_PUBLICATIONS); + criteria.addSelectColumn(WORKS_IN_PROGRESS); + criteria.addSelectColumn(PROJECTS); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Publication row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + Publication obj = (Publication) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + Publication obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setFormalPublications(row.getValue(offset + 1).asString()); + obj.setWorksInProgress(row.getValue(offset + 2).asString()); + obj.setProjects(row.getValue(offset + 3).asString()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BasePublicationPeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(PublicationPeer.row2Object(row, 1, + PublicationPeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BasePublicationPeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BasePublicationPeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Publication obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(Publication obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Publication obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Publication obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Publication) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(Publication obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(Publication) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Publication obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(Publication) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Publication obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BasePublicationPeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( Publication obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(FORMAL_PUBLICATIONS, obj.getFormalPublications()); + criteria.add(WORKS_IN_PROGRESS, obj.getWorksInProgress()); + criteria.add(PROJECTS, obj.getProjects()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Publication retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Publication retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + Publication retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Publication retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (Publication)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BaseResearchInterest.java b/src/java/org/thdl/roster/om/BaseResearchInterest.java new file mode 100755 index 0000000..5f599f3 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseResearchInterest.java @@ -0,0 +1,1432 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to ResearchInterest + */ +public abstract class BaseResearchInterest extends BaseObject +{ + /** The Peer class */ + private static final ResearchInterestPeer peer = + new ResearchInterestPeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the interests field + */ + private String interests; + + /** + * The value for the activities field + */ + private String activities; + + /** + * The value for the collaboration_interests field + */ + private String collaboration_interests; + + /** + * The value for the focus_from field + */ + private Integer focus_from; + + /** + * The value for the focus_to field + */ + private Integer focus_to; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + + // update associated Member + if (collMembers != null) + { + for (int i = 0; i < collMembers.size(); i++) + { + ((Member) collMembers.get(i)) + .setResearchInterestId(v); + } + } + + // update associated ResearchInterestLanguage + if (collResearchInterestLanguages != null) + { + for (int i = 0; i < collResearchInterestLanguages.size(); i++) + { + ((ResearchInterestLanguage) collResearchInterestLanguages.get(i)) + .setResearchInterestId(v); + } + } + + // update associated ResearchInterestCulturalArea + if (collResearchInterestCulturalAreas != null) + { + for (int i = 0; i < collResearchInterestCulturalAreas.size(); i++) + { + ((ResearchInterestCulturalArea) collResearchInterestCulturalAreas.get(i)) + .setResearchInterestId(v); + } + } + + // update associated ResearchInterestDiscipline + if (collResearchInterestDisciplines != null) + { + for (int i = 0; i < collResearchInterestDisciplines.size(); i++) + { + ((ResearchInterestDiscipline) collResearchInterestDisciplines.get(i)) + .setResearchInterestId(v); + } + } + } + + + /** + * Get the Interests + * + * @return String + */ + public String getInterests() + { + return interests; + } + + + /** + * Set the value of Interests + * + * @param v new value + */ + public void setInterests(String v) + { + + + + if (!ObjectUtils.equals(this.interests, v)) + { + this.interests = v; + setModified(true); + } + + + } + + + /** + * Get the Activities + * + * @return String + */ + public String getActivities() + { + return activities; + } + + + /** + * Set the value of Activities + * + * @param v new value + */ + public void setActivities(String v) + { + + + + if (!ObjectUtils.equals(this.activities, v)) + { + this.activities = v; + setModified(true); + } + + + } + + + /** + * Get the CollaborationInterests + * + * @return String + */ + public String getCollaborationInterests() + { + return collaboration_interests; + } + + + /** + * Set the value of CollaborationInterests + * + * @param v new value + */ + public void setCollaborationInterests(String v) + { + + + + if (!ObjectUtils.equals(this.collaboration_interests, v)) + { + this.collaboration_interests = v; + setModified(true); + } + + + } + + + /** + * Get the FocusFrom + * + * @return Integer + */ + public Integer getFocusFrom() + { + return focus_from; + } + + + /** + * Set the value of FocusFrom + * + * @param v new value + */ + public void setFocusFrom(Integer v) + { + + + + if (!ObjectUtils.equals(this.focus_from, v)) + { + this.focus_from = v; + setModified(true); + } + + + } + + + /** + * Get the FocusTo + * + * @return Integer + */ + public Integer getFocusTo() + { + return focus_to; + } + + + /** + * Set the value of FocusTo + * + * @param v new value + */ + public void setFocusTo(Integer v) + { + + + + if (!ObjectUtils.equals(this.focus_to, v)) + { + this.focus_to = v; + setModified(true); + } + + + } + + + + + + + /** + * Collection to store aggregation of collMembers + */ + protected List collMembers; + + /** + * Temporary storage of collMembers to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initMembers() + { + if (collMembers == null) + { + collMembers = new ArrayList(); + } + } + + /** + * Method called to associate a Member object to this object + * through the Member foreign key attribute + * + * @param l Member + * @throws TorqueException + */ + public void addMember(Member l) throws TorqueException + { + getMembers().add(l); + l.setResearchInterest((ResearchInterest) this); + } + + /** + * The criteria used to select the current contents of collMembers + */ + private Criteria lastMembersCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getMembers(new Criteria()) + * + * @throws TorqueException + */ + public List getMembers() throws TorqueException + { + if (collMembers == null) + { + collMembers = getMembers(new Criteria(10)); + } + return collMembers; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this ResearchInterest has previously + * been saved, it will retrieve related Members from storage. + * If this ResearchInterest is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getMembers(Criteria criteria) throws TorqueException + { + if (collMembers == null) + { + if (isNew()) + { + collMembers = new ArrayList(); + } + else + { + criteria.add(MemberPeer.RESEARCH_INTEREST_ID, getId() ); + collMembers = MemberPeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(MemberPeer.RESEARCH_INTEREST_ID, getId()); + if (!lastMembersCriteria.equals(criteria)) + { + collMembers = MemberPeer.doSelect(criteria); + } + } + } + lastMembersCriteria = criteria; + + return collMembers; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getMembers(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getMembers(Connection con) throws TorqueException + { + if (collMembers == null) + { + collMembers = getMembers(new Criteria(10), con); + } + return collMembers; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this ResearchInterest has previously + * been saved, it will retrieve related Members from storage. + * If this ResearchInterest is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getMembers(Criteria criteria, Connection con) + throws TorqueException + { + if (collMembers == null) + { + if (isNew()) + { + collMembers = new ArrayList(); + } + else + { + criteria.add(MemberPeer.RESEARCH_INTEREST_ID, getId()); + collMembers = MemberPeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(MemberPeer.RESEARCH_INTEREST_ID, getId()); + if (!lastMembersCriteria.equals(criteria)) + { + collMembers = MemberPeer.doSelect(criteria, con); + } + } + } + lastMembersCriteria = criteria; + + return collMembers; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /** + * Collection to store aggregation of collResearchInterestLanguages + */ + protected List collResearchInterestLanguages; + + /** + * Temporary storage of collResearchInterestLanguages to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initResearchInterestLanguages() + { + if (collResearchInterestLanguages == null) + { + collResearchInterestLanguages = new ArrayList(); + } + } + + /** + * Method called to associate a ResearchInterestLanguage object to this object + * through the ResearchInterestLanguage foreign key attribute + * + * @param l ResearchInterestLanguage + * @throws TorqueException + */ + public void addResearchInterestLanguage(ResearchInterestLanguage l) throws TorqueException + { + getResearchInterestLanguages().add(l); + l.setResearchInterest((ResearchInterest) this); + } + + /** + * The criteria used to select the current contents of collResearchInterestLanguages + */ + private Criteria lastResearchInterestLanguagesCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getResearchInterestLanguages(new Criteria()) + * + * @throws TorqueException + */ + public List getResearchInterestLanguages() throws TorqueException + { + if (collResearchInterestLanguages == null) + { + collResearchInterestLanguages = getResearchInterestLanguages(new Criteria(10)); + } + return collResearchInterestLanguages; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this ResearchInterest has previously + * been saved, it will retrieve related ResearchInterestLanguages from storage. + * If this ResearchInterest is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getResearchInterestLanguages(Criteria criteria) throws TorqueException + { + if (collResearchInterestLanguages == null) + { + if (isNew()) + { + collResearchInterestLanguages = new ArrayList(); + } + else + { + criteria.add(ResearchInterestLanguagePeer.RESEARCH_INTEREST_ID, getId() ); + collResearchInterestLanguages = ResearchInterestLanguagePeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ResearchInterestLanguagePeer.RESEARCH_INTEREST_ID, getId()); + if (!lastResearchInterestLanguagesCriteria.equals(criteria)) + { + collResearchInterestLanguages = ResearchInterestLanguagePeer.doSelect(criteria); + } + } + } + lastResearchInterestLanguagesCriteria = criteria; + + return collResearchInterestLanguages; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getResearchInterestLanguages(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getResearchInterestLanguages(Connection con) throws TorqueException + { + if (collResearchInterestLanguages == null) + { + collResearchInterestLanguages = getResearchInterestLanguages(new Criteria(10), con); + } + return collResearchInterestLanguages; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this ResearchInterest has previously + * been saved, it will retrieve related ResearchInterestLanguages from storage. + * If this ResearchInterest is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getResearchInterestLanguages(Criteria criteria, Connection con) + throws TorqueException + { + if (collResearchInterestLanguages == null) + { + if (isNew()) + { + collResearchInterestLanguages = new ArrayList(); + } + else + { + criteria.add(ResearchInterestLanguagePeer.RESEARCH_INTEREST_ID, getId()); + collResearchInterestLanguages = ResearchInterestLanguagePeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ResearchInterestLanguagePeer.RESEARCH_INTEREST_ID, getId()); + if (!lastResearchInterestLanguagesCriteria.equals(criteria)) + { + collResearchInterestLanguages = ResearchInterestLanguagePeer.doSelect(criteria, con); + } + } + } + lastResearchInterestLanguagesCriteria = criteria; + + return collResearchInterestLanguages; + } + + + + + + + + + + + + + + + + + + + + + + + + + + /** + * Collection to store aggregation of collResearchInterestCulturalAreas + */ + protected List collResearchInterestCulturalAreas; + + /** + * Temporary storage of collResearchInterestCulturalAreas to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initResearchInterestCulturalAreas() + { + if (collResearchInterestCulturalAreas == null) + { + collResearchInterestCulturalAreas = new ArrayList(); + } + } + + /** + * Method called to associate a ResearchInterestCulturalArea object to this object + * through the ResearchInterestCulturalArea foreign key attribute + * + * @param l ResearchInterestCulturalArea + * @throws TorqueException + */ + public void addResearchInterestCulturalArea(ResearchInterestCulturalArea l) throws TorqueException + { + getResearchInterestCulturalAreas().add(l); + l.setResearchInterest((ResearchInterest) this); + } + + /** + * The criteria used to select the current contents of collResearchInterestCulturalAreas + */ + private Criteria lastResearchInterestCulturalAreasCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getResearchInterestCulturalAreas(new Criteria()) + * + * @throws TorqueException + */ + public List getResearchInterestCulturalAreas() throws TorqueException + { + if (collResearchInterestCulturalAreas == null) + { + collResearchInterestCulturalAreas = getResearchInterestCulturalAreas(new Criteria(10)); + } + return collResearchInterestCulturalAreas; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this ResearchInterest has previously + * been saved, it will retrieve related ResearchInterestCulturalAreas from storage. + * If this ResearchInterest is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getResearchInterestCulturalAreas(Criteria criteria) throws TorqueException + { + if (collResearchInterestCulturalAreas == null) + { + if (isNew()) + { + collResearchInterestCulturalAreas = new ArrayList(); + } + else + { + criteria.add(ResearchInterestCulturalAreaPeer.RESEARCH_INTEREST_ID, getId() ); + collResearchInterestCulturalAreas = ResearchInterestCulturalAreaPeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ResearchInterestCulturalAreaPeer.RESEARCH_INTEREST_ID, getId()); + if (!lastResearchInterestCulturalAreasCriteria.equals(criteria)) + { + collResearchInterestCulturalAreas = ResearchInterestCulturalAreaPeer.doSelect(criteria); + } + } + } + lastResearchInterestCulturalAreasCriteria = criteria; + + return collResearchInterestCulturalAreas; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getResearchInterestCulturalAreas(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getResearchInterestCulturalAreas(Connection con) throws TorqueException + { + if (collResearchInterestCulturalAreas == null) + { + collResearchInterestCulturalAreas = getResearchInterestCulturalAreas(new Criteria(10), con); + } + return collResearchInterestCulturalAreas; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this ResearchInterest has previously + * been saved, it will retrieve related ResearchInterestCulturalAreas from storage. + * If this ResearchInterest is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getResearchInterestCulturalAreas(Criteria criteria, Connection con) + throws TorqueException + { + if (collResearchInterestCulturalAreas == null) + { + if (isNew()) + { + collResearchInterestCulturalAreas = new ArrayList(); + } + else + { + criteria.add(ResearchInterestCulturalAreaPeer.RESEARCH_INTEREST_ID, getId()); + collResearchInterestCulturalAreas = ResearchInterestCulturalAreaPeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ResearchInterestCulturalAreaPeer.RESEARCH_INTEREST_ID, getId()); + if (!lastResearchInterestCulturalAreasCriteria.equals(criteria)) + { + collResearchInterestCulturalAreas = ResearchInterestCulturalAreaPeer.doSelect(criteria, con); + } + } + } + lastResearchInterestCulturalAreasCriteria = criteria; + + return collResearchInterestCulturalAreas; + } + + + + + + + + + + + + + + + + + + + + + + + + + + /** + * Collection to store aggregation of collResearchInterestDisciplines + */ + protected List collResearchInterestDisciplines; + + /** + * Temporary storage of collResearchInterestDisciplines to save a possible db hit in + * the event objects are add to the collection, but the + * complete collection is never requested. + */ + protected void initResearchInterestDisciplines() + { + if (collResearchInterestDisciplines == null) + { + collResearchInterestDisciplines = new ArrayList(); + } + } + + /** + * Method called to associate a ResearchInterestDiscipline object to this object + * through the ResearchInterestDiscipline foreign key attribute + * + * @param l ResearchInterestDiscipline + * @throws TorqueException + */ + public void addResearchInterestDiscipline(ResearchInterestDiscipline l) throws TorqueException + { + getResearchInterestDisciplines().add(l); + l.setResearchInterest((ResearchInterest) this); + } + + /** + * The criteria used to select the current contents of collResearchInterestDisciplines + */ + private Criteria lastResearchInterestDisciplinesCriteria = null; + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getResearchInterestDisciplines(new Criteria()) + * + * @throws TorqueException + */ + public List getResearchInterestDisciplines() throws TorqueException + { + if (collResearchInterestDisciplines == null) + { + collResearchInterestDisciplines = getResearchInterestDisciplines(new Criteria(10)); + } + return collResearchInterestDisciplines; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this ResearchInterest has previously + * been saved, it will retrieve related ResearchInterestDisciplines from storage. + * If this ResearchInterest is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * + * @throws TorqueException + */ + public List getResearchInterestDisciplines(Criteria criteria) throws TorqueException + { + if (collResearchInterestDisciplines == null) + { + if (isNew()) + { + collResearchInterestDisciplines = new ArrayList(); + } + else + { + criteria.add(ResearchInterestDisciplinePeer.RESEARCH_INTEREST_ID, getId() ); + collResearchInterestDisciplines = ResearchInterestDisciplinePeer.doSelect(criteria); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ResearchInterestDisciplinePeer.RESEARCH_INTEREST_ID, getId()); + if (!lastResearchInterestDisciplinesCriteria.equals(criteria)) + { + collResearchInterestDisciplines = ResearchInterestDisciplinePeer.doSelect(criteria); + } + } + } + lastResearchInterestDisciplinesCriteria = criteria; + + return collResearchInterestDisciplines; + } + + /** + * If this collection has already been initialized, returns + * the collection. Otherwise returns the results of + * getResearchInterestDisciplines(new Criteria(),Connection) + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getResearchInterestDisciplines(Connection con) throws TorqueException + { + if (collResearchInterestDisciplines == null) + { + collResearchInterestDisciplines = getResearchInterestDisciplines(new Criteria(10), con); + } + return collResearchInterestDisciplines; + } + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this ResearchInterest has previously + * been saved, it will retrieve related ResearchInterestDisciplines from storage. + * If this ResearchInterest is new, it will return + * an empty collection or the current collection, the criteria + * is ignored on a new object. + * This method takes in the Connection also as input so that + * referenced objects can also be obtained using a Connection + * that is taken as input + */ + public List getResearchInterestDisciplines(Criteria criteria, Connection con) + throws TorqueException + { + if (collResearchInterestDisciplines == null) + { + if (isNew()) + { + collResearchInterestDisciplines = new ArrayList(); + } + else + { + criteria.add(ResearchInterestDisciplinePeer.RESEARCH_INTEREST_ID, getId()); + collResearchInterestDisciplines = ResearchInterestDisciplinePeer.doSelect(criteria, con); + } + } + else + { + // criteria has no effect for a new object + if (!isNew()) + { + // the following code is to determine if a new query is + // called for. If the criteria is the same as the last + // one, just return the collection. + criteria.add(ResearchInterestDisciplinePeer.RESEARCH_INTEREST_ID, getId()); + if (!lastResearchInterestDisciplinesCriteria.equals(criteria)) + { + collResearchInterestDisciplines = ResearchInterestDisciplinePeer.doSelect(criteria, con); + } + } + } + lastResearchInterestDisciplinesCriteria = criteria; + + return collResearchInterestDisciplines; + } + + + + + + + + + + + + + + + + + + + + + + + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("Interests"); + fieldNames.add("Activities"); + fieldNames.add("CollaborationInterests"); + fieldNames.add("FocusFrom"); + fieldNames.add("FocusTo"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("Interests")) + { + return getInterests(); + } + if (name.equals("Activities")) + { + return getActivities(); + } + if (name.equals("CollaborationInterests")) + { + return getCollaborationInterests(); + } + if (name.equals("FocusFrom")) + { + return getFocusFrom(); + } + if (name.equals("FocusTo")) + { + return getFocusTo(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(ResearchInterestPeer.ID)) + { + return getId(); + } + if (name.equals(ResearchInterestPeer.INTERESTS)) + { + return getInterests(); + } + if (name.equals(ResearchInterestPeer.ACTIVITIES)) + { + return getActivities(); + } + if (name.equals(ResearchInterestPeer.COLLABORATION_INTERESTS)) + { + return getCollaborationInterests(); + } + if (name.equals(ResearchInterestPeer.FOCUS_FROM)) + { + return getFocusFrom(); + } + if (name.equals(ResearchInterestPeer.FOCUS_TO)) + { + return getFocusTo(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getInterests(); + } + if (pos == 2) + { + return getActivities(); + } + if (pos == 3) + { + return getCollaborationInterests(); + } + if (pos == 4) + { + return getFocusFrom(); + } + if (pos == 5) + { + return getFocusTo(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(ResearchInterestPeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + ResearchInterestPeer.doInsert((ResearchInterest) this, con); + setNew(false); + } + else + { + ResearchInterestPeer.doUpdate((ResearchInterest) this, con); + } + } + + + + if (collMembers != null) + { + for (int i = 0; i < collMembers.size(); i++) + { + ((Member) collMembers.get(i)).save(con); + } + } + + + if (collResearchInterestLanguages != null) + { + for (int i = 0; i < collResearchInterestLanguages.size(); i++) + { + ((ResearchInterestLanguage) collResearchInterestLanguages.get(i)).save(con); + } + } + + + if (collResearchInterestCulturalAreas != null) + { + for (int i = 0; i < collResearchInterestCulturalAreas.size(); i++) + { + ((ResearchInterestCulturalArea) collResearchInterestCulturalAreas.get(i)).save(con); + } + } + + + if (collResearchInterestDisciplines != null) + { + for (int i = 0; i < collResearchInterestDisciplines.size(); i++) + { + ((ResearchInterestDiscipline) collResearchInterestDisciplines.get(i)).save(con); + } + } + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + throws TorqueException + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) throws TorqueException + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public ResearchInterest copy() throws TorqueException + { + return copyInto(new ResearchInterest()); + } + + protected ResearchInterest copyInto(ResearchInterest copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setInterests(interests); + copyObj.setActivities(activities); + copyObj.setCollaborationInterests(collaboration_interests); + copyObj.setFocusFrom(focus_from); + copyObj.setFocusTo(focus_to); + + copyObj.setNew(false); + + + List v = getMembers(); + for (int i = 0; i < v.size(); i++) + { + Member obj = (Member) v.get(i); + copyObj.addMember(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + + + v = getResearchInterestLanguages(); + for (int i = 0; i < v.size(); i++) + { + ResearchInterestLanguage obj = (ResearchInterestLanguage) v.get(i); + copyObj.addResearchInterestLanguage(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + + + v = getResearchInterestCulturalAreas(); + for (int i = 0; i < v.size(); i++) + { + ResearchInterestCulturalArea obj = (ResearchInterestCulturalArea) v.get(i); + copyObj.addResearchInterestCulturalArea(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + + + v = getResearchInterestDisciplines(); + for (int i = 0; i < v.size(); i++) + { + ResearchInterestDiscipline obj = (ResearchInterestDiscipline) v.get(i); + copyObj.addResearchInterestDiscipline(obj.copy()); + ((Persistent) v.get(i)).setNew(true); + } + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public ResearchInterestPeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BaseResearchInterestCulturalArea.java b/src/java/org/thdl/roster/om/BaseResearchInterestCulturalArea.java new file mode 100755 index 0000000..5c15b53 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseResearchInterestCulturalArea.java @@ -0,0 +1,584 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to ResearchInterestCulturalArea + */ +public abstract class BaseResearchInterestCulturalArea extends BaseObject +{ + /** The Peer class */ + private static final ResearchInterestCulturalAreaPeer peer = + new ResearchInterestCulturalAreaPeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the cultural_area_id field + */ + private Integer cultural_area_id; + + /** + * The value for the research_interest_id field + */ + private Integer research_interest_id; + + /** + * The value for the relevance field + */ + private Integer relevance; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + } + + + /** + * Get the CulturalAreaId + * + * @return Integer + */ + public Integer getCulturalAreaId() + { + return cultural_area_id; + } + + + /** + * Set the value of CulturalAreaId + * + * @param v new value + */ + public void setCulturalAreaId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.cultural_area_id, v)) + { + this.cultural_area_id = v; + setModified(true); + } + + + if (aCulturalArea != null && !ObjectUtils.equals(aCulturalArea.getId(), v)) + { + aCulturalArea = null; + } + + } + + + /** + * Get the ResearchInterestId + * + * @return Integer + */ + public Integer getResearchInterestId() + { + return research_interest_id; + } + + + /** + * Set the value of ResearchInterestId + * + * @param v new value + */ + public void setResearchInterestId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.research_interest_id, v)) + { + this.research_interest_id = v; + setModified(true); + } + + + if (aResearchInterest != null && !ObjectUtils.equals(aResearchInterest.getId(), v)) + { + aResearchInterest = null; + } + + } + + + /** + * Get the Relevance + * + * @return Integer + */ + public Integer getRelevance() + { + return relevance; + } + + + /** + * Set the value of Relevance + * + * @param v new value + */ + public void setRelevance(Integer v) + { + + + + if (!ObjectUtils.equals(this.relevance, v)) + { + this.relevance = v; + setModified(true); + } + + + } + + + + + + + + private ResearchInterest aResearchInterest; + + /** + * Declares an association between this object and a ResearchInterest object + * + * @param v ResearchInterest + * @throws TorqueException + */ + public void setResearchInterest(ResearchInterest v) throws TorqueException + { + if (v == null) + { + setResearchInterestId((Integer)null); + } + else + { + setResearchInterestId(v.getId()); + } + aResearchInterest = v; + } + + + /** + * Get the associated ResearchInterest object + * + * @return the associated ResearchInterest object + * @throws TorqueException + */ + public ResearchInterest getResearchInterest() throws TorqueException + { + if (aResearchInterest == null && (!ObjectUtils.equals(this.research_interest_id, null))) + { + aResearchInterest = ResearchInterestPeer.retrieveByPK(SimpleKey.keyFor(this.research_interest_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + ResearchInterest obj = ResearchInterestPeer.retrieveByPK(this.research_interest_id); + obj.addResearchInterestCulturalAreas(this); + */ + } + return aResearchInterest; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setResearchInterestKey(ObjectKey key) throws TorqueException + { + + setResearchInterestId(new Integer(((NumberKey) key).intValue())); + } + + + + + private CulturalArea aCulturalArea; + + /** + * Declares an association between this object and a CulturalArea object + * + * @param v CulturalArea + * @throws TorqueException + */ + public void setCulturalArea(CulturalArea v) throws TorqueException + { + if (v == null) + { + setCulturalAreaId((Integer)null); + } + else + { + setCulturalAreaId(v.getId()); + } + aCulturalArea = v; + } + + + /** + * Get the associated CulturalArea object + * + * @return the associated CulturalArea object + * @throws TorqueException + */ + public CulturalArea getCulturalArea() throws TorqueException + { + if (aCulturalArea == null && (!ObjectUtils.equals(this.cultural_area_id, null))) + { + aCulturalArea = CulturalAreaPeer.retrieveByPK(SimpleKey.keyFor(this.cultural_area_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + CulturalArea obj = CulturalAreaPeer.retrieveByPK(this.cultural_area_id); + obj.addResearchInterestCulturalAreas(this); + */ + } + return aCulturalArea; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setCulturalAreaKey(ObjectKey key) throws TorqueException + { + + setCulturalAreaId(new Integer(((NumberKey) key).intValue())); + } + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("CulturalAreaId"); + fieldNames.add("ResearchInterestId"); + fieldNames.add("Relevance"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("CulturalAreaId")) + { + return getCulturalAreaId(); + } + if (name.equals("ResearchInterestId")) + { + return getResearchInterestId(); + } + if (name.equals("Relevance")) + { + return getRelevance(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(ResearchInterestCulturalAreaPeer.ID)) + { + return getId(); + } + if (name.equals(ResearchInterestCulturalAreaPeer.CULTURAL_AREA_ID)) + { + return getCulturalAreaId(); + } + if (name.equals(ResearchInterestCulturalAreaPeer.RESEARCH_INTEREST_ID)) + { + return getResearchInterestId(); + } + if (name.equals(ResearchInterestCulturalAreaPeer.RELEVANCE)) + { + return getRelevance(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getCulturalAreaId(); + } + if (pos == 2) + { + return getResearchInterestId(); + } + if (pos == 3) + { + return getRelevance(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(ResearchInterestCulturalAreaPeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + ResearchInterestCulturalAreaPeer.doInsert((ResearchInterestCulturalArea) this, con); + setNew(false); + } + else + { + ResearchInterestCulturalAreaPeer.doUpdate((ResearchInterestCulturalArea) this, con); + } + } + + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public ResearchInterestCulturalArea copy() throws TorqueException + { + return copyInto(new ResearchInterestCulturalArea()); + } + + protected ResearchInterestCulturalArea copyInto(ResearchInterestCulturalArea copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setCulturalAreaId(cultural_area_id); + copyObj.setResearchInterestId(research_interest_id); + copyObj.setRelevance(relevance); + + copyObj.setNew(false); + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public ResearchInterestCulturalAreaPeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BaseResearchInterestCulturalAreaPeer.java b/src/java/org/thdl/roster/om/BaseResearchInterestCulturalAreaPeer.java new file mode 100755 index 0000000..bd7982d --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseResearchInterestCulturalAreaPeer.java @@ -0,0 +1,946 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BaseResearchInterestCulturalAreaPeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "ResearchInterestCulturalArea"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(ResearchInterestCulturalAreaMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the CULTURAL_AREA_ID field */ + public static final String CULTURAL_AREA_ID; + /** the column name for the RESEARCH_INTEREST_ID field */ + public static final String RESEARCH_INTEREST_ID; + /** the column name for the RELEVANCE field */ + public static final String RELEVANCE; + + static + { + ID = "ResearchInterestCulturalArea.ID"; + CULTURAL_AREA_ID = "ResearchInterestCulturalArea.CULTURAL_AREA_ID"; + RESEARCH_INTEREST_ID = "ResearchInterestCulturalArea.RESEARCH_INTEREST_ID"; + RELEVANCE = "ResearchInterestCulturalArea.RELEVANCE"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(ResearchInterestCulturalAreaMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 4; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.ResearchInterestCulturalArea"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BaseResearchInterestCulturalAreaPeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(CULTURAL_AREA_ID); + criteria.addSelectColumn(RESEARCH_INTEREST_ID); + criteria.addSelectColumn(RELEVANCE); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ResearchInterestCulturalArea row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + ResearchInterestCulturalArea obj = (ResearchInterestCulturalArea) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + ResearchInterestCulturalArea obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setCulturalAreaId(row.getValue(offset + 1).asIntegerObj()); + obj.setResearchInterestId(row.getValue(offset + 2).asIntegerObj()); + obj.setRelevance(row.getValue(offset + 3).asIntegerObj()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BaseResearchInterestCulturalAreaPeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(ResearchInterestCulturalAreaPeer.row2Object(row, 1, + ResearchInterestCulturalAreaPeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BaseResearchInterestCulturalAreaPeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BaseResearchInterestCulturalAreaPeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(ResearchInterestCulturalArea obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(ResearchInterestCulturalArea obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(ResearchInterestCulturalArea obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ResearchInterestCulturalArea obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(ResearchInterestCulturalArea) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(ResearchInterestCulturalArea obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(ResearchInterestCulturalArea) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(ResearchInterestCulturalArea obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ResearchInterestCulturalArea) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ResearchInterestCulturalArea obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BaseResearchInterestCulturalAreaPeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( ResearchInterestCulturalArea obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(CULTURAL_AREA_ID, obj.getCulturalAreaId()); + criteria.add(RESEARCH_INTEREST_ID, obj.getResearchInterestId()); + criteria.add(RELEVANCE, obj.getRelevance()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ResearchInterestCulturalArea retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ResearchInterestCulturalArea retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + ResearchInterestCulturalArea retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ResearchInterestCulturalArea retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (ResearchInterestCulturalArea)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + + + /** + * selects a collection of ResearchInterestCulturalArea objects pre-filled with their + * ResearchInterest objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in ResearchInterestCulturalAreaPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinResearchInterest(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + ResearchInterestCulturalAreaPeer.addSelectColumns(c); + int offset = numColumns + 1; + ResearchInterestPeer.addSelectColumns(c); + + + c.addJoin(ResearchInterestCulturalAreaPeer.RESEARCH_INTEREST_ID, + ResearchInterestPeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = ResearchInterestCulturalAreaPeer.getOMClass(); + + ResearchInterestCulturalArea obj1 = (ResearchInterestCulturalArea) ResearchInterestCulturalAreaPeer + .row2Object(row, 1, omClass); + + + omClass = ResearchInterestPeer.getOMClass(); + ResearchInterest obj2 = (ResearchInterest)ResearchInterestPeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + ResearchInterestCulturalArea temp_obj1 = (ResearchInterestCulturalArea)results.get(j); + ResearchInterest temp_obj2 = (ResearchInterest)temp_obj1.getResearchInterest(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addResearchInterestCulturalArea(obj1); + break; + } + } + if (newObject) + { + obj2.initResearchInterestCulturalAreas(); + obj2.addResearchInterestCulturalArea(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + + /** + * selects a collection of ResearchInterestCulturalArea objects pre-filled with their + * CulturalArea objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in ResearchInterestCulturalAreaPeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinCulturalArea(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + ResearchInterestCulturalAreaPeer.addSelectColumns(c); + int offset = numColumns + 1; + CulturalAreaPeer.addSelectColumns(c); + + + c.addJoin(ResearchInterestCulturalAreaPeer.CULTURAL_AREA_ID, + CulturalAreaPeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = ResearchInterestCulturalAreaPeer.getOMClass(); + + ResearchInterestCulturalArea obj1 = (ResearchInterestCulturalArea) ResearchInterestCulturalAreaPeer + .row2Object(row, 1, omClass); + + + omClass = CulturalAreaPeer.getOMClass(); + CulturalArea obj2 = (CulturalArea)CulturalAreaPeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + ResearchInterestCulturalArea temp_obj1 = (ResearchInterestCulturalArea)results.get(j); + CulturalArea temp_obj2 = (CulturalArea)temp_obj1.getCulturalArea(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addResearchInterestCulturalArea(obj1); + break; + } + } + if (newObject) + { + obj2.initResearchInterestCulturalAreas(); + obj2.addResearchInterestCulturalArea(obj1); + } + results.add(obj1); + } + return results; + } + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BaseResearchInterestDiscipline.java b/src/java/org/thdl/roster/om/BaseResearchInterestDiscipline.java new file mode 100755 index 0000000..2a105f1 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseResearchInterestDiscipline.java @@ -0,0 +1,584 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to ResearchInterestDiscipline + */ +public abstract class BaseResearchInterestDiscipline extends BaseObject +{ + /** The Peer class */ + private static final ResearchInterestDisciplinePeer peer = + new ResearchInterestDisciplinePeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the discipline_id field + */ + private Integer discipline_id; + + /** + * The value for the research_interest_id field + */ + private Integer research_interest_id; + + /** + * The value for the relevance field + */ + private Integer relevance; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + } + + + /** + * Get the DisciplineId + * + * @return Integer + */ + public Integer getDisciplineId() + { + return discipline_id; + } + + + /** + * Set the value of DisciplineId + * + * @param v new value + */ + public void setDisciplineId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.discipline_id, v)) + { + this.discipline_id = v; + setModified(true); + } + + + if (aDiscipline != null && !ObjectUtils.equals(aDiscipline.getId(), v)) + { + aDiscipline = null; + } + + } + + + /** + * Get the ResearchInterestId + * + * @return Integer + */ + public Integer getResearchInterestId() + { + return research_interest_id; + } + + + /** + * Set the value of ResearchInterestId + * + * @param v new value + */ + public void setResearchInterestId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.research_interest_id, v)) + { + this.research_interest_id = v; + setModified(true); + } + + + if (aResearchInterest != null && !ObjectUtils.equals(aResearchInterest.getId(), v)) + { + aResearchInterest = null; + } + + } + + + /** + * Get the Relevance + * + * @return Integer + */ + public Integer getRelevance() + { + return relevance; + } + + + /** + * Set the value of Relevance + * + * @param v new value + */ + public void setRelevance(Integer v) + { + + + + if (!ObjectUtils.equals(this.relevance, v)) + { + this.relevance = v; + setModified(true); + } + + + } + + + + + + + + private ResearchInterest aResearchInterest; + + /** + * Declares an association between this object and a ResearchInterest object + * + * @param v ResearchInterest + * @throws TorqueException + */ + public void setResearchInterest(ResearchInterest v) throws TorqueException + { + if (v == null) + { + setResearchInterestId((Integer)null); + } + else + { + setResearchInterestId(v.getId()); + } + aResearchInterest = v; + } + + + /** + * Get the associated ResearchInterest object + * + * @return the associated ResearchInterest object + * @throws TorqueException + */ + public ResearchInterest getResearchInterest() throws TorqueException + { + if (aResearchInterest == null && (!ObjectUtils.equals(this.research_interest_id, null))) + { + aResearchInterest = ResearchInterestPeer.retrieveByPK(SimpleKey.keyFor(this.research_interest_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + ResearchInterest obj = ResearchInterestPeer.retrieveByPK(this.research_interest_id); + obj.addResearchInterestDisciplines(this); + */ + } + return aResearchInterest; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setResearchInterestKey(ObjectKey key) throws TorqueException + { + + setResearchInterestId(new Integer(((NumberKey) key).intValue())); + } + + + + + private Discipline aDiscipline; + + /** + * Declares an association between this object and a Discipline object + * + * @param v Discipline + * @throws TorqueException + */ + public void setDiscipline(Discipline v) throws TorqueException + { + if (v == null) + { + setDisciplineId((Integer)null); + } + else + { + setDisciplineId(v.getId()); + } + aDiscipline = v; + } + + + /** + * Get the associated Discipline object + * + * @return the associated Discipline object + * @throws TorqueException + */ + public Discipline getDiscipline() throws TorqueException + { + if (aDiscipline == null && (!ObjectUtils.equals(this.discipline_id, null))) + { + aDiscipline = DisciplinePeer.retrieveByPK(SimpleKey.keyFor(this.discipline_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + Discipline obj = DisciplinePeer.retrieveByPK(this.discipline_id); + obj.addResearchInterestDisciplines(this); + */ + } + return aDiscipline; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setDisciplineKey(ObjectKey key) throws TorqueException + { + + setDisciplineId(new Integer(((NumberKey) key).intValue())); + } + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("DisciplineId"); + fieldNames.add("ResearchInterestId"); + fieldNames.add("Relevance"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("DisciplineId")) + { + return getDisciplineId(); + } + if (name.equals("ResearchInterestId")) + { + return getResearchInterestId(); + } + if (name.equals("Relevance")) + { + return getRelevance(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(ResearchInterestDisciplinePeer.ID)) + { + return getId(); + } + if (name.equals(ResearchInterestDisciplinePeer.DISCIPLINE_ID)) + { + return getDisciplineId(); + } + if (name.equals(ResearchInterestDisciplinePeer.RESEARCH_INTEREST_ID)) + { + return getResearchInterestId(); + } + if (name.equals(ResearchInterestDisciplinePeer.RELEVANCE)) + { + return getRelevance(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getDisciplineId(); + } + if (pos == 2) + { + return getResearchInterestId(); + } + if (pos == 3) + { + return getRelevance(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(ResearchInterestDisciplinePeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + ResearchInterestDisciplinePeer.doInsert((ResearchInterestDiscipline) this, con); + setNew(false); + } + else + { + ResearchInterestDisciplinePeer.doUpdate((ResearchInterestDiscipline) this, con); + } + } + + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public ResearchInterestDiscipline copy() throws TorqueException + { + return copyInto(new ResearchInterestDiscipline()); + } + + protected ResearchInterestDiscipline copyInto(ResearchInterestDiscipline copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setDisciplineId(discipline_id); + copyObj.setResearchInterestId(research_interest_id); + copyObj.setRelevance(relevance); + + copyObj.setNew(false); + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public ResearchInterestDisciplinePeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BaseResearchInterestDisciplinePeer.java b/src/java/org/thdl/roster/om/BaseResearchInterestDisciplinePeer.java new file mode 100755 index 0000000..96ef3cd --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseResearchInterestDisciplinePeer.java @@ -0,0 +1,946 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BaseResearchInterestDisciplinePeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "ResearchInterestDiscipline"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(ResearchInterestDisciplineMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the DISCIPLINE_ID field */ + public static final String DISCIPLINE_ID; + /** the column name for the RESEARCH_INTEREST_ID field */ + public static final String RESEARCH_INTEREST_ID; + /** the column name for the RELEVANCE field */ + public static final String RELEVANCE; + + static + { + ID = "ResearchInterestDiscipline.ID"; + DISCIPLINE_ID = "ResearchInterestDiscipline.DISCIPLINE_ID"; + RESEARCH_INTEREST_ID = "ResearchInterestDiscipline.RESEARCH_INTEREST_ID"; + RELEVANCE = "ResearchInterestDiscipline.RELEVANCE"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(ResearchInterestDisciplineMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 4; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.ResearchInterestDiscipline"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BaseResearchInterestDisciplinePeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(DISCIPLINE_ID); + criteria.addSelectColumn(RESEARCH_INTEREST_ID); + criteria.addSelectColumn(RELEVANCE); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ResearchInterestDiscipline row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + ResearchInterestDiscipline obj = (ResearchInterestDiscipline) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + ResearchInterestDiscipline obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setDisciplineId(row.getValue(offset + 1).asIntegerObj()); + obj.setResearchInterestId(row.getValue(offset + 2).asIntegerObj()); + obj.setRelevance(row.getValue(offset + 3).asIntegerObj()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BaseResearchInterestDisciplinePeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(ResearchInterestDisciplinePeer.row2Object(row, 1, + ResearchInterestDisciplinePeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BaseResearchInterestDisciplinePeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BaseResearchInterestDisciplinePeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(ResearchInterestDiscipline obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(ResearchInterestDiscipline obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(ResearchInterestDiscipline obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ResearchInterestDiscipline obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(ResearchInterestDiscipline) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(ResearchInterestDiscipline obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(ResearchInterestDiscipline) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(ResearchInterestDiscipline obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ResearchInterestDiscipline) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ResearchInterestDiscipline obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BaseResearchInterestDisciplinePeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( ResearchInterestDiscipline obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(DISCIPLINE_ID, obj.getDisciplineId()); + criteria.add(RESEARCH_INTEREST_ID, obj.getResearchInterestId()); + criteria.add(RELEVANCE, obj.getRelevance()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ResearchInterestDiscipline retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ResearchInterestDiscipline retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + ResearchInterestDiscipline retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ResearchInterestDiscipline retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (ResearchInterestDiscipline)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + + + /** + * selects a collection of ResearchInterestDiscipline objects pre-filled with their + * ResearchInterest objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in ResearchInterestDisciplinePeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinResearchInterest(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + ResearchInterestDisciplinePeer.addSelectColumns(c); + int offset = numColumns + 1; + ResearchInterestPeer.addSelectColumns(c); + + + c.addJoin(ResearchInterestDisciplinePeer.RESEARCH_INTEREST_ID, + ResearchInterestPeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = ResearchInterestDisciplinePeer.getOMClass(); + + ResearchInterestDiscipline obj1 = (ResearchInterestDiscipline) ResearchInterestDisciplinePeer + .row2Object(row, 1, omClass); + + + omClass = ResearchInterestPeer.getOMClass(); + ResearchInterest obj2 = (ResearchInterest)ResearchInterestPeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + ResearchInterestDiscipline temp_obj1 = (ResearchInterestDiscipline)results.get(j); + ResearchInterest temp_obj2 = (ResearchInterest)temp_obj1.getResearchInterest(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addResearchInterestDiscipline(obj1); + break; + } + } + if (newObject) + { + obj2.initResearchInterestDisciplines(); + obj2.addResearchInterestDiscipline(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + + /** + * selects a collection of ResearchInterestDiscipline objects pre-filled with their + * Discipline objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in ResearchInterestDisciplinePeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinDiscipline(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + ResearchInterestDisciplinePeer.addSelectColumns(c); + int offset = numColumns + 1; + DisciplinePeer.addSelectColumns(c); + + + c.addJoin(ResearchInterestDisciplinePeer.DISCIPLINE_ID, + DisciplinePeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = ResearchInterestDisciplinePeer.getOMClass(); + + ResearchInterestDiscipline obj1 = (ResearchInterestDiscipline) ResearchInterestDisciplinePeer + .row2Object(row, 1, omClass); + + + omClass = DisciplinePeer.getOMClass(); + Discipline obj2 = (Discipline)DisciplinePeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + ResearchInterestDiscipline temp_obj1 = (ResearchInterestDiscipline)results.get(j); + Discipline temp_obj2 = (Discipline)temp_obj1.getDiscipline(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addResearchInterestDiscipline(obj1); + break; + } + } + if (newObject) + { + obj2.initResearchInterestDisciplines(); + obj2.addResearchInterestDiscipline(obj1); + } + results.add(obj1); + } + return results; + } + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BaseResearchInterestLanguage.java b/src/java/org/thdl/roster/om/BaseResearchInterestLanguage.java new file mode 100755 index 0000000..84f9651 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseResearchInterestLanguage.java @@ -0,0 +1,584 @@ +package org.thdl.roster.om; + + +import java.math.BigDecimal; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Date; +import java.util.Collections; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.apache.torque.TorqueException; +import org.apache.torque.om.BaseObject; +import org.apache.torque.om.ComboKey; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.util.Criteria; +import org.apache.torque.util.Transaction; + + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + * You should not use this class directly. It should not even be + * extended all references should be to ResearchInterestLanguage + */ +public abstract class BaseResearchInterestLanguage extends BaseObject +{ + /** The Peer class */ + private static final ResearchInterestLanguagePeer peer = + new ResearchInterestLanguagePeer(); + + + /** + * The value for the id field + */ + private Integer id; + + /** + * The value for the language_id field + */ + private Integer language_id; + + /** + * The value for the research_interest_id field + */ + private Integer research_interest_id; + + /** + * The value for the relevance field + */ + private Integer relevance; + + + /** + * Get the Id + * + * @return Integer + */ + public Integer getId() + { + return id; + } + + + /** + * Set the value of Id + * + * @param v new value + */ + public void setId(Integer v) + { + + + + if (!ObjectUtils.equals(this.id, v)) + { + this.id = v; + setModified(true); + } + + + } + + + /** + * Get the LanguageId + * + * @return Integer + */ + public Integer getLanguageId() + { + return language_id; + } + + + /** + * Set the value of LanguageId + * + * @param v new value + */ + public void setLanguageId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.language_id, v)) + { + this.language_id = v; + setModified(true); + } + + + if (aLanguage != null && !ObjectUtils.equals(aLanguage.getId(), v)) + { + aLanguage = null; + } + + } + + + /** + * Get the ResearchInterestId + * + * @return Integer + */ + public Integer getResearchInterestId() + { + return research_interest_id; + } + + + /** + * Set the value of ResearchInterestId + * + * @param v new value + */ + public void setResearchInterestId(Integer v) throws TorqueException + { + + + + if (!ObjectUtils.equals(this.research_interest_id, v)) + { + this.research_interest_id = v; + setModified(true); + } + + + if (aResearchInterest != null && !ObjectUtils.equals(aResearchInterest.getId(), v)) + { + aResearchInterest = null; + } + + } + + + /** + * Get the Relevance + * + * @return Integer + */ + public Integer getRelevance() + { + return relevance; + } + + + /** + * Set the value of Relevance + * + * @param v new value + */ + public void setRelevance(Integer v) + { + + + + if (!ObjectUtils.equals(this.relevance, v)) + { + this.relevance = v; + setModified(true); + } + + + } + + + + + + + + private ResearchInterest aResearchInterest; + + /** + * Declares an association between this object and a ResearchInterest object + * + * @param v ResearchInterest + * @throws TorqueException + */ + public void setResearchInterest(ResearchInterest v) throws TorqueException + { + if (v == null) + { + setResearchInterestId((Integer)null); + } + else + { + setResearchInterestId(v.getId()); + } + aResearchInterest = v; + } + + + /** + * Get the associated ResearchInterest object + * + * @return the associated ResearchInterest object + * @throws TorqueException + */ + public ResearchInterest getResearchInterest() throws TorqueException + { + if (aResearchInterest == null && (!ObjectUtils.equals(this.research_interest_id, null))) + { + aResearchInterest = ResearchInterestPeer.retrieveByPK(SimpleKey.keyFor(this.research_interest_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + ResearchInterest obj = ResearchInterestPeer.retrieveByPK(this.research_interest_id); + obj.addResearchInterestLanguages(this); + */ + } + return aResearchInterest; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setResearchInterestKey(ObjectKey key) throws TorqueException + { + + setResearchInterestId(new Integer(((NumberKey) key).intValue())); + } + + + + + private Language aLanguage; + + /** + * Declares an association between this object and a Language object + * + * @param v Language + * @throws TorqueException + */ + public void setLanguage(Language v) throws TorqueException + { + if (v == null) + { + setLanguageId((Integer)null); + } + else + { + setLanguageId(v.getId()); + } + aLanguage = v; + } + + + /** + * Get the associated Language object + * + * @return the associated Language object + * @throws TorqueException + */ + public Language getLanguage() throws TorqueException + { + if (aLanguage == null && (!ObjectUtils.equals(this.language_id, null))) + { + aLanguage = LanguagePeer.retrieveByPK(SimpleKey.keyFor(this.language_id)); + + /* The following can be used instead of the line above to + guarantee the related object contains a reference + to this object, but this level of coupling + may be undesirable in many circumstances. + As it can lead to a db query with many results that may + never be used. + Language obj = LanguagePeer.retrieveByPK(this.language_id); + obj.addResearchInterestLanguages(this); + */ + } + return aLanguage; + } + + /** + * Provides convenient way to set a relationship based on a + * ObjectKey. e.g. + * bar.setFooKey(foo.getPrimaryKey()) + * + */ + public void setLanguageKey(ObjectKey key) throws TorqueException + { + + setLanguageId(new Integer(((NumberKey) key).intValue())); + } + + + + private static List fieldNames = null; + + /** + * Generate a list of field names. + * + * @return a list of field names + */ + public static synchronized List getFieldNames() + { + if (fieldNames == null) + { + fieldNames = new ArrayList(); + fieldNames.add("Id"); + fieldNames.add("LanguageId"); + fieldNames.add("ResearchInterestId"); + fieldNames.add("Relevance"); + fieldNames = Collections.unmodifiableList(fieldNames); + } + return fieldNames; + } + + /** + * Retrieves a field from the object by name passed in as a String. + * + * @param name field name + * @return value + */ + public Object getByName(String name) + { + if (name.equals("Id")) + { + return getId(); + } + if (name.equals("LanguageId")) + { + return getLanguageId(); + } + if (name.equals("ResearchInterestId")) + { + return getResearchInterestId(); + } + if (name.equals("Relevance")) + { + return getRelevance(); + } + return null; + } + /** + * Retrieves a field from the object by name passed in + * as a String. The String must be one of the static + * Strings defined in this Class' Peer. + * + * @param name peer name + * @return value + */ + public Object getByPeerName(String name) + { + if (name.equals(ResearchInterestLanguagePeer.ID)) + { + return getId(); + } + if (name.equals(ResearchInterestLanguagePeer.LANGUAGE_ID)) + { + return getLanguageId(); + } + if (name.equals(ResearchInterestLanguagePeer.RESEARCH_INTEREST_ID)) + { + return getResearchInterestId(); + } + if (name.equals(ResearchInterestLanguagePeer.RELEVANCE)) + { + return getRelevance(); + } + return null; + } + + /** + * Retrieves a field from the object by Position as specified + * in the xml schema. Zero-based. + * + * @param pos position in xml schema + * @return value + */ + public Object getByPosition(int pos) + { + if (pos == 0) + { + return getId(); + } + if (pos == 1) + { + return getLanguageId(); + } + if (pos == 2) + { + return getResearchInterestId(); + } + if (pos == 3) + { + return getRelevance(); + } + return null; + } + + + + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * + * @throws Exception + */ + public void save() throws Exception + { + save(ResearchInterestLanguagePeer.getMapBuilder() + .getDatabaseMap().getName()); + } + + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. + * Note: this code is here because the method body is + * auto-generated conditionally and therefore needs to be + * in this file instead of in the super class, BaseObject. + * + * @param dbName + * @throws TorqueException + */ + public void save(String dbName) throws TorqueException + { + Connection con = null; + try + { + con = Transaction.begin(dbName); + save(con); + Transaction.commit(con); + } + catch(TorqueException e) + { + Transaction.safeRollback(con); + throw e; + } + + } + + /** flag to prevent endless save loop, if this object is referenced + by another object which falls in this transaction. */ + private boolean alreadyInSave = false; + /** + * Stores the object in the database. If the object is new, + * it inserts it; otherwise an update is performed. This method + * is meant to be used as part of a transaction, otherwise use + * the save() method and the connection details will be handled + * internally + * + * @param con + * @throws TorqueException + */ + public void save(Connection con) throws TorqueException + { + if (!alreadyInSave) + { + alreadyInSave = true; + + + + + // If this object has been modified, then save it to the database. + if (isModified()) + { + if (isNew()) + { + ResearchInterestLanguagePeer.doInsert((ResearchInterestLanguage) this, con); + setNew(false); + } + else + { + ResearchInterestLanguagePeer.doUpdate((ResearchInterestLanguage) this, con); + } + } + + alreadyInSave = false; + } + } + + + + + + + /** + * Set the PrimaryKey using ObjectKey. + * + * @param id ObjectKey + */ + public void setPrimaryKey(ObjectKey key) + + { + setId(new Integer(((NumberKey) key).intValue())); + } + + /** + * Set the PrimaryKey using a String. + * + * @param key + */ + public void setPrimaryKey(String key) + { + setId(new Integer(key)); + } + + + /** + * returns an id that differentiates this object from others + * of its class. + */ + public ObjectKey getPrimaryKey() + { + return SimpleKey.keyFor(getId()); + } + + + + /** + * Makes a copy of this object. + * It creates a new object filling in the simple attributes. + * It then fills all the association collections and sets the + * related objects to isNew=true. + */ + public ResearchInterestLanguage copy() throws TorqueException + { + return copyInto(new ResearchInterestLanguage()); + } + + protected ResearchInterestLanguage copyInto(ResearchInterestLanguage copyObj) throws TorqueException + { + copyObj.setId(id); + copyObj.setLanguageId(language_id); + copyObj.setResearchInterestId(research_interest_id); + copyObj.setRelevance(relevance); + + copyObj.setNew(false); + copyObj.setNew(true); + + copyObj.setId((Integer)null); + return copyObj; + } + + /** + * returns a peer instance associated with this om. Since Peer classes + * are not to have any instance attributes, this method returns the + * same instance for all member of this class. The method could therefore + * be static, but this would prevent one from overriding the behavior. + */ + public ResearchInterestLanguagePeer getPeer() + { + return peer; + } +} diff --git a/src/java/org/thdl/roster/om/BaseResearchInterestLanguagePeer.java b/src/java/org/thdl/roster/om/BaseResearchInterestLanguagePeer.java new file mode 100755 index 0000000..9ecacba --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseResearchInterestLanguagePeer.java @@ -0,0 +1,946 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BaseResearchInterestLanguagePeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "ResearchInterestLanguage"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(ResearchInterestLanguageMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the LANGUAGE_ID field */ + public static final String LANGUAGE_ID; + /** the column name for the RESEARCH_INTEREST_ID field */ + public static final String RESEARCH_INTEREST_ID; + /** the column name for the RELEVANCE field */ + public static final String RELEVANCE; + + static + { + ID = "ResearchInterestLanguage.ID"; + LANGUAGE_ID = "ResearchInterestLanguage.LANGUAGE_ID"; + RESEARCH_INTEREST_ID = "ResearchInterestLanguage.RESEARCH_INTEREST_ID"; + RELEVANCE = "ResearchInterestLanguage.RELEVANCE"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(ResearchInterestLanguageMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 4; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.ResearchInterestLanguage"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BaseResearchInterestLanguagePeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(LANGUAGE_ID); + criteria.addSelectColumn(RESEARCH_INTEREST_ID); + criteria.addSelectColumn(RELEVANCE); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ResearchInterestLanguage row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + ResearchInterestLanguage obj = (ResearchInterestLanguage) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + ResearchInterestLanguage obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setLanguageId(row.getValue(offset + 1).asIntegerObj()); + obj.setResearchInterestId(row.getValue(offset + 2).asIntegerObj()); + obj.setRelevance(row.getValue(offset + 3).asIntegerObj()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BaseResearchInterestLanguagePeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(ResearchInterestLanguagePeer.row2Object(row, 1, + ResearchInterestLanguagePeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BaseResearchInterestLanguagePeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BaseResearchInterestLanguagePeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(ResearchInterestLanguage obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(ResearchInterestLanguage obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(ResearchInterestLanguage obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ResearchInterestLanguage obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(ResearchInterestLanguage) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(ResearchInterestLanguage obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(ResearchInterestLanguage) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(ResearchInterestLanguage obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ResearchInterestLanguage) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ResearchInterestLanguage obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BaseResearchInterestLanguagePeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( ResearchInterestLanguage obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(LANGUAGE_ID, obj.getLanguageId()); + criteria.add(RESEARCH_INTEREST_ID, obj.getResearchInterestId()); + criteria.add(RELEVANCE, obj.getRelevance()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ResearchInterestLanguage retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ResearchInterestLanguage retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + ResearchInterestLanguage retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ResearchInterestLanguage retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (ResearchInterestLanguage)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + + + /** + * selects a collection of ResearchInterestLanguage objects pre-filled with their + * ResearchInterest objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in ResearchInterestLanguagePeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinResearchInterest(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + ResearchInterestLanguagePeer.addSelectColumns(c); + int offset = numColumns + 1; + ResearchInterestPeer.addSelectColumns(c); + + + c.addJoin(ResearchInterestLanguagePeer.RESEARCH_INTEREST_ID, + ResearchInterestPeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = ResearchInterestLanguagePeer.getOMClass(); + + ResearchInterestLanguage obj1 = (ResearchInterestLanguage) ResearchInterestLanguagePeer + .row2Object(row, 1, omClass); + + + omClass = ResearchInterestPeer.getOMClass(); + ResearchInterest obj2 = (ResearchInterest)ResearchInterestPeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + ResearchInterestLanguage temp_obj1 = (ResearchInterestLanguage)results.get(j); + ResearchInterest temp_obj2 = (ResearchInterest)temp_obj1.getResearchInterest(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addResearchInterestLanguage(obj1); + break; + } + } + if (newObject) + { + obj2.initResearchInterestLanguages(); + obj2.addResearchInterestLanguage(obj1); + } + results.add(obj1); + } + return results; + } + + + + + + + /** + * selects a collection of ResearchInterestLanguage objects pre-filled with their + * Language objects. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in ResearchInterestLanguagePeer. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static List doSelectJoinLanguage(Criteria c) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // c.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (c.getDbName() == Torque.getDefaultDB()) + { + c.setDbName(DATABASE_NAME); + } + + ResearchInterestLanguagePeer.addSelectColumns(c); + int offset = numColumns + 1; + LanguagePeer.addSelectColumns(c); + + + c.addJoin(ResearchInterestLanguagePeer.LANGUAGE_ID, + LanguagePeer.ID); + + + + List rows = BasePeer.doSelect(c); + List results = new ArrayList(); + + for (int i = 0; i < rows.size(); i++) + { + Record row = (Record) rows.get(i); + + Class omClass = ResearchInterestLanguagePeer.getOMClass(); + + ResearchInterestLanguage obj1 = (ResearchInterestLanguage) ResearchInterestLanguagePeer + .row2Object(row, 1, omClass); + + + omClass = LanguagePeer.getOMClass(); + Language obj2 = (Language)LanguagePeer + .row2Object(row, offset, omClass); + + boolean newObject = true; + for (int j = 0; j < results.size(); j++) + { + ResearchInterestLanguage temp_obj1 = (ResearchInterestLanguage)results.get(j); + Language temp_obj2 = (Language)temp_obj1.getLanguage(); + if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey())) + { + newObject = false; + temp_obj2.addResearchInterestLanguage(obj1); + break; + } + } + if (newObject) + { + obj2.initResearchInterestLanguages(); + obj2.addResearchInterestLanguage(obj1); + } + results.add(obj1); + } + return results; + } + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/BaseResearchInterestPeer.java b/src/java/org/thdl/roster/om/BaseResearchInterestPeer.java new file mode 100755 index 0000000..9020158 --- /dev/null +++ b/src/java/org/thdl/roster/om/BaseResearchInterestPeer.java @@ -0,0 +1,802 @@ +package org.thdl.roster.om; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.TableMap; +import org.apache.torque.om.DateKey; +import org.apache.torque.om.NumberKey; +import org.apache.torque.om.StringKey; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.SimpleKey; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; + +import com.workingdogs.village.DataSetException; +import com.workingdogs.village.QueryDataSet; +import com.workingdogs.village.Record; + +// Local classes +import org.thdl.roster.om.map.*; + + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public abstract class BaseResearchInterestPeer + extends BasePeer +{ + + /** the default database name for this class */ + public static final String DATABASE_NAME = "Roster"; + + /** the table name for this class */ + public static final String TABLE_NAME = "ResearchInterest"; + + /** + * @return the map builder for this peer + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static MapBuilder getMapBuilder() + throws TorqueException + { + return getMapBuilder(ResearchInterestMapBuilder.CLASS_NAME); + } + + /** the column name for the ID field */ + public static final String ID; + /** the column name for the INTERESTS field */ + public static final String INTERESTS; + /** the column name for the ACTIVITIES field */ + public static final String ACTIVITIES; + /** the column name for the COLLABORATION_INTERESTS field */ + public static final String COLLABORATION_INTERESTS; + /** the column name for the FOCUS_FROM field */ + public static final String FOCUS_FROM; + /** the column name for the FOCUS_TO field */ + public static final String FOCUS_TO; + + static + { + ID = "ResearchInterest.ID"; + INTERESTS = "ResearchInterest.INTERESTS"; + ACTIVITIES = "ResearchInterest.ACTIVITIES"; + COLLABORATION_INTERESTS = "ResearchInterest.COLLABORATION_INTERESTS"; + FOCUS_FROM = "ResearchInterest.FOCUS_FROM"; + FOCUS_TO = "ResearchInterest.FOCUS_TO"; + + if (Torque.isInit()) + { + try + { + getMapBuilder(); + } + catch (Exception e) + { + category.error("Could not initialize Peer", e); + } + } + else + { + Torque.registerMapBuilder(ResearchInterestMapBuilder.CLASS_NAME); + } + } + + + /** number of columns for this peer */ + public static final int numColumns = 6; + + /** A class that can be returned by this peer. */ + protected static final String CLASSNAME_DEFAULT = + "org.thdl.roster.om.ResearchInterest"; + + /** A class that can be returned by this peer. */ + protected static final Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT); + + /** + * Class object initialization method. + * + * @param className name of the class to initialize + * @return the initialized class + */ + private static Class initClass(String className) + { + Class c = null; + try + { + c = Class.forName(className); + } + catch (Throwable t) + { + category.error("A FATAL ERROR has occurred which should not " + + "have happened under any circumstance. Please notify " + + "the Turbine developers " + + "and give as many details as possible (including the error " + + "stack trace).", t); + + // Error objects should always be propogated. + if (t instanceof Error) + { + throw (Error) t.fillInStackTrace(); + } + } + return c; + } + + + /** + * Get the list of objects for a ResultSet. Please not that your + * resultset MUST return columns in the right order. You can use + * getFieldNames() in BaseObject to get the correct sequence. + * + * @param results the ResultSet + * @return the list of objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List resultSet2Objects(java.sql.ResultSet results) + throws TorqueException + { + try + { + QueryDataSet qds = null; + List rows = null; + try + { + qds = new QueryDataSet(results); + rows = getSelectResults(qds); + } + finally + { + if (qds != null) + { + qds.close(); + } + } + + return populateObjects(rows); + } + catch (SQLException e) + { + throw new TorqueException(e); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + + + /** + * Method to do inserts. + * + * @param criteria object used to create the INSERT statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria) + throws TorqueException + { + return BaseResearchInterestPeer + .doInsert(criteria, (Connection) null); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object used to create the INSERT statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ObjectKey doInsert(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + return BasePeer.doInsert(criteria); + } + else + { + return BasePeer.doInsert(criteria, con); + } + } + + /** + * Add all the columns needed to create a new object. + * + * @param criteria object containing the columns to add. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void addSelectColumns(Criteria criteria) + throws TorqueException + { + criteria.addSelectColumn(ID); + criteria.addSelectColumn(INTERESTS); + criteria.addSelectColumn(ACTIVITIES); + criteria.addSelectColumn(COLLABORATION_INTERESTS); + criteria.addSelectColumn(FOCUS_FROM); + criteria.addSelectColumn(FOCUS_TO); + } + + + /** + * Create a new object of type cls from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ResearchInterest row2Object(Record row, + int offset, + Class cls) + throws TorqueException + { + try + { + ResearchInterest obj = (ResearchInterest) cls.newInstance(); + populateObject(row, offset, obj); + obj.setModified(false); + obj.setNew(false); + + return obj; + } + catch (InstantiationException e) + { + throw new TorqueException(e); + } + catch (IllegalAccessException e) + { + throw new TorqueException(e); + } + } + + /** + * Populates an object from a resultset row starting + * from a specified offset. This is done so that you can select + * other rows than just those needed for this object. You may + * for example want to create two objects from the same row. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void populateObject(Record row, + int offset, + ResearchInterest obj) + throws TorqueException + { + try + { + obj.setId(row.getValue(offset + 0).asIntegerObj()); + obj.setInterests(row.getValue(offset + 1).asString()); + obj.setActivities(row.getValue(offset + 2).asString()); + obj.setCollaborationInterests(row.getValue(offset + 3).asString()); + obj.setFocusFrom(row.getValue(offset + 4).asIntegerObj()); + obj.setFocusTo(row.getValue(offset + 5).asIntegerObj()); + } + catch (DataSetException e) + { + throw new TorqueException(e); + } + } + + /** + * Method to do selects. + * + * @param criteria object used to create the SELECT statement. + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria) throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria)); + } + + /** + * Method to do selects within a transaction. + * + * @param criteria object used to create the SELECT statement. + * @param con the connection to use + * @return List of selected Objects + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(Criteria criteria, Connection con) + throws TorqueException + { + return populateObjects(doSelectVillageRecords(criteria, con)); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method handles connections internally. The Record objects + * returned by this method should be considered readonly. Do not + * alter the data and call save(), your results may vary, but are + * certainly likely to result in hard to track MT bugs. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria) + throws TorqueException + { + return BaseResearchInterestPeer + .doSelectVillageRecords(criteria, (Connection) null); + } + + /** + * Grabs the raw Village records to be formed into objects. + * This method should be used for transactions + * + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelectVillageRecords(Criteria criteria, Connection con) + throws TorqueException + { + + if (criteria.getSelectColumns().size() == 0) + { + addSelectColumns(criteria); + } + + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + // BasePeer returns a List of Value (Village) arrays. The array + // order follows the order columns were placed in the Select clause. + if (con == null) + { + return BasePeer.doSelect(criteria); + } + else + { + return BasePeer.doSelect(criteria, con); + } + } + + /** + * The returned List will contain objects of the default type or + * objects that inherit from the default. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List populateObjects(List records) + throws TorqueException + { + List results = new ArrayList(records.size()); + + // populate the object(s) + for (int i = 0; i < records.size(); i++) + { + Record row = (Record) records.get(i); + results.add(ResearchInterestPeer.row2Object(row, 1, + ResearchInterestPeer.getOMClass())); + } + return results; + } + + + /** + * The class that the Peer will make instances of. + * If the BO is abstract then you must implement this method + * in the BO. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static Class getOMClass() + throws TorqueException + { + return CLASS_DEFAULT; + } + + + /** + * Method to do updates. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria) throws TorqueException + { + BaseResearchInterestPeer + .doUpdate(criteria, (Connection) null); + } + + /** + * Method to do updates. This method is to be used during a transaction, + * otherwise use the doUpdate(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used to create the UPDATE + * statement. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(Criteria criteria, Connection con) + throws TorqueException + { + Criteria selectCriteria = new Criteria(DATABASE_NAME, 2); + selectCriteria.put(ID, criteria.remove(ID)); + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doUpdate(selectCriteria, criteria); + } + else + { + BasePeer.doUpdate(selectCriteria, criteria, con); + } + } + + /** + * Method to do deletes. + * + * @param criteria object containing data that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria) throws TorqueException + { + BaseResearchInterestPeer + .doDelete(criteria, (Connection) null); + } + + /** + * Method to do deletes. This method is to be used during a transaction, + * otherwise use the doDelete(Criteria) method. It will take care of + * the connection details internally. + * + * @param criteria object containing data that is used DELETE from database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(Criteria criteria, Connection con) + throws TorqueException + { + + // Set the correct dbName if it has not been overridden + // criteria.getDbName will return the same object if not set to + // another value so == check is okay and faster + if (criteria.getDbName() == Torque.getDefaultDB()) + { + criteria.setDbName(DATABASE_NAME); + } + if (con == null) + { + BasePeer.doDelete(criteria); + } + else + { + BasePeer.doDelete(criteria, con); + } + } + + /** + * Method to do selects + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List doSelect(ResearchInterest obj) throws TorqueException + { + return doSelect(buildCriteria(obj)); + } + + /** + * Method to do inserts + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(ResearchInterest obj) throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj))); + obj.setNew(false); + obj.setModified(false); + } + + /** + * @param obj the data object to update in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(ResearchInterest obj) throws TorqueException + { + doUpdate(buildCriteria(obj)); + obj.setModified(false); + } + + /** + * @param obj the data object to delete in the database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ResearchInterest obj) throws TorqueException + { + doDelete(buildCriteria(obj)); + } + + /** + * Method to do inserts. This method is to be used during a transaction, + * otherwise use the doInsert(ResearchInterest) method. It will take + * care of the connection details internally. + * + * @param obj the data object to insert into the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doInsert(ResearchInterest obj, Connection con) + throws TorqueException + { + obj.setPrimaryKey(doInsert(buildCriteria(obj), con)); + obj.setNew(false); + obj.setModified(false); + } + + /** + * Method to do update. This method is to be used during a transaction, + * otherwise use the doUpdate(ResearchInterest) method. It will take + * care of the connection details internally. + * + * @param obj the data object to update in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doUpdate(ResearchInterest obj, Connection con) + throws TorqueException + { + doUpdate(buildCriteria(obj), con); + obj.setModified(false); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ResearchInterest) method. It will take + * care of the connection details internally. + * + * @param obj the data object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ResearchInterest obj, Connection con) + throws TorqueException + { + doDelete(buildCriteria(obj), con); + } + + /** + * Method to do deletes. + * + * @param pk ObjectKey that is used DELETE from database. + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk) throws TorqueException + { + BaseResearchInterestPeer + .doDelete(pk, (Connection) null); + } + + /** + * Method to delete. This method is to be used during a transaction, + * otherwise use the doDelete(ObjectKey) method. It will take + * care of the connection details internally. + * + * @param pk the primary key for the object to delete in the database. + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static void doDelete(ObjectKey pk, Connection con) + throws TorqueException + { + doDelete(buildCriteria(pk), con); + } + + /** Build a Criteria object from an ObjectKey */ + public static Criteria buildCriteria( ObjectKey pk ) + { + Criteria criteria = new Criteria(); + criteria.add(ID, pk); + return criteria; + } + + /** Build a Criteria object from the data object for this peer */ + public static Criteria buildCriteria( ResearchInterest obj ) + { + Criteria criteria = new Criteria(DATABASE_NAME); + if (!obj.isNew()) + criteria.add(ID, obj.getId()); + criteria.add(INTERESTS, obj.getInterests()); + criteria.add(ACTIVITIES, obj.getActivities()); + criteria.add(COLLABORATION_INTERESTS, obj.getCollaborationInterests()); + criteria.add(FOCUS_FROM, obj.getFocusFrom()); + criteria.add(FOCUS_TO, obj.getFocusTo()); + return criteria; + } + + + + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ResearchInterest retrieveByPK(Integer pk) + throws TorqueException + { + return retrieveByPK(SimpleKey.keyFor(pk)); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ResearchInterest retrieveByPK(ObjectKey pk) + throws TorqueException + { + Connection db = null; + ResearchInterest retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPK(pk, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a single object by pk + * + * @param pk the primary key + * @param con the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static ResearchInterest retrieveByPK(ObjectKey pk, Connection con) + throws TorqueException + { + Criteria criteria = buildCriteria(pk); + List v = doSelect(criteria, con); + if (v.size() != 1) + { + throw new TorqueException("Failed to select one and only one row."); + } + else + { + return (ResearchInterest)v.get(0); + } + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs(List pks) + throws TorqueException + { + Connection db = null; + List retVal = null; + try + { + db = Torque.getConnection(DATABASE_NAME); + retVal = retrieveByPKs(pks, db); + } + finally + { + Torque.closeConnection(db); + } + return(retVal); + } + + /** + * Retrieve a multiple objects by pk + * + * @param pks List of primary keys + * @param dbcon the connection to use + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + public static List retrieveByPKs( List pks, Connection dbcon ) + throws TorqueException + { + List objs = null; + if (pks == null || pks.size() == 0) + { + objs = new LinkedList(); + } + else + { + Criteria criteria = new Criteria(); + criteria.addIn( ID, pks ); + objs = doSelect(criteria, dbcon); + } + return objs; + } + + + + + + + + + + + /** + * Returns the TableMap related to this peer. This method is not + * needed for general use but a specific application could have a need. + * + * @throws TorqueException Any exceptions caught during processing will be + * rethrown wrapped into a TorqueException. + */ + protected static TableMap getTableMap() + throws TorqueException + { + return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME); + } + } diff --git a/src/java/org/thdl/roster/om/ContactInfo.java b/src/java/org/thdl/roster/om/ContactInfo.java new file mode 100755 index 0000000..82a36bb --- /dev/null +++ b/src/java/org/thdl/roster/om/ContactInfo.java @@ -0,0 +1,36 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; +import org.apache.torque.TorqueException; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class ContactInfo + extends org.thdl.roster.om.BaseContactInfo + implements java.io.Serializable, Persistent +{ + public Address getAddress() throws TorqueException + { + if ( null == super.getAddress() ) + { + super.setAddress( new Address() ); + } + return super.getAddress(); + } + public ContactInfo() throws TorqueException + { + super(); + setAddress( new Address() ); + setPhoneRelatedByPhone( new Phone() ); + setPhoneRelatedByFax( new Phone() ); + } +} diff --git a/src/java/org/thdl/roster/om/ContactInfoPeer.java b/src/java/org/thdl/roster/om/ContactInfoPeer.java new file mode 100755 index 0000000..0ab9384 --- /dev/null +++ b/src/java/org/thdl/roster/om/ContactInfoPeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class ContactInfoPeer + extends org.thdl.roster.om.BaseContactInfoPeer +{ +} diff --git a/src/java/org/thdl/roster/om/Country.java b/src/java/org/thdl/roster/om/Country.java new file mode 100755 index 0000000..d5b97a0 --- /dev/null +++ b/src/java/org/thdl/roster/om/Country.java @@ -0,0 +1,27 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; +import org.apache.torque.TorqueException; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class Country + extends org.thdl.roster.om.BaseCountry + implements java.io.Serializable, Persistent +{ + public Country() throws TorqueException + { + super(); + setId( new Integer( 0 ) ); + setCountry( "" ); + } +} diff --git a/src/java/org/thdl/roster/om/CountryPeer.java b/src/java/org/thdl/roster/om/CountryPeer.java new file mode 100755 index 0000000..bf39f2b --- /dev/null +++ b/src/java/org/thdl/roster/om/CountryPeer.java @@ -0,0 +1,22 @@ +package org.thdl.roster.om; + +import org.apache.torque.util.*; +import java.util.*; +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class CountryPeer + extends org.thdl.roster.om.BaseCountryPeer +{ + static public List doSelectAll() throws Exception + { + Criteria crit = new Criteria(); + return doSelect(crit); + } +} diff --git a/src/java/org/thdl/roster/om/CulturalArea.java b/src/java/org/thdl/roster/om/CulturalArea.java new file mode 100755 index 0000000..f3ae327 --- /dev/null +++ b/src/java/org/thdl/roster/om/CulturalArea.java @@ -0,0 +1,20 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class CulturalArea + extends org.thdl.roster.om.BaseCulturalArea + implements java.io.Serializable, Persistent +{ +} diff --git a/src/java/org/thdl/roster/om/CulturalAreaPeer.java b/src/java/org/thdl/roster/om/CulturalAreaPeer.java new file mode 100755 index 0000000..fccc248 --- /dev/null +++ b/src/java/org/thdl/roster/om/CulturalAreaPeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class CulturalAreaPeer + extends org.thdl.roster.om.BaseCulturalAreaPeer +{ +} diff --git a/src/java/org/thdl/roster/om/Discipline.java b/src/java/org/thdl/roster/om/Discipline.java new file mode 100755 index 0000000..f7403a0 --- /dev/null +++ b/src/java/org/thdl/roster/om/Discipline.java @@ -0,0 +1,20 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class Discipline + extends org.thdl.roster.om.BaseDiscipline + implements java.io.Serializable, Persistent +{ +} diff --git a/src/java/org/thdl/roster/om/DisciplinePeer.java b/src/java/org/thdl/roster/om/DisciplinePeer.java new file mode 100755 index 0000000..0ec36b7 --- /dev/null +++ b/src/java/org/thdl/roster/om/DisciplinePeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class DisciplinePeer + extends org.thdl.roster.om.BaseDisciplinePeer +{ +} diff --git a/src/java/org/thdl/roster/om/Document.java b/src/java/org/thdl/roster/om/Document.java new file mode 100755 index 0000000..132b2e6 --- /dev/null +++ b/src/java/org/thdl/roster/om/Document.java @@ -0,0 +1,20 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class Document + extends org.thdl.roster.om.BaseDocument + implements java.io.Serializable, Persistent +{ +} diff --git a/src/java/org/thdl/roster/om/DocumentPeer.java b/src/java/org/thdl/roster/om/DocumentPeer.java new file mode 100755 index 0000000..7ccf819 --- /dev/null +++ b/src/java/org/thdl/roster/om/DocumentPeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class DocumentPeer + extends org.thdl.roster.om.BaseDocumentPeer +{ +} diff --git a/src/java/org/thdl/roster/om/DocumentType.java b/src/java/org/thdl/roster/om/DocumentType.java new file mode 100755 index 0000000..67ea33d --- /dev/null +++ b/src/java/org/thdl/roster/om/DocumentType.java @@ -0,0 +1,20 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class DocumentType + extends org.thdl.roster.om.BaseDocumentType + implements Persistent +{ +} diff --git a/src/java/org/thdl/roster/om/DocumentTypePeer.java b/src/java/org/thdl/roster/om/DocumentTypePeer.java new file mode 100755 index 0000000..c9c2fab --- /dev/null +++ b/src/java/org/thdl/roster/om/DocumentTypePeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class DocumentTypePeer + extends org.thdl.roster.om.BaseDocumentTypePeer +{ +} diff --git a/src/java/org/thdl/roster/om/Language.java b/src/java/org/thdl/roster/om/Language.java new file mode 100755 index 0000000..6ef3546 --- /dev/null +++ b/src/java/org/thdl/roster/om/Language.java @@ -0,0 +1,20 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class Language + extends org.thdl.roster.om.BaseLanguage + implements java.io.Serializable, Persistent +{ +} diff --git a/src/java/org/thdl/roster/om/LanguagePeer.java b/src/java/org/thdl/roster/om/LanguagePeer.java new file mode 100755 index 0000000..c70c9ba --- /dev/null +++ b/src/java/org/thdl/roster/om/LanguagePeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class LanguagePeer + extends org.thdl.roster.om.BaseLanguagePeer +{ +} diff --git a/src/java/org/thdl/roster/om/Member.java b/src/java/org/thdl/roster/om/Member.java new file mode 100755 index 0000000..520c99f --- /dev/null +++ b/src/java/org/thdl/roster/om/Member.java @@ -0,0 +1,72 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class Member extends org.thdl.roster.om.BaseMember implements RosterMember, java.io.Serializable +{ + + public void setMemberData( RosterMemberData memberData ) throws RosterMemberTypeException + { + throw new RosterMemberTypeException( "Can't set memberData of generic instance of RosterMember, class " + this.getClass().getName() ); + } + + public RosterMemberData getMemberData() throws RosterMemberTypeException + { + throw new RosterMemberTypeException( "Can't get memberData of generic instance of RosterMember, class " + this.getClass().getName() ); + } + + public void save() throws Exception + { + java.util.Date now = new java.util.Date( System.currentTimeMillis() ); + setModifiedOn( now ); + super.save(); + } +//synthetic accessors + public boolean getPersonMember() { + boolean b = false; + if ( this instanceof Person ) + { + b=true; + } + return b; + } + public boolean getProjectMember() { + boolean b = false; + if ( this instanceof Project ) + { + b=true; + } + return b; + } + public boolean getOrganizationMember() { + boolean b = false; + if ( this instanceof Organization ) + { + b=true; + } + return b; + } + public void save( Integer thdlUserId ) + { + if ( isNew() ) + { + setCreatedBy( thdlUserId ); + setModifiedBy( thdlUserId ); + java.util.Date now = new java.util.Date( System.currentTimeMillis() ); + setCreatedOn( now ); + setModifiedOn( now ); + setDeleted( "false" ); + } + } +} diff --git a/src/java/org/thdl/roster/om/MemberPeer.java b/src/java/org/thdl/roster/om/MemberPeer.java new file mode 100755 index 0000000..8c542fe --- /dev/null +++ b/src/java/org/thdl/roster/om/MemberPeer.java @@ -0,0 +1,147 @@ +package org.thdl.roster.om; + +import org.thdl.roster.RosterQuery; +import org.apache.torque.*; +import org.apache.torque.util.*; +import java.util.*; +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class MemberPeer extends org.thdl.roster.om.BaseMemberPeer +{ + public static String esc( String rawText ) throws TorqueException + { + return SqlExpression.quoteAndEscapeText( rawText, Torque.getDB( Torque.getDefaultDB() ) ); + } + +// Custom Query helpers + +/* public static List executeQuery( RosterQuery query) throws TorqueException + { + StringBuffer sql = new StringBuffer() ; + sql.append( " SELECT DISTINCT Member.* FROM Member, PersonData, ProjectData, OrganizationData, ContactInfo, Address, ResearchInterest, ResearchInterestDiscipline, ResearchInterestCulturalArea, ResearchInterestLanguage " ); + sql.append( "\nWHERE Member.deleted = 'false' "); + appendMemberTypes( sql, query ); + appendNames( sql, query ); + appendCountries( sql, query ); + appendDiscipline( sql, query ); + appendLanguage( sql, query ); + appendCulturalArea( sql, query ); + query.setPeerGeneratedSql( sql.toString() ); + //List villageRecords = MemberPeer.executeQuery( sql.toString() ); + //List villageRecords = MemberPeer.executeQuery( "SELECT * FROM Member" ); + return null;//MemberPeer.populateObjects( villageRecords ); + } + + public static void appendCulturalArea( StringBuffer sql, RosterQuery query ) + { + if ( null != query.getSelectedCulturalArea() ) + { + sql.append( " \nAND Member.research_interest_id = ResearchInterest.id " ); + sql.append( " \nAND ResearchInterest.id = ResearchInterestCulturalArea.research_interest_id " ); + sql.append( " \nAND ResearchInterestCulturalArea.cultural_area_id = " ); + sql.append( query.getSelectedCulturalArea() ); + } + } + + public static void appendLanguage( StringBuffer sql, RosterQuery query ) + { + if ( null != query.getSelectedLanguage() ) + { + sql.append( " \nAND Member.research_interest_id = ResearchInterest.id " ); + sql.append( " \nAND ResearchInterest.id = ResearchInterestLanguage.research_interest_id " ); + sql.append( " \nAND ResearchInterestLanguage.language_id = " ); + sql.append( query.getSelectedLanguage() ); + } + } + + public static void appendDiscipline( StringBuffer sql, RosterQuery query ) + { + if ( null != query.getSelectedDiscipline() ) + { + sql.append( " \nAND Member.research_interest_id = ResearchInterest.id " ); + sql.append( " \nAND ResearchInterest.id = ResearchInterestDiscipline.research_interest_id " ); + sql.append( " \nAND ResearchInterestDiscipline.discipline_id = " ); + sql.append( query.getSelectedDiscipline() ); + } + } + + public static void appendCountries( StringBuffer sql, RosterQuery query ) throws TorqueException + { + Iterator countries = query.getCountries().keySet().iterator(); + while ( countries.hasNext() ) + { + Country key = (Country)countries.next(); + Boolean value = (Boolean) query.getCountries().get( key ); + if ( value.equals( Boolean.FALSE ) ) + { + sql.append( " \nAND Member.contact_info_id = ContactInfo.id " ); + sql.append( " \nAND ContactInfo.address_id = Address.id " ); + sql.append( " \nAND " ); + sql.append( AddressPeer.COUNTRY_ID ); + sql.append( " <> " ); + sql.append( key.getId() ); + } + } + } + + public static void appendNames( StringBuffer sql, RosterQuery query ) throws TorqueException + { + if ( null != query.getName() && ! query.getName().equals( "" ) ) + { + String name = "%" + query.getName() + "%"; + name = esc( name ); + sql.append( "\nAND " ); + sql.append( "\n( " ); + sql.append( "\n ( " ); + sql.append( "\n Member.person_data_id = PersonData.id " ); + sql.append( "\n AND " ); + sql.append( "\n ( " ); + sql.append( "\n PersonData.firstname LIKE " ); + sql.append( name ); + sql.append( "\n OR" ); + sql.append( "\n PersonData.lastname LIKE " ); + sql.append( name ); + sql.append( "\n ) " ); + sql.append( "\n )" ); + sql.append( "\n OR" ); + sql.append( "\n (" ); + sql.append( "\n Member.project_data_id = ProjectData.id" ); + sql.append( "\n AND" ); + sql.append( "\n ProjectData.name LIKE " ); + sql.append( name ); + sql.append( "\n )" ); + sql.append( "\n OR" ); + sql.append( "\n (" ); + sql.append( "\n Member.organization_data_id = OrganizationData.id" ); + sql.append( "\n AND" ); + sql.append( "\n OrganizationData.name LIKE " ); + sql.append( name ); + sql.append( "\n )" ); + sql.append( "\n)" ); + } + } + + public static void appendMemberTypes( StringBuffer sql, RosterQuery query ) throws TorqueException + { + Iterator memTypes = query.getMemberTypes().keySet().iterator(); + while ( memTypes.hasNext() ) + { + String key = (String)memTypes.next(); + Boolean value = (Boolean) query.getMemberTypes().get( key ); + if ( value.equals( Boolean.FALSE ) ) + { + sql.append( " \nAND " ); + sql.append( MemberPeer.MEMBER_TYPE ); + sql.append( " NOT LIKE " ); + sql.append( esc( key ) ); + } + } + } */ +} diff --git a/src/java/org/thdl/roster/om/Organization.java b/src/java/org/thdl/roster/om/Organization.java new file mode 100755 index 0000000..e2edb20 --- /dev/null +++ b/src/java/org/thdl/roster/om/Organization.java @@ -0,0 +1,71 @@ +package org.thdl.roster.om; + +import java.util.*; +import org.apache.torque.om.BaseObject; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; +import org.apache.torque.TorqueException; + + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 12:26:47 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class Organization extends org.thdl.roster.om.Member implements RosterMember +{ +//attributes + RosterMemberData memberData; +//accessors + public void setMemberData (RosterMemberData memberData) throws RosterMemberTypeException + { + if ( memberData instanceof OrganizationData ) + { + try { + OrganizationData pd = (OrganizationData) memberData; + setOrganizationData( pd ); + } + catch ( TorqueException te ) + { + throw new RosterMemberTypeException( te.getMessage() ); + } + } + else + { + throw new RosterMemberTypeException( "MemberData must be a OrganizationData for this object" ); + } + } + public RosterMemberData getMemberData() throws RosterMemberTypeException + { + try { + return getOrganizationData(); + } + catch ( TorqueException te ) + { + throw new RosterMemberTypeException( te.getMessage() ); + } + } +//helpers + public Member copy() throws TorqueException + { + Organization organization = new Organization(); + organization = (Organization) copyInto( organization ); + organization.setOrganizationData( getOrganizationData().copy() ); + return organization; + } + +//constructors + public Organization() throws TorqueException + { + setMemberType(MemberPeer.CLASSKEY_ORGANIZATION); + setOrganizationData( new OrganizationData() ); + setContactInfo( new ContactInfo() ); + setResearchInterest( new ResearchInterest() ); + setPublication( new Publication() ); + //setDocument( new Document() ); + } +} diff --git a/src/java/org/thdl/roster/om/OrganizationData.java b/src/java/org/thdl/roster/om/OrganizationData.java new file mode 100755 index 0000000..b87fd1e --- /dev/null +++ b/src/java/org/thdl/roster/om/OrganizationData.java @@ -0,0 +1,63 @@ +package org.thdl.roster.om; + +import org.apache.torque.om.Persistent; +import org.apache.torque.*; +import org.apache.torque.util.*; +import java.util.*; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class OrganizationData + extends org.thdl.roster.om.BaseOrganizationData + implements java.io.Serializable, RosterMemberData +{ + //attributes + private List organizationTypeIdList; + //accessors + public void setId(Integer v) throws TorqueException + { + super.setId( v ); + setOrganizationTypeIdList( buildIdList() ); + } + public void setOrganizationTypeIdList( List organizationTypeIdList ) + { + this.organizationTypeIdList = organizationTypeIdList; + } + public List getOrganizationTypeIdList() throws TorqueException + { + return organizationTypeIdList; + } + //helpers + public List buildIdList() throws TorqueException + { + Criteria crit = new Criteria(); + crit.add( OrganizationOrganizationTypePeer.ORGANIZATION_DATA_ID, getId() ); + crit.addAscendingOrderByColumn( OrganizationOrganizationTypePeer.RELEVANCE ); + List idSourceList = OrganizationOrganizationTypePeer.doSelect( crit ); + LinkedList newList = new LinkedList(); + ListIterator iterator = idSourceList.listIterator( 0 ); + while ( iterator.hasNext() ) + { + OrganizationOrganizationType ppt = (OrganizationOrganizationType) iterator.next(); + Integer id = ppt.getOrganizationType().getId(); + newList.add( id ); + } + return newList; + } + + public java.util.List getMemberTypes() throws org.apache.torque.TorqueException + { + return getOrganizationOrganizationTypes(); + } + public void setMemberTypes( java.util.List memberTypes ) + { + // WRONG setOrganizationOrganizationTypes( memberTypes ); + } +} diff --git a/src/java/org/thdl/roster/om/OrganizationDataPeer.java b/src/java/org/thdl/roster/om/OrganizationDataPeer.java new file mode 100755 index 0000000..258ee10 --- /dev/null +++ b/src/java/org/thdl/roster/om/OrganizationDataPeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class OrganizationDataPeer + extends org.thdl.roster.om.BaseOrganizationDataPeer +{ +} diff --git a/src/java/org/thdl/roster/om/OrganizationOrganizationType.java b/src/java/org/thdl/roster/om/OrganizationOrganizationType.java new file mode 100755 index 0000000..eede56b --- /dev/null +++ b/src/java/org/thdl/roster/om/OrganizationOrganizationType.java @@ -0,0 +1,44 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; +import org.apache.torque.TorqueException; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class OrganizationOrganizationType + extends org.thdl.roster.om.BaseOrganizationOrganizationType + implements java.io.Serializable, Persistent, RosterMergeData +{ + public void setByPosition( int position, Integer data ) throws TorqueException + { + if ( position == 1 ) + { + setId( data ); + } + if ( position == 2 ) + { + setOrganizationTypeId( data ); + } + if ( position == 3 ) + { + setOrganizationDataId( data ); + } + if ( position == 4 ) + { + setRelevance( data ); + } + } + public void remove() throws TorqueException + { + getPeer().doDelete( this ); + } +} diff --git a/src/java/org/thdl/roster/om/OrganizationOrganizationTypePeer.java b/src/java/org/thdl/roster/om/OrganizationOrganizationTypePeer.java new file mode 100755 index 0000000..da64e38 --- /dev/null +++ b/src/java/org/thdl/roster/om/OrganizationOrganizationTypePeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class OrganizationOrganizationTypePeer + extends org.thdl.roster.om.BaseOrganizationOrganizationTypePeer +{ +} diff --git a/src/java/org/thdl/roster/om/OrganizationType.java b/src/java/org/thdl/roster/om/OrganizationType.java new file mode 100755 index 0000000..75b3b9a --- /dev/null +++ b/src/java/org/thdl/roster/om/OrganizationType.java @@ -0,0 +1,20 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class OrganizationType + extends org.thdl.roster.om.BaseOrganizationType + implements java.io.Serializable, Persistent +{ +} diff --git a/src/java/org/thdl/roster/om/OrganizationTypePeer.java b/src/java/org/thdl/roster/om/OrganizationTypePeer.java new file mode 100755 index 0000000..7f0a8c2 --- /dev/null +++ b/src/java/org/thdl/roster/om/OrganizationTypePeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class OrganizationTypePeer + extends org.thdl.roster.om.BaseOrganizationTypePeer +{ +} diff --git a/src/java/org/thdl/roster/om/Person.java b/src/java/org/thdl/roster/om/Person.java new file mode 100755 index 0000000..71afca6 --- /dev/null +++ b/src/java/org/thdl/roster/om/Person.java @@ -0,0 +1,80 @@ +package org.thdl.roster.om; + +import java.util.*; +import org.apache.torque.om.BaseObject; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; +import org.apache.torque.TorqueException; +import org.thdl.users.*; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 12:26:47 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class Person extends org.thdl.roster.om.Member implements RosterMember, java.io.Serializable +{ +//attributes +//accessors + public void setMemberData (RosterMemberData memberData) throws RosterMemberTypeException + { + if ( memberData instanceof PersonData ) + { + try { + PersonData pd = (PersonData) memberData; + setPersonData( pd ); + } + catch ( TorqueException te ) + { + throw new RosterMemberTypeException( te.getMessage() ); + } + } + else + { + throw new RosterMemberTypeException( "MemberData must be a PersonData for this object" ); + } + } + public RosterMemberData getMemberData() throws RosterMemberTypeException + { + try { + return getPersonData(); + } + catch ( TorqueException te ) + { + throw new RosterMemberTypeException( te.getMessage() ); + } + } +//helpers + public Member copy() throws TorqueException + { + Person person = new Person(); + person = (Person) copyInto( person ); + person.setPersonData( getPersonData().copy() ); + return person; + } + +//constructors + public Person() throws TorqueException + { + super(); + setMemberType(MemberPeer.CLASSKEY_PERSON); + setPersonData( new PersonData() ); + setContactInfo( new ContactInfo() ); + setResearchInterest( new ResearchInterest() ); + setPublication( new Publication() ); + //setDocument( new Document() ); + } + public Person( ThdlUser user ) throws TorqueException + { + this(); + getPersonData().setThdlUserId( new Integer( user.getId() ) ); + getPersonData().setFirstname( user.getFirstname() ); + getPersonData().setMiddlename( user.getMiddlename() ); + getPersonData().setLastname( user.getLastname() ); + //getPersonData().setEmail( user.getEmail() ); + } +} diff --git a/src/java/org/thdl/roster/om/PersonData.java b/src/java/org/thdl/roster/om/PersonData.java new file mode 100755 index 0000000..bf57211 --- /dev/null +++ b/src/java/org/thdl/roster/om/PersonData.java @@ -0,0 +1,89 @@ +package org.thdl.roster.om; + +import org.apache.torque.om.Persistent; +import org.apache.torque.*; +import org.apache.torque.util.*; +import java.util.*; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ + +public class PersonData + extends org.thdl.roster.om.BasePersonData + implements RosterMemberData, java.io.Serializable +{ + //attributes + private List personTypeIdList; + //accessors + public void setId(Integer v) throws TorqueException + { + super.setId( v ); + setPersonTypeIdList( buildIdList() ); + } + public void setPersonTypeIdList( List personTypeIdList ) + { + this.personTypeIdList = personTypeIdList; + } + public List getPersonTypeIdList() throws TorqueException + { + return personTypeIdList; + } + //helpers + public String getName() + { + String name = null; + if ( null != getLastname() ) + { + name = getLastname(); + } + if ( null != getFirstname() ) + { + if ( null != name ) + { + name = getFirstname() + " " + name; + } + else + { + name = getFirstname(); + } + } + return name; + } + + public String getDescription() + { + return getBio(); + } + + public List buildIdList() throws TorqueException + { + Criteria crit = new Criteria(); + crit.add( PersonPersonTypePeer.PERSON_DATA_ID, getId() ); + crit.addAscendingOrderByColumn( PersonPersonTypePeer.RELEVANCE ); + List idSourceList = PersonPersonTypePeer.doSelect( crit ); + LinkedList newList = new LinkedList(); + ListIterator iterator = idSourceList.listIterator( 0 ); + while ( iterator.hasNext() ) + { + PersonPersonType ppt = (PersonPersonType) iterator.next(); + Integer id = ppt.getPersonType().getId(); + newList.add( id ); + } + return newList; + } + public java.util.List getMemberTypes() throws org.apache.torque.TorqueException + { + return getPersonPersonTypes(); + } + public void setMemberTypes( java.util.List memberTypes ) + { + // WRONG setPersonPersonTypes( memberTypes ); + } +} diff --git a/src/java/org/thdl/roster/om/PersonDataPeer.java b/src/java/org/thdl/roster/om/PersonDataPeer.java new file mode 100755 index 0000000..ee98695 --- /dev/null +++ b/src/java/org/thdl/roster/om/PersonDataPeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class PersonDataPeer + extends org.thdl.roster.om.BasePersonDataPeer +{ +} diff --git a/src/java/org/thdl/roster/om/PersonPersonType.java b/src/java/org/thdl/roster/om/PersonPersonType.java new file mode 100755 index 0000000..b62fab0 --- /dev/null +++ b/src/java/org/thdl/roster/om/PersonPersonType.java @@ -0,0 +1,44 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; +import org.apache.torque.*; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class PersonPersonType + extends org.thdl.roster.om.BasePersonPersonType + implements java.io.Serializable, Persistent, RosterMergeData +{ + public void setByPosition( int position, Integer data ) throws TorqueException + { + if ( position == 1 ) + { + setId( data ); + } + if ( position == 2 ) + { + setPersonTypeId( data ); + } + if ( position == 3 ) + { + setPersonDataId( data ); + } + if ( position == 4 ) + { + setRelevance( data ); + } + } + public void remove() throws TorqueException + { + getPeer().doDelete( this ); + } +} diff --git a/src/java/org/thdl/roster/om/PersonPersonTypePeer.java b/src/java/org/thdl/roster/om/PersonPersonTypePeer.java new file mode 100755 index 0000000..94a8756 --- /dev/null +++ b/src/java/org/thdl/roster/om/PersonPersonTypePeer.java @@ -0,0 +1,19 @@ +package org.thdl.roster.om; + +import org.apache.torque.*; +import java.util.*; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class PersonPersonTypePeer + extends org.thdl.roster.om.BasePersonPersonTypePeer +{ + +} diff --git a/src/java/org/thdl/roster/om/PersonType.java b/src/java/org/thdl/roster/om/PersonType.java new file mode 100755 index 0000000..162c844 --- /dev/null +++ b/src/java/org/thdl/roster/om/PersonType.java @@ -0,0 +1,20 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class PersonType + extends org.thdl.roster.om.BasePersonType + implements java.io.Serializable, Persistent +{ +} diff --git a/src/java/org/thdl/roster/om/PersonTypePeer.java b/src/java/org/thdl/roster/om/PersonTypePeer.java new file mode 100755 index 0000000..7abda81 --- /dev/null +++ b/src/java/org/thdl/roster/om/PersonTypePeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class PersonTypePeer + extends org.thdl.roster.om.BasePersonTypePeer +{ +} diff --git a/src/java/org/thdl/roster/om/Phone.java b/src/java/org/thdl/roster/om/Phone.java new file mode 100755 index 0000000..000a7d9 --- /dev/null +++ b/src/java/org/thdl/roster/om/Phone.java @@ -0,0 +1,24 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class Phone + extends org.thdl.roster.om.BasePhone + implements java.io.Serializable, Persistent +{ + public Phone() + { + super(); + } +} diff --git a/src/java/org/thdl/roster/om/PhonePeer.java b/src/java/org/thdl/roster/om/PhonePeer.java new file mode 100755 index 0000000..3973b72 --- /dev/null +++ b/src/java/org/thdl/roster/om/PhonePeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class PhonePeer + extends org.thdl.roster.om.BasePhonePeer +{ +} diff --git a/src/java/org/thdl/roster/om/Project.java b/src/java/org/thdl/roster/om/Project.java new file mode 100755 index 0000000..b7fa2c5 --- /dev/null +++ b/src/java/org/thdl/roster/om/Project.java @@ -0,0 +1,70 @@ +package org.thdl.roster.om; + +import java.util.*; +import org.apache.torque.om.BaseObject; +import org.apache.torque.util.BasePeer; +import org.apache.torque.util.Criteria; +import org.apache.torque.TorqueException; + + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 12:26:47 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class Project extends org.thdl.roster.om.Member implements RosterMember +{ +//attributes +//accessors + public void setMemberData (RosterMemberData memberData) throws RosterMemberTypeException + { + if ( memberData instanceof ProjectData ) + { + try { + ProjectData pd = (ProjectData) memberData; + setProjectData( pd ); + } + catch ( TorqueException te ) + { + throw new RosterMemberTypeException( te.getMessage() ); + } + } + else + { + throw new RosterMemberTypeException( "MemberData must be a ProjectData for this object" ); + } + } + public RosterMemberData getMemberData() throws RosterMemberTypeException + { + try + { + return getProjectData(); + } + catch ( TorqueException te ) + { + throw new RosterMemberTypeException( te.getMessage() ); + } + } +//helpers + public Member copy() throws TorqueException + { + Project project = new Project(); + project = (Project) copyInto( project ); + project.setProjectData( getProjectData().copy() ); + return project; + } +//constructors + public Project() throws TorqueException + { + setMemberType(MemberPeer.CLASSKEY_PROJECT); + setProjectData( new ProjectData() ); + setContactInfo( new ContactInfo() ); + setResearchInterest( new ResearchInterest() ); + setPublication( new Publication() ); + //setDocument( new Document() ); + } +} diff --git a/src/java/org/thdl/roster/om/ProjectData.java b/src/java/org/thdl/roster/om/ProjectData.java new file mode 100755 index 0000000..1bb5f87 --- /dev/null +++ b/src/java/org/thdl/roster/om/ProjectData.java @@ -0,0 +1,64 @@ +package org.thdl.roster.om; + +import org.apache.torque.om.Persistent; +import org.apache.torque.*; +import org.apache.torque.util.*; +import java.util.*; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class ProjectData + extends org.thdl.roster.om.BaseProjectData + implements java.io.Serializable, RosterMemberData +{ + //attributes + private List projectTypeIdList; + //accessors + public void setId(Integer v) throws TorqueException + { + super.setId( v ); + setProjectTypeIdList( buildIdList() ); + } + public void setProjectTypeIdList( List projectTypeIdList ) + { + this.projectTypeIdList = projectTypeIdList; + } + public List getProjectTypeIdList() throws TorqueException + { + return projectTypeIdList; + } + //helpers + public List buildIdList() throws TorqueException + { + Criteria crit = new Criteria(); + crit.add( ProjectProjectTypePeer.PROJECT_DATA_ID, getId() ); + crit.addAscendingOrderByColumn( ProjectProjectTypePeer.RELEVANCE ); + List idSourceList = ProjectProjectTypePeer.doSelect( crit ); + LinkedList newList = new LinkedList(); + ListIterator iterator = idSourceList.listIterator( 0 ); + while ( iterator.hasNext() ) + { + ProjectProjectType ppt = (ProjectProjectType) iterator.next(); + Integer id = ppt.getProjectType().getId(); + newList.add( id ); + } + return newList; + } + + + public java.util.List getMemberTypes() throws org.apache.torque.TorqueException + { + return getProjectProjectTypes(); + } + public void setMemberTypes( java.util.List memberTypes ) + { + // WRONG setPersonPersonTypes( memberTypes ); + } +} diff --git a/src/java/org/thdl/roster/om/ProjectDataPeer.java b/src/java/org/thdl/roster/om/ProjectDataPeer.java new file mode 100755 index 0000000..2023c2e --- /dev/null +++ b/src/java/org/thdl/roster/om/ProjectDataPeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class ProjectDataPeer + extends org.thdl.roster.om.BaseProjectDataPeer +{ +} diff --git a/src/java/org/thdl/roster/om/ProjectProjectType.java b/src/java/org/thdl/roster/om/ProjectProjectType.java new file mode 100755 index 0000000..244c886 --- /dev/null +++ b/src/java/org/thdl/roster/om/ProjectProjectType.java @@ -0,0 +1,44 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; +import org.apache.torque.TorqueException; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class ProjectProjectType + extends org.thdl.roster.om.BaseProjectProjectType + implements java.io.Serializable, Persistent, RosterMergeData +{ + public void setByPosition( int position, Integer data ) throws TorqueException + { + if ( position == 1 ) + { + setId( data ); + } + if ( position == 2 ) + { + setProjectTypeId( data ); + } + if ( position == 3 ) + { + setProjectDataId( data ); + } + if ( position == 4 ) + { + setRelevance( data ); + } + } + public void remove() throws TorqueException + { + getPeer().doDelete( this ); + } +} diff --git a/src/java/org/thdl/roster/om/ProjectProjectTypePeer.java b/src/java/org/thdl/roster/om/ProjectProjectTypePeer.java new file mode 100755 index 0000000..966bbc4 --- /dev/null +++ b/src/java/org/thdl/roster/om/ProjectProjectTypePeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class ProjectProjectTypePeer + extends org.thdl.roster.om.BaseProjectProjectTypePeer +{ +} diff --git a/src/java/org/thdl/roster/om/ProjectType.java b/src/java/org/thdl/roster/om/ProjectType.java new file mode 100755 index 0000000..482fbf7 --- /dev/null +++ b/src/java/org/thdl/roster/om/ProjectType.java @@ -0,0 +1,20 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class ProjectType + extends org.thdl.roster.om.BaseProjectType + implements java.io.Serializable, Persistent +{ +} diff --git a/src/java/org/thdl/roster/om/ProjectTypePeer.java b/src/java/org/thdl/roster/om/ProjectTypePeer.java new file mode 100755 index 0000000..d36dbd5 --- /dev/null +++ b/src/java/org/thdl/roster/om/ProjectTypePeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class ProjectTypePeer + extends org.thdl.roster.om.BaseProjectTypePeer +{ +} diff --git a/src/java/org/thdl/roster/om/Publication.java b/src/java/org/thdl/roster/om/Publication.java new file mode 100755 index 0000000..865fa51 --- /dev/null +++ b/src/java/org/thdl/roster/om/Publication.java @@ -0,0 +1,20 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class Publication + extends org.thdl.roster.om.BasePublication + implements java.io.Serializable, Persistent +{ +} diff --git a/src/java/org/thdl/roster/om/PublicationPeer.java b/src/java/org/thdl/roster/om/PublicationPeer.java new file mode 100755 index 0000000..1836328 --- /dev/null +++ b/src/java/org/thdl/roster/om/PublicationPeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class PublicationPeer + extends org.thdl.roster.om.BasePublicationPeer +{ +} diff --git a/src/java/org/thdl/roster/om/ResearchInterest.java b/src/java/org/thdl/roster/om/ResearchInterest.java new file mode 100755 index 0000000..af412f1 --- /dev/null +++ b/src/java/org/thdl/roster/om/ResearchInterest.java @@ -0,0 +1,105 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; +import org.apache.torque.*; +import org.apache.torque.util.*; +import java.util.*; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class ResearchInterest extends org.thdl.roster.om.BaseResearchInterest implements java.io.Serializable, Persistent +{ +//attributes + private List disciplineIdList; + private List languageIdList; + private List culturalAreaIdList; +//accessors + public void setId(Integer v) throws TorqueException + { + super.setId( v ); + setDisciplineIdList( buildDisciplineIdList() ); + setLanguageIdList( buildLanguageIdList() ); + setCulturalAreaIdList( buildCulturalAreaIdList() ); + } + public void setDisciplineIdList(List disciplineIdList) throws TorqueException { + //if (disciplineIdList == null) throw new TorqueException( "attempt to set discipline IdList to null" ); + this.disciplineIdList = disciplineIdList; + } + public void setLanguageIdList(List languageIdList) { + this.languageIdList = languageIdList; + } + public void setCulturalAreaIdList(List culturalAreaIdList) { + this.culturalAreaIdList = culturalAreaIdList; + } + public List getDisciplineIdList() throws TorqueException { + return disciplineIdList; + } + public List getLanguageIdList() throws TorqueException { + return languageIdList; + } + public List getCulturalAreaIdList() throws TorqueException { + return culturalAreaIdList; + } +// helpers + public List buildDisciplineIdList() throws TorqueException + { + Criteria crit = new Criteria(); + crit.add( ResearchInterestDisciplinePeer.RESEARCH_INTEREST_ID, getId() ); + crit.addAscendingOrderByColumn( ResearchInterestDisciplinePeer.RELEVANCE ); + List idSourceList = ResearchInterestDisciplinePeer.doSelect( crit ); + LinkedList newList = new LinkedList(); + ListIterator iterator = idSourceList.listIterator( 0 ); + while ( iterator.hasNext() ) + { + ResearchInterestDiscipline rid = (ResearchInterestDiscipline) iterator.next(); + Integer id = rid.getDiscipline().getId(); + newList.add( id ); + } + return newList; + } + public List buildLanguageIdList() throws TorqueException + { + Criteria crit = new Criteria(); + crit.add( ResearchInterestLanguagePeer.RESEARCH_INTEREST_ID, getId() ); + crit.addAscendingOrderByColumn( ResearchInterestLanguagePeer.RELEVANCE ); + List idSourceList = ResearchInterestLanguagePeer.doSelect( crit ); + LinkedList newList = new LinkedList(); + ListIterator iterator = idSourceList.listIterator( 0 ); + while ( iterator.hasNext() ) + { + ResearchInterestLanguage rid = (ResearchInterestLanguage) iterator.next(); + Integer id = rid.getLanguage().getId(); + newList.add( id ); + } + return newList; + } + public List buildCulturalAreaIdList() throws TorqueException + { + Criteria crit = new Criteria(); + crit.add( ResearchInterestCulturalAreaPeer.RESEARCH_INTEREST_ID, getId() ); + crit.addAscendingOrderByColumn( ResearchInterestCulturalAreaPeer.RELEVANCE ); + List idSourceList = ResearchInterestCulturalAreaPeer.doSelect( crit ); + LinkedList newList = new LinkedList(); + ListIterator iterator = idSourceList.listIterator( 0 ); + while ( iterator.hasNext() ) + { + ResearchInterestCulturalArea rid = (ResearchInterestCulturalArea) iterator.next(); + Integer id = rid.getCulturalArea().getId(); + newList.add( id ); + } + return newList; + } + public ResearchInterest() + { + } + +} diff --git a/src/java/org/thdl/roster/om/ResearchInterestCulturalArea.java b/src/java/org/thdl/roster/om/ResearchInterestCulturalArea.java new file mode 100755 index 0000000..9e6e42a --- /dev/null +++ b/src/java/org/thdl/roster/om/ResearchInterestCulturalArea.java @@ -0,0 +1,44 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; +import org.apache.torque.TorqueException; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class ResearchInterestCulturalArea + extends org.thdl.roster.om.BaseResearchInterestCulturalArea + implements java.io.Serializable, Persistent, RosterMergeData +{ + public void setByPosition( int position, Integer data ) throws TorqueException + { + if ( position == 1 ) + { + setId( data ); + } + if ( position == 2 ) + { + setCulturalAreaId( data ); + } + if ( position == 3 ) + { + setResearchInterestId( data ); + } + if ( position == 4 ) + { + setRelevance( data ); + } + } + public void remove() throws TorqueException + { + getPeer().doDelete( this ); + } +} diff --git a/src/java/org/thdl/roster/om/ResearchInterestCulturalAreaPeer.java b/src/java/org/thdl/roster/om/ResearchInterestCulturalAreaPeer.java new file mode 100755 index 0000000..01e487d --- /dev/null +++ b/src/java/org/thdl/roster/om/ResearchInterestCulturalAreaPeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class ResearchInterestCulturalAreaPeer + extends org.thdl.roster.om.BaseResearchInterestCulturalAreaPeer +{ +} diff --git a/src/java/org/thdl/roster/om/ResearchInterestDiscipline.java b/src/java/org/thdl/roster/om/ResearchInterestDiscipline.java new file mode 100755 index 0000000..bb17280 --- /dev/null +++ b/src/java/org/thdl/roster/om/ResearchInterestDiscipline.java @@ -0,0 +1,44 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; +import org.apache.torque.TorqueException; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class ResearchInterestDiscipline + extends org.thdl.roster.om.BaseResearchInterestDiscipline + implements java.io.Serializable, Persistent, RosterMergeData +{ + public void setByPosition( int position, Integer data ) throws TorqueException + { + if ( position == 1 ) + { + setId( data ); + } + if ( position == 2 ) + { + setDisciplineId( data ); + } + if ( position == 3 ) + { + setResearchInterestId( data ); + } + if ( position == 4 ) + { + setRelevance( data ); + } + } + public void remove() throws TorqueException + { + getPeer().doDelete( this ); + } +} diff --git a/src/java/org/thdl/roster/om/ResearchInterestDisciplinePeer.java b/src/java/org/thdl/roster/om/ResearchInterestDisciplinePeer.java new file mode 100755 index 0000000..e143c38 --- /dev/null +++ b/src/java/org/thdl/roster/om/ResearchInterestDisciplinePeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class ResearchInterestDisciplinePeer + extends org.thdl.roster.om.BaseResearchInterestDisciplinePeer +{ +} diff --git a/src/java/org/thdl/roster/om/ResearchInterestLanguage.java b/src/java/org/thdl/roster/om/ResearchInterestLanguage.java new file mode 100755 index 0000000..a071b24 --- /dev/null +++ b/src/java/org/thdl/roster/om/ResearchInterestLanguage.java @@ -0,0 +1,45 @@ + +package org.thdl.roster.om; + + +import org.apache.torque.om.Persistent; +import org.apache.torque.TorqueException; +import org.apache.torque.TorqueException; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Mon Mar 17 09:22:14 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class ResearchInterestLanguage + extends org.thdl.roster.om.BaseResearchInterestLanguage + implements java.io.Serializable, Persistent, RosterMergeData +{ + public void setByPosition( int position, Integer data ) throws TorqueException + { + if ( position == 1 ) + { + setId( data ); + } + if ( position == 2 ) + { + setLanguageId( data ); + } + if ( position == 3 ) + { + setResearchInterestId( data ); + } + if ( position == 4 ) + { + setRelevance( data ); + } + } + public void remove() throws TorqueException + { + getPeer().doDelete( this ); + } +} diff --git a/src/java/org/thdl/roster/om/ResearchInterestLanguagePeer.java b/src/java/org/thdl/roster/om/ResearchInterestLanguagePeer.java new file mode 100755 index 0000000..e615352 --- /dev/null +++ b/src/java/org/thdl/roster/om/ResearchInterestLanguagePeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Mon Mar 17 09:22:14 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class ResearchInterestLanguagePeer + extends org.thdl.roster.om.BaseResearchInterestLanguagePeer +{ +} diff --git a/src/java/org/thdl/roster/om/ResearchInterestPeer.java b/src/java/org/thdl/roster/om/ResearchInterestPeer.java new file mode 100755 index 0000000..9bd8fa2 --- /dev/null +++ b/src/java/org/thdl/roster/om/ResearchInterestPeer.java @@ -0,0 +1,15 @@ +package org.thdl.roster.om; + +/** + * The skeleton for this class was autogenerated by Torque on: + * + * [Thu Feb 27 15:11:05 EST 2003] + * + * You should add additional methods to this class to meet the + * application requirements. This class will only be generated as + * long as it does not already exist in the output directory. + */ +public class ResearchInterestPeer + extends org.thdl.roster.om.BaseResearchInterestPeer +{ +} diff --git a/src/java/org/thdl/roster/om/RosterMember.java b/src/java/org/thdl/roster/om/RosterMember.java new file mode 100755 index 0000000..e0c420a --- /dev/null +++ b/src/java/org/thdl/roster/om/RosterMember.java @@ -0,0 +1,7 @@ +package org.thdl.roster.om; + +public interface RosterMember extends org.apache.torque.om.Persistent +{ +public void setMemberData( RosterMemberData memberData ) throws RosterMemberTypeException; +public RosterMemberData getMemberData() throws RosterMemberTypeException; +} diff --git a/src/java/org/thdl/roster/om/RosterMemberData.java b/src/java/org/thdl/roster/om/RosterMemberData.java new file mode 100755 index 0000000..6c0c9d8 --- /dev/null +++ b/src/java/org/thdl/roster/om/RosterMemberData.java @@ -0,0 +1,11 @@ +package org.thdl.roster.om; + +public interface RosterMemberData extends org.apache.torque.om.Persistent +{ + public Integer getId() throws org.apache.torque.TorqueException; + public java.util.List getMemberTypes() throws org.apache.torque.TorqueException; + public String getDescription(); + public void setMemberTypes( java.util.List memberTypes ); + public void save() throws java.lang.Exception; + public String getName() throws java.lang.Exception; +} diff --git a/src/java/org/thdl/roster/om/RosterMemberType.java b/src/java/org/thdl/roster/om/RosterMemberType.java new file mode 100755 index 0000000..dca0472 --- /dev/null +++ b/src/java/org/thdl/roster/om/RosterMemberType.java @@ -0,0 +1,5 @@ +package org.thdl.roster.om; + +public interface RosterMemberType +{ +} diff --git a/src/java/org/thdl/roster/om/RosterMemberTypeException.java b/src/java/org/thdl/roster/om/RosterMemberTypeException.java new file mode 100755 index 0000000..0afc127 --- /dev/null +++ b/src/java/org/thdl/roster/om/RosterMemberTypeException.java @@ -0,0 +1,13 @@ +package org.thdl.roster.om; + +public class RosterMemberTypeException extends Exception +{ + public RosterMemberTypeException() + { + super(); + } + public RosterMemberTypeException( java.lang.String msg ) + { + super( msg ); + } +} diff --git a/src/java/org/thdl/roster/om/RosterMergeData.java b/src/java/org/thdl/roster/om/RosterMergeData.java new file mode 100755 index 0000000..0dc4f0d --- /dev/null +++ b/src/java/org/thdl/roster/om/RosterMergeData.java @@ -0,0 +1,10 @@ +package org.thdl.roster.om; + +public interface RosterMergeData +{ + public Object getByPosition( int pos ); + public org.apache.torque.om.ObjectKey getPrimaryKey(); + public void setByPosition( int position, Integer data ) throws java.lang.Exception; + public void save() throws java.lang.Exception; + public void remove() throws java.lang.Exception; +} diff --git a/src/java/org/thdl/roster/om/RosterOmException.java b/src/java/org/thdl/roster/om/RosterOmException.java new file mode 100755 index 0000000..28d2dba --- /dev/null +++ b/src/java/org/thdl/roster/om/RosterOmException.java @@ -0,0 +1,13 @@ +package org.thdl.roster.om; + +public class RosterOmException extends Exception +{ + public RosterOmException() + { + super(); + } + public RosterOmException( java.lang.String msg ) + { + super( msg ); + } +} diff --git a/src/java/org/thdl/roster/om/map/AddressMapBuilder.java b/src/java/org/thdl/roster/om/map/AddressMapBuilder.java new file mode 100755 index 0000000..f767c80 --- /dev/null +++ b/src/java/org/thdl/roster/om/map/AddressMapBuilder.java @@ -0,0 +1,82 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class AddressMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.AddressMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("Address"); + TableMap tMap = dbMap.getTable("Address"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("Address.ID", new Integer(0)); + tMap.addColumn("Address.ADDRESS", new String()); + tMap.addColumn("Address.CITY", new String()); + tMap.addColumn("Address.REGION", new String()); + tMap.addColumn("Address.ZIP", new String()); + tMap.addForeignKey( + "Address.COUNTRY_ID", new Integer(0) , "Country" , + "id"); + } +} diff --git a/src/java/org/thdl/roster/om/map/ContactInfoMapBuilder.java b/src/java/org/thdl/roster/om/map/ContactInfoMapBuilder.java new file mode 100755 index 0000000..96e3b71 --- /dev/null +++ b/src/java/org/thdl/roster/om/map/ContactInfoMapBuilder.java @@ -0,0 +1,87 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class ContactInfoMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.ContactInfoMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("ContactInfo"); + TableMap tMap = dbMap.getTable("ContactInfo"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("ContactInfo.ID", new Integer(0)); + tMap.addColumn("ContactInfo.CONTACT_NAME", new String()); + tMap.addColumn("ContactInfo.EMAIL", new String()); + tMap.addColumn("ContactInfo.WEBSITE", new String()); + tMap.addForeignKey( + "ContactInfo.PHONE", new Integer(0) , "Phone" , + "id"); + tMap.addForeignKey( + "ContactInfo.FAX", new Integer(0) , "Phone" , + "id"); + tMap.addForeignKey( + "ContactInfo.ADDRESS_ID", new Integer(0) , "Address" , + "id"); + } +} diff --git a/src/java/org/thdl/roster/om/map/CountryMapBuilder.java b/src/java/org/thdl/roster/om/map/CountryMapBuilder.java new file mode 100755 index 0000000..143b843 --- /dev/null +++ b/src/java/org/thdl/roster/om/map/CountryMapBuilder.java @@ -0,0 +1,76 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class CountryMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.CountryMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("Country"); + TableMap tMap = dbMap.getTable("Country"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("Country.ID", new Integer(0)); + tMap.addColumn("Country.COUNTRY", new String()); + } +} diff --git a/src/java/org/thdl/roster/om/map/CulturalAreaMapBuilder.java b/src/java/org/thdl/roster/om/map/CulturalAreaMapBuilder.java new file mode 100755 index 0000000..d28b07d --- /dev/null +++ b/src/java/org/thdl/roster/om/map/CulturalAreaMapBuilder.java @@ -0,0 +1,76 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class CulturalAreaMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.CulturalAreaMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("CulturalArea"); + TableMap tMap = dbMap.getTable("CulturalArea"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("CulturalArea.ID", new Integer(0)); + tMap.addColumn("CulturalArea.CULTURAL_AREA", new String()); + } +} diff --git a/src/java/org/thdl/roster/om/map/DisciplineMapBuilder.java b/src/java/org/thdl/roster/om/map/DisciplineMapBuilder.java new file mode 100755 index 0000000..1c8746f --- /dev/null +++ b/src/java/org/thdl/roster/om/map/DisciplineMapBuilder.java @@ -0,0 +1,76 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class DisciplineMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.DisciplineMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("Discipline"); + TableMap tMap = dbMap.getTable("Discipline"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("Discipline.ID", new Integer(0)); + tMap.addColumn("Discipline.DISCIPLINE", new String()); + } +} diff --git a/src/java/org/thdl/roster/om/map/DocumentMapBuilder.java b/src/java/org/thdl/roster/om/map/DocumentMapBuilder.java new file mode 100755 index 0000000..cbe6127 --- /dev/null +++ b/src/java/org/thdl/roster/om/map/DocumentMapBuilder.java @@ -0,0 +1,85 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class DocumentMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.DocumentMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("Document"); + TableMap tMap = dbMap.getTable("Document"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("Document.ID", new Integer(0)); + tMap.addForeignKey( + "Document.MEMBER_ID", new Integer(0) , "Member" , + "id"); + tMap.addForeignKey( + "Document.DOCUMENT_TYPE_ID", new Integer(0) , "DocumentType" , + "id"); + tMap.addColumn("Document.CONTENT_TYPE", new String()); + tMap.addColumn("Document.PATH", new String()); + tMap.addColumn("Document.FILENAME", new String()); + tMap.addColumn("Document.LABEL", new String()); + } +} diff --git a/src/java/org/thdl/roster/om/map/DocumentTypeMapBuilder.java b/src/java/org/thdl/roster/om/map/DocumentTypeMapBuilder.java new file mode 100755 index 0000000..a0ad42e --- /dev/null +++ b/src/java/org/thdl/roster/om/map/DocumentTypeMapBuilder.java @@ -0,0 +1,76 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class DocumentTypeMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.DocumentTypeMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("DocumentType"); + TableMap tMap = dbMap.getTable("DocumentType"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("DocumentType.ID", new Integer(0)); + tMap.addColumn("DocumentType.DOCUMENT_TYPE", new String()); + } +} diff --git a/src/java/org/thdl/roster/om/map/LanguageMapBuilder.java b/src/java/org/thdl/roster/om/map/LanguageMapBuilder.java new file mode 100755 index 0000000..1efbb30 --- /dev/null +++ b/src/java/org/thdl/roster/om/map/LanguageMapBuilder.java @@ -0,0 +1,76 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class LanguageMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.LanguageMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("Language"); + TableMap tMap = dbMap.getTable("Language"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("Language.ID", new Integer(0)); + tMap.addColumn("Language.LANGUAGE", new String()); + } +} diff --git a/src/java/org/thdl/roster/om/map/MemberMapBuilder.java b/src/java/org/thdl/roster/om/map/MemberMapBuilder.java new file mode 100755 index 0000000..bea8bc7 --- /dev/null +++ b/src/java/org/thdl/roster/om/map/MemberMapBuilder.java @@ -0,0 +1,99 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class MemberMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.MemberMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("Member"); + TableMap tMap = dbMap.getTable("Member"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("Member.ID", new Integer(0)); + tMap.addColumn("Member.CREATED_BY", new Integer(0)); + tMap.addColumn("Member.MODIFIED_BY", new Integer(0)); + tMap.addColumn("Member.CREATED_ON", new Date()); + tMap.addColumn("Member.MODIFIED_ON", new Date()); + tMap.addColumn("Member.DELETED", new String()); + tMap.addForeignKey( + "Member.CONTACT_INFO_ID", new Integer(0) , "ContactInfo" , + "id"); + tMap.addForeignKey( + "Member.RESEARCH_INTEREST_ID", new Integer(0) , "ResearchInterest" , + "id"); + tMap.addForeignKey( + "Member.PUBLICATION_ID", new Integer(0) , "Publication" , + "id"); + tMap.addColumn("Member.MEMBER_TYPE", new String()); + tMap.addForeignKey( + "Member.PERSON_DATA_ID", new Integer(0) , "PersonData" , + "id"); + tMap.addForeignKey( + "Member.PROJECT_DATA_ID", new Integer(0) , "ProjectData" , + "id"); + tMap.addForeignKey( + "Member.ORGANIZATION_DATA_ID", new Integer(0) , "OrganizationData" , + "id"); + } +} diff --git a/src/java/org/thdl/roster/om/map/OrganizationDataMapBuilder.java b/src/java/org/thdl/roster/om/map/OrganizationDataMapBuilder.java new file mode 100755 index 0000000..19f64ce --- /dev/null +++ b/src/java/org/thdl/roster/om/map/OrganizationDataMapBuilder.java @@ -0,0 +1,84 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class OrganizationDataMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.OrganizationDataMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("OrganizationData"); + TableMap tMap = dbMap.getTable("OrganizationData"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("OrganizationData.ID", new Integer(0)); + tMap.addColumn("OrganizationData.NAME", new String()); + tMap.addColumn("OrganizationData.PARENT_ORGANIZATION", new String()); + tMap.addColumn("OrganizationData.DIVISIONS", new String()); + tMap.addColumn("OrganizationData.PEOPLE", new String()); + tMap.addColumn("OrganizationData.MAILING_LIST", new String()); + tMap.addColumn("OrganizationData.DESCRIPTION", new String()); + tMap.addColumn("OrganizationData.HISTORY", new String()); + tMap.addColumn("OrganizationData.EDUCATION_PROGRAMS", new String()); + tMap.addColumn("OrganizationData.RESOURCES", new String()); + } +} diff --git a/src/java/org/thdl/roster/om/map/OrganizationOrganizationTypeMapBuilder.java b/src/java/org/thdl/roster/om/map/OrganizationOrganizationTypeMapBuilder.java new file mode 100755 index 0000000..d3c1aa4 --- /dev/null +++ b/src/java/org/thdl/roster/om/map/OrganizationOrganizationTypeMapBuilder.java @@ -0,0 +1,82 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class OrganizationOrganizationTypeMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.OrganizationOrganizationTypeMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("OrganizationOrganizationType"); + TableMap tMap = dbMap.getTable("OrganizationOrganizationType"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("OrganizationOrganizationType.ID", new Integer(0)); + tMap.addForeignKey( + "OrganizationOrganizationType.ORGANIZATION_TYPE_ID", new Integer(0) , "OrganizationType" , + "id"); + tMap.addForeignKey( + "OrganizationOrganizationType.ORGANIZATION_DATA_ID", new Integer(0) , "OrganizationData" , + "id"); + tMap.addColumn("OrganizationOrganizationType.RELEVANCE", new Integer(0)); + } +} diff --git a/src/java/org/thdl/roster/om/map/OrganizationTypeMapBuilder.java b/src/java/org/thdl/roster/om/map/OrganizationTypeMapBuilder.java new file mode 100755 index 0000000..eafd9ff --- /dev/null +++ b/src/java/org/thdl/roster/om/map/OrganizationTypeMapBuilder.java @@ -0,0 +1,76 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class OrganizationTypeMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.OrganizationTypeMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("OrganizationType"); + TableMap tMap = dbMap.getTable("OrganizationType"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("OrganizationType.ID", new Integer(0)); + tMap.addColumn("OrganizationType.ORGANIZATION_TYPE", new String()); + } +} diff --git a/src/java/org/thdl/roster/om/map/PersonDataMapBuilder.java b/src/java/org/thdl/roster/om/map/PersonDataMapBuilder.java new file mode 100755 index 0000000..a94d8dc --- /dev/null +++ b/src/java/org/thdl/roster/om/map/PersonDataMapBuilder.java @@ -0,0 +1,95 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class PersonDataMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.PersonDataMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("PersonData"); + TableMap tMap = dbMap.getTable("PersonData"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("PersonData.ID", new Integer(0)); + tMap.addColumn("PersonData.THDL_USER_ID", new Integer(0)); + tMap.addColumn("PersonData.FIRSTNAME", new String()); + tMap.addColumn("PersonData.MIDDLENAME", new String()); + tMap.addColumn("PersonData.LASTNAME", new String()); + tMap.addColumn("PersonData.BIO", new String()); + tMap.addColumn("PersonData.HISTORY", new String()); + tMap.addColumn("PersonData.PARENT_ORGANIZATION", new String()); + tMap.addColumn("PersonData.SCHOOL", new String()); + tMap.addColumn("PersonData.DEPARTMENT", new String()); + tMap.addColumn("PersonData.PROGRAM", new String()); + tMap.addColumn("PersonData.ADVISOR", new String()); + tMap.addColumn("PersonData.HIGHEST_DEGREE", new String()); + tMap.addColumn("PersonData.YEAR_BEGAN", new Integer(0)); + tMap.addColumn("PersonData.YEAR_FINISHED", new Integer(0)); + tMap.addColumn("PersonData.OTHER_BACKGROUNDS", new String()); + tMap.addColumn("PersonData.ORGANIZATION", new String()); + tMap.addColumn("PersonData.DIVISION", new String()); + tMap.addColumn("PersonData.TITLE", new String()); + tMap.addColumn("PersonData.START_DATE", new Integer(0)); + tMap.addColumn("PersonData.JOB_DESCRIPTION", new String()); + } +} diff --git a/src/java/org/thdl/roster/om/map/PersonPersonTypeMapBuilder.java b/src/java/org/thdl/roster/om/map/PersonPersonTypeMapBuilder.java new file mode 100755 index 0000000..cd8e6f6 --- /dev/null +++ b/src/java/org/thdl/roster/om/map/PersonPersonTypeMapBuilder.java @@ -0,0 +1,82 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class PersonPersonTypeMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.PersonPersonTypeMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("PersonPersonType"); + TableMap tMap = dbMap.getTable("PersonPersonType"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("PersonPersonType.ID", new Integer(0)); + tMap.addForeignKey( + "PersonPersonType.PERSON_TYPE_ID", new Integer(0) , "PersonType" , + "id"); + tMap.addForeignKey( + "PersonPersonType.PERSON_DATA_ID", new Integer(0) , "PersonData" , + "id"); + tMap.addColumn("PersonPersonType.RELEVANCE", new Integer(0)); + } +} diff --git a/src/java/org/thdl/roster/om/map/PersonTypeMapBuilder.java b/src/java/org/thdl/roster/om/map/PersonTypeMapBuilder.java new file mode 100755 index 0000000..867ed7c --- /dev/null +++ b/src/java/org/thdl/roster/om/map/PersonTypeMapBuilder.java @@ -0,0 +1,76 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class PersonTypeMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.PersonTypeMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("PersonType"); + TableMap tMap = dbMap.getTable("PersonType"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("PersonType.ID", new Integer(0)); + tMap.addColumn("PersonType.PERSON_TYPE", new String()); + } +} diff --git a/src/java/org/thdl/roster/om/map/PhoneMapBuilder.java b/src/java/org/thdl/roster/om/map/PhoneMapBuilder.java new file mode 100755 index 0000000..6f85d78 --- /dev/null +++ b/src/java/org/thdl/roster/om/map/PhoneMapBuilder.java @@ -0,0 +1,78 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class PhoneMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.PhoneMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("Phone"); + TableMap tMap = dbMap.getTable("Phone"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("Phone.ID", new Integer(0)); + tMap.addColumn("Phone.COUNTRY_CODE", new Integer(0)); + tMap.addColumn("Phone.AREA_CODE", new Integer(0)); + tMap.addColumn("Phone.NUMBER", new Integer(0)); + } +} diff --git a/src/java/org/thdl/roster/om/map/ProjectDataMapBuilder.java b/src/java/org/thdl/roster/om/map/ProjectDataMapBuilder.java new file mode 100755 index 0000000..d018906 --- /dev/null +++ b/src/java/org/thdl/roster/om/map/ProjectDataMapBuilder.java @@ -0,0 +1,84 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class ProjectDataMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.ProjectDataMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("ProjectData"); + TableMap tMap = dbMap.getTable("ProjectData"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("ProjectData.ID", new Integer(0)); + tMap.addColumn("ProjectData.NAME", new String()); + tMap.addColumn("ProjectData.PARENT_ORGANIZATION", new String()); + tMap.addColumn("ProjectData.DIVISIONS", new String()); + tMap.addColumn("ProjectData.PEOPLE", new String()); + tMap.addColumn("ProjectData.MAILING_LIST", new String()); + tMap.addColumn("ProjectData.DESCRIPTION", new String()); + tMap.addColumn("ProjectData.HISTORY", new String()); + tMap.addColumn("ProjectData.EDUCATION_PROGRAMS", new String()); + tMap.addColumn("ProjectData.RESOURCES", new String()); + } +} diff --git a/src/java/org/thdl/roster/om/map/ProjectProjectTypeMapBuilder.java b/src/java/org/thdl/roster/om/map/ProjectProjectTypeMapBuilder.java new file mode 100755 index 0000000..bbaffac --- /dev/null +++ b/src/java/org/thdl/roster/om/map/ProjectProjectTypeMapBuilder.java @@ -0,0 +1,82 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class ProjectProjectTypeMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.ProjectProjectTypeMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("ProjectProjectType"); + TableMap tMap = dbMap.getTable("ProjectProjectType"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("ProjectProjectType.ID", new Integer(0)); + tMap.addForeignKey( + "ProjectProjectType.PROJECT_TYPE_ID", new Integer(0) , "ProjectType" , + "id"); + tMap.addForeignKey( + "ProjectProjectType.PROJECT_DATA_ID", new Integer(0) , "ProjectData" , + "id"); + tMap.addColumn("ProjectProjectType.RELEVANCE", new Integer(0)); + } +} diff --git a/src/java/org/thdl/roster/om/map/ProjectTypeMapBuilder.java b/src/java/org/thdl/roster/om/map/ProjectTypeMapBuilder.java new file mode 100755 index 0000000..563eab7 --- /dev/null +++ b/src/java/org/thdl/roster/om/map/ProjectTypeMapBuilder.java @@ -0,0 +1,76 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class ProjectTypeMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.ProjectTypeMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("ProjectType"); + TableMap tMap = dbMap.getTable("ProjectType"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("ProjectType.ID", new Integer(0)); + tMap.addColumn("ProjectType.PROJECT_TYPE", new String()); + } +} diff --git a/src/java/org/thdl/roster/om/map/PublicationMapBuilder.java b/src/java/org/thdl/roster/om/map/PublicationMapBuilder.java new file mode 100755 index 0000000..eda7208 --- /dev/null +++ b/src/java/org/thdl/roster/om/map/PublicationMapBuilder.java @@ -0,0 +1,78 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class PublicationMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.PublicationMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("Publication"); + TableMap tMap = dbMap.getTable("Publication"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("Publication.ID", new Integer(0)); + tMap.addColumn("Publication.FORMAL_PUBLICATIONS", new String()); + tMap.addColumn("Publication.WORKS_IN_PROGRESS", new String()); + tMap.addColumn("Publication.PROJECTS", new String()); + } +} diff --git a/src/java/org/thdl/roster/om/map/ResearchInterestCulturalAreaMapBuilder.java b/src/java/org/thdl/roster/om/map/ResearchInterestCulturalAreaMapBuilder.java new file mode 100755 index 0000000..9047d4a --- /dev/null +++ b/src/java/org/thdl/roster/om/map/ResearchInterestCulturalAreaMapBuilder.java @@ -0,0 +1,82 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class ResearchInterestCulturalAreaMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.ResearchInterestCulturalAreaMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("ResearchInterestCulturalArea"); + TableMap tMap = dbMap.getTable("ResearchInterestCulturalArea"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("ResearchInterestCulturalArea.ID", new Integer(0)); + tMap.addForeignKey( + "ResearchInterestCulturalArea.CULTURAL_AREA_ID", new Integer(0) , "CulturalArea" , + "id"); + tMap.addForeignKey( + "ResearchInterestCulturalArea.RESEARCH_INTEREST_ID", new Integer(0) , "ResearchInterest" , + "id"); + tMap.addColumn("ResearchInterestCulturalArea.RELEVANCE", new Integer(0)); + } +} diff --git a/src/java/org/thdl/roster/om/map/ResearchInterestDisciplineMapBuilder.java b/src/java/org/thdl/roster/om/map/ResearchInterestDisciplineMapBuilder.java new file mode 100755 index 0000000..5548d8f --- /dev/null +++ b/src/java/org/thdl/roster/om/map/ResearchInterestDisciplineMapBuilder.java @@ -0,0 +1,82 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class ResearchInterestDisciplineMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.ResearchInterestDisciplineMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("ResearchInterestDiscipline"); + TableMap tMap = dbMap.getTable("ResearchInterestDiscipline"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("ResearchInterestDiscipline.ID", new Integer(0)); + tMap.addForeignKey( + "ResearchInterestDiscipline.DISCIPLINE_ID", new Integer(0) , "Discipline" , + "id"); + tMap.addForeignKey( + "ResearchInterestDiscipline.RESEARCH_INTEREST_ID", new Integer(0) , "ResearchInterest" , + "id"); + tMap.addColumn("ResearchInterestDiscipline.RELEVANCE", new Integer(0)); + } +} diff --git a/src/java/org/thdl/roster/om/map/ResearchInterestLanguageMapBuilder.java b/src/java/org/thdl/roster/om/map/ResearchInterestLanguageMapBuilder.java new file mode 100755 index 0000000..98074e8 --- /dev/null +++ b/src/java/org/thdl/roster/om/map/ResearchInterestLanguageMapBuilder.java @@ -0,0 +1,82 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class ResearchInterestLanguageMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.ResearchInterestLanguageMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("ResearchInterestLanguage"); + TableMap tMap = dbMap.getTable("ResearchInterestLanguage"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("ResearchInterestLanguage.ID", new Integer(0)); + tMap.addForeignKey( + "ResearchInterestLanguage.LANGUAGE_ID", new Integer(0) , "Language" , + "id"); + tMap.addForeignKey( + "ResearchInterestLanguage.RESEARCH_INTEREST_ID", new Integer(0) , "ResearchInterest" , + "id"); + tMap.addColumn("ResearchInterestLanguage.RELEVANCE", new Integer(0)); + } +} diff --git a/src/java/org/thdl/roster/om/map/ResearchInterestMapBuilder.java b/src/java/org/thdl/roster/om/map/ResearchInterestMapBuilder.java new file mode 100755 index 0000000..7bff797 --- /dev/null +++ b/src/java/org/thdl/roster/om/map/ResearchInterestMapBuilder.java @@ -0,0 +1,80 @@ +package org.thdl.roster.om.map; + +import java.util.Date; +import java.math.BigDecimal; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.map.MapBuilder; +import org.apache.torque.map.DatabaseMap; +import org.apache.torque.map.TableMap; + +/** + * This class was autogenerated by Torque on: + * + * [Wed May 14 19:01:42 EDT 2003] + * + */ +public class ResearchInterestMapBuilder implements MapBuilder +{ + /** + * The name of this class + */ + public static final String CLASS_NAME = + "org.thdl.roster.om.map.ResearchInterestMapBuilder"; + + + /** + * The database map. + */ + private DatabaseMap dbMap = null; + + /** + * Tells us if this DatabaseMapBuilder is built so that we + * don't have to re-build it every time. + * + * @return true if this DatabaseMapBuilder is built + */ + public boolean isBuilt() + { + if (dbMap != null) + { + return true; + } + return false; + } + + /** + * Gets the databasemap this map builder built. + * + * @return the databasemap + */ + public DatabaseMap getDatabaseMap() + { + return this.dbMap; + } + + /** + * The doBuild() method builds the DatabaseMap + * + * @throws TorqueException + */ + public void doBuild() throws TorqueException + { + dbMap = Torque.getDatabaseMap("Roster"); + + dbMap.addTable("ResearchInterest"); + TableMap tMap = dbMap.getTable("ResearchInterest"); + + tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); + + tMap.setPrimaryKeyMethodInfo(tMap.getName()); + + tMap.addPrimaryKey("ResearchInterest.ID", new Integer(0)); + tMap.addColumn("ResearchInterest.INTERESTS", new String()); + tMap.addColumn("ResearchInterest.ACTIVITIES", new String()); + tMap.addColumn("ResearchInterest.COLLABORATION_INTERESTS", new String()); + tMap.addColumn("ResearchInterest.FOCUS_FROM", new Integer(0)); + tMap.addColumn("ResearchInterest.FOCUS_TO", new Integer(0)); + } +} diff --git a/src/java/org/thdl/roster/pages/.DS_Store b/src/java/org/thdl/roster/pages/.DS_Store new file mode 100755 index 0000000..34acba6 Binary files /dev/null and b/src/java/org/thdl/roster/pages/.DS_Store differ diff --git a/src/java/org/thdl/roster/pages/Admin.html b/src/java/org/thdl/roster/pages/Admin.html new file mode 100755 index 0000000..4e31e92 --- /dev/null +++ b/src/java/org/thdl/roster/pages/Admin.html @@ -0,0 +1 @@ +

Restart
Reset
Testing

\ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/Admin.page b/src/java/org/thdl/roster/pages/Admin.page new file mode 100755 index 0000000..0452857 --- /dev/null +++ b/src/java/org/thdl/roster/pages/Admin.page @@ -0,0 +1,24 @@ + + + + + + + Adminstration of Roster + + + + + restart + + + + reset + + + Test + + + diff --git a/src/java/org/thdl/roster/pages/Edit.html b/src/java/org/thdl/roster/pages/Edit.html new file mode 100755 index 0000000..00caa07 --- /dev/null +++ b/src/java/org/thdl/roster/pages/Edit.html @@ -0,0 +1,15 @@ + + + + Simple + + + +This application demonstrates some dynamic behavior using Tapestry components. + +

The current date and time is: Current Date + +

Click here to refresh. + + + diff --git a/src/java/org/thdl/roster/pages/Edit.java b/src/java/org/thdl/roster/pages/Edit.java new file mode 100755 index 0000000..5cdbc26 --- /dev/null +++ b/src/java/org/thdl/roster/pages/Edit.java @@ -0,0 +1,19 @@ +package org.thdl.roster.pages; + +import java.util.Date; + +import org.apache.tapestry.html.BasePage; + +/** + * @version $Id: Edit.java,v 1.1 2004/01/07 15:32:42 travismccauley Exp $ + * @author Howard Lewis Ship + * + **/ + +public class Edit extends RosterPage +{ + public Date getCurrentDate() + { + return new Date(); + } +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/Edit.page b/src/java/org/thdl/roster/pages/Edit.page new file mode 100755 index 0000000..72821f1 --- /dev/null +++ b/src/java/org/thdl/roster/pages/Edit.page @@ -0,0 +1,16 @@ + + + + + + + + + + + Home + + + diff --git a/src/java/org/thdl/roster/pages/Home.html b/src/java/org/thdl/roster/pages/Home.html new file mode 100755 index 0000000..9ab4490 --- /dev/null +++ b/src/java/org/thdl/roster/pages/Home.html @@ -0,0 +1,38 @@ + +

+

Search

+

+ Find a Person, Organization, or Project by Name:
+ +

+
+ +

Create a New Roster Entry

+

+ Add a new Person
+ Add a new Organization
+ Add a new Project +

+ +

Edit an Existing Entry

+ +
+

Username: + Password :
+
+ For login assistance, see main Login Page. +

+
+
+ + +

Your Entries

+ +
+ + \ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/Home.java b/src/java/org/thdl/roster/pages/Home.java new file mode 100755 index 0000000..f38cd41 --- /dev/null +++ b/src/java/org/thdl/roster/pages/Home.java @@ -0,0 +1,157 @@ +package org.thdl.roster.pages; + +import java.util.*; +import org.apache.tapestry.*; +import org.apache.tapestry.form.*; +import org.apache.torque.*; +import org.apache.torque.util.*; +import org.thdl.roster.*; +import org.thdl.roster.om.*; +import org.apache.log4j.*; + +public class Home extends RosterPage +{ +//attributes + private RosterQuery rosterQuery; + private String login; + private String password; + private Member member; +//accessors + public void setMember(Member member) { + this.member = member; + } + public Member getMember() { + return member; + } + public void setLogin(String login) { + this.login = login; + } + public void setPassword(String password) { + this.password = password; + } + public String getLogin() { + return login; + } + public String getPassword() { + return password; + } + + public void setRosterQuery(RosterQuery rosterQuery) { + this.rosterQuery = rosterQuery; + } + public RosterQuery getRosterQuery() { + if ( null == rosterQuery ) + { + Global global = (Global) getGlobal(); + setRosterQuery( new RosterQuery( global.getRepresentedCountries() ) ); + } + return rosterQuery; + } +//helpers + public List getPersonalEntries() + { + List entries = new LinkedList(); + Visit visit = (Visit)getVisit(); + if ( visit.isAuthenticated() ) + { + Integer userId = new Integer( visit.getThdlUser().getId() ); + Global global = (Global) getGlobal(); + Iterator iter = global.getAllPeople().iterator(); + while( iter.hasNext() ) + { + Member mem = (Member)iter.next(); + if ( mem.getCreatedBy().equals( userId ) ) + { + entries.add( mem ); + } + } + iter = global.getAllOrganizations().iterator(); + while( iter.hasNext() ) + { + Member mem = (Member)iter.next(); + if ( mem.getCreatedBy().equals( userId ) ) + { + entries.add( mem ); + } + } + iter = global.getAllProjects().iterator(); + while( iter.hasNext() ) + { + Member mem = (Member)iter.next(); + if ( mem.getCreatedBy().equals( userId ) ) + { + entries.add( mem ); + } + } + } + return entries; + } +//listeners + public void loginToEdit( IRequestCycle cycle ) + { + //test for Login.validateUser then either forward to ContactInfo/Home + Login loginPage = (Login)cycle.getPage( "Login" ); + loginPage.setLogin( getLogin() ); + loginPage.setPassword( getPassword() ); + if ( loginPage.validateUser() ) + { + if ( getPersonalEntries().size() == 1 ) + { + Visit visit = (Visit) getVisit(); + visit.setMember( (Member)getPersonalEntries().get( 0 ) ); + IPage page = cycle.getPage( "Contact" ); + page.validate( cycle ); + cycle.activate( page ); + } + } + else + { + setWarning( "Invalid Login/Password combination" ); + } + } + + public void editMember( IRequestCycle cycle ) + { + MembersPage page = (MembersPage)cycle.getPage( "People" ); + page.editMember( cycle ); + } + public void addNewMember( IRequestCycle cycle ) + { + MembersPage page = (MembersPage)cycle.getPage( "People" ); + page.addNewMember( cycle ); + } + public void processForm( IRequestCycle cycle ) throws Exception + { + List members = null; + try + { + Global global =(Global)getGlobal(); + RosterQueryAgent agent = new RosterQueryAgent( global.getTorqueConfig() ); + String sql = agent.buildQuery( getRosterQuery() ); + Logger logger = Logger.getLogger("org.thdl.roster"); + logger.debug( "About to call RosterQueryAgent.executeQuery( sql ) where sql = " +sql ); + members = agent.executeQuery( sql ); + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } + MembersPage page = (MembersPage) cycle.getPage( "SearchResults" ); + page.setMembers( members ); + cycle.activate( page ); + } + public void detach() + { + getRosterQuery().clear(); + setLogin( null ); + setPassword( null ); + super.detach(); + } + +//constructors + + public Home() + { + super(); + } +} diff --git a/src/java/org/thdl/roster/pages/Home.page b/src/java/org/thdl/roster/pages/Home.page new file mode 100755 index 0000000..ea96213 --- /dev/null +++ b/src/java/org/thdl/roster/pages/Home.page @@ -0,0 +1,75 @@ + + + + + + + Home + + + + + + + + + + + + + + + + + + person + + + + + + organization + + + + + + project + + + + + + + + + + + + + + + + + + + + + + + li + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/pages/Login.html b/src/java/org/thdl/roster/pages/Login.html new file mode 100755 index 0000000..c612d9c --- /dev/null +++ b/src/java/org/thdl/roster/pages/Login.html @@ -0,0 +1,81 @@ + + +
+ +
+

Login

+
+

+ If you have never before registered to use a THDL + resource and therefore lack a THDL user name, please click here to + obtain one. If you are unsure what a THDL user name is or why you + need it, please read the section below, "Why do I need a THDL username?". +

+ +

Enter your THDL username: + (or your e-mail address).
+ Enter your THDL password : + +

+
+
+ +
+

Forgot Your Password

+
+

Please contact travis.mccauley@virginia.edu for login remiders until we activate the automated reminder feature below.

+

+ Did you forget your login? Enter your email address and we'll send it to you. +
+ Email: + +

+
+
+ +

Why do I need a THDL username?

+

+THDL offers a variety of resources such as the Community Roster, the +Tibetan Dictionary, the Audio-Video database and so forth which +allow general users to customize these resources to their needs, as +well as collaborators from around the world to simultaneously work +on building the resources. To faciliate use of THDL, we have created +a unified THDL login ID respository that can be utilized to +personalize your use of THDL, as well as access your own information +within THDL. Once you have created your own THDL ID, you can use +that single ID to maintain your own resources and preferences within +THDL. If you have never before registered with THDL and lack an ID, +then you will need to first register and obtain a personalized +username/password for this purpose. For example, individuals wanting +to create a Community Roster entry for themselves will first need a +THDL user name in order to create a roster entry. To create your own +THDL ID, please click here. +

+ +

THDL Privacy Policy

+

+We will never rent, lend, sell or otherwise distribute your e-mail address, street address or phone number to anyone. +The Community Roster is a publically accessible directory, however, so if you do not wish your +contact information to be made public, please do not include it in your entry. +

+
+ +
+ +
+

Register as a New User

+
+

Firstname:

+

Middlename:

+

Lastname:

+

Email:

+

Username:

+

Password:

+

Repeat Password:

+

Password Hint:

+

+
+
+
+ +
\ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/Login.java b/src/java/org/thdl/roster/pages/Login.java new file mode 100755 index 0000000..4b3a858 --- /dev/null +++ b/src/java/org/thdl/roster/pages/Login.java @@ -0,0 +1,182 @@ +package org.thdl.roster.pages; + +import java.util.*; +import java.text.*; +import org.apache.torque.*; +import org.apache.tapestry.*; +import org.apache.tapestry.html.BasePage; + +import org.thdl.users.*; +import org.thdl.roster.*; +import org.thdl.roster.om.*; +import org.thdl.roster.components.Border; +import org.apache.log4j.*; + +public class Login extends RosterPage +{ +//attributes + private boolean newUser; + private String login; + private String password; + private String passwordCopy; + private String forward; +//accessors + public void setNewUser(boolean newUser) { + this.newUser = newUser; + } + public boolean getNewUser() { + return newUser; + } + public void setLogin(String login) { + this.login = login; + } + public void setPassword(String password) { + this.password = password; + } + public String getLogin() { + return login; + } + public String getPassword() { + return password; + } + public void setPasswordCopy(String passwordCopy) { + this.passwordCopy = passwordCopy; + } + public String getPasswordCopy() { + return passwordCopy; + } + public void setForward(String forward) { + this.forward = forward; + Tapestry.fireObservedChange( this, "forward", forward ); + } + public String getForward() { + if (null == forward) + { + setForward( "Home" ); + } + return forward; + } +//helpers + public boolean validateUser() + { + boolean rVal = false; + ThdlUser thdlUser = null; + try + { + thdlUser = ThdlUserRepository.getInstance().validate( getLogin(), getPassword() ); + rVal = true; + Visit visit = (Visit) getVisit(); + visit.setThdlUser( thdlUser ); + visit.setAuthenticated( true ); + } + catch (ThdlUserRepositoryException ture) + { + setMessage( ture.getMessage() ); + } + + return rVal; + } + //tapestry helpers + public void detach() + { + setLogin( null ); + setPassword( null ); + setPasswordCopy( null ); + setMessage( null ); + setWarning( null ); + setNewUser( false ); + super.detach(); + } + //tapestry listeners + public void registerNewUser(IRequestCycle cycle) + { + setNewUser( true ); + } + public void loginFormSubmit(IRequestCycle cycle) + { + if ( validateUser() ) + { + proceed( cycle ); + } + } + private void proceed( IRequestCycle cycle ) + { + Visit visit = (Visit) getVisit(); + + //do some logging + String name = visit.getThdlUser().getFirstname() + " " + visit.getThdlUser().getLastname() ; + Date now = new Date( System.currentTimeMillis() ); + String date = new SimpleDateFormat().format( now ); + Logger logger = Logger.getLogger( "org.thdl.roster.pages" ); + logger.info( name + " logged in at " + date ); + Member member = (Member) visit.getMember(); + if ( null != member && member.isNew() ) + { + try + { + member.getContactInfo().setContactName( visit.getThdlUser().getFirstname() + " " + visit.getThdlUser().getLastname() ); + member.getContactInfo().setEmail( visit.getThdlUser().getEmail() ); + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } + } + RosterPage page = (RosterPage) cycle.getPage( getForward() ); + page.validate( cycle ); + cycle.activate( page ); + } + public void sendInfoFormSubmit(IRequestCycle cycle) + { + Visit visit = (Visit) getVisit(); + } + public void newUserFormSubmit(IRequestCycle cycle) + { + Visit visit = (Visit) getVisit(); + try + { + boolean insertUser=false; + if ( ThdlUserRepository.getInstance().doesNotAlreadyExist( visit.getThdlUser() ) ) + { + insertUser=true; + } + if ( ! getPassword().equals( getPasswordCopy() ) ) + { + insertUser=false; + setWarning( "Your two password entries were not the same. Please re-enter your password." ); + } + else + { + visit.getThdlUser().setPassword( getPassword() ); + } + + if ( insertUser ) + { + ThdlUserRepository.getInstance().insertUser( visit.getThdlUser() ); + setMessage( "Your new user entry was successfully submitted." ); + visit.setAuthenticated( true ); + proceed( cycle ); + } + else + { + setMessage( "Your new user entry was not submitted." ); + } + } + catch (UsernameAlreadyExistsException uaee) + { + setWarning( uaee.getMessage() ); + } + catch (UserEmailAlreadyExistsException ueaee) + { + setWarning( ueaee.getMessage() ); + } + catch (ThdlUserRepositoryException ture) + { + setWarning( ture.getMessage() ); + } + } + public Login() + { + setNewUser( false ); + } +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/Login.page b/src/java/org/thdl/roster/pages/Login.page new file mode 100755 index 0000000..5b3cec3 --- /dev/null +++ b/src/java/org/thdl/roster/pages/Login.page @@ -0,0 +1,123 @@ + + + + + + + Roster Login Page + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Send Login Information + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/pages/Member.html b/src/java/org/thdl/roster/pages/Member.html new file mode 100755 index 0000000..361007b --- /dev/null +++ b/src/java/org/thdl/roster/pages/Member.html @@ -0,0 +1 @@ +

Essentials | Background | Activities | Works | Contact | Files

Essentials

Back to top

Activities

Fields:
Cultural Focus:
Languages Used:

Historical Focus: From the century to the century.

Back to top

Works

Back to top

Contact Information


Back to top

Further Resources

Files

To download these files: right-click (mac: control-click) the link and in Internet Explorer, choose Dowload Link to Disk and in Netscape, choose Save Link Target As.... If you just click the link, the file might open in your browser with unexpected or undesirable results.

Entry created:
Entry revised:

Back to top

\ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/Member.page b/src/java/org/thdl/roster/pages/Member.page new file mode 100755 index 0000000..05dfcc6 --- /dev/null +++ b/src/java/org/thdl/roster/pages/Member.page @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + Contact Name + + + + + + + + + + Website + + + + + + Email + + + + + + Website + + + + + + + + + + + Phone + + + + + Fax + + + + + + + + + + + + + + + + + + + + + + + + + + + + Formal Products/Publications + + + + + + Works In Progress + + + + + + Projects + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Activities + + + + + + Research Interests + + + + + + Collaboration Interests + + + + + + + + + diff --git a/src/java/org/thdl/roster/pages/MemberPage.java b/src/java/org/thdl/roster/pages/MemberPage.java new file mode 100755 index 0000000..f7697f7 --- /dev/null +++ b/src/java/org/thdl/roster/pages/MemberPage.java @@ -0,0 +1,28 @@ +package org.thdl.roster.pages; + +import org.thdl.roster.om.*; +import org.apache.torque.*; + +public class MemberPage extends RosterPage +{ +//attributes + private Member member; +//accessors + public void setMember(Member member) { + this.member = member; + } + public Member getMember() { + return member; + } +//helpers + public boolean isHistoricalDisplayOk() throws TorqueException + { + ResearchInterest ri = getMember().getResearchInterest(); + Integer neg1 = new Integer( -1 ); + boolean b = ! ( neg1.equals( ri.getFocusFrom() ) || neg1.equals( ri.getFocusTo() ) ); + return b; + } + public MemberPage() + { + } +} diff --git a/src/java/org/thdl/roster/pages/Members.html b/src/java/org/thdl/roster/pages/Members.html new file mode 100755 index 0000000..17d28e2 --- /dev/null +++ b/src/java/org/thdl/roster/pages/Members.html @@ -0,0 +1,55 @@ + + +

+

+ + +

+ +

Recent Entries

+ +
+ +
+

+ + +

+ () +
+ +
+ () +
+ +
+ () +
+ + + + +
+ + + +

+ +
+

+ +

+
+ +
+ +
+ + +
\ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/Members.page b/src/java/org/thdl/roster/pages/Members.page new file mode 100755 index 0000000..53bcd8d --- /dev/null +++ b/src/java/org/thdl/roster/pages/Members.page @@ -0,0 +1,74 @@ + + + + + + + + + + + + + person + + + + + + organization + + + + + + project + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/pages/MembersPage.java b/src/java/org/thdl/roster/pages/MembersPage.java new file mode 100755 index 0000000..f42e182 --- /dev/null +++ b/src/java/org/thdl/roster/pages/MembersPage.java @@ -0,0 +1,206 @@ +package org.thdl.roster.pages; + +import java.util.*; +import org.apache.torque.*; +import org.apache.torque.util.*; +import org.apache.tapestry.html.BasePage; +import org.apache.tapestry.IRequestCycle; + +import org.apache.tapestry.IPage; +import org.apache.tapestry.ApplicationRuntimeException; +import org.thdl.roster.*; +import org.thdl.roster.om.*; + +public class MembersPage extends RosterPage +{ +//attributes + private HashMap memberTypes; + private List members; + private Member member; + private boolean memberTypeChanged; +//accessors + public void setMemberTypeChanged(boolean memberTypeChanged) { + this.memberTypeChanged = memberTypeChanged; + } + public boolean getMemberTypeChanged() { + return memberTypeChanged; + } + public void setMembers(List members) { + this.members = members; + } + public void setMember(Member member) { + setMemberTypeChanged( false ); + if ( null != member && ! member.getClass().isInstance( getMember() ) ) + { + setMemberTypeChanged( true ); + } + this.member = member; + } + public List getMembers() { + return members; + } + public Member getMember() { + return member; + } + public void setMemberTypes(HashMap memberTypes) { + this.memberTypes = memberTypes; + } + public HashMap getMemberTypes() { + return memberTypes; + } +//synthetic accessors + public String getMemberTypeHeader() + { + String memType = getMember().getMemberType(); + if ( memType.equals( "person" ) ) + memType = "People"; + else if ( memType.equals( "organization" ) ) + memType = "Organizations"; + else if ( memType.equals( "project" ) ) + memType = "Projects"; + return memType; + } + public List getAllGivenTypeOfMembers() + { + List members = null; + Global global = (Global) getGlobal(); + if ( getPageName().equals( "People" ) ) + { + members = global.getAllPeople(); + } + if ( getPageName().equals( "Projects" ) ) + { + members = global.getAllProjects(); + } + if ( getPageName().equals( "Organizations" ) ) + { + members = global.getAllOrganizations(); + } + return members; + } + +//listeners + + public void addNewMember( IRequestCycle cycle ) + { + Object[] params = cycle.getServiceParameters(); + String memberType = (String) params[0]; + RosterMember member = (RosterMember) getMemberTypes().get( memberType ); + try + { + Visit visit = (Visit) getVisit(); + visit.setMember( produceMember( member ) ); + } + catch ( TorqueException e ) + { + throw new ApplicationRuntimeException( e ); + } + catch ( RosterMemberTypeException e ) + { + throw new ApplicationRuntimeException( e ); + } + IPage page = cycle.getPage( "Contact" ); + page.validate( cycle ); + cycle.activate( page ); + } + + public void viewMember( IRequestCycle cycle ) + { + Integer memberPK = (Integer)cycle.getServiceParameters()[0]; + Member member = null; + try + { + member = MemberPeer.retrieveByPK( memberPK ); + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } + + MemberPage page = null; + if ( member instanceof Person ) + { + page = (MemberPage) cycle.getPage( "Person" ); + } + else if ( member instanceof Project ) + { + page = (MemberPage) cycle.getPage( "Project" ); + } + else if ( member instanceof Organization ) + { + page = (MemberPage) cycle.getPage( "Organization" ); + } + page.setMember( member ); + cycle.activate( page ); + } + public void editMember( IRequestCycle cycle ) + { + Visit visit = (Visit) getVisit(); + Object[] objArray = cycle.getServiceParameters(); + Object obj = objArray[0]; + Integer memberPK = (Integer) obj; + + try + { + visit.setMember( MemberPeer.retrieveByPK( memberPK ) ); + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } + + IPage page = cycle.getPage( "Contact" ); + page.validate( cycle ); + cycle.activate( page ); + } + +//helpers + public RosterMember produceMember( RosterMember rosterMember ) throws TorqueException, RosterMemberTypeException + { + if ( rosterMember instanceof Person ) + { + Person pers = (Person) rosterMember; + rosterMember = (Person) pers.copy(); + } + else if ( rosterMember instanceof Project ) + { + Project proj = (Project) rosterMember; + rosterMember = (Project) proj.copy(); + } + else if ( rosterMember instanceof Organization ) + { + Organization org = (Organization) rosterMember; + rosterMember = (Organization) org.copy(); + } + return rosterMember; + } + + public void detach() + { + super.detach(); + } + +//constructors + public MembersPage() + { + try + { + if ( ! Torque.isInit() ) + { + Global global = (Global) getGlobal(); + Torque.init( global.getTorqueConfig() ); + } + Person person = new Person(); + Project project = new Project(); + Organization org = new Organization(); + setMemberTypes( new HashMap() ); + getMemberTypes().put( "person" , person ); + getMemberTypes().put( "project" , project ); + getMemberTypes().put( "organization" , org ); + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( te.getMessage() ); + } + } +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/RosterPage.java b/src/java/org/thdl/roster/pages/RosterPage.java new file mode 100755 index 0000000..d8c52e7 --- /dev/null +++ b/src/java/org/thdl/roster/pages/RosterPage.java @@ -0,0 +1,99 @@ +package org.thdl.roster.pages; + +import org.apache.torque.*; +import org.apache.tapestry.*; +import org.apache.tapestry.html.BasePage; +import org.thdl.roster.*; + +public class RosterPage extends BasePage +{ +//attributes + private String message; + private String warning; + private String nextPage; +//accessors + public void setNextPage(String nextPage) { + this.nextPage = nextPage; + } + public String getNextPage() { + return nextPage; + } + + public void setMessage(String message) + { + this.message = message; + } + + public String getMessage() + { + return message; + } + + public void setWarning(String warning) + { + this.warning = warning; + } + + public String getWarning() + { + return warning; + } +//helpers + public void torqueInit() + { + try + { + if ( ! Torque.isInit() ) + { + Global global = (Global) getGlobal(); + Torque.init( global.getTorqueConfig() ); + } + } + catch (TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } + } + + public boolean isLoggedIn() + { + Visit visit = (Visit)getPage().getEngine().getVisit(); + boolean b = false; + if (null != visit && visit.isAuthenticated() ) + b = true; + return b; + } + + public void logout(IRequestCycle cycle) + { + getEngine().setVisit(null); + RosterPage home = (RosterPage)cycle.getPage("Home"); + home.setMessage("You have successfully logged out of the Thdl Community Roster."); + cycle.activate(home); + } + + public void detach() + { + setMessage(null); + setWarning(null); + super.detach(); + } +//constructors + public RosterPage() + { + super(); + try + { + if ( !Torque.isInit() ) + { + Global global = (Global) getGlobal(); + Torque.init( global.getTorqueConfig() ); + } + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( "Torque Exception says: " + te.getMessage(), te ); + } + } + +} diff --git a/src/java/org/thdl/roster/pages/Search.html b/src/java/org/thdl/roster/pages/Search.html new file mode 100755 index 0000000..b68729e --- /dev/null +++ b/src/java/org/thdl/roster/pages/Search.html @@ -0,0 +1,38 @@ + +
+

Names and Text Fields

+

+ These text search fields are optional. You can leave them blank
and narrow your search with the other parameters below.

+ Name contains:
+ Organizational Base contains:
+ Any text field contains: +

+

Roster Member Types

+

+ +
+
+ Choose a language:
+

+ +

+ +

+ +
+
\ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/Search.java b/src/java/org/thdl/roster/pages/Search.java new file mode 100755 index 0000000..2d1ada7 --- /dev/null +++ b/src/java/org/thdl/roster/pages/Search.java @@ -0,0 +1,303 @@ +package org.thdl.roster.pages; + +import java.util.*; +import org.apache.tapestry.*; +import org.apache.tapestry.form.*; +import org.apache.torque.*; +import org.apache.torque.util.*; +import org.thdl.roster.*; +import org.thdl.roster.om.*; +import org.apache.log4j.*; + +public class Search extends RosterPage +{ +//attributes + private RosterQuery rosterQuery; + private IPropertySelectionModel disciplineModel; + private IPropertySelectionModel culturalAreaModel; + private IPropertySelectionModel languageModel; + private IPropertySelectionModel personTypeModel; + private IPropertySelectionModel projectTypeModel; + private IPropertySelectionModel organizationTypeModel; + +//accessors + public void setCulturalAreaModel( IPropertySelectionModel culturalAreaModel ) + { + this.culturalAreaModel = culturalAreaModel; + } + + public IPropertySelectionModel getCulturalAreaModel() + { + if ( culturalAreaModel == null ) + { + setCulturalAreaModel( buildCulturalAreaModel() ); + } + return culturalAreaModel; + } + + public void setLanguageModel( IPropertySelectionModel languageModel ) + { + this.languageModel = languageModel; + } + + public IPropertySelectionModel getLanguageModel() + { + if ( languageModel == null ) + { + setLanguageModel( buildLanguageModel() ); + } + return languageModel; + } + + public void setDisciplineModel( IPropertySelectionModel disciplineModel ) + { + this.disciplineModel = disciplineModel; + } + + public IPropertySelectionModel getDisciplineModel() + { + if ( disciplineModel == null ) + { + setDisciplineModel( buildDisciplineModel() ); + } + return disciplineModel; + } + + public void setRosterQuery(RosterQuery rosterQuery) { + this.rosterQuery = rosterQuery; + } + public RosterQuery getRosterQuery() { + if ( null == rosterQuery ) + { + Global global = (Global) getGlobal(); + setRosterQuery( new RosterQuery( global.getRepresentedCountries() ) ); + } + return rosterQuery; + } +//helpers + public IPropertySelectionModel buildDisciplineModel() + { + List disciplines; + try + { + Criteria crit = new Criteria(); + crit.addAscendingOrderByColumn( DisciplinePeer.DISCIPLINE ); + disciplines = new LinkedList( BaseDisciplinePeer.doSelect( crit ) ); + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( "Torque Exception says: " + te.getMessage(), te ); + } + EntitySelectionModel disciplineModel = new EntitySelectionModel(); + ListIterator looper = disciplines.listIterator( 0 ); + disciplineModel.add( null , "All Disciplines" ); + while ( looper.hasNext() ) + { + Discipline discipline = (Discipline) looper.next(); + disciplineModel.add( discipline.getId(), discipline.getDiscipline() ); + } + return disciplineModel; + } + public IPropertySelectionModel buildCulturalAreaModel() + { + LinkedList list; + try + { + Criteria crit = new Criteria(); + crit.addAscendingOrderByColumn( CulturalAreaPeer.CULTURAL_AREA ); + list = new LinkedList( BaseCulturalAreaPeer.doSelect( crit ) ); + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( "Torque Exception says: " + te.getMessage(), te ); + } + EntitySelectionModel culturalAreaModel = new EntitySelectionModel(); + ListIterator looper = list.listIterator( 0 ); + culturalAreaModel.add( null, "All Areas" ); + while ( looper.hasNext() ) + { + CulturalArea culturalArea = (CulturalArea) looper.next(); + culturalAreaModel.add( culturalArea.getId(), culturalArea.getCulturalArea() ); + } + return culturalAreaModel; + } + + + public IPropertySelectionModel buildLanguageModel() + { + LinkedList list; + try + { + Criteria crit = new Criteria(); + crit.addAscendingOrderByColumn( LanguagePeer.LANGUAGE ); + list = new LinkedList( BaseLanguagePeer.doSelect( crit ) ); + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( "Torque Exception says: " + te.getMessage(), te ); + } + EntitySelectionModel languageModel = new EntitySelectionModel(); + ListIterator looper = list.listIterator( 0 ); + languageModel.add( null, "All Languages" ); + while ( looper.hasNext() ) + { + Language language = (Language) looper.next(); + languageModel.add( language.getId(), language.getLanguage() ); + } + return languageModel; + } + + + public void setPersonTypeModel(IPropertySelectionModel personTypeModel) + { + this.personTypeModel = personTypeModel; + } + + public IPropertySelectionModel getPersonTypeModel() + { + if (personTypeModel == null) + { + setPersonTypeModel( buildPersonTypeModel() ); + } + return personTypeModel; + } + + public void setProjectTypeModel(IPropertySelectionModel projectTypeModel) + { + this.projectTypeModel = projectTypeModel; + } + + public IPropertySelectionModel getProjectTypeModel() + { + if (projectTypeModel == null) + { + setProjectTypeModel( buildProjectTypeModel() ); + } + return projectTypeModel; + } + + public void setOrganizationTypeModel(IPropertySelectionModel organizationTypeModel) + { + this.organizationTypeModel = organizationTypeModel; + } + + public IPropertySelectionModel getOrganizationTypeModel() + { + if (organizationTypeModel == null) + { + setOrganizationTypeModel( buildOrganizationTypeModel() ); + } + return organizationTypeModel; + } + + public IPropertySelectionModel buildPersonTypeModel() + { + try + { + EntitySelectionModel personTypeModel = new EntitySelectionModel(); + Criteria crit = new Criteria(); + crit.addAscendingOrderByColumn( PersonTypePeer.PERSON_TYPE ); + LinkedList list = new LinkedList( PersonTypePeer.doSelect( crit ) ); + PersonType personType; + ListIterator looper = list.listIterator( 0 ); + personTypeModel.add( null, "All People" ); + while ( looper.hasNext() ) + { + personType = (PersonType) looper.next(); + personTypeModel.add( personType.getId(), personType.getPersonType() ); + } + return personTypeModel; + } + catch (TorqueException te) { + throw new ApplicationRuntimeException( "Torque Exception says: " + te.getMessage(), te ); + } + } + + public IPropertySelectionModel buildProjectTypeModel() + { + try + { + EntitySelectionModel projectTypeModel = new EntitySelectionModel(); + Criteria crit = new Criteria(); + crit.addAscendingOrderByColumn( ProjectTypePeer.PROJECT_TYPE ); + LinkedList list = new LinkedList( ProjectTypePeer.doSelect( crit ) ); + ProjectType projectType; + ListIterator looper = list.listIterator( 0 ); + projectTypeModel.add( null, "All Projects" ); + while ( looper.hasNext() ) + { + projectType = (ProjectType) looper.next(); + projectTypeModel.add( projectType.getId(), projectType.getProjectType() ); + } + return projectTypeModel; + } + catch (TorqueException te) { + throw new ApplicationRuntimeException( "Torque Exception says: " + te.getMessage(), te ); + } + } + + public IPropertySelectionModel buildOrganizationTypeModel() + { + try + { + EntitySelectionModel organizationTypeModel = new EntitySelectionModel(); + Criteria crit = new Criteria(); + crit.addAscendingOrderByColumn( OrganizationTypePeer.ORGANIZATION_TYPE ); + LinkedList list = new LinkedList( OrganizationTypePeer.doSelect( crit ) ); + OrganizationType organizationType; + ListIterator looper = list.listIterator( 0 ); + organizationTypeModel.add( null, "All Organizations"); + while ( looper.hasNext() ) + { + organizationType = (OrganizationType) looper.next(); + organizationTypeModel.add( organizationType.getId(), organizationType.getOrganizationType() ); + } + return organizationTypeModel; + } + catch (TorqueException te) { + throw new ApplicationRuntimeException( "Torque Exception says: " + te.getMessage(), te ); + } + } + +//listeners + + public void processForm( IRequestCycle cycle ) throws Exception + { + List members = null; + try + { + Global global =(Global)getGlobal(); + RosterQueryAgent agent = new RosterQueryAgent( global.getTorqueConfig() ); + String sql = agent.buildQuery( getRosterQuery() ); + Logger logger = Logger.getLogger("org.thdl.roster"); + logger.debug( "About to call RosterQueryAgent.executeQuery( sql ) where sql = " +sql ); + members = agent.executeQuery( sql ); + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } + if ( members != null && members.size() > 0 ) + { + MembersPage page = (MembersPage) cycle.getPage( "SearchResults" ); + page.setMembers( members ); + cycle.activate( page ); + } + else + { + setWarning( "Search returned zero results. Please try again" ); + } + } + public void detach() + { + getRosterQuery().clear(); + super.detach(); + } + +//constructors + + public Search() + { + super(); + } +} diff --git a/src/java/org/thdl/roster/pages/Search.page b/src/java/org/thdl/roster/pages/Search.page new file mode 100755 index 0000000..19235a7 --- /dev/null +++ b/src/java/org/thdl/roster/pages/Search.page @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + Search + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/pages/SearchResults.html b/src/java/org/thdl/roster/pages/SearchResults.html new file mode 100755 index 0000000..7381ae8 --- /dev/null +++ b/src/java/org/thdl/roster/pages/SearchResults.html @@ -0,0 +1,42 @@ + + +
+ +
+

+
+ +
+ +

+ + +

+ () +
+ +
+ () +
+ +
+ () +
+ + + +
+ + + +
+ + read more + +

+ +
+ +
+ +
\ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/SearchResults.page b/src/java/org/thdl/roster/pages/SearchResults.page new file mode 100755 index 0000000..10d3bc5 --- /dev/null +++ b/src/java/org/thdl/roster/pages/SearchResults.page @@ -0,0 +1,61 @@ + + + + + + + Search Results + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/pages/forms/.DS_Store b/src/java/org/thdl/roster/pages/forms/.DS_Store new file mode 100755 index 0000000..5008ddf Binary files /dev/null and b/src/java/org/thdl/roster/pages/forms/.DS_Store differ diff --git a/src/java/org/thdl/roster/pages/forms/ContactInfo.html b/src/java/org/thdl/roster/pages/forms/ContactInfo.html new file mode 100755 index 0000000..65f6c7e --- /dev/null +++ b/src/java/org/thdl/roster/pages/forms/ContactInfo.html @@ -0,0 +1,45 @@ + +

Please enter any contact information you would like to share with others. +Most fields are optional but please be sure to enter a contact name, email address and your country. +

+ +

THDL Privacy Policy

+

+We will never rent, lend, sell or otherwise distribute your e-mail address, street address or phone number to anyone. +The Community Roster is a publically accessible directory, however, so if you do not wish your +contact information to be made public, please do not include it in your entry. +

+ + + + + +

+ Contact name:
+ Email:
+ Website: +

+ +

Address

+ +

+

+

+ +

Phone Numbers

+ +

+ The three boxes correspond to country code, area code, and personal number. Please leave the first box empty if you don't know the country code +

+

+ Phone:


+ Fax:
+

+ + + + + + + + \ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/forms/ContactInfo.page b/src/java/org/thdl/roster/pages/forms/ContactInfo.page new file mode 100755 index 0000000..4b57d0b --- /dev/null +++ b/src/java/org/thdl/roster/pages/forms/ContactInfo.page @@ -0,0 +1,66 @@ + + + + + + + Contact Information + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Continue + continue + + + + + Finish + + finish + + + + + diff --git a/src/java/org/thdl/roster/pages/forms/ContactInfoPage.java b/src/java/org/thdl/roster/pages/forms/ContactInfoPage.java new file mode 100755 index 0000000..b3e9e55 --- /dev/null +++ b/src/java/org/thdl/roster/pages/forms/ContactInfoPage.java @@ -0,0 +1,70 @@ +package org.thdl.roster.pages.forms; + +import java.util.List; +import java.util.LinkedList; +import org.apache.torque.*; +import org.apache.tapestry.html.BasePage; +import org.apache.tapestry.IRequestCycle; +import org.apache.tapestry.IEngine; +import org.apache.tapestry.PageRedirectException; +import org.apache.tapestry.ApplicationRuntimeException; +import org.thdl.roster.*; +import org.thdl.roster.om.*; + +public class ContactInfoPage extends MemberFormSeries +{ + +//tapestry listeners + public void processForm(IRequestCycle cycle) + { + Visit visit = (Visit) getVisit(); + Member member = (Member) visit.getMember(); + member.save( new Integer( visit.getThdlUser().getId() ) ); + try + { + if ( member instanceof Person ) + { + Person person = (Person)member; + person.getPersonData().setFirstname( visit.getThdlUser().getFirstname() ); + person.getPersonData().setLastname( visit.getThdlUser().getLastname() ); + person.getPersonData().setMiddlename( visit.getThdlUser().getMiddlename() ); + } + member.getContactInfo().getAddress().save(); + member.getContactInfo().getPhoneRelatedByPhone().save(); + member.getContactInfo().getPhoneRelatedByFax().save(); + member.getContactInfo().setAddressKey( member.getContactInfo().getAddress().getPrimaryKey() ); + member.getContactInfo().setPhoneRelatedByPhoneKey( member.getContactInfo().getPhoneRelatedByPhone().getPrimaryKey() ); + member.getContactInfo().setPhoneRelatedByFaxKey( member.getContactInfo().getPhoneRelatedByFax().getPrimaryKey() ); + member.getContactInfo().save(); + member.setContactInfoKey( member.getContactInfo().getPrimaryKey() ); + member.save(); + } + catch (Exception e ) + { + throw new ApplicationRuntimeException( e ); + } + } + public void detach() + { + setNextPage( "Background" ); + super.detach(); + } + +//constructors + public ContactInfoPage() + { + try + { + if ( !Torque.isInit() ) + { + Global global = (Global) getGlobal(); + Torque.init( global.getTorqueConfig() ); + } + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( "Torque Exception says: " + te.getMessage(), te ); + } + setNextPage("Background"); + } +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/forms/MemberData.html b/src/java/org/thdl/roster/pages/forms/MemberData.html new file mode 100755 index 0000000..1db59bb --- /dev/null +++ b/src/java/org/thdl/roster/pages/forms/MemberData.html @@ -0,0 +1,32 @@ + +

Please enter information about your history and work background. +All fields are optional but please at least enter an overview/brief bio to give others a sense of who you are. You can use the word "freelance" and so forth in appropriate places such as "organizational base" and "organization" if you are self-employed.

+ + + +

+ Choose items from below that best describe you. Then sort your selections by relevance: + +

+ + + +

+ Choose items from below that best describe your organization. Then sort your selections by relevance: + + + + + + \ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/forms/MemberData.java b/src/java/org/thdl/roster/pages/forms/MemberData.java new file mode 100755 index 0000000..383b2a8 --- /dev/null +++ b/src/java/org/thdl/roster/pages/forms/MemberData.java @@ -0,0 +1,265 @@ +package org.thdl.roster.pages.forms; + +import java.util.*; + +import org.apache.tapestry.*; +import org.apache.tapestry.html.*; +import org.apache.tapestry.form.*; +import org.apache.tapestry.contrib.palette.SortMode; + +import org.apache.torque.*; +import org.apache.torque.om.*; +import org.apache.torque.util.*; + +import org.thdl.roster.*; +import org.thdl.roster.om.*; +import org.thdl.roster.pages.*; + +public class MemberData extends MemberFormSeries +{ +//attributes + // private List selectedMemberTypes; + private IPropertySelectionModel personTypeModel; + private IPropertySelectionModel projectTypeModel; + private IPropertySelectionModel organizationTypeModel; +//accessors + public void setPersonTypeModel(IPropertySelectionModel personTypeModel) + { + this.personTypeModel = personTypeModel; + } + + public IPropertySelectionModel getPersonTypeModel() + { + if (personTypeModel == null) + { + setPersonTypeModel( buildPersonTypeModel() ); + } + return personTypeModel; + } + + public void setProjectTypeModel(IPropertySelectionModel projectTypeModel) + { + this.projectTypeModel = projectTypeModel; + } + + public IPropertySelectionModel getProjectTypeModel() + { + if (projectTypeModel == null) + { + setProjectTypeModel( buildProjectTypeModel() ); + } + return projectTypeModel; + } + + public void setOrganizationTypeModel(IPropertySelectionModel organizationTypeModel) + { + this.organizationTypeModel = organizationTypeModel; + } + + public IPropertySelectionModel getOrganizationTypeModel() + { + if (organizationTypeModel == null) + { + setOrganizationTypeModel( buildOrganizationTypeModel() ); + } + return organizationTypeModel; + } + +/* public List getSelectedMemberTypes() + { + return selectedMemberTypes; + } + + public void setSelectedMemberTypes(List selectedMemberTypes) + { + this.selectedMemberTypes = selectedMemberTypes; + } + */ +//helpers +//tapestry listeners + public void processForm(IRequestCycle cycle) + { + Visit visit = (Visit) getVisit(); + Member member = (Member) visit.getMember(); + if ( member instanceof Person ) + { + try + { + Person person = (Person) member; + + //don't move this line! + List flatDataIds = person.getPersonData().getPersonTypeIdList(); + + Integer userId = new Integer( visit.getThdlUser().getId() ); + person.getPersonData().setThdlUserId( userId ); + person.getPersonData().save(); + person.setPersonDataKey( member.getPersonData().getPrimaryKey() ); + person.save(); + + Criteria crit = new Criteria(); + crit.add( PersonPersonTypePeer.PERSON_DATA_ID, person.getPersonData().getId() ); + List torqueObjects = PersonPersonTypePeer.doSelect( crit ); + + Integer memberDataId = person.getPersonData().getId(); + + PersonPersonType template = new PersonPersonType(); + + PaletteMergeTableProcessor.processPalette( flatDataIds, torqueObjects, memberDataId, template ); + } + catch ( RosterMemberTypeException rmte ) + { + throw new ApplicationRuntimeException( rmte ); + } + catch (Exception e) + { + throw new ApplicationRuntimeException( e ); + } + } + if ( member instanceof Organization ) + { + try + { + Organization organization = (Organization) member; + + //don't move this line! + List flatDataIds = organization.getOrganizationData().getOrganizationTypeIdList(); + + organization.getOrganizationData().save(); + organization.setOrganizationDataKey( member.getOrganizationData().getPrimaryKey() ); + organization.save(); + + Criteria crit = new Criteria(); + crit.add( OrganizationOrganizationTypePeer.ORGANIZATION_DATA_ID, organization.getOrganizationData().getId() ); + List torqueObjects = OrganizationOrganizationTypePeer.doSelect( crit ); + Integer memberDataId = organization.getOrganizationData().getId(); + OrganizationOrganizationType template = new OrganizationOrganizationType(); + PaletteMergeTableProcessor.processPalette( flatDataIds, torqueObjects, memberDataId, template ); + } + catch ( RosterMemberTypeException rmte ) + { + throw new ApplicationRuntimeException( rmte ); + } + catch (Exception e) + { + throw new ApplicationRuntimeException( e ); + } + } + if ( member instanceof Project ) + { + try + { + Project project = (Project) member; + + //don't move this line! + List flatDataIds = project.getProjectData().getProjectTypeIdList(); + + project.getProjectData().save(); + project.setProjectDataKey( member.getProjectData().getPrimaryKey() ); + project.save(); + + Criteria crit = new Criteria(); + crit.add( ProjectProjectTypePeer.PROJECT_DATA_ID, project.getProjectData().getId() ); + List torqueObjects = ProjectProjectTypePeer.doSelect( crit ); + Integer memberDataId = project.getProjectData().getId(); + ProjectProjectType template = new ProjectProjectType(); + PaletteMergeTableProcessor.processPalette( flatDataIds, torqueObjects, memberDataId, template ); + } + catch ( RosterMemberTypeException rmte ) + { + throw new ApplicationRuntimeException( rmte ); + } + catch (Exception e) + { + throw new ApplicationRuntimeException( e ); + } + } + } + + public IPropertySelectionModel buildPersonTypeModel() + { + try + { + EntitySelectionModel personTypeModel = new EntitySelectionModel(); + Criteria crit = new Criteria(); + crit.addAscendingOrderByColumn( PersonTypePeer.PERSON_TYPE ); + LinkedList list = new LinkedList( PersonTypePeer.doSelect( crit ) ); + PersonType personType; + ListIterator looper = list.listIterator( 0 ); + while ( looper.hasNext() ) + { + personType = (PersonType) looper.next(); + personTypeModel.add( personType.getId(), personType.getPersonType() ); + } + return personTypeModel; + } + catch (TorqueException te) { + throw new ApplicationRuntimeException( "Torque Exception says: " + te.getMessage(), te ); + } + } + public IPropertySelectionModel buildProjectTypeModel() + { + try + { + EntitySelectionModel projectTypeModel = new EntitySelectionModel(); + Criteria crit = new Criteria(); + crit.addAscendingOrderByColumn( ProjectTypePeer.PROJECT_TYPE ); + LinkedList list = new LinkedList( ProjectTypePeer.doSelect( crit ) ); + ProjectType projectType; + ListIterator looper = list.listIterator( 0 ); + while ( looper.hasNext() ) + { + projectType = (ProjectType) looper.next(); + projectTypeModel.add( projectType.getId(), projectType.getProjectType() ); + } + return projectTypeModel; + } + catch (TorqueException te) { + throw new ApplicationRuntimeException( "Torque Exception says: " + te.getMessage(), te ); + } + } + public IPropertySelectionModel buildOrganizationTypeModel() + { + try + { + EntitySelectionModel organizationTypeModel = new EntitySelectionModel(); + Criteria crit = new Criteria(); + crit.addAscendingOrderByColumn( OrganizationTypePeer.ORGANIZATION_TYPE ); + LinkedList list = new LinkedList( OrganizationTypePeer.doSelect( crit ) ); + OrganizationType organizationType; + ListIterator looper = list.listIterator( 0 ); + while ( looper.hasNext() ) + { + organizationType = (OrganizationType) looper.next(); + organizationTypeModel.add( organizationType.getId(), organizationType.getOrganizationType() ); + } + return organizationTypeModel; + } + catch (TorqueException te) { + throw new ApplicationRuntimeException( "Torque Exception says: " + te.getMessage(), te ); + } + } + public void detach() + { + setNextPage( "Activities" ); + super.detach(); + } + +//constructors + public MemberData() + { + try + { + if ( !Torque.isInit() ) + { + Global global = (Global) getGlobal(); + Torque.init( global.getTorqueConfig() ); + } + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( "Torque Exception says: " + te.getMessage(), te ); + } + setNextPage( "Activities" ); + } + +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/forms/MemberData.page b/src/java/org/thdl/roster/pages/forms/MemberData.page new file mode 100755 index 0000000..468c22f --- /dev/null +++ b/src/java/org/thdl/roster/pages/forms/MemberData.page @@ -0,0 +1,92 @@ + + + + + + + Background Information + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + palette + + + + + + + + + + + + + + + palette + + + + + + + + + + + + + + + palette + + + + + + + + + + Continue + continue + + + + + Finish + + finish + + + diff --git a/src/java/org/thdl/roster/pages/forms/MemberFormSeries.java b/src/java/org/thdl/roster/pages/forms/MemberFormSeries.java new file mode 100755 index 0000000..92ee5da --- /dev/null +++ b/src/java/org/thdl/roster/pages/forms/MemberFormSeries.java @@ -0,0 +1,141 @@ +package org.thdl.roster.pages.forms; + +import java.util.List; +import java.util.LinkedList; +import org.apache.tapestry.html.BasePage; +import org.apache.tapestry.IRequestCycle; +import org.apache.tapestry.IEngine; + +import org.apache.tapestry.*; +import org.thdl.roster.*; +import org.thdl.roster.om.*; +import org.thdl.roster.pages.*; + +public abstract class MemberFormSeries extends SecureRosterPage +{ +//attributes + private String token; +//accessors + public void setToken(String token) { + this.token = token; + } + public String getToken() { + return token; + } +//helpers +//tapestry listeners + public abstract void processForm( IRequestCycle cycle ); + + public boolean tokensValidate() + { + return true; + } + + public void forward( IRequestCycle cycle ) + { + String warning = null; + String message = null; + if ( tokensValidate() ) + { + processForm( cycle ); + message= "Your " + getPageName() + " data was saved in your profile."; + } + else + { + warning="Invalid reload attempt; your form submission was not processed."; + } + + String newToken = null; + try + { + newToken = TokenMaker.make(); + } + catch ( java.security.NoSuchAlgorithmException nsae ) + { + throw new ApplicationRuntimeException( nsae ); + } + + MemberFormSeries page = (MemberFormSeries)cycle.getPage( getNextPage() ); + page.setToken( newToken ); + Visit visit = (Visit)getVisit(); + visit.setToken( newToken ); + + page.setWarning( warning ); + page.setMessage( message ); + page.validate( cycle ); + cycle.activate( page ); + } + + public void finish( IRequestCycle cycle ) + { + Visit visit = (Visit)getVisit(); + Member member = (Member) visit.getMember(); + Global global = (Global) getGlobal(); + + if ( tokensValidate() ) + { + processForm( cycle ); + } + + visit.setToken( null ); + + MemberPage page = null; + if ( member instanceof Person ) + { + page = (MemberPage)cycle.getPage( "Person" ); + global.setAllPeople( global.refreshPeople() ); + } + else if ( member instanceof Project ) + { + page = (MemberPage)cycle.getPage( "Project" ); + global.setAllProjects( global.refreshProjects() ); + } + else if ( member instanceof Organization ) + { + page = (MemberPage)cycle.getPage( "Organization" ); + global.setAllOrganizations( global.refreshOrganizations() ); + } + global.setRepresentedCountries( global.refreshRepresentedCountries() ); + page.setMember( member ); + cycle.activate( page ); + } + + public void validate(IRequestCycle cycle) + { + Visit visit = (Visit) getVisit(); + Member member = (Member)visit.getMember(); + if ( null == member ) + { + RosterPage home = (RosterPage) cycle.getPage( "Home" ); + home.setWarning( "There was no Roster Member in your session. This is possibly due to navigating to an edit screen after your session had timed out." ); + throw new PageRedirectException( home ); + } + + super.validate( cycle ); + + if ( ! member.isNew() ) + { + Integer owner = member.getCreatedBy(); + Integer user = new Integer( visit.getThdlUser().getId() ); + if ( ! owner.equals( user ) ) + { + RosterPage home = (RosterPage) cycle.getPage( "Home" ); + home.setWarning( "You are not logged in as the owner of this entry." ); + throw new PageRedirectException( home ); + } + } + } +//synthetic accessors + +//constructors + public MemberFormSeries() + { + super(); + /* List list = java.util.Collections.synchronizedList( new LinkedList() ); + setForward( list ); + getForward().add( "Contact" ); + getForward().add( "Background" ); + getForward().add( "Research" ); + getForward().add( "Publications" ); */ + } +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/forms/Publications.html b/src/java/org/thdl/roster/pages/forms/Publications.html new file mode 100755 index 0000000..c71b70a --- /dev/null +++ b/src/java/org/thdl/roster/pages/forms/Publications.html @@ -0,0 +1 @@ +

Here you can share information about your work. You may upload more detailed documents about your work on the next page but if you do so, please refer people to the appropriate files on this page.

Formal Products/Publications: This might be recordings for a musician, art, a technique for making cement blocks, a computer program or any other product or publication.

Works in Progress:

Projects:

\ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/forms/Publications.page b/src/java/org/thdl/roster/pages/forms/Publications.page new file mode 100755 index 0000000..04cbac9 --- /dev/null +++ b/src/java/org/thdl/roster/pages/forms/Publications.page @@ -0,0 +1,51 @@ + + + + + + + Works: Products, Publications, Projects + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Continue + continue + + + + + Finish + + finish + + + diff --git a/src/java/org/thdl/roster/pages/forms/PublicationsPage.java b/src/java/org/thdl/roster/pages/forms/PublicationsPage.java new file mode 100755 index 0000000..ddaa2b1 --- /dev/null +++ b/src/java/org/thdl/roster/pages/forms/PublicationsPage.java @@ -0,0 +1,74 @@ +package org.thdl.roster.pages.forms; + +import java.io.*; +import java.util.*; + +import org.thdl.roster.*; +import org.thdl.roster.om.*; +import org.thdl.roster.pages.*; + +import org.apache.tapestry.ApplicationRuntimeException; +import org.apache.tapestry.IRequestCycle; +import org.apache.tapestry.IPage; +import org.apache.tapestry.request.IUploadFile; +import org.apache.tapestry.form.IPropertySelectionModel; + +import org.apache.commons.lang.exception.NestableException; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.util.Criteria; + +/** + * Description of the Class + * + *@author travis + *@created March 11, 2003 + */ +public class PublicationsPage extends MemberFormSeries { + + /** + * Description of the Method + * + *@param cycle Description of the Parameter + */ + public void processForm(IRequestCycle cycle) + { + Visit visit = (Visit) getVisit(); + Member member = (Member) visit.getMember(); + try + { + member.getPublication().save(); + member.setPublicationKey( member.getPublication().getPrimaryKey() ); + member.save(); + } + catch (Exception e) + { + throw new ApplicationRuntimeException( e ); + } + } + + public void detach() + { + setNextPage( "Uploads" ); + super.detach(); + } + + public PublicationsPage() + { + try + { + if ( !Torque.isInit() ) + { + Global global = (Global) getGlobal(); + Torque.init( global.getTorqueConfig() ); + } + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( "Torque Exception says: " + te.getMessage(), te ); + } + setNextPage( "Uploads" ); + } +} + diff --git a/src/java/org/thdl/roster/pages/forms/ResearchInterests.html b/src/java/org/thdl/roster/pages/forms/ResearchInterests.html new file mode 100755 index 0000000..f9167a2 --- /dev/null +++ b/src/java/org/thdl/roster/pages/forms/ResearchInterests.html @@ -0,0 +1 @@ +

Use this area to describe your current activities, research or other work. If your work is historical, then you can enter the centuries you focus on.

Fields

Languages Used century to the
Research Interests: "Research" should be understood loosely to signify any thing you are seriously investigating, and by no means is limited to academic research

Collaboration Interests:

\ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/forms/ResearchInterests.page b/src/java/org/thdl/roster/pages/forms/ResearchInterests.page new file mode 100755 index 0000000..69c79a0 --- /dev/null +++ b/src/java/org/thdl/roster/pages/forms/ResearchInterests.page @@ -0,0 +1,82 @@ + + + + + + + Activities and Research + + + + + + + + + + + + + + + + palette + + + + + + + palette + + + + + + + palette + + + + + + + + + + + + + + + + + + + + + + + + + + + Continue + continue + + + + + Finish + + finish + + + + + + + + diff --git a/src/java/org/thdl/roster/pages/forms/ResearchInterestsPage.java b/src/java/org/thdl/roster/pages/forms/ResearchInterestsPage.java new file mode 100755 index 0000000..3c79aeb --- /dev/null +++ b/src/java/org/thdl/roster/pages/forms/ResearchInterestsPage.java @@ -0,0 +1,308 @@ +package org.thdl.roster.pages.forms; + +import java.util.*; +import org.thdl.roster.*; +import org.thdl.roster.om.*; +import org.thdl.roster.pages.*; +import org.apache.tapestry.ApplicationRuntimeException; +import org.apache.tapestry.IRequestCycle; +import org.apache.tapestry.form.IPropertySelectionModel; +import org.apache.commons.lang.exception.NestableException; +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.util.Criteria; + +/** + * Description of the Class + * + *@author travis + *@created March 11, 2003 + */ +public class ResearchInterestsPage extends MemberFormSeries +{ + + private IPropertySelectionModel disciplineModel; + private IPropertySelectionModel culturalAreaModel; + private IPropertySelectionModel languageModel; + private IPropertySelectionModel centuries; + + + /** + * Sets the centuries attribute of the ResearchInterestsPage object + * + *@param centuries The new centuries value + */ + public void setCenturies( IPropertySelectionModel centuries ) + { + this.centuries = centuries; + } + + + /** + * Gets the centuries attribute of the ResearchInterestsPage object + * + *@return The centuries value + */ + public IPropertySelectionModel getCenturies() + { + if ( null == centuries ) + { + setCenturies( buildCenturiesModel() ); + } + return centuries; + } + + + /** + * Sets the disciplineModel attribute of the ResearchInterestsPage object + * + *@param disciplineModel The new disciplineModel value + */ + public void setDisciplineModel( IPropertySelectionModel disciplineModel ) + { + this.disciplineModel = disciplineModel; + } + + + /** + * Gets the disciplineModel attribute of the ResearchInterestsPage object + * + *@return The disciplineModel value + */ + public IPropertySelectionModel getDisciplineModel() + { + if ( disciplineModel == null ) + { + setDisciplineModel( buildDisciplineModel() ); + } + return disciplineModel; + } + + /** + * Sets the culturalAreaModel attribute of the ResearchInterestsPage object + * + *@param culturalAreaModel The new culturalAreaModel value + */ + public void setCulturalAreaModel( IPropertySelectionModel culturalAreaModel ) + { + this.culturalAreaModel = culturalAreaModel; + } + + + /** + * Gets the culturalAreaModel attribute of the ResearchInterestsPage object + * + *@return The culturalAreaModel value + */ + public IPropertySelectionModel getCulturalAreaModel() + { + if ( culturalAreaModel == null ) + { + setCulturalAreaModel( buildCulturalAreaModel() ); + } + return culturalAreaModel; + } + + /** + * Sets the languageModel attribute of the ResearchInterestsPage object + * + *@param languageModel The new languageModel value + */ + public void setLanguageModel( IPropertySelectionModel languageModel ) + { + this.languageModel = languageModel; + } + + + /** + * Gets the languageModel attribute of the ResearchInterestsPage object + * + *@return The languageModel value + */ + public IPropertySelectionModel getLanguageModel() + { + if ( languageModel == null ) + { + setLanguageModel( buildLanguageModel() ); + } + return languageModel; + } + + /** + * Description of the Method + * + *@return Description of the Return Value + */ + public IPropertySelectionModel buildDisciplineModel() + { + LinkedList list; + try + { + Criteria crit = new Criteria(); + crit.addAscendingOrderByColumn( DisciplinePeer.DISCIPLINE ); + list = new LinkedList( BaseDisciplinePeer.doSelect( crit ) ); + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( "Torque Exception says: " + te.getMessage(), te ); + } + EntitySelectionModel disciplineModel = new EntitySelectionModel(); + ListIterator looper = list.listIterator( 0 ); + while ( looper.hasNext() ) + { + Discipline discipline = (Discipline) looper.next(); + disciplineModel.add( discipline.getId(), discipline.getDiscipline() ); + } + return disciplineModel; + } + + + /** + * Description of the Method + * + *@return Description of the Return Value + */ + public IPropertySelectionModel buildCulturalAreaModel() + { + LinkedList list; + try + { + Criteria crit = new Criteria(); + crit.addAscendingOrderByColumn( CulturalAreaPeer.CULTURAL_AREA ); + list = new LinkedList( BaseCulturalAreaPeer.doSelect( crit ) ); + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( "Torque Exception says: " + te.getMessage(), te ); + } + EntitySelectionModel culturalAreaModel = new EntitySelectionModel(); + ListIterator looper = list.listIterator( 0 ); + while ( looper.hasNext() ) + { + CulturalArea culturalArea = (CulturalArea) looper.next(); + culturalAreaModel.add( culturalArea.getId(), culturalArea.getCulturalArea() ); + } + return culturalAreaModel; + } + + + /** + * Description of the Method + * + *@return Description of the Return Value + */ + public IPropertySelectionModel buildLanguageModel() + { + LinkedList list; + try + { + Criteria crit = new Criteria(); + crit.addAscendingOrderByColumn( LanguagePeer.LANGUAGE ); + list = new LinkedList( BaseLanguagePeer.doSelect( crit ) ); + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( "Torque Exception says: " + te.getMessage(), te ); + } + EntitySelectionModel languageModel = new EntitySelectionModel(); + ListIterator looper = list.listIterator( 0 ); + while ( looper.hasNext() ) + { + Language language = (Language) looper.next(); + languageModel.add( language.getId(), language.getLanguage() ); + } + return languageModel; + } + + /** + * Description of the Method + * + *@return Description of the Return Value + */ + public IPropertySelectionModel buildCenturiesModel() + { + EntitySelectionModel centuriesModel = new EntitySelectionModel(); + String centuries[] = { "","twenty-first", "twentieth", "nineteenth", "eighteenth", "seventeenth", "sixteenth", "fifteenth", "fourteenth", "thirteenth", "twelfth", "eleventh", "tenth", "ninth", "eighth", "seventh", "pre-seventh" }; + int centIntegers[] = { -1, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 0 }; + for ( int i = 0; i < centuries.length; i++ ) + { + centuriesModel.add( new Integer( centIntegers[i] ), centuries[i] ); + } + return centuriesModel; + } + + /** + * This is the form listener that saves the + * + *@param cycle Description of the Parameter + */ + public void processForm( IRequestCycle cycle ) + { + Visit visit = (Visit) getVisit(); + Member member = (Member) visit.getMember(); + try + { + List disciplineIds = member.getResearchInterest().getDisciplineIdList(); + List languageIds = member.getResearchInterest().getLanguageIdList(); + List cultAreaIds = member.getResearchInterest().getCulturalAreaIdList(); + + member.getResearchInterest().save(); + member.setResearchInterestKey( member.getResearchInterest().getPrimaryKey() ); + member.save(); + + Criteria crit; + List torqueObjects; + Integer foreignKey2; + + crit = new Criteria(); + crit.add( ResearchInterestDisciplinePeer.RESEARCH_INTEREST_ID, member.getResearchInterest().getId() ); + torqueObjects = ResearchInterestDisciplinePeer.doSelect( crit ); + foreignKey2 = member.getResearchInterest().getId(); + ResearchInterestDiscipline template = new ResearchInterestDiscipline(); + PaletteMergeTableProcessor.processPalette( disciplineIds, torqueObjects, foreignKey2, template ); + + crit = new Criteria(); + crit.add( ResearchInterestLanguagePeer.RESEARCH_INTEREST_ID, member.getResearchInterest().getId() ); + torqueObjects = ResearchInterestLanguagePeer.doSelect( crit ); + foreignKey2 = member.getResearchInterest().getId(); + ResearchInterestLanguage template2 = new ResearchInterestLanguage(); + PaletteMergeTableProcessor.processPalette( languageIds, torqueObjects, foreignKey2, template2 ); + + crit = new Criteria(); + crit.add( ResearchInterestCulturalAreaPeer.RESEARCH_INTEREST_ID, member.getResearchInterest().getId() ); + torqueObjects = ResearchInterestCulturalAreaPeer.doSelect( crit ); + foreignKey2 = member.getResearchInterest().getId(); + ResearchInterestCulturalArea template3 = new ResearchInterestCulturalArea(); + PaletteMergeTableProcessor.processPalette( cultAreaIds, torqueObjects, foreignKey2, template3 ); + } + catch (Exception e) + { + throw new ApplicationRuntimeException( e.getMessage(), e ); + } + } + + public void detach() + { + setNextPage( "Works" ); + super.detach(); + } + + /** Constructor for the ResearchInterestsPage object */ + public ResearchInterestsPage() + { + try + { + if ( !Torque.isInit() ) + { + Global global = (Global) getGlobal(); + Torque.init( global.getTorqueConfig() ); + } + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( "Torque Exception says: " + te.getMessage(), te ); + } + setNextPage( "Works" ); + } +} + diff --git a/src/java/org/thdl/roster/pages/forms/RosterValidationDelegate.java b/src/java/org/thdl/roster/pages/forms/RosterValidationDelegate.java new file mode 100755 index 0000000..e92627f --- /dev/null +++ b/src/java/org/thdl/roster/pages/forms/RosterValidationDelegate.java @@ -0,0 +1,101 @@ +package org.thdl.roster.pages.forms; + + + +import org.apache.tapestry.IMarkupWriter; + +import org.apache.tapestry.IRequestCycle; + + + +import org.apache.tapestry.form.IFormComponent; + +import org.apache.tapestry.valid.ValidationDelegate; + + + +/** + + * + + * @author Howard Lewis Ship + + * @version $Id: RosterValidationDelegate.java,v 1.1 2004/01/07 15:32:42 travismccauley Exp $ + + * @since 1.0.6 + + * + + **/ + + + +public class RosterValidationDelegate extends ValidationDelegate + +{ + + public void writeAttributes(IMarkupWriter writer, IRequestCycle cycle) + + { + + if (isInError()) + + writer.attribute("class", "field-error"); + + } + + + + public void writeSuffix(IMarkupWriter writer, IRequestCycle cycle) + + { + + if (isInError()) + + { + + writer.print(" "); + + writer.beginEmpty("img"); + + writer.attribute("src", "images/workbench/Warning-small.gif"); + + writer.attribute("height", 20); + + writer.attribute("width", 20); + + } + + } + + + + public void writeLabelPrefix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle) + + { + + if (isInError(component)) + + { + + writer.begin("span"); + + writer.attribute("class", "label-error"); + + } + + } + + + + public void writeLabelSuffix(IFormComponent component, IMarkupWriter writer, IRequestCycle cycle) + + { + + if (isInError(component)) + + writer.end(); // + + } + +} \ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/forms/SecureRosterPage.java b/src/java/org/thdl/roster/pages/forms/SecureRosterPage.java new file mode 100755 index 0000000..620ce98 --- /dev/null +++ b/src/java/org/thdl/roster/pages/forms/SecureRosterPage.java @@ -0,0 +1,42 @@ +package org.thdl.roster.pages.forms; + +import org.apache.tapestry.*; +import org.thdl.roster.*; +import org.thdl.roster.om.*; +import org.thdl.roster.pages.*; +import org.apache.torque.*; + +public abstract class SecureRosterPage extends RosterPage +{ + /* DO NOT DELETE: THIS IS A HANDY TESTING HACK TO SEE SOME OF THE OBJECTS IN VISIT + public String getMessage() + { + Visit visit = (Visit)getVisit(); + String snapshot=null; + try { + snapshot = visit.getSnapshot(); + } + catch (TorqueException te ) + { + throw new ApplicationRuntimeException( te ); + } + return snapshot; + } */ + + public void validate(IRequestCycle cycle) + { + Visit visit = (Visit) getVisit(); + if ( ! visit.isAuthenticated() ) + { + IPage page = cycle.getPage( "Login" ); + Login loginPage = (Login)page; + loginPage.setForward( getPageName() ); + throw new PageRedirectException( loginPage ); + } + super.validate( cycle ); + } + public SecureRosterPage() + { + super(); + } +} diff --git a/src/java/org/thdl/roster/pages/forms/SortModeStrings.properties b/src/java/org/thdl/roster/pages/forms/SortModeStrings.properties new file mode 100755 index 0000000..80f5b7e --- /dev/null +++ b/src/java/org/thdl/roster/pages/forms/SortModeStrings.properties @@ -0,0 +1 @@ +# $Id: SortModeStrings.properties,v 1.1 2004/01/07 15:32:42 travismccauley Exp $ NONE=None LABEL=Label VALUE=Value USER=Manual \ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/forms/Uploads.html b/src/java/org/thdl/roster/pages/forms/Uploads.html new file mode 100755 index 0000000..be0b7c4 --- /dev/null +++ b/src/java/org/thdl/roster/pages/forms/Uploads.html @@ -0,0 +1 @@ +

You can use this area to share documents such as your CV, promotional literature, application forms, or any other documents pertaining to your work. We hope this service will also encourage collaboration. One use for this space is as a venue for provisional materials or unfinished work that you think might be an arena for collaboration.

Upload a New File

Document type:

Currently accepted file types are: gif, jpeg, html, plain text, PDF files, RTF files, Word documents, Powerpoint, and zip files

Delete an Old File

\ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/forms/Uploads.java b/src/java/org/thdl/roster/pages/forms/Uploads.java new file mode 100755 index 0000000..e530d54 --- /dev/null +++ b/src/java/org/thdl/roster/pages/forms/Uploads.java @@ -0,0 +1,329 @@ +package org.thdl.roster.pages.forms; + +import java.io.*; +import java.util.*; + +import org.thdl.roster.*; +import org.thdl.roster.om.*; +import org.thdl.roster.pages.*; + +import org.apache.tapestry.*; +import org.apache.tapestry.request.IUploadFile; +import org.apache.tapestry.form.IPropertySelectionModel; + +import org.apache.commons.lang.exception.NestableException; + +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.util.Criteria; + +/** + * Description of the Class + * + *@author travis + *@created March 11, 2003 + */ +public class Uploads extends MemberFormSeries { +//attributes + private static final String[] ACCEPTED_MIME_TYPES = { "image/gif", "image/jpeg", "text/html", "text/plain", "application/pdf", "application/rtf", "application/msword", "application/vnd.ms-powerpoint", "application/zip", "application/x-zip-compressed" }; + private Document document; + private IUploadFile file; + private Integer documentType; + private IPropertySelectionModel documentTypeModel; +//accessors + public void setDocument(Document document) { + this.document = document; + } + public Document getDocument() { + return document; + } + public void setFile(IUploadFile file) { + this.file = file; + } + public IUploadFile getFile() { + return file; + } + public void setDocumentType(Integer documentType) { + this.documentType = documentType; + } + public Integer getDocumentType() { + return documentType; + } + public void setDocumentTypeModel(IPropertySelectionModel documentTypeModel) { + this.documentTypeModel = documentTypeModel; + } + public IPropertySelectionModel getDocumentTypeModel() { + if (null== documentTypeModel) + { + setDocumentTypeModel( buildDocumentTypeModel() ); + } + return documentTypeModel; + } +//helpers + public IPropertySelectionModel buildDocumentTypeModel() { + LinkedList list; + try { + Criteria crit = new Criteria(); + crit.addAscendingOrderByColumn( DocumentTypePeer.DOCUMENT_TYPE ); + list = new LinkedList(BaseDocumentTypePeer.doSelect(crit)); + } catch (TorqueException te) { + throw new ApplicationRuntimeException("Torque Exception says: " + te.getMessage(), te); + } + EntitySelectionModel documentTypeModel = new EntitySelectionModel(); + ListIterator looper = list.listIterator(0); + while ( looper.hasNext() ) { + DocumentType documentType = (DocumentType) looper.next(); + documentTypeModel.add(documentType.getId(), documentType.getDocumentType()); + } + return documentTypeModel; + } + + /** + * Description of the Method + * + *@param cycle Description of the Parameter + */ + public void processForm(IRequestCycle cycle) + { + Visit visit = (Visit) getVisit(); + Member member = (Member) visit.getMember(); + processFile( cycle, member ); + try + { + member.save(); + } + catch (Exception e) + { + throw new ApplicationRuntimeException( e ); + } + } + + public boolean mimeTypeOk() + { + boolean pass = false; + for (int index = 0; index < ACCEPTED_MIME_TYPES.length; index++) + { + if ( getFile().getContentType().equals( ACCEPTED_MIME_TYPES[ index ] ) ) + { + pass = true; + } + } + return pass; + } + + public boolean tokensValidate() + { + Visit visit = (Visit) getVisit(); + String visitToken = visit.getToken(); + String pageToken = getToken(); + + boolean validTokens = false; + if ( null != visitToken && null != pageToken && visitToken.equals( pageToken ) ) + { + validTokens = true; + } + return validTokens; + } + + public void processFile( IRequestCycle cycle, Member member ) + { + String filename = null; + int streamLength = 0; + + try + { + streamLength = getFile().getStream().available() ; + } + catch (IOException ioe ) + { + throw new ApplicationRuntimeException( ioe ); + } + + Document doc = null; + + if ( streamLength < 8 ) + { + return; + } + else if ( ! mimeTypeOk() ) + { + RosterPage page = (RosterPage)cycle.getPage( "Uploads" ); + page.setWarning( "Invalid File Type: " + getFile().getContentType() ); + page.validate( cycle ); + throw new PageRedirectException( page ); + } + else + { + StringTokenizer st = new StringTokenizer( getFile().getFileName(), "\\" ); + while ( st.hasMoreTokens() ) + { + filename = st.nextToken(); + } + + try + { + doc = new Document(); + doc.setMemberId( member.getId() ); + doc.setFilename( filename ); + doc.setContentType( getFile().getContentType() ); + doc.setPath( "/roster/uploads/" ); + doc.setDocumentTypeId( getDocumentType() ); + doc.save(); + member.addDocument( doc ); + } + catch (Exception e) + { + throw new ApplicationRuntimeException( e ); + } + } + + InputStream fis = getFile().getStream(); + FileOutputStream fos = null; + + String absolutePath = cycle.getRequestContext().getServlet().getInitParameter( "roster-uploads-directory" ); + File aFile = new File( absolutePath + filename ); + int uniqueifier = 1; + + while ( aFile.exists() ) + { + uniqueifier++; + StringTokenizer filenameTokens = new StringTokenizer( filename, ".", true ); + StringBuffer newFilename = new StringBuffer(); + while ( filenameTokens.hasMoreTokens() ) + { + String tok = filenameTokens.nextToken(); + if ( tok.equals( "." ) ) + { + newFilename.append( uniqueifier ); + } + newFilename.append( tok ); + } + aFile = new File( absolutePath + newFilename.toString() ); + doc.setFilename( newFilename.toString() ); + } + + try + { + fos = new FileOutputStream( aFile ); + } + catch (IOException ioe) + { + throw new ApplicationRuntimeException( ioe ); + } + + try + { + byte[] buffer = new byte[1024]; + while ( true ) + { + int length = fis.read( buffer ); + if (length < 0) + { + break; + } + fos.write(buffer, 0, length); + } + fis.close(); + fos.close(); + } + catch (IOException ioe) + { + throw new ApplicationRuntimeException( ioe ); + } + finally + { + if (fis != null) + { + try + { + fis.close(); + } + catch (IOException ioe) + { + throw new ApplicationRuntimeException( ioe ); + } + } + if (fos != null) + { + try + { + fos.close(); + } + catch (IOException ioe) + { + throw new ApplicationRuntimeException( ioe ); + } + } + } + } + + public void deleteFile( IRequestCycle cycle ) + { + Integer docId = (Integer) cycle.getServiceParameters()[0]; + Document doc = null; + try + { + doc = DocumentPeer.retrieveByPK( docId ); + } + catch (TorqueException te ) + { + throw new ApplicationRuntimeException( te.getMessage(), te ); + } + + + File file = null; + String warning = null; + String message = null; + if (null != doc) + { + String absolutePath = cycle.getRequestContext().getServlet().getInitParameter( "roster-uploads-directory" ); + file = new File( absolutePath + doc.getFilename() ); + file.delete(); + message = "Your document, " + doc.getFilename() + ", was deleted."; + try + { + DocumentPeer.doDelete( doc ); + } + catch (TorqueException te ) + { + throw new ApplicationRuntimeException( te.getMessage(), te ); + } + } + + try + { + Visit visit = (Visit) getVisit(); + Member member = (Member)visit.getMember(); + member.getDocuments( new Criteria() ); + } + catch (Exception te ) + { + throw new ApplicationRuntimeException( te.getMessage(), te ); + } + } + + + public void detach() + { + setNextPage( "Home" ); + super.detach(); + } + + public Uploads() + { + try + { + if ( !Torque.isInit() ) + { + Global global = (Global) getGlobal(); + Torque.init( global.getTorqueConfig() ); + } + } + catch ( TorqueException te ) + { + throw new ApplicationRuntimeException( "Torque Exception says: " + te.getMessage(), te ); + } + setNextPage( "Home" ); + } +} + diff --git a/src/java/org/thdl/roster/pages/forms/Uploads.page b/src/java/org/thdl/roster/pages/forms/Uploads.page new file mode 100755 index 0000000..2398be1 --- /dev/null +++ b/src/java/org/thdl/roster/pages/forms/Uploads.page @@ -0,0 +1,83 @@ + + + + + + + Uploads + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + continue + display: none; + + + + + Upload + + moreUploads + + + + + Finish + + finish + + + + + + li + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/pages/test/Test.html b/src/java/org/thdl/roster/pages/test/Test.html new file mode 100755 index 0000000..ed0aed1 --- /dev/null +++ b/src/java/org/thdl/roster/pages/test/Test.html @@ -0,0 +1 @@ +

click to test validate and redirect method in testPage2

reset member and view in page2

Here is theSelected's address: ''


\ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/test/Test.page b/src/java/org/thdl/roster/pages/test/Test.page new file mode 100755 index 0000000..9d3cdb9 --- /dev/null +++ b/src/java/org/thdl/roster/pages/test/Test.page @@ -0,0 +1,61 @@ + + + + + + + Test Page + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java/org/thdl/roster/pages/test/Test2.html b/src/java/org/thdl/roster/pages/test/Test2.html new file mode 100755 index 0000000..8fba212 --- /dev/null +++ b/src/java/org/thdl/roster/pages/test/Test2.html @@ -0,0 +1 @@ +

Member: ''

\ No newline at end of file diff --git a/src/java/org/thdl/roster/pages/test/Test2.page b/src/java/org/thdl/roster/pages/test/Test2.page new file mode 100755 index 0000000..0dfe978 --- /dev/null +++ b/src/java/org/thdl/roster/pages/test/Test2.page @@ -0,0 +1,12 @@ + + + + + + + + + + diff --git a/src/java/org/thdl/roster/pages/test/TestPage.java b/src/java/org/thdl/roster/pages/test/TestPage.java new file mode 100755 index 0000000..a152f20 --- /dev/null +++ b/src/java/org/thdl/roster/pages/test/TestPage.java @@ -0,0 +1,114 @@ +package org.thdl.roster.pages.test; + +import org.thdl.roster.*; +import org.thdl.roster.om.*; +import org.thdl.roster.pages.*; +import org.thdl.roster.pages.test.*; +import org.apache.tapestry.*; +import org.apache.tapestry.html.*; +import java.util.*; +import org.apache.tapestry.request.IUploadFile; + +public class TestPage extends org.thdl.roster.pages.RosterPage //org.apache.tapestry.html.BasePage +{ + private static final String[] ACCEPTED_MIME_TYPES = { "image/gif", "image/jpeg", "text/html", "text/plain", "application/pdf", "application/rtf", "application/msword", "application/vnd.ms-powerpoint", "application/zip", "application/x-zip-compressed" }; + + private List theSelected; + private List theSelected2; + private List theSelected3; + + private IUploadFile theFile; + private String token; + private String[] tokens; +public void setTokens(String[] tokens) { + this.tokens = tokens; +} +public String[] getTokens() { + return tokens; +} +public void setTheFile(IUploadFile theFile) { + this.theFile = theFile; +} +public void setToken(String token) { + this.token = token; +} +public IUploadFile getTheFile() { + return theFile; +} +public String getToken() { + return token; +} + + +public void processFile(IRequestCycle cycle) +{ + StringTokenizer toks = new StringTokenizer( getTheFile().getFileName(), "\\" ); + String[] sa = new String[ toks.countTokens() ]; + int i=0; + int count = toks.countTokens(); + while (toks.hasMoreTokens()) + { + sa[ i ]= i +" " +toks.nextToken(); + if ( i == count-1 ) setMessage( "Filename: " + sa[ i ] ); + i++; + } + setTokens( sa ); + setWarning( "mime type: " + getTheFile().getContentType() ); +} + + + public void setTheSelected(List theSelected) { + if (null == theSelected) throw new ApplicationRuntimeException( "null theSelected" ); + this.theSelected = theSelected; + } + public List getTheSelected() { + return theSelected; + } + public void setTheSelected3(List theSelected3) { + this.theSelected3 = theSelected3; + } + public void setTheSelected2(List theSelected2) { + this.theSelected2 = theSelected2; + } + public List getTheSelected3() { + return theSelected3; + } + public List getTheSelected2() { + return theSelected2; + } + + public void processForm( IRequestCycle cycle ) + { + getEngine().setVisit( null ); + + Visit visit = (Visit)getVisit(); + String s = "Sponge Bob"; + visit.setTest( s ); + cycle.activate( "Test2" ); + } + public void testValidate( IRequestCycle cycle ) + { + RosterPage page = (RosterPage)cycle.getPage( "Test2" ); + page.validate( cycle ); + cycle.activate( page ); + } + + public EntitySelectionModel getTestModel() + { + EntitySelectionModel model = new EntitySelectionModel(); + model.add( new Integer( 1 ), "1 Little Indian" ); + model.add( new Integer( 2 ), "2 Little Indians" ); + model.add( new Integer( 3 ), "3 Little Indians" ); + model.add( new Integer( 4 ), "4 Little Indians" ); + return model; + } + public void processPalette( IRequestCycle cycle ) + { + cycle.activate( "Admin" ); + } + + public TestPage() + { + super(); + } +} diff --git a/src/java/org/thdl/roster/pages/test/TestPage2.java b/src/java/org/thdl/roster/pages/test/TestPage2.java new file mode 100755 index 0000000..bfe8f2c --- /dev/null +++ b/src/java/org/thdl/roster/pages/test/TestPage2.java @@ -0,0 +1,71 @@ +package org.thdl.roster.pages.test; + +import org.thdl.roster.*; +import org.thdl.roster.om.*; +import org.thdl.roster.pages.*; +import org.thdl.roster.pages.test.*; +import org.apache.tapestry.*; +import org.apache.tapestry.html.*; +import java.util.List; + +public class TestPage2 extends org.thdl.roster.pages.RosterPage //org.apache.tapestry.html.BasePage +{ + private List theSelected; + private List theSelected2; + private List theSelected3; + + public void setTheSelected(List theSelected) { + if (null == theSelected) throw new ApplicationRuntimeException( "null theSelected" ); + this.theSelected = theSelected; + } + public List getTheSelected() { + return theSelected; + } + public void setTheSelected3(List theSelected3) { + this.theSelected3 = theSelected3; + } + public void setTheSelected2(List theSelected2) { + this.theSelected2 = theSelected2; + } + public List getTheSelected3() { + return theSelected3; + } + public List getTheSelected2() { + return theSelected2; + } + + public void validate(IRequestCycle cycle) + { + RosterPage home = (RosterPage) cycle.getPage( "Home" ); + home.setWarning( "There was no Roster Member in your session. This is possibly due to navigating to an edit screen after your session had timed out." ); + throw new PageRedirectException( home ); + } + public void processForm( IRequestCycle cycle ) + { + getEngine().setVisit( null ); + + Visit visit = (Visit)getVisit(); + String s = "Sponge Bob"; + visit.setTest( s ); + cycle.activate( "Test2" ); + } + + public EntitySelectionModel getTestModel() + { + EntitySelectionModel model = new EntitySelectionModel(); + model.add( new Integer( 1 ), "1 Little Indian" ); + model.add( new Integer( 2 ), "2 Little Indians" ); + model.add( new Integer( 3 ), "3 Little Indians" ); + model.add( new Integer( 4 ), "4 Little Indians" ); + return model; + } + public void processPalette( IRequestCycle cycle ) + { + cycle.activate( "Admin" ); + } + + public TestPage2() + { + super(); + } +} diff --git a/src/java/org/thdl/roster/velocity.log b/src/java/org/thdl/roster/velocity.log new file mode 100755 index 0000000..46d2dff --- /dev/null +++ b/src/java/org/thdl/roster/velocity.log @@ -0,0 +1,236 @@ +2003-02-27 15:11:04,008 - SimpleLog4JLogSystem initialized using logfile 'velocity.log' +2003-02-27 15:11:04,011 - ************************************************************** +2003-02-27 15:11:04,011 - Starting Jakarta Velocity v1.3 +2003-02-27 15:11:04,012 - RuntimeInstance initializing. +2003-02-27 15:11:04,012 - Default Properties File: org/apache/velocity/runtime/defaults/velocity.properties +2003-02-27 15:11:04,012 - Trying to use logger class org.apache.velocity.runtime.log.AvalonLogSystem +2003-02-27 15:11:04,015 - Couldn't find class org.apache.velocity.runtime.log.AvalonLogSystem or necessary supporting classes in classpath. Exception : java.lang.NoClassDefFoundError: org/apache/log/format/Formatter +2003-02-27 15:11:04,015 - Trying to use logger class org.apache.velocity.runtime.log.SimpleLog4JLogSystem +2003-02-27 15:11:04,015 - Using logger class org.apache.velocity.runtime.log.SimpleLog4JLogSystem +2003-02-27 15:11:04,036 - Default ResourceManager initializing. (class org.apache.velocity.runtime.resource.ResourceManagerImpl) +2003-02-27 15:11:04,059 - Resource Loader Instantiated: org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:04,060 - FileResourceLoader : initialization starting. +2003-02-27 15:11:04,061 - FileResourceLoader : adding path '/Users/travis/torque-3.0/templates' +2003-02-27 15:11:04,062 - FileResourceLoader : initialization complete. +2003-02-27 15:11:04,073 - ResourceCache : initialized. (class org.apache.velocity.runtime.resource.ResourceCacheImpl) +2003-02-27 15:11:04,078 - Default ResourceManager initialization complete. +2003-02-27 15:11:04,089 - Loaded System Directive: org.apache.velocity.runtime.directive.Literal +2003-02-27 15:11:04,098 - Loaded System Directive: org.apache.velocity.runtime.directive.Macro +2003-02-27 15:11:04,109 - Loaded System Directive: org.apache.velocity.runtime.directive.Parse +2003-02-27 15:11:04,123 - Loaded System Directive: org.apache.velocity.runtime.directive.Include +2003-02-27 15:11:04,134 - Loaded System Directive: org.apache.velocity.runtime.directive.Foreach +2003-02-27 15:11:04,799 - Created: 20 parsers. +2003-02-27 15:11:04,800 - Velocimacro : initialization starting. +2003-02-27 15:11:04,800 - Velocimacro : adding VMs from VM library template : VM_global_library.vm +2003-02-27 15:11:04,814 - ResourceManager : unable to find resource 'VM_global_library.vm' in any resource loader. +2003-02-27 15:11:04,814 - Velocimacro : error using VM library template VM_global_library.vm : org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'VM_global_library.vm' +2003-02-27 15:11:04,815 - Velocimacro : VM library template macro registration complete. +2003-02-27 15:11:04,815 - Velocimacro : allowInline = true : VMs can be defined inline in templates +2003-02-27 15:11:04,816 - Velocimacro : allowInlineToOverride = false : VMs defined inline may NOT replace previous VM definitions +2003-02-27 15:11:04,816 - Velocimacro : allowInlineLocal = false : VMs defined inline will be global in scope if allowed. +2003-02-27 15:11:04,816 - Velocimacro : messages on : VM system will output logging messages +2003-02-27 15:11:04,817 - Velocimacro : autoload off : VM system will not automatically reload global library macros +2003-02-27 15:11:04,817 - Velocimacro : initialization complete. +2003-02-27 15:11:04,818 - Velocity successfully started. +2003-02-27 15:11:06,045 - ResourceManager : found om/Control.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:06,982 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:07,353 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:07,356 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:07,827 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:07,943 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:07,950 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:07,961 - ResourceManager : found om/MultiExtendObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:07,970 - ResourceManager : found om/MultiExtendObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:07,979 - ResourceManager : found om/MultiExtendObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:08,268 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:08,331 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:08,333 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:09,076 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:09,186 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:09,193 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:09,414 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:09,468 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:09,484 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:09,841 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:09,920 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:09,928 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:10,463 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:10,511 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:10,513 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:10,811 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:10,917 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:10,924 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:11,108 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:11,174 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:11,176 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:11,472 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:11,522 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:11,531 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:12,080 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:12,144 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:12,146 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:12,411 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:12,453 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:12,459 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:12,659 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:12,694 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:12,696 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:12,958 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:13,373 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:13,379 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:13,548 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:13,583 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:13,585 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:13,845 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:13,921 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:13,928 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:14,105 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:14,161 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:14,163 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:14,432 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:14,821 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:14,827 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:14,997 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:15,035 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:15,037 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:15,300 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:15,393 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:15,399 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:15,744 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:15,776 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:15,778 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:16,036 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:16,062 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:16,067 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:16,253 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:16,305 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:16,307 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:16,907 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:16,937 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:16,943 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:17,124 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:17,191 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:17,193 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:17,462 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:17,487 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:17,493 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:17,669 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:17,702 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:17,705 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:18,353 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:18,379 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:18,385 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:18,590 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:18,624 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:18,626 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:18,890 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:18,917 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:18,924 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:19,105 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:19,159 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:19,161 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:19,816 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:19,847 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:19,852 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:20,024 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:20,057 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:20,059 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:20,322 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:20,348 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:20,354 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:20,544 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:20,576 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:20,579 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:20,848 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:20,873 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:20,879 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:21,398 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:21,441 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:21,443 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:21,728 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:21,753 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:21,780 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:21,937 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:22,001 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:22,004 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:22,250 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:22,296 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:22,302 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:22,485 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:22,526 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:22,528 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:23,157 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:23,182 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:23,187 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:23,356 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:23,398 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:23,400 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:23,655 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:23,680 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:23,686 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:23,865 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:23,906 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:23,908 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:24,165 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:24,202 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:24,207 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:24,386 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:24,427 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:24,429 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:24,997 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:25,044 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:25,051 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:25,209 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:25,273 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:25,275 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:25,543 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:25,568 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:25,574 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:25,758 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:25,799 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:25,801 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:26,060 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:26,085 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:26,091 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:26,577 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:26,618 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:26,620 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:26,925 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:26,956 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:26,961 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:27,141 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:27,185 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:27,187 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:27,445 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:27,473 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:27,500 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:27,655 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:27,718 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:27,720 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:28,330 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:28,373 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:28,379 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:28,555 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:28,595 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:28,597 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:28,854 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:28,880 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:28,885 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:29,061 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:29,101 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:29,103 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:29,378 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:29,403 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:29,409 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:29,920 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:29,965 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:29,967 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:30,223 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:30,256 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:30,263 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:30,439 - ResourceManager : found om/Peer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:30,480 - ResourceManager : found om/MapBuilder.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:30,482 - Error in evaluation of == expression. Both arguments must be of the same Class. Currently left = class java.lang.Boolean, right = class java.lang.String. om/MapBuilder.vm [line 28, column 28] (ASTEQNode) +2003-02-27 15:11:30,950 - ResourceManager : found om/Object.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:31,009 - ResourceManager : found om/ExtensionObject.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader +2003-02-27 15:11:31,016 - ResourceManager : found om/ExtensionPeer.vm with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader diff --git a/src/java/report.roster-repository.om.generation b/src/java/report.roster-repository.om.generation new file mode 100755 index 0000000..2a3af22 --- /dev/null +++ b/src/java/report.roster-repository.om.generation @@ -0,0 +1,327 @@ + + + + + org.thdl.roster.om + org.thdl.roster.om + org.thdl.roster.om.map + + Failed to create dir or dir already exists: /Users/travis/webapps/roster/src/java/org/thdl/roster/om/ + + Failed to create dir or dir already exists: /Users/travis/webapps/roster/src/java/org/thdl/roster/om/map/ + + Failed to create dir or dir already exists: /Users/travis/webapps/roster/src/java/org/thdl/roster/om/ + + Member + + + + + + + + + + + + + PersonData + + + + + + + + + + + + + ProjectData + + + + + + + + + + + + + OrganizationData + + + + + + + + + + + + + ContactInfo + + + + + + + + + + + + + Address + + + + + + + + + + + + + Phone + + + + + + + + + + + + + Publication + + + + + + + + + + + + + ResearchInterest + + + + + + + + + + + + + Document + + + + + + + + + + + + + Country + + + + + + + + + + + + + CulturalArea + + + + + + + + + + + + + Language + + + + + + + + + + + + + Discipline + + + + + + + + + + + + + DocumentType + + + + + + + + + + + + + ProjectType + + + + + + + + + + + + + OrganizationType + + + + + + + + + + + + + PersonType + + + + + + + + + + + + + PersonPersonType + + + + + + + + + + + + + OrganizationOrganizationType + + + + + + + + + + + + + ProjectProjectType + + + + + + + + + + + + + ResearchInterestLanguage + + + + + + + + + + + + + ResearchInterestCulturalArea + + + + + + + + + + + + + ResearchInterestDiscipline + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/sql/.DS_Store b/src/sql/.DS_Store new file mode 100755 index 0000000..5008ddf Binary files /dev/null and b/src/sql/.DS_Store differ diff --git a/src/sql/countries.sql b/src/sql/countries.sql new file mode 100755 index 0000000..93c9d62 --- /dev/null +++ b/src/sql/countries.sql @@ -0,0 +1,263 @@ + Database Roster - table Country running on localhost + +# phpMyAdmin MySQL-Dump +# version 2.3.2 +# http://www.phpmyadmin.net/ (download page) +# +# Host: localhost +# Generation Time: Mar 04, 2003 at 05:15 PM +# Server version: 3.23.52 +# PHP Version: 4.2.3 +# Database : `Roster` + +# +# Dumping data for table `Country` +# + +INSERT INTO Country VALUES (1, 'USA'); +INSERT INTO Country VALUES (2, 'Albania'); +INSERT INTO Country VALUES (3, 'Algeria'); +INSERT INTO Country VALUES (4, 'American Samoa'); +INSERT INTO Country VALUES (5, 'Andorra'); +INSERT INTO Country VALUES (6, 'Angola'); +INSERT INTO Country VALUES (7, 'Anguilla'); +INSERT INTO Country VALUES (8, 'Antarctica'); +INSERT INTO Country VALUES (9, 'Antigua And Barbuda'); +INSERT INTO Country VALUES (10, 'Argentina'); +INSERT INTO Country VALUES (11, 'Armenia'); +INSERT INTO Country VALUES (12, 'Aruba'); +INSERT INTO Country VALUES (13, 'Australia'); +INSERT INTO Country VALUES (14, 'Austria'); +INSERT INTO Country VALUES (15, 'Azerbaijan'); +INSERT INTO Country VALUES (16, 'Bahamas'); +INSERT INTO Country VALUES (17, 'Bahrain'); +INSERT INTO Country VALUES (18, 'Bangladesh'); +INSERT INTO Country VALUES (19, 'Barbados'); +INSERT INTO Country VALUES (20, 'Belarus'); +INSERT INTO Country VALUES (21, 'Belgium'); +INSERT INTO Country VALUES (22, 'Belize'); +INSERT INTO Country VALUES (23, 'Benin'); +INSERT INTO Country VALUES (24, 'Bermuda'); +INSERT INTO Country VALUES (25, 'Bhutan'); +INSERT INTO Country VALUES (26, 'Bolivia'); +INSERT INTO Country VALUES (27, 'Bosnia and Herzegovina'); +INSERT INTO Country VALUES (28, 'Botswana'); +INSERT INTO Country VALUES (29, 'Bouvet Island'); +INSERT INTO Country VALUES (30, 'Brazil'); +INSERT INTO Country VALUES (31, 'British Indian Ocean Territory'); +INSERT INTO Country VALUES (32, 'Brunei Darussalam'); +INSERT INTO Country VALUES (33, 'Bulgaria'); +INSERT INTO Country VALUES (34, 'Burkina Faso'); +INSERT INTO Country VALUES (35, 'Burma'); +INSERT INTO Country VALUES (36, 'Burundi'); +INSERT INTO Country VALUES (37, 'Cambodia'); +INSERT INTO Country VALUES (38, 'Cameroon'); +INSERT INTO Country VALUES (39, 'Canada'); +INSERT INTO Country VALUES (40, 'Cape Verde'); +INSERT INTO Country VALUES (41, 'Cayman Islands'); +INSERT INTO Country VALUES (42, 'Central African Republic'); +INSERT INTO Country VALUES (43, 'Chad'); +INSERT INTO Country VALUES (44, 'Chile'); +INSERT INTO Country VALUES (45, 'China'); +INSERT INTO Country VALUES (46, 'Christmas Island'); +INSERT INTO Country VALUES (47, 'Cocos (Keeling) Islands'); +INSERT INTO Country VALUES (48, 'Colombia'); +INSERT INTO Country VALUES (49, 'Comoros'); +INSERT INTO Country VALUES (50, 'Congo'); +INSERT INTO Country VALUES (51, 'Congo, the Democratic Republic of the'); +INSERT INTO Country VALUES (52, 'Cook Islands'); +INSERT INTO Country VALUES (53, 'Costa Rica'); +INSERT INTO Country VALUES (54, 'Cote d\'Ivoire'); +INSERT INTO Country VALUES (55, 'Croatia'); +INSERT INTO Country VALUES (56, 'Cyprus'); +INSERT INTO Country VALUES (57, 'Czech Republic'); +INSERT INTO Country VALUES (58, 'Denmark'); +INSERT INTO Country VALUES (59, 'Djibouti'); +INSERT INTO Country VALUES (60, 'Dominica'); +INSERT INTO Country VALUES (61, 'Dominican Republic'); +INSERT INTO Country VALUES (62, 'East Timor'); +INSERT INTO Country VALUES (63, 'Ecuador'); +INSERT INTO Country VALUES (64, 'Egypt'); +INSERT INTO Country VALUES (65, 'El Salvador'); +INSERT INTO Country VALUES (66, 'England'); +INSERT INTO Country VALUES (67, 'Equatorial Guinea'); +INSERT INTO Country VALUES (68, 'Eritrea'); +INSERT INTO Country VALUES (69, 'Espana'); +INSERT INTO Country VALUES (70, 'Estonia'); +INSERT INTO Country VALUES (71, 'Ethiopia'); +INSERT INTO Country VALUES (72, 'Falkland Islands'); +INSERT INTO Country VALUES (73, 'Faroe Islands'); +INSERT INTO Country VALUES (74, 'Fiji'); +INSERT INTO Country VALUES (75, 'Finland'); +INSERT INTO Country VALUES (76, 'France'); +INSERT INTO Country VALUES (77, 'French Guiana'); +INSERT INTO Country VALUES (78, 'French Polynesia'); +INSERT INTO Country VALUES (79, 'French Southern Territories'); +INSERT INTO Country VALUES (80, 'Gabon'); +INSERT INTO Country VALUES (81, 'Gambia'); +INSERT INTO Country VALUES (82, 'Georgia'); +INSERT INTO Country VALUES (83, 'Germany'); +INSERT INTO Country VALUES (84, 'Ghana'); +INSERT INTO Country VALUES (85, 'Gibraltar'); +INSERT INTO Country VALUES (86, 'Great Britain'); +INSERT INTO Country VALUES (87, 'Greece'); +INSERT INTO Country VALUES (88, 'Greenland'); +INSERT INTO Country VALUES (89, 'Grenada'); +INSERT INTO Country VALUES (90, 'Guadeloupe'); +INSERT INTO Country VALUES (91, 'Guam'); +INSERT INTO Country VALUES (92, 'Guatemala'); +INSERT INTO Country VALUES (93, 'Guinea'); +INSERT INTO Country VALUES (94, 'Guinea-Bissau'); +INSERT INTO Country VALUES (95, 'Guyana'); +INSERT INTO Country VALUES (96, 'Haiti'); +INSERT INTO Country VALUES (97, 'Heard and Mc Donald Islands'); +INSERT INTO Country VALUES (98, 'Honduras'); +INSERT INTO Country VALUES (99, 'Hong Kong'); +INSERT INTO Country VALUES (100, 'Hungary'); +INSERT INTO Country VALUES (101, 'Iceland'); +INSERT INTO Country VALUES (102, 'India'); +INSERT INTO Country VALUES (103, 'Indonesia'); +INSERT INTO Country VALUES (104, 'Ireland'); +INSERT INTO Country VALUES (105, 'Israel'); +INSERT INTO Country VALUES (106, 'Italy'); +INSERT INTO Country VALUES (107, 'Jamaica'); +INSERT INTO Country VALUES (108, 'Japan'); +INSERT INTO Country VALUES (109, 'Jordan'); +INSERT INTO Country VALUES (110, 'Kazakhstan'); +INSERT INTO Country VALUES (111, 'Kenya'); +INSERT INTO Country VALUES (112, 'Kiribati'); +INSERT INTO Country VALUES (113, 'Korea (North)'); +INSERT INTO Country VALUES (114, 'Korea, Republic of'); +INSERT INTO Country VALUES (115, 'Korea (South)'); +INSERT INTO Country VALUES (116, 'Kuwait'); +INSERT INTO Country VALUES (117, 'Kyrgyzstan'); +INSERT INTO Country VALUES (118, 'Lao People\'s Democratic Republic'); +INSERT INTO Country VALUES (119, 'Latvia'); +INSERT INTO Country VALUES (120, 'Lebanon'); +INSERT INTO Country VALUES (121, 'Lesotho'); +INSERT INTO Country VALUES (122, 'Liberia'); +INSERT INTO Country VALUES (123, 'Liechtenstein'); +INSERT INTO Country VALUES (124, 'Lithuania'); +INSERT INTO Country VALUES (125, 'Luxembourg'); +INSERT INTO Country VALUES (126, 'Macau'); +INSERT INTO Country VALUES (127, 'Macedonia'); +INSERT INTO Country VALUES (128, 'Madagascar'); +INSERT INTO Country VALUES (129, 'Malawi'); +INSERT INTO Country VALUES (130, 'Malaysia'); +INSERT INTO Country VALUES (131, 'Maldives'); +INSERT INTO Country VALUES (132, 'Mali'); +INSERT INTO Country VALUES (133, 'Malta'); +INSERT INTO Country VALUES (134, 'Marshall Islands'); +INSERT INTO Country VALUES (135, 'Martinique'); +INSERT INTO Country VALUES (136, 'Mauritania'); +INSERT INTO Country VALUES (137, 'Mauritius'); +INSERT INTO Country VALUES (138, 'Mayotte'); +INSERT INTO Country VALUES (139, 'Mexico'); +INSERT INTO Country VALUES (140, 'Micronesia, Federated States of'); +INSERT INTO Country VALUES (141, 'Moldova, Republic of'); +INSERT INTO Country VALUES (142, 'Monaco'); +INSERT INTO Country VALUES (143, 'Mongolia'); +INSERT INTO Country VALUES (144, 'Montserrat'); +INSERT INTO Country VALUES (145, 'Morocco'); +INSERT INTO Country VALUES (146, 'Mozambique'); +INSERT INTO Country VALUES (147, 'Myanmar'); +INSERT INTO Country VALUES (148, 'Namibia'); +INSERT INTO Country VALUES (149, 'Nauru'); +INSERT INTO Country VALUES (150, 'Nepal'); +INSERT INTO Country VALUES (151, 'Netherlands'); +INSERT INTO Country VALUES (152, 'Netherlands Antilles'); +INSERT INTO Country VALUES (153, 'New Caledonia'); +INSERT INTO Country VALUES (154, 'New Zealand'); +INSERT INTO Country VALUES (155, 'Nicaragua'); +INSERT INTO Country VALUES (156, 'Niger'); +INSERT INTO Country VALUES (157, 'Nigeria'); +INSERT INTO Country VALUES (158, 'Niue'); +INSERT INTO Country VALUES (159, 'Norfolk Island'); +INSERT INTO Country VALUES (160, 'Northern Ireland'); +INSERT INTO Country VALUES (161, 'Northern Mariana Islands'); +INSERT INTO Country VALUES (162, 'Norway'); +INSERT INTO Country VALUES (163, 'Oman'); +INSERT INTO Country VALUES (164, 'Pakistan'); +INSERT INTO Country VALUES (165, 'Palau'); +INSERT INTO Country VALUES (166, 'Panama'); +INSERT INTO Country VALUES (167, 'Papua New Guinea'); +INSERT INTO Country VALUES (168, 'Paraguay'); +INSERT INTO Country VALUES (169, 'Peru'); +INSERT INTO Country VALUES (170, 'Philippines'); +INSERT INTO Country VALUES (171, 'Pitcairn'); +INSERT INTO Country VALUES (172, 'Poland'); +INSERT INTO Country VALUES (173, 'Portugal'); +INSERT INTO Country VALUES (174, 'Puerto Rico'); +INSERT INTO Country VALUES (175, 'Qatar'); +INSERT INTO Country VALUES (176, 'Reunion'); +INSERT INTO Country VALUES (177, 'Romania'); +INSERT INTO Country VALUES (178, 'Russia'); +INSERT INTO Country VALUES (179, 'Russian Federation'); +INSERT INTO Country VALUES (180, 'Rwanda'); +INSERT INTO Country VALUES (181, 'Saint Kitts and Nevis'); +INSERT INTO Country VALUES (182, 'Saint Lucia'); +INSERT INTO Country VALUES (183, 'Saint Vincent and the Grenadines'); +INSERT INTO Country VALUES (184, 'Samoa (Independent)'); +INSERT INTO Country VALUES (185, 'San Marino'); +INSERT INTO Country VALUES (186, 'Sao Tome and Principe'); +INSERT INTO Country VALUES (187, 'Saudi Arabia'); +INSERT INTO Country VALUES (188, 'Scotland'); +INSERT INTO Country VALUES (189, 'Senegal'); +INSERT INTO Country VALUES (190, 'Seychelles'); +INSERT INTO Country VALUES (191, 'Sierra Leone'); +INSERT INTO Country VALUES (192, 'Singapore'); +INSERT INTO Country VALUES (193, 'Slovakia'); +INSERT INTO Country VALUES (194, 'Slovenia'); +INSERT INTO Country VALUES (195, 'Solomon Islands'); +INSERT INTO Country VALUES (196, 'Somalia'); +INSERT INTO Country VALUES (197, 'South Africa'); +INSERT INTO Country VALUES (198, 'South Georgia and the South Sandwich Islands'); +INSERT INTO Country VALUES (199, 'South Korea'); +INSERT INTO Country VALUES (200, 'Spain'); +INSERT INTO Country VALUES (201, 'Sri Lanka'); +INSERT INTO Country VALUES (202, 'St. Helena'); +INSERT INTO Country VALUES (203, 'St. Pierre and Miquelon'); +INSERT INTO Country VALUES (204, 'Suriname'); +INSERT INTO Country VALUES (205, 'Svalbard and Jan Mayen Islands'); +INSERT INTO Country VALUES (206, 'Swaziland'); +INSERT INTO Country VALUES (207, 'Sweden'); +INSERT INTO Country VALUES (208, 'Switzerland'); +INSERT INTO Country VALUES (209, 'Taiwan'); +INSERT INTO Country VALUES (210, 'Tajikistan'); +INSERT INTO Country VALUES (211, 'Tanzania'); +INSERT INTO Country VALUES (212, 'Thailand'); +INSERT INTO Country VALUES (213, 'Togo'); +INSERT INTO Country VALUES (214, 'Tokelau'); +INSERT INTO Country VALUES (215, 'Tonga'); +INSERT INTO Country VALUES (216, 'Trinidad'); +INSERT INTO Country VALUES (217, 'Trinidad and Tobago'); +INSERT INTO Country VALUES (218, 'Tunisia'); +INSERT INTO Country VALUES (219, 'Turkey'); +INSERT INTO Country VALUES (220, 'Turkmenistan'); +INSERT INTO Country VALUES (221, 'Turks and Caicos Islands'); +INSERT INTO Country VALUES (222, 'Tuvalu'); +INSERT INTO Country VALUES (223, 'Uganda'); +INSERT INTO Country VALUES (224, 'Ukraine'); +INSERT INTO Country VALUES (225, 'United Arab Emirates'); +INSERT INTO Country VALUES (226, 'United Kingdom'); +INSERT INTO Country VALUES (227, 'United States'); +INSERT INTO Country VALUES (228, 'United States Minor Outlying Islands'); +INSERT INTO Country VALUES (229, 'Uruguay'); +INSERT INTO Country VALUES (230, 'USA'); +INSERT INTO Country VALUES (231, 'Uzbekistan'); +INSERT INTO Country VALUES (232, 'Vanuatu'); +INSERT INTO Country VALUES (233, 'Vatican City State (Holy See)'); +INSERT INTO Country VALUES (234, 'Venezuela'); +INSERT INTO Country VALUES (235, 'Viet Nam'); +INSERT INTO Country VALUES (236, 'Virgin Islands (British)'); +INSERT INTO Country VALUES (237, 'Virgin Islands (U.S.)'); +INSERT INTO Country VALUES (238, 'Wales'); +INSERT INTO Country VALUES (239, 'Wallis and Futuna Islands'); +INSERT INTO Country VALUES (240, 'Western Sahara'); +INSERT INTO Country VALUES (241, 'Yemen'); +INSERT INTO Country VALUES (242, 'Zambia'); +INSERT INTO Country VALUES (243, 'Zimbabwe'); + + + + diff --git a/src/sql/create-db.sql b/src/sql/create-db.sql new file mode 100755 index 0000000..f0a9473 --- /dev/null +++ b/src/sql/create-db.sql @@ -0,0 +1,3 @@ +drop database if exists Roster; +create database Roster; + diff --git a/src/sql/id-table-schema.sql b/src/sql/id-table-schema.sql new file mode 100755 index 0000000..02f0c89 --- /dev/null +++ b/src/sql/id-table-schema.sql @@ -0,0 +1,16 @@ + +# ----------------------------------------------------------------------- +# ID_TABLE +# ----------------------------------------------------------------------- +drop table if exists ID_TABLE; + +CREATE TABLE ID_TABLE +( + ID_TABLE_ID INTEGER NOT NULL, + TABLE_NAME VARCHAR (255) NOT NULL, + NEXT_ID INTEGER, + QUANTITY INTEGER, + PRIMARY KEY(ID_TABLE_ID), + UNIQUE (TABLE_NAME) +); + diff --git a/src/sql/report.idtable-init.sql.generation b/src/sql/report.idtable-init.sql.generation new file mode 100755 index 0000000..8b13789 --- /dev/null +++ b/src/sql/report.idtable-init.sql.generation @@ -0,0 +1 @@ + diff --git a/src/sql/report.roster-repository.sql.generation b/src/sql/report.roster-repository.sql.generation new file mode 100755 index 0000000..8974c3f --- /dev/null +++ b/src/sql/report.roster-repository.sql.generation @@ -0,0 +1,65 @@ + + + + File to be created: id-table-schema.sql + + Primary Key: Yes + + + + + + + File to be created: roster-schema.sql + + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + Primary Key: Yes + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/sql/roster-schema-idtable-init.sql b/src/sql/roster-schema-idtable-init.sql new file mode 100755 index 0000000..8e48ebb --- /dev/null +++ b/src/sql/roster-schema-idtable-init.sql @@ -0,0 +1,24 @@ +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (101, 'Member', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (102, 'PersonData', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (103, 'ProjectData', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (104, 'OrganizationData', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (105, 'ContactInfo', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (106, 'Address', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (107, 'Phone', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (108, 'Publication', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (109, 'ResearchInterest', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (110, 'Document', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (111, 'Country', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (112, 'CulturalArea', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (113, 'Language', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (114, 'Discipline', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (115, 'DocumentType', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (116, 'ProjectType', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (117, 'OrganizationType', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (118, 'PersonType', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (119, 'PersonPersonType', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (120, 'OrganizationOrganizationType', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (121, 'ProjectProjectType', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (122, 'ResearchInterestLanguage', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (123, 'ResearchInterestCulturalArea', 1000, 10); +insert into ID_TABLE (id_table_id, table_name, next_id, quantity) VALUES (124, 'ResearchInterestDiscipline', 1000, 10); diff --git a/src/sql/roster-schema.sql b/src/sql/roster-schema.sql new file mode 100755 index 0000000..51f28c5 --- /dev/null +++ b/src/sql/roster-schema.sql @@ -0,0 +1,416 @@ + +# ----------------------------------------------------------------------- +# Member +# ----------------------------------------------------------------------- +drop table if exists Member; + +CREATE TABLE Member +( + id INTEGER NOT NULL, + created_by INTEGER NOT NULL, + modified_by INTEGER NOT NULL, + created_on TIMESTAMP NOT NULL, + modified_on TIMESTAMP NOT NULL, + deleted CHAR (5) NOT NULL, + contact_info_id INTEGER, + research_interest_id INTEGER, + publication_id INTEGER, + member_type VARCHAR (24) NOT NULL, + person_data_id INTEGER, + project_data_id INTEGER, + organization_data_id INTEGER, + PRIMARY KEY(id), + FOREIGN KEY (contact_info_id) REFERENCES ContactInfo (id), + FOREIGN KEY (research_interest_id) REFERENCES ResearchInterest (id), + FOREIGN KEY (publication_id) REFERENCES Publication (id), + FOREIGN KEY (person_data_id) REFERENCES PersonData (id), + FOREIGN KEY (project_data_id) REFERENCES ProjectData (id), + FOREIGN KEY (organization_data_id) REFERENCES OrganizationData (id) +); + +# ----------------------------------------------------------------------- +# PersonData +# ----------------------------------------------------------------------- +drop table if exists PersonData; + +CREATE TABLE PersonData +( + id INTEGER NOT NULL, + thdl_user_id INTEGER NOT NULL, + firstname MEDIUMTEXT, + middlename MEDIUMTEXT, + lastname MEDIUMTEXT, + bio LONGTEXT, + history LONGTEXT, + parent_organization MEDIUMTEXT, + school MEDIUMTEXT, + department MEDIUMTEXT, + program MEDIUMTEXT, + advisor MEDIUMTEXT, + highest_degree MEDIUMTEXT, + year_began INTEGER, + year_finished INTEGER, + other_backgrounds LONGTEXT, + organization MEDIUMTEXT, + division MEDIUMTEXT, + title MEDIUMTEXT, + start_date INTEGER, + job_description LONGTEXT, + PRIMARY KEY(id) +); + +# ----------------------------------------------------------------------- +# ProjectData +# ----------------------------------------------------------------------- +drop table if exists ProjectData; + +CREATE TABLE ProjectData +( + id INTEGER NOT NULL, + name MEDIUMTEXT, + parent_organization MEDIUMTEXT, + divisions MEDIUMTEXT, + people MEDIUMTEXT, + mailing_list MEDIUMTEXT, + description LONGTEXT, + history LONGTEXT, + education_programs LONGTEXT, + resources LONGTEXT, + PRIMARY KEY(id) +); + +# ----------------------------------------------------------------------- +# OrganizationData +# ----------------------------------------------------------------------- +drop table if exists OrganizationData; + +CREATE TABLE OrganizationData +( + id INTEGER NOT NULL, + name MEDIUMTEXT, + parent_organization MEDIUMTEXT, + divisions MEDIUMTEXT, + people MEDIUMTEXT, + mailing_list MEDIUMTEXT, + description LONGTEXT, + history LONGTEXT, + education_programs LONGTEXT, + resources LONGTEXT, + PRIMARY KEY(id) +); + +# ----------------------------------------------------------------------- +# ContactInfo +# ----------------------------------------------------------------------- +drop table if exists ContactInfo; + +CREATE TABLE ContactInfo +( + id INTEGER NOT NULL, + contact_name MEDIUMTEXT, + email MEDIUMTEXT, + website MEDIUMTEXT, + phone INTEGER, + fax INTEGER, + address_id INTEGER, + PRIMARY KEY(id), + FOREIGN KEY (address_id) REFERENCES Address (id), + FOREIGN KEY (phone) REFERENCES Phone (id), + FOREIGN KEY (fax) REFERENCES Phone (id) +); + +# ----------------------------------------------------------------------- +# Address +# ----------------------------------------------------------------------- +drop table if exists Address; + +CREATE TABLE Address +( + id INTEGER NOT NULL, + address MEDIUMTEXT, + city MEDIUMTEXT, + region MEDIUMTEXT, + zip MEDIUMTEXT, + country_id INTEGER, + PRIMARY KEY(id), + FOREIGN KEY (country_id) REFERENCES Country (id) +); + +# ----------------------------------------------------------------------- +# Phone +# ----------------------------------------------------------------------- +drop table if exists Phone; + +CREATE TABLE Phone +( + id INTEGER NOT NULL, + country_code INTEGER, + area_code INTEGER, + number INTEGER, + PRIMARY KEY(id) +); + +# ----------------------------------------------------------------------- +# Publication +# ----------------------------------------------------------------------- +drop table if exists Publication; + +CREATE TABLE Publication +( + id INTEGER NOT NULL, + formal_publications LONGTEXT, + works_in_progress LONGTEXT, + projects LONGTEXT, + PRIMARY KEY(id) +); + +# ----------------------------------------------------------------------- +# ResearchInterest +# ----------------------------------------------------------------------- +drop table if exists ResearchInterest; + +CREATE TABLE ResearchInterest +( + id INTEGER NOT NULL, + interests LONGTEXT, + activities LONGTEXT, + collaboration_interests LONGTEXT, + focus_from INTEGER, + focus_to INTEGER, + PRIMARY KEY(id) +); + +# ----------------------------------------------------------------------- +# Document +# ----------------------------------------------------------------------- +drop table if exists Document; + +CREATE TABLE Document +( + id INTEGER NOT NULL, + member_id INTEGER, + document_type_id INTEGER, + content_type MEDIUMTEXT, + path MEDIUMTEXT, + filename MEDIUMTEXT, + label MEDIUMTEXT, + PRIMARY KEY(id), + FOREIGN KEY (member_id) REFERENCES Member (id), + FOREIGN KEY (document_type_id) REFERENCES DocumentType (id) +); + +# ----------------------------------------------------------------------- +# Country +# ----------------------------------------------------------------------- +drop table if exists Country; + +CREATE TABLE Country +( + id INTEGER NOT NULL, + country MEDIUMTEXT NOT NULL, + PRIMARY KEY(id) +); + +# ----------------------------------------------------------------------- +# CulturalArea +# ----------------------------------------------------------------------- +drop table if exists CulturalArea; + +CREATE TABLE CulturalArea +( + id INTEGER NOT NULL, + cultural_area MEDIUMTEXT NOT NULL, + PRIMARY KEY(id) +); + +# ----------------------------------------------------------------------- +# Language +# ----------------------------------------------------------------------- +drop table if exists Language; + +CREATE TABLE Language +( + id INTEGER NOT NULL, + language MEDIUMTEXT NOT NULL, + PRIMARY KEY(id) +); + +# ----------------------------------------------------------------------- +# Discipline +# ----------------------------------------------------------------------- +drop table if exists Discipline; + +CREATE TABLE Discipline +( + id INTEGER NOT NULL, + discipline MEDIUMTEXT NOT NULL, + PRIMARY KEY(id) +); + +# ----------------------------------------------------------------------- +# DocumentType +# ----------------------------------------------------------------------- +drop table if exists DocumentType; + +CREATE TABLE DocumentType +( + id INTEGER NOT NULL, + document_type MEDIUMTEXT NOT NULL, + PRIMARY KEY(id) +); + +# ----------------------------------------------------------------------- +# ProjectType +# ----------------------------------------------------------------------- +drop table if exists ProjectType; + +CREATE TABLE ProjectType +( + id INTEGER NOT NULL, + project_type MEDIUMTEXT NOT NULL, + PRIMARY KEY(id) +); + +# ----------------------------------------------------------------------- +# OrganizationType +# ----------------------------------------------------------------------- +drop table if exists OrganizationType; + +CREATE TABLE OrganizationType +( + id INTEGER NOT NULL, + organization_type MEDIUMTEXT NOT NULL, + PRIMARY KEY(id) +); + +# ----------------------------------------------------------------------- +# PersonType +# ----------------------------------------------------------------------- +drop table if exists PersonType; + +CREATE TABLE PersonType +( + id INTEGER NOT NULL, + person_type MEDIUMTEXT NOT NULL, + PRIMARY KEY(id) +); + +# ----------------------------------------------------------------------- +# PersonPersonType +# ----------------------------------------------------------------------- +drop table if exists PersonPersonType; + +CREATE TABLE PersonPersonType +( + id INTEGER NOT NULL, + person_type_id INTEGER NOT NULL, + person_data_id INTEGER NOT NULL, + relevance INTEGER NOT NULL, + PRIMARY KEY(id), + FOREIGN KEY (person_data_id) REFERENCES PersonData (id), + FOREIGN KEY (person_type_id) REFERENCES PersonType (id) +); + +# ----------------------------------------------------------------------- +# OrganizationOrganizationType +# ----------------------------------------------------------------------- +drop table if exists OrganizationOrganizationType; + +CREATE TABLE OrganizationOrganizationType +( + id INTEGER NOT NULL, + organization_type_id INTEGER NOT NULL, + organization_data_id INTEGER NOT NULL, + relevance INTEGER NOT NULL, + PRIMARY KEY(id), + FOREIGN KEY (organization_data_id) REFERENCES OrganizationData (id), + FOREIGN KEY (organization_type_id) REFERENCES OrganizationType (id) +); + +# ----------------------------------------------------------------------- +# ProjectProjectType +# ----------------------------------------------------------------------- +drop table if exists ProjectProjectType; + +CREATE TABLE ProjectProjectType +( + id INTEGER NOT NULL, + project_type_id INTEGER NOT NULL, + project_data_id INTEGER NOT NULL, + relevance INTEGER NOT NULL, + PRIMARY KEY(id), + FOREIGN KEY (project_data_id) REFERENCES ProjectData (id), + FOREIGN KEY (project_type_id) REFERENCES ProjectType (id) +); + +# ----------------------------------------------------------------------- +# ResearchInterestLanguage +# ----------------------------------------------------------------------- +drop table if exists ResearchInterestLanguage; + +CREATE TABLE ResearchInterestLanguage +( + id INTEGER NOT NULL, + language_id INTEGER NOT NULL, + research_interest_id INTEGER NOT NULL, + relevance INTEGER NOT NULL, + PRIMARY KEY(id), + FOREIGN KEY (research_interest_id) REFERENCES ResearchInterest (id), + FOREIGN KEY (language_id) REFERENCES Language (id) +); + +# ----------------------------------------------------------------------- +# ResearchInterestCulturalArea +# ----------------------------------------------------------------------- +drop table if exists ResearchInterestCulturalArea; + +CREATE TABLE ResearchInterestCulturalArea +( + id INTEGER NOT NULL, + cultural_area_id INTEGER NOT NULL, + research_interest_id INTEGER NOT NULL, + relevance INTEGER NOT NULL, + PRIMARY KEY(id), + FOREIGN KEY (research_interest_id) REFERENCES ResearchInterest (id), + FOREIGN KEY (cultural_area_id) REFERENCES CulturalArea (id) +); + +# ----------------------------------------------------------------------- +# ResearchInterestDiscipline +# ----------------------------------------------------------------------- +drop table if exists ResearchInterestDiscipline; + +CREATE TABLE ResearchInterestDiscipline +( + id INTEGER NOT NULL, + discipline_id INTEGER NOT NULL, + research_interest_id INTEGER NOT NULL, + relevance INTEGER NOT NULL, + PRIMARY KEY(id), + FOREIGN KEY (research_interest_id) REFERENCES ResearchInterest (id), + FOREIGN KEY (discipline_id) REFERENCES Discipline (id) +); + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/sql/sqldb.map b/src/sql/sqldb.map new file mode 100755 index 0000000..413752c --- /dev/null +++ b/src/sql/sqldb.map @@ -0,0 +1,4 @@ +#Sqlfile -> Database map +#Wed May 14 19:01:31 EDT 2003 +roster-schema.sql=Roster +id-table-schema.sql=Roster diff --git a/utility.js b/utility.js new file mode 100755 index 0000000..cc727d7 --- /dev/null +++ b/utility.js @@ -0,0 +1,47 @@ +// ************************ +// layer utility routines * +// ************************ + +function getStyleObject(objectId) { + // cross-browser function to get an object's style object given its id + if(document.getElementById && document.getElementById(objectId)) { + // W3C DOM + return document.getElementById(objectId).style; + } else if (document.all && document.all(objectId)) { + // MSIE 4 DOM + return document.all(objectId).style; + } else if (document.layers && document.layers[objectId]) { + // NN 4 DOM.. note: this won't find nested layers + return document.layers[objectId]; + } else { + return false; + } +} // getStyleObject + +function changeObjectVisibility(objectId, newVisibility) { + // get a reference to the cross-browser style object and make sure the object exists + var styleObject = getStyleObject(objectId); + if(styleObject) { + styleObject.visibility = newVisibility; + return true; + } else { + // we couldn't find the object, so we can't change its visibility + return false; + } +} // changeObjectVisibility + +function moveObject(objectId, newXCoordinate, newYCoordinate) { + // get a reference to the cross-browser style object and make sure the object exists + var styleObject = getStyleObject(objectId); + if(styleObject) { + styleObject.left = newXCoordinate; + styleObject.top = newYCoordinate; + return true; + } else { + // we couldn't find the object, so we can't very well move it + return false; + } +} // moveObject + + +