/tests/com/google/appengine/datanucleus/test/HasOneToManyLongPkListJDO.java

http://datanucleus-appengine.googlecode.com/ · Java · 94 lines · 57 code · 19 blank · 18 comment · 0 complexity · 396bbb8f3a88c4151febc0fc7c586485 MD5 · raw file

  1. /**********************************************************************
  2. Copyright (c) 2009 Google Inc.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. **********************************************************************/
  13. package com.google.appengine.datanucleus.test;
  14. import com.google.appengine.datanucleus.Utils;
  15. import java.util.ArrayList;
  16. import java.util.Collection;
  17. import java.util.List;
  18. import javax.jdo.annotations.Element;
  19. import javax.jdo.annotations.IdGeneratorStrategy;
  20. import javax.jdo.annotations.Order;
  21. import javax.jdo.annotations.PersistenceCapable;
  22. import javax.jdo.annotations.Persistent;
  23. import javax.jdo.annotations.PrimaryKey;
  24. /**
  25. * @author Max Ross <maxr@google.com>
  26. */
  27. @PersistenceCapable(detachable = "true")
  28. public class HasOneToManyLongPkListJDO implements HasOneToManyLongPkJDO {
  29. @PrimaryKey
  30. @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
  31. private Long key;
  32. @Persistent
  33. private String val;
  34. @Element(dependent = "true")
  35. @Order(column = "flights_INTEGER_IDX_longpk")
  36. private List<Flight> flights = Utils.newArrayList();
  37. @Persistent(mappedBy = "parent")
  38. @Element(dependent = "true")
  39. private List<BidirectionalChildLongPkListJDO> bidirChildren = new ArrayList<BidirectionalChildLongPkListJDO>();
  40. @Order(column = "hasKeyPks_INTEGER_IDX_longpk")
  41. private List<HasKeyPkJDO> hasKeyPks = new ArrayList<HasKeyPkJDO>();
  42. public void addFlight(Flight flight) {
  43. flights.add(flight);
  44. }
  45. public Collection<Flight> getFlights() {
  46. return flights;
  47. }
  48. public void addBidirChild(BidirectionalChildLongPkJDO child) {
  49. bidirChildren.add((BidirectionalChildLongPkListJDO) child);
  50. }
  51. public Collection<BidirectionalChildLongPkJDO> getBidirChildren() {
  52. return (List) bidirChildren;
  53. }
  54. public Long getId() {
  55. return key;
  56. }
  57. public void addHasKeyPk(HasKeyPkJDO val) {
  58. hasKeyPks.add(val);
  59. }
  60. public String getVal() {
  61. return val;
  62. }
  63. public void setVal(String val) {
  64. this.val = val;
  65. }
  66. public void removeFlights(Collection<Flight> flights) {
  67. this.flights.removeAll(flights);
  68. }
  69. public void removeBidirChildren(Collection<BidirectionalChildLongPkJDO> bidirChildren) {
  70. this.bidirChildren.removeAll(bidirChildren);
  71. }
  72. }