View Javadoc

1   package org.kuali.mobility.events.util;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   
6   import org.apache.commons.collections.CollectionUtils;
7   import org.apache.commons.collections.Transformer;
8   import org.kuali.mobility.events.entity.Event;
9   import org.kuali.mobility.events.entity.EventContactImpl;
10  import org.kuali.mobility.events.entity.EventImpl;
11  
12  public class EventTransform implements Transformer{
13  
14  
15  	@Override
16  	public Object transform(Object obj) {
17  		EventImpl proxy = null;
18  
19  		if( obj instanceof EventImpl ) {
20  			proxy = (EventImpl)obj;
21  		} else if(obj instanceof Event){
22  			proxy = new EventImpl();
23  			proxy.setEventId(((Event)obj).getEventId());
24  			proxy.setType(((Event)obj).getType());
25  			proxy.setTitle(((Event)obj).getTitle());
26  			proxy.setStartDate(((Event)obj).getStartDate());
27  			proxy.setEndDate(((Event)obj).getEndDate());
28  			proxy.setDisplayStartTime(((Event)obj).getDisplayStartTime());
29  			proxy.setDisplayEndTime(((Event)obj).getDisplayEndTime());
30  			proxy.setDisplayStartDate(((Event)obj).getDisplayStartDate());
31  			proxy.setDisplayEndDate(((Event)obj).getDisplayEndDate());
32  			proxy.setLink(((Event)obj).getLink());
33  			proxy.setLocation(((Event)obj).getLocation());
34  			proxy.setAllDay(((Event)obj).isAllDay());
35  			proxy.setCategory(((Event)obj).getCategory());
36  			proxy.setCost(((Event)obj).getCost());
37  			proxy.setDescription(((Event)obj).getDescription());
38  			proxy.setOtherInfo(((Event)obj).getOtherInfo());
39  
40  			List<EventContactImpl> contacts = new ArrayList<EventContactImpl>();
41  			CollectionUtils.collect(((Event)obj).getContact(),new EventContactTransform(), contacts);
42  			proxy.setContact(contacts);
43  		}
44  		return proxy;
45  	}
46  
47  }