1packageorg.apache.jetspeed.om.dbregistry;
23import java.math.BigDecimal;
4import java.sql.Connection;
5import java.sql.SQLException;
6import java.util.ArrayList;
7import java.util.Date;
8import java.util.Iterator;
9import java.util.LinkedList;
10import java.util.List;
1112import org.apache.torque.NoRowsException;
13import org.apache.torque.TooManyRowsException;
14import org.apache.torque.Torque;
15import org.apache.torque.TorqueException;
16import org.apache.torque.map.MapBuilder;
17import org.apache.torque.map.TableMap;
18import org.apache.torque.om.DateKey;
19import org.apache.torque.om.NumberKey;
20import org.apache.torque.om.StringKey;
21import org.apache.torque.om.ObjectKey;
22import org.apache.torque.om.SimpleKey;
23import org.apache.torque.util.BasePeer;
24import org.apache.torque.util.Criteria;
2526import com.workingdogs.village.DataSetException;
27import com.workingdogs.village.QueryDataSet;
28import com.workingdogs.village.Record;
2930// Local classes31importorg.apache.jetspeed.om.dbregistry.map.*;
32333435/***36 * This class was autogenerated by Torque on:37 *38 * [Thu Apr 22 23:12:36 EDT 2004]39 *40 */41publicabstractclassBasePortletParameterPeer42extends BasePeer
43 {
4445/*** the default database name for this class */46publicstaticfinal String DATABASE_NAME = "default";
4748/*** the table name for this class */49publicstaticfinal String TABLE_NAME = "PORTLET_PARAMETER";
5051/***52 * @return the map builder for this peer53 * @throws TorqueException Any exceptions caught during processing will be54 * rethrown wrapped into a TorqueException.55 */56publicstatic MapBuilder getMapBuilder()
57 throws TorqueException
58 {
59return getMapBuilder(PortletParameterMapBuilder.CLASS_NAME);
60 }
6162/*** the column name for the ID field */63publicstaticfinal String ID;
64/*** the column name for the NAME field */65publicstaticfinal String NAME;
66/*** the column name for the VALUE field */67publicstaticfinal String VALUE;
68/*** the column name for the TYPE field */69publicstaticfinal String TYPE;
70/*** the column name for the HIDDEN field */71publicstaticfinal String HIDDEN;
72/*** the column name for the ROLE field */73publicstaticfinal String ROLE;
74/*** the column name for the CACHEDONVALUE field */75publicstaticfinal String CACHEDONVALUE;
76/*** the column name for the CACHEDONNAME field */77publicstaticfinal String CACHEDONNAME;
78/*** the column name for the TITLE field */79publicstaticfinal String TITLE;
80/*** the column name for the DESCRIPTION field */81publicstaticfinal String DESCRIPTION;
82/*** the column name for the IMAGE field */83publicstaticfinal String IMAGE;
84/*** the column name for the PORTLET_ID field */85publicstaticfinal String PORTLET_ID;
86/*** the column name for the SECURITY field */87publicstaticfinal String SECURITY;
8889static90 {
91 ID = "PORTLET_PARAMETER.ID";
92 NAME = "PORTLET_PARAMETER.NAME";
93 VALUE = "PORTLET_PARAMETER.VALUE";
94 TYPE = "PORTLET_PARAMETER.TYPE";
95 HIDDEN = "PORTLET_PARAMETER.HIDDEN";
96 ROLE = "PORTLET_PARAMETER.ROLE";
97 CACHEDONVALUE = "PORTLET_PARAMETER.CACHEDONVALUE";
98 CACHEDONNAME = "PORTLET_PARAMETER.CACHEDONNAME";
99 TITLE = "PORTLET_PARAMETER.TITLE";
100 DESCRIPTION = "PORTLET_PARAMETER.DESCRIPTION";
101 IMAGE = "PORTLET_PARAMETER.IMAGE";
102 PORTLET_ID = "PORTLET_PARAMETER.PORTLET_ID";
103 SECURITY = "PORTLET_PARAMETER.SECURITY";
104if (Torque.isInit())
105 {
106try107 {
108 getMapBuilder();
109 }
110catch (Exception e)
111 {
112 log.error("Could not initialize Peer", e);
113 }
114 }
115else116 {
117 Torque.registerMapBuilder(PortletParameterMapBuilder.CLASS_NAME);
118 }
119 }
120121/*** number of columns for this peer */122publicstaticfinalint numColumns = 13;
123124/*** A class that can be returned by this peer. */125protectedstaticfinal String CLASSNAME_DEFAULT =
126"org.apache.jetspeed.om.dbregistry.PortletParameter";
127128/*** A class that can be returned by this peer. */129protectedstaticfinal Class CLASS_DEFAULT = initClass(CLASSNAME_DEFAULT);
130131/***132 * Class object initialization method.133 *134 * @param className name of the class to initialize135 * @return the initialized class136 */137privatestatic Class initClass(String className)
138 {
139 Class c = null;
140try141 {
142 c = Class.forName(className);
143 }
144catch (Throwable t)
145 {
146 log.error("A FATAL ERROR has occurred which should not "147 + "have happened under any circumstance. Please notify "148 + "the Torque developers <turbine-torque-dev@jakarta.apache.org> "149 + "and give as many details as possible (including the error "150 + "stack trace).", t);
151152// Error objects should always be propogated.153if (t instanceof Error)
154 {
155throw (Error) t.fillInStackTrace();
156 }
157 }
158return c;
159 }
160161/***162 * Get the list of objects for a ResultSet. Please not that your163 * resultset MUST return columns in the right order. You can use164 * getFieldNames() in BaseObject to get the correct sequence.165 *166 * @param results the ResultSet167 * @return the list of objects168 * @throws TorqueException Any exceptions caught during processing will be169 * rethrown wrapped into a TorqueException.170 */171publicstatic List resultSet2Objects(java.sql.ResultSet results)
172 throws TorqueException
173 {
174try175 {
176 QueryDataSet qds = null;
177 List rows = null;
178try179 {
180 qds = new QueryDataSet(results);
181 rows = getSelectResults(qds);
182 }
183finally184 {
185if (qds != null)
186 {
187 qds.close();
188 }
189 }
190191return populateObjects(rows);
192 }
193catch (SQLException e)
194 {
195thrownew TorqueException(e);
196 }
197catch (DataSetException e)
198 {
199thrownew TorqueException(e);
200 }
201 }
202203204205/***206 * Method to do inserts.207 *208 * @param criteria object used to create the INSERT statement.209 * @throws TorqueException Any exceptions caught during processing will be210 * rethrown wrapped into a TorqueException.211 */212publicstatic ObjectKey doInsert(Criteria criteria)
213 throws TorqueException
214 {
215returnBasePortletParameterPeer216 .doInsert(criteria, (Connection) null);
217 }
218219/***220 * Method to do inserts. This method is to be used during a transaction,221 * otherwise use the doInsert(Criteria) method. It will take care of222 * the connection details internally.223 *224 * @param criteria object used to create the INSERT statement.225 * @param con the connection to use226 * @throws TorqueException Any exceptions caught during processing will be227 * rethrown wrapped into a TorqueException.228 */229publicstatic ObjectKey doInsert(Criteria criteria, Connection con)
230 throws TorqueException
231 {
232// check for conversion from boolean to int233if (criteria.containsKey(HIDDEN))
234 {
235 Object possibleBoolean = criteria.get(HIDDEN);
236if (possibleBoolean instanceof Boolean)
237 {
238if (((Boolean) possibleBoolean).booleanValue())
239 {
240 criteria.add(HIDDEN, 1);
241 }
242else243 {
244 criteria.add(HIDDEN, 0);
245 }
246 }
247 }
248// check for conversion from boolean to int249if (criteria.containsKey(CACHEDONVALUE))
250 {
251 Object possibleBoolean = criteria.get(CACHEDONVALUE);
252if (possibleBoolean instanceof Boolean)
253 {
254if (((Boolean) possibleBoolean).booleanValue())
255 {
256 criteria.add(CACHEDONVALUE, 1);
257 }
258else259 {
260 criteria.add(CACHEDONVALUE, 0);
261 }
262 }
263 }
264// check for conversion from boolean to int265if (criteria.containsKey(CACHEDONNAME))
266 {
267 Object possibleBoolean = criteria.get(CACHEDONNAME);
268if (possibleBoolean instanceof Boolean)
269 {
270if (((Boolean) possibleBoolean).booleanValue())
271 {
272 criteria.add(CACHEDONNAME, 1);
273 }
274else275 {
276 criteria.add(CACHEDONNAME, 0);
277 }
278 }
279 }
280281// Set the correct dbName if it has not been overridden282// criteria.getDbName will return the same object if not set to283// another value so == check is okay and faster284if (criteria.getDbName() == Torque.getDefaultDB())
285 {
286 criteria.setDbName(DATABASE_NAME);
287 }
288if (con == null)
289 {
290return BasePeer.doInsert(criteria);
291 }
292else293 {
294return BasePeer.doInsert(criteria, con);
295 }
296 }
297298/***299 * Add all the columns needed to create a new object.300 *301 * @param criteria object containing the columns to add.302 * @throws TorqueException Any exceptions caught during processing will be303 * rethrown wrapped into a TorqueException.304 */305publicstaticvoid addSelectColumns(Criteria criteria)
306 throws TorqueException
307 {
308 criteria.addSelectColumn(ID);
309 criteria.addSelectColumn(NAME);
310 criteria.addSelectColumn(VALUE);
311 criteria.addSelectColumn(TYPE);
312 criteria.addSelectColumn(HIDDEN);
313 criteria.addSelectColumn(ROLE);
314 criteria.addSelectColumn(CACHEDONVALUE);
315 criteria.addSelectColumn(CACHEDONNAME);
316 criteria.addSelectColumn(TITLE);
317 criteria.addSelectColumn(DESCRIPTION);
318 criteria.addSelectColumn(IMAGE);
319 criteria.addSelectColumn(PORTLET_ID);
320 criteria.addSelectColumn(SECURITY);
321 }
322323/***324 * Create a new object of type cls from a resultset row starting325 * from a specified offset. This is done so that you can select326 * other rows than just those needed for this object. You may327 * for example want to create two objects from the same row.328 *329 * @throws TorqueException Any exceptions caught during processing will be330 * rethrown wrapped into a TorqueException.331 */332publicstaticPortletParameter row2Object(Record row,
333int offset,
334 Class cls)
335 throws TorqueException
336 {
337try338 {
339PortletParameter obj = (PortletParameter) cls.newInstance();
340 PortletParameterPeer.populateObject(row, offset, obj);
341 obj.setModified(false);
342 obj.setNew(false);
343344return obj;
345 }
346catch (InstantiationException e)
347 {
348thrownew TorqueException(e);
349 }
350catch (IllegalAccessException e)
351 {
352thrownew TorqueException(e);
353 }
354 }
355356/***357 * Populates an object from a resultset row starting358 * from a specified offset. This is done so that you can select359 * other rows than just those needed for this object. You may360 * for example want to create two objects from the same row.361 *362 * @throws TorqueException Any exceptions caught during processing will be363 * rethrown wrapped into a TorqueException.364 */365publicstaticvoid populateObject(Record row,
366int offset,
367PortletParameter obj)
368 throws TorqueException
369 {
370try371 {
372 obj.setId(row.getValue(offset + 0).asLong());
373 obj.setName(row.getValue(offset + 1).asString());
374 obj.setValue(row.getValue(offset + 2).asString());
375 obj.setType(row.getValue(offset + 3).asString());
376 obj.setHidden(row.getValue(offset + 4).asBoolean());
377 obj.setRole(row.getValue(offset + 5).asString());
378 obj.setCachedonvalue(row.getValue(offset + 6).asBoolean());
379 obj.setCachedonname(row.getValue(offset + 7).asBoolean());
380 obj.setTitle(row.getValue(offset + 8).asString());
381 obj.setDescription(row.getValue(offset + 9).asString());
382 obj.setImage(row.getValue(offset + 10).asString());
383 obj.setPortletId(row.getValue(offset + 11).asLong());
384 obj.setSecurityRef(row.getValue(offset + 12).asString());
385 }
386catch (DataSetException e)
387 {
388thrownew TorqueException(e);
389 }
390 }
391392/***393 * Method to do selects.394 *395 * @param criteria object used to create the SELECT statement.396 * @return List of selected Objects397 * @throws TorqueException Any exceptions caught during processing will be398 * rethrown wrapped into a TorqueException.399 */400publicstatic List doSelect(Criteria criteria) throws TorqueException
401 {
402return populateObjects(doSelectVillageRecords(criteria));
403 }
404405/***406 * Method to do selects within a transaction.407 *408 * @param criteria object used to create the SELECT statement.409 * @param con the connection to use410 * @return List of selected Objects411 * @throws TorqueException Any exceptions caught during processing will be412 * rethrown wrapped into a TorqueException.413 */414publicstatic List doSelect(Criteria criteria, Connection con)
415 throws TorqueException
416 {
417return populateObjects(doSelectVillageRecords(criteria, con));
418 }
419420/***421 * Grabs the raw Village records to be formed into objects.422 * This method handles connections internally. The Record objects423 * returned by this method should be considered readonly. Do not424 * alter the data and call save(), your results may vary, but are425 * certainly likely to result in hard to track MT bugs.426 *427 * @throws TorqueException Any exceptions caught during processing will be428 * rethrown wrapped into a TorqueException.429 */430publicstatic List doSelectVillageRecords(Criteria criteria)
431 throws TorqueException
432 {
433returnBasePortletParameterPeer434 .doSelectVillageRecords(criteria, (Connection) null);
435 }
436437/***438 * Grabs the raw Village records to be formed into objects.439 * This method should be used for transactions440 *441 * @param con the connection to use442 * @throws TorqueException Any exceptions caught during processing will be443 * rethrown wrapped into a TorqueException.444 */445publicstatic List doSelectVillageRecords(Criteria criteria, Connection con)
446 throws TorqueException
447 {
448if (criteria.getSelectColumns().size() == 0)
449 {
450 addSelectColumns(criteria);
451 }
452453// check for conversion from boolean to int454if (criteria.containsKey(HIDDEN))
455 {
456 Object possibleBoolean = criteria.get(HIDDEN);
457if (possibleBoolean instanceof Boolean)
458 {
459if (((Boolean) possibleBoolean).booleanValue())
460 {
461 criteria.add(HIDDEN, 1);
462 }
463else464 {
465 criteria.add(HIDDEN, 0);
466 }
467 }
468 }
469// check for conversion from boolean to int470if (criteria.containsKey(CACHEDONVALUE))
471 {
472 Object possibleBoolean = criteria.get(CACHEDONVALUE);
473if (possibleBoolean instanceof Boolean)
474 {
475if (((Boolean) possibleBoolean).booleanValue())
476 {
477 criteria.add(CACHEDONVALUE, 1);
478 }
479else480 {
481 criteria.add(CACHEDONVALUE, 0);
482 }
483 }
484 }
485// check for conversion from boolean to int486if (criteria.containsKey(CACHEDONNAME))
487 {
488 Object possibleBoolean = criteria.get(CACHEDONNAME);
489if (possibleBoolean instanceof Boolean)
490 {
491if (((Boolean) possibleBoolean).booleanValue())
492 {
493 criteria.add(CACHEDONNAME, 1);
494 }
495else496 {
497 criteria.add(CACHEDONNAME, 0);
498 }
499 }
500 }
501502// Set the correct dbName if it has not been overridden503// criteria.getDbName will return the same object if not set to504// another value so == check is okay and faster505if (criteria.getDbName() == Torque.getDefaultDB())
506 {
507 criteria.setDbName(DATABASE_NAME);
508 }
509// BasePeer returns a List of Value (Village) arrays. The array510// order follows the order columns were placed in the Select clause.511if (con == null)
512 {
513return BasePeer.doSelect(criteria);
514 }
515else516 {
517return BasePeer.doSelect(criteria, con);
518 }
519 }
520521/***522 * The returned List will contain objects of the default type or523 * objects that inherit from the default.524 *525 * @throws TorqueException Any exceptions caught during processing will be526 * rethrown wrapped into a TorqueException.527 */528publicstatic List populateObjects(List records)
529 throws TorqueException
530 {
531 List results = new ArrayList(records.size());
532533// populate the object(s)534for (int i = 0; i < records.size(); i++)
535 {
536 Record row = (Record) records.get(i);
537 results.add(PortletParameterPeer.row2Object(row, 1,
538 PortletParameterPeer.getOMClass()));
539 }
540return results;
541 }
542543544/***545 * The class that the Peer will make instances of.546 * If the BO is abstract then you must implement this method547 * in the BO.548 *549 * @throws TorqueException Any exceptions caught during processing will be550 * rethrown wrapped into a TorqueException.551 */552publicstatic Class getOMClass()
553 throws TorqueException
554 {
555return CLASS_DEFAULT;
556 }
557558/***559 * Method to do updates.560 *561 * @param criteria object containing data that is used to create the UPDATE562 * statement.563 * @throws TorqueException Any exceptions caught during processing will be564 * rethrown wrapped into a TorqueException.565 */566publicstaticvoid doUpdate(Criteria criteria) throws TorqueException
567 {
568BasePortletParameterPeer569 .doUpdate(criteria, (Connection) null);
570 }
571572/***573 * Method to do updates. This method is to be used during a transaction,574 * otherwise use the doUpdate(Criteria) method. It will take care of575 * the connection details internally.576 *577 * @param criteria object containing data that is used to create the UPDATE578 * statement.579 * @param con the connection to use580 * @throws TorqueException Any exceptions caught during processing will be581 * rethrown wrapped into a TorqueException.582 */583publicstaticvoid doUpdate(Criteria criteria, Connection con)
584 throws TorqueException
585 {
586 Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
587 selectCriteria.put(ID, criteria.remove(ID));
588// check for conversion from boolean to int589if (criteria.containsKey(HIDDEN))
590 {
591 Object possibleBoolean = criteria.get(HIDDEN);
592if (possibleBoolean instanceof Boolean)
593 {
594if (((Boolean) possibleBoolean).booleanValue())
595 {
596 criteria.add(HIDDEN, 1);
597 }
598else599 {
600 criteria.add(HIDDEN, 0);
601 }
602 }
603 }
604// check for conversion from boolean to int605if (criteria.containsKey(CACHEDONVALUE))
606 {
607 Object possibleBoolean = criteria.get(CACHEDONVALUE);
608if (possibleBoolean instanceof Boolean)
609 {
610if (((Boolean) possibleBoolean).booleanValue())
611 {
612 criteria.add(CACHEDONVALUE, 1);
613 }
614else615 {
616 criteria.add(CACHEDONVALUE, 0);
617 }
618 }
619 }
620// check for conversion from boolean to int621if (criteria.containsKey(CACHEDONNAME))
622 {
623 Object possibleBoolean = criteria.get(CACHEDONNAME);
624if (possibleBoolean instanceof Boolean)
625 {
626if (((Boolean) possibleBoolean).booleanValue())
627 {
628 criteria.add(CACHEDONNAME, 1);
629 }
630else631 {
632 criteria.add(CACHEDONNAME, 0);
633 }
634 }
635 }
636637// Set the correct dbName if it has not been overridden638// criteria.getDbName will return the same object if not set to639// another value so == check is okay and faster640if (criteria.getDbName() == Torque.getDefaultDB())
641 {
642 criteria.setDbName(DATABASE_NAME);
643 }
644if (con == null)
645 {
646 BasePeer.doUpdate(selectCriteria, criteria);
647 }
648else649 {
650 BasePeer.doUpdate(selectCriteria, criteria, con);
651 }
652 }
653654/***655 * Method to do deletes.656 *657 * @param criteria object containing data that is used DELETE from database.658 * @throws TorqueException Any exceptions caught during processing will be659 * rethrown wrapped into a TorqueException.660 */661publicstaticvoid doDelete(Criteria criteria) throws TorqueException
662 {
663BasePortletParameterPeer664 .doDelete(criteria, (Connection) null);
665 }
666667/***668 * Method to do deletes. This method is to be used during a transaction,669 * otherwise use the doDelete(Criteria) method. It will take care of670 * the connection details internally.671 *672 * @param criteria object containing data that is used DELETE from database.673 * @param con the connection to use674 * @throws TorqueException Any exceptions caught during processing will be675 * rethrown wrapped into a TorqueException.676 */677publicstaticvoid doDelete(Criteria criteria, Connection con)
678 throws TorqueException
679 {
680// check for conversion from boolean to int681if (criteria.containsKey(HIDDEN))
682 {
683 Object possibleBoolean = criteria.get(HIDDEN);
684if (possibleBoolean instanceof Boolean)
685 {
686if (((Boolean) possibleBoolean).booleanValue())
687 {
688 criteria.add(HIDDEN, 1);
689 }
690else691 {
692 criteria.add(HIDDEN, 0);
693 }
694 }
695 }
696// check for conversion from boolean to int697if (criteria.containsKey(CACHEDONVALUE))
698 {
699 Object possibleBoolean = criteria.get(CACHEDONVALUE);
700if (possibleBoolean instanceof Boolean)
701 {
702if (((Boolean) possibleBoolean).booleanValue())
703 {
704 criteria.add(CACHEDONVALUE, 1);
705 }
706else707 {
708 criteria.add(CACHEDONVALUE, 0);
709 }
710 }
711 }
712// check for conversion from boolean to int713if (criteria.containsKey(CACHEDONNAME))
714 {
715 Object possibleBoolean = criteria.get(CACHEDONNAME);
716if (possibleBoolean instanceof Boolean)
717 {
718if (((Boolean) possibleBoolean).booleanValue())
719 {
720 criteria.add(CACHEDONNAME, 1);
721 }
722else723 {
724 criteria.add(CACHEDONNAME, 0);
725 }
726 }
727 }
728729// Set the correct dbName if it has not been overridden730// criteria.getDbName will return the same object if not set to731// another value so == check is okay and faster732if (criteria.getDbName() == Torque.getDefaultDB())
733 {
734 criteria.setDbName(DATABASE_NAME);
735 }
736if (con == null)
737 {
738 BasePeer.doDelete(criteria);
739 }
740else741 {
742 BasePeer.doDelete(criteria, con);
743 }
744 }
745746/***747 * Method to do selects748 *749 * @throws TorqueException Any exceptions caught during processing will be750 * rethrown wrapped into a TorqueException.751 */752publicstatic List doSelect(PortletParameter obj) throws TorqueException
753 {
754return doSelect(buildCriteria(obj));
755 }
756757/***758 * Method to do inserts759 *760 * @throws TorqueException Any exceptions caught during processing will be761 * rethrown wrapped into a TorqueException.762 */763publicstaticvoid doInsert(PortletParameter obj) throws TorqueException
764 {
765 obj.setPrimaryKey(doInsert(buildCriteria(obj)));
766 obj.setNew(false);
767 obj.setModified(false);
768 }
769770/***771 * @param obj the data object to update in the database.772 * @throws TorqueException Any exceptions caught during processing will be773 * rethrown wrapped into a TorqueException.774 */775publicstaticvoid doUpdate(PortletParameter obj) throws TorqueException
776 {
777 doUpdate(buildCriteria(obj));
778 obj.setModified(false);
779 }
780781/***782 * @param obj the data object to delete in the database.783 * @throws TorqueException Any exceptions caught during processing will be784 * rethrown wrapped into a TorqueException.785 */786publicstaticvoid doDelete(PortletParameter obj) throws TorqueException
787 {
788 doDelete(buildCriteria(obj));
789 }
790791/***792 * Method to do inserts. This method is to be used during a transaction,793 * otherwise use the doInsert(PortletParameter) method. It will take794 * care of the connection details internally.795 *796 * @param obj the data object to insert into the database.797 * @param con the connection to use798 * @throws TorqueException Any exceptions caught during processing will be799 * rethrown wrapped into a TorqueException.800 */801publicstaticvoid doInsert(PortletParameter obj, Connection con)
802 throws TorqueException
803 {
804 obj.setPrimaryKey(doInsert(buildCriteria(obj), con));
805 obj.setNew(false);
806 obj.setModified(false);
807 }
808809/***810 * Method to do update. This method is to be used during a transaction,811 * otherwise use the doUpdate(PortletParameter) method. It will take812 * care of the connection details internally.813 *814 * @param obj the data object to update in the database.815 * @param con the connection to use816 * @throws TorqueException Any exceptions caught during processing will be817 * rethrown wrapped into a TorqueException.818 */819publicstaticvoid doUpdate(PortletParameter obj, Connection con)
820 throws TorqueException
821 {
822 doUpdate(buildCriteria(obj), con);
823 obj.setModified(false);
824 }
825826/***827 * Method to delete. This method is to be used during a transaction,828 * otherwise use the doDelete(PortletParameter) method. It will take829 * care of the connection details internally.830 *831 * @param obj the data object to delete in the database.832 * @param con the connection to use833 * @throws TorqueException Any exceptions caught during processing will be834 * rethrown wrapped into a TorqueException.835 */836publicstaticvoid doDelete(PortletParameter obj, Connection con)
837 throws TorqueException
838 {
839 doDelete(buildCriteria(obj), con);
840 }
841842/***843 * Method to do deletes.844 *845 * @param pk ObjectKey that is used DELETE from database.846 * @throws TorqueException Any exceptions caught during processing will be847 * rethrown wrapped into a TorqueException.848 */849publicstaticvoid doDelete(ObjectKey pk) throws TorqueException
850 {
851BasePortletParameterPeer852 .doDelete(pk, (Connection) null);
853 }
854855/***856 * Method to delete. This method is to be used during a transaction,857 * otherwise use the doDelete(ObjectKey) method. It will take858 * care of the connection details internally.859 *860 * @param pk the primary key for the object to delete in the database.861 * @param con the connection to use862 * @throws TorqueException Any exceptions caught during processing will be863 * rethrown wrapped into a TorqueException.864 */865publicstaticvoid doDelete(ObjectKey pk, Connection con)
866 throws TorqueException
867 {
868 doDelete(buildCriteria(pk), con);
869 }
870871/*** Build a Criteria object from an ObjectKey */872publicstatic Criteria buildCriteria( ObjectKey pk )
873 {
874 Criteria criteria = new Criteria();
875 criteria.add(ID, pk);
876return criteria;
877 }
878879/*** Build a Criteria object from the data object for this peer */880publicstatic Criteria buildCriteria( PortletParameter obj )
881 {
882 Criteria criteria = new Criteria(DATABASE_NAME);
883if (!obj.isNew())
884 criteria.add(ID, obj.getId());
885 criteria.add(NAME, obj.getName());
886 criteria.add(VALUE, obj.getValue());
887 criteria.add(TYPE, obj.getType());
888 criteria.add(HIDDEN, obj.getHidden());
889 criteria.add(ROLE, obj.getRole());
890 criteria.add(CACHEDONVALUE, obj.getCachedonvalue());
891 criteria.add(CACHEDONNAME, obj.getCachedonname());
892 criteria.add(TITLE, obj.getTitle());
893 criteria.add(DESCRIPTION, obj.getDescription());
894 criteria.add(IMAGE, obj.getImage());
895 criteria.add(PORTLET_ID, obj.getPortletId());
896 criteria.add(SECURITY, obj.getSecurityRef());
897return criteria;
898 }
899900901/***902 * Retrieve a single object by pk903 *904 * @param pk the primary key905 * @throws TorqueException Any exceptions caught during processing will be906 * rethrown wrapped into a TorqueException.907 * @throws NoRowsException Primary key was not found in database.908 * @throws TooManyRowsException Primary key was not found in database.909 */910publicstaticPortletParameter retrieveByPK(long pk)
911 throws TorqueException, NoRowsException, TooManyRowsException
912 {
913return retrieveByPK(SimpleKey.keyFor(pk));
914 }
915916/***917 * Retrieve a single object by pk918 *919 * @param pk the primary key920 * @throws TorqueException Any exceptions caught during processing will be921 * rethrown wrapped into a TorqueException.922 * @throws NoRowsException Primary key was not found in database.923 * @throws TooManyRowsException Primary key was not found in database.924 */925publicstaticPortletParameter retrieveByPK(ObjectKey pk)
926 throws TorqueException, NoRowsException, TooManyRowsException
927 {
928 Connection db = null;
929PortletParameter retVal = null;
930try931 {
932 db = Torque.getConnection(DATABASE_NAME);
933 retVal = retrieveByPK(pk, db);
934 }
935finally936 {
937 Torque.closeConnection(db);
938 }
939return(retVal);
940 }
941942/***943 * Retrieve a single object by pk944 *945 * @param pk the primary key946 * @param con the connection to use947 * @throws TorqueException Any exceptions caught during processing will be948 * rethrown wrapped into a TorqueException.949 * @throws NoRowsException Primary key was not found in database.950 * @throws TooManyRowsException Primary key was not found in database.951 */952publicstaticPortletParameter retrieveByPK(ObjectKey pk, Connection con)
953 throws TorqueException, NoRowsException, TooManyRowsException
954 {
955 Criteria criteria = buildCriteria(pk);
956 List v = doSelect(criteria, con);
957if (v.size() == 0)
958 {
959thrownew NoRowsException("Failed to select a row.");
960 }
961elseif (v.size() > 1)
962 {
963thrownew TooManyRowsException("Failed to select only one row.");
964 }
965else966 {
967return (PortletParameter)v.get(0);
968 }
969 }
970971/***972 * Retrieve a multiple objects by pk973 *974 * @param pks List of primary keys975 * @throws TorqueException Any exceptions caught during processing will be976 * rethrown wrapped into a TorqueException.977 */978publicstatic List retrieveByPKs(List pks)
979 throws TorqueException
980 {
981 Connection db = null;
982 List retVal = null;
983try984 {
985 db = Torque.getConnection(DATABASE_NAME);
986 retVal = retrieveByPKs(pks, db);
987 }
988finally989 {
990 Torque.closeConnection(db);
991 }
992return(retVal);
993 }
994995/***996 * Retrieve a multiple objects by pk997 *998 * @param pks List of primary keys999 * @param dbcon the connection to use1000 * @throws TorqueException Any exceptions caught during processing will be1001 * rethrown wrapped into a TorqueException.1002 */1003publicstatic List retrieveByPKs( List pks, Connection dbcon )
1004 throws TorqueException
1005 {
1006 List objs = null;
1007if (pks == null || pks.size() == 0)
1008 {
1009 objs = new LinkedList();
1010 }
1011else1012 {
1013 Criteria criteria = new Criteria();
1014 criteria.addIn( ID, pks );
1015 objs = doSelect(criteria, dbcon);
1016 }
1017return objs;
1018 }
10191020102110221023102410251026102710281029/***1030 * selects a collection of PortletParameter objects pre-filled with their1031 * PortletDbEntry objects.1032 *1033 * This method is protected by default in order to keep the public1034 * api reasonable. You can provide public methods for those you1035 * actually need in PortletParameterPeer.1036 *1037 * @throws TorqueException Any exceptions caught during processing will be1038 * rethrown wrapped into a TorqueException.1039 */1040protectedstatic List doSelectJoinPortletDbEntry(Criteria c)
1041 throws TorqueException
1042 {
1043// Set the correct dbName if it has not been overridden1044// c.getDbName will return the same object if not set to1045// another value so == check is okay and faster1046if (c.getDbName() == Torque.getDefaultDB())
1047 {
1048 c.setDbName(DATABASE_NAME);
1049 }
10501051 PortletParameterPeer.addSelectColumns(c);
1052int offset = numColumns + 1;
1053 PortletDbEntryPeer.addSelectColumns(c);
105410551056 c.addJoin(PortletParameterPeer.PORTLET_ID,
1057 PortletDbEntryPeer.ID);
105810591060// check for conversion from boolean to int1061if (c.containsKey(HIDDEN))
1062 {
1063 Object possibleBoolean = c.get(HIDDEN);
1064if (possibleBoolean instanceof Boolean)
1065 {
1066if (((Boolean) possibleBoolean).booleanValue())
1067 {
1068 c.add(HIDDEN, 1);
1069 }
1070else1071 {
1072 c.add(HIDDEN, 0);
1073 }
1074 }
1075 }
1076// check for conversion from boolean to int1077if (c.containsKey(CACHEDONVALUE))
1078 {
1079 Object possibleBoolean = c.get(CACHEDONVALUE);
1080if (possibleBoolean instanceof Boolean)
1081 {
1082if (((Boolean) possibleBoolean).booleanValue())
1083 {
1084 c.add(CACHEDONVALUE, 1);
1085 }
1086else1087 {
1088 c.add(CACHEDONVALUE, 0);
1089 }
1090 }
1091 }
1092// check for conversion from boolean to int1093if (c.containsKey(CACHEDONNAME))
1094 {
1095 Object possibleBoolean = c.get(CACHEDONNAME);
1096if (possibleBoolean instanceof Boolean)
1097 {
1098if (((Boolean) possibleBoolean).booleanValue())
1099 {
1100 c.add(CACHEDONNAME, 1);
1101 }
1102else1103 {
1104 c.add(CACHEDONNAME, 0);
1105 }
1106 }
1107 }
11081109 List rows = BasePeer.doSelect(c);
1110 List results = new ArrayList();
11111112for (int i = 0; i < rows.size(); i++)
1113 {
1114 Record row = (Record) rows.get(i);
11151116 Class omClass = PortletParameterPeer.getOMClass();
1117PortletParameter obj1 = (PortletParameter) PortletParameterPeer
1118 .row2Object(row, 1, omClass);
1119 omClass = PortletDbEntryPeer.getOMClass();
1120PortletDbEntry obj2 = (PortletDbEntry)PortletDbEntryPeer
1121 .row2Object(row, offset, omClass);
11221123boolean newObject = true;
1124for (int j = 0; j < results.size(); j++)
1125 {
1126PortletParameter temp_obj1 = (PortletParameter)results.get(j);
1127PortletDbEntry temp_obj2 = (PortletDbEntry)temp_obj1.getPortletDbEntry();
1128if (temp_obj2.getPrimaryKey().equals(obj2.getPrimaryKey()))
1129 {
1130 newObject = false;
1131 temp_obj2.addPortletParameter(obj1);
1132break;
1133 }
1134 }
1135if (newObject)
1136 {
1137 obj2.initPortletParameters();
1138 obj2.addPortletParameter(obj1);
1139 }
1140 results.add(obj1);
1141 }
1142return results;
1143 }
11441145114611471148/***1149 * Returns the TableMap related to this peer. This method is not1150 * needed for general use but a specific application could have a need.1151 *1152 * @throws TorqueException Any exceptions caught during processing will be1153 * rethrown wrapped into a TorqueException.1154 */1155protectedstatic TableMap getTableMap()
1156 throws TorqueException
1157 {
1158return Torque.getDatabaseMap(DATABASE_NAME).getTable(TABLE_NAME);
1159 }
1160 }