View Javadoc

1   /**
2    * Copyright 2005-2007 the original author or authors.
3    *
4    * Licensed under the Gnu General Pubic License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with
6    * the License. You may obtain a copy of the License at
7    *
8    *      http://www.opensource.org/licenses/gpl-license.php
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13   * See the Gnu General Public License for more details.
14   */
15  package org.figure8.join.view;
16  
17  import org.figure8.join.businessobjects.environment.Gateway;
18  
19  import java.util.Map;
20  import java.util.Date;
21  import java.util.List;
22  import java.util.HashMap;
23  import java.util.ArrayList;
24  import java.io.Serializable;
25  /**
26   * This a JavaBean encasulating a Gateway domain model object
27   * and its information on EIS mappings done during a tracking period.
28   * Instance of <code>GatewayTrackingView</code> class are intended to be
29   * stored within an Http layer context.
30   * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
31   * @version $Revision: 1.2 $
32   */
33  public class GatewayTrackingView implements Serializable{
34  
35     // Attributes ---------------------------------------------------------------
36  
37     /** The start date of the tracking period for Gateway changes */
38     protected Date startDate;
39     /** The end date of the tracking period for Gateway changes */
40     protected Date endDate;
41     /** The encapsulated gateway domain object */
42     protected Gateway gateway = null;
43  
44     /** A map of mappings done during tracking period, organized on EIS type */
45     protected Map eisMappings = new HashMap();
46  
47  
48     // Constructors -------------------------------------------------------------
49  
50     /**
51      * Creates a new instance of GatewayTrackingView
52      * @param gateway The wrapped gateway domain object
53      * @param startDate The start date of the tracking period of this view
54      * @param endDate The end date of the tracking period of this view
55      */
56     public GatewayTrackingView(Gateway gateway, Date startDate, Date endDate){
57        this.gateway = gateway;
58        this.startDate = startDate;
59        this.endDate = endDate;
60     }
61  
62  
63     // Public -------------------------------------------------------------------
64  
65     /** @return The start date of the tracking period for Gateway changes */
66     public Date getStartDate(){
67        return startDate;
68     }
69     /** @return The end date of the tracking period for Gateway changes */
70     public Date getEndDate(){
71        return endDate;
72     }
73     /** @return The encapsulated gateway domain object */
74     public Gateway getGateway(){
75        return gateway;
76     }
77  
78     /**
79      * Get the EIS mappings done during the tracking period
80      * @return A map where keys are the resource type and values are list of mappings for the type
81      */
82     public Map getEISMappings(){
83        return eisMappings;
84     }
85     /**
86      * Add a EISMapping to existing mappings for this tracking view
87      * @param mapping The versioned EIS resource mapping to add
88      */
89     public void addEISMapping(VersionedResourceMapping mapping){
90        // Retrieve mappings for this resource type.
91        List mappings = (List)eisMappings.get(mapping.getResourceView().getResource().getResourceType());
92        // Add mapping to list of mappings.
93        if (mappings == null) mappings = new ArrayList();
94        mappings.add(mapping);
95        // Update the map of versioned resource mappings.
96        eisMappings.put(mapping.getResourceView().getResource().getResourceType(), mappings);
97     }
98  }