View Javadoc

1   /*
2    * Copyright 2011-2012 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.mobility.events.util;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.apache.commons.collections.CollectionUtils;
22  import org.apache.commons.collections.Transformer;
23  import org.kuali.mobility.events.entity.Category;
24  import org.kuali.mobility.events.entity.CategoryImpl;
25  import org.kuali.mobility.events.entity.DayImpl;
26  
27  /**
28   *
29   * @author Aniruddha Jani <ajani@vivantech.com>
30   */
31  public class CategoryTransform implements Transformer {
32  
33      @Override
34      public CategoryImpl transform( Object obj ) {
35      	CategoryImpl proxy = null;
36  
37          if( obj instanceof Category ) {
38              proxy = new CategoryImpl();
39              proxy.setCategoryId(((Category)obj).getCategoryId());
40              proxy.setCampus(((Category)obj).getCampus());
41              proxy.setOrder(((Category)obj).getOrder());
42              proxy.setReturnPage(((Category)obj).getReturnPage());
43              proxy.setTitle(((Category)obj).getTitle());
44              proxy.setUrlString(((Category)obj).getUrlString());
45                          
46              List<DayImpl> days = new ArrayList<DayImpl>();
47              CollectionUtils.collect(((Category)obj).getDays(), new DayTransform(), days );
48              proxy.setDays(days);
49          }
50  
51          return proxy;
52      }
53  
54  }