1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package de.bea.domingo.groupware.map;
23
24 import java.util.List;
25
26 import de.bea.domingo.DViewEntry;
27 import de.bea.domingo.groupware.Contact;
28 import de.bea.domingo.groupware.ContactDigest;
29 import de.bea.domingo.map.BaseMapper;
30 import de.bea.domingo.map.DirectMapper;
31 import de.bea.domingo.map.MappingException;
32 import de.bea.domingo.map.MethodNotFoundException;
33
34 /***
35 * Mapper for Contact entries - common functonality between Public and Private
36 * address books.
37 *
38 * @see de.bea.domingo.groupware.Contact
39 * @see de.bea.domingo.groupware.ContactDigest
40 * @see de.bea.domingo.groupware.map.PublicContactMapper
41 * @see de.bea.domingo.groupware.map.PrivateContactMapper
42 * @author <a href=mailto:schwarz_dot_dan_at_gmail_dot_com>Daniel Schwarz</a>
43 */
44 public abstract class BaseContactMapper extends BaseMapper {
45
46 private static final Class INSTANCE_CLASS = Contact.class;
47
48 private static final Class DIGEST_CLASS = ContactDigest.class;
49
50 /***
51 * Constructor.
52 *
53 * @throws MethodNotFoundException if a getter or setter method was not
54 * found in the instance or digest class
55 */
56 public BaseContactMapper() throws MethodNotFoundException {
57 super(INSTANCE_CLASS, DIGEST_CLASS);
58 add(new DirectMapper("FullName", String.class));
59 add(new DirectMapper("MailAddress", "Email", String.class));
60 }
61
62 /***
63 * {@inheritDoc}
64 * @see de.bea.domingo.groupware.map.BaseContactMapper#map(de.bea.domingo.DViewEntry, java.lang.Object)
65 */
66 public final void map(final DViewEntry viewEntry, final Object object) throws MappingException {
67 ContactDigest digest = (ContactDigest) object;
68 List columnValues = viewEntry.getColumnValues();
69 digest.setUnid(viewEntry.getUniversalID());
70 mapColumnValues(columnValues, digest);
71 }
72
73 /***
74 * Maps the column values a contact digest.
75 * Implemented by database/view-specific subclasses.
76 *
77 * @param columnValues column values of a view entry.
78 * @param digest the digest to map the column values into
79 */
80 protected abstract void mapColumnValues(final List columnValues, final ContactDigest digest);
81
82 /***
83 * {@inheritDoc}
84 *
85 * @see de.bea.domingo.map.DMapper#newDigest()
86 */
87 public final Object newDigest() {
88 return new ContactDigest();
89 }
90
91 /***
92 * {@inheritDoc}
93 * @see de.bea.domingo.map.DMapper#newInstance()
94 */
95 public final Object newInstance() {
96 return new Contact();
97 }
98 }