01: /*
02: * Copyright 2006 Davide Deidda
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: /*
18: * Person.java
19: *
20: * Created on 22 aprile 2005, 20.38
21: */
22:
23: /**
24: *
25: * @author davide
26: */package it.biobytes.ammentos.test;
27:
28: import it.biobytes.ammentos.*;
29: import static it.biobytes.ammentos.FieldTypeEnum.*;
30: import java.util.*;
31:
32: @PersistentEntity(sourceDomain="people",primaryKey="id",validator="it.biobytes.ammentos.test.PersonValidator")
33: public class Person {
34: @PersistentField(fieldName="id")
35: private String m_id;
36:
37: @PersistentField(typeClass="it.biobytes.ammentos.fieldtypes.StringType")
38: private String name;
39:
40: @PersistentField(fieldName="surname",description="code",type=STRING)
41: private String m_surname;
42:
43: @PersistentList(itemsClass="it.biobytes.ammentos.test.Person",query="bestFriend_id=?")
44: private List<Person> m_bestFriends;
45:
46: public Person(String id) {
47: m_id = id;
48: m_bestFriends = new ArrayList<Person>();
49: }
50:
51: public Person(String id, String name, String surname) {
52: this (id);
53: this .name = name;
54: m_surname = surname;
55: }
56:
57: public void setBestFriendFor(Person person) {
58: m_bestFriends.add(person);
59: }
60:
61: public int countBestFriends() {
62: return m_bestFriends.size();
63: }
64:
65: private Person() {
66: }
67:
68: public String getId() {
69: return m_id;
70: }
71:
72: public String getName() {
73: return name;
74: }
75:
76: public void setName(String m_name) {
77: this .name = m_name;
78: }
79:
80: public String getSurname() {
81: return m_surname;
82: }
83:
84: public void setSurname(String m_surname) {
85: this.m_surname = m_surname;
86: }
87: }
|