View Javadoc

1   /*
2    * This file is part of Domingo
3    * an Open Source Java-API to Lotus Notes/Domino
4    * hosted at http://domingo.sourceforge.net
5    *
6    * Copyright (c) 2003-2007 Beck et al. projects GmbH Munich, Germany (http://www.bea.de)
7    *
8    * This library is free software; you can redistribute it and/or
9    * modify it under the terms of the GNU Lesser General Public
10   * License as published by the Free Software Foundation; either
11   * version 2.1 of the License, or (at your option) any later version.
12   *
13   * This library is distributed in the hope that it will be useful,
14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   * Lesser General Public License for more details.
17   *
18   * You should have received a copy of the GNU Lesser General Public
19   * License along with this library; if not, write to the Free Software
20   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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  }