PageRenderTime 87ms CodeModel.GetById 72ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

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