View Javadoc

1   package org.musicontroller.gui.admin;
2   
3   import java.util.List;
4   
5   import org.apache.log4j.Logger;
6   import org.apache.tapestry.IExternalPage;
7   import org.apache.tapestry.IRequestCycle;
8   import org.apache.tapestry.html.BasePage;
9   import org.musicontroller.core.Song;
10  import org.musicontroller.dao.Dao;
11  
12  public abstract class DoubleSongs extends BasePage implements IExternalPage {
13  	private static final Logger log = Logger.getLogger(DoubleSongs.class);
14  	
15  	public abstract Dao getDao();
16  
17  	private Long[] _pair;
18  	public Long[] getPair() {
19  		if (_pair==null) {
20  			_pair = new Long[2];
21  		}
22  		return _pair;
23  	}
24  	
25  	public void setPair(Long[] pair) {
26  		_pair = pair;
27  	}
28  
29  	public void activateExternalPage(Object[] args, IRequestCycle cycle) {
30  		//Nothing to do here
31  	}
32  	
33  	public List<Long[]> getDoubles() {
34  		return getDao().getDoubleSongs();
35  	}
36  	
37  	public Song getSong1() {
38  		return getDao().getSongById(getPair()[0]);
39  	}
40  
41  	public Song getSong2() {
42  		return getDao().getSongById(getPair()[1]);
43  	}
44  	
45  	public void mergeSongs(IRequestCycle cycle) {
46  		log.debug("Merging songid: "+getPair()[1]+" into this songid: "+getPair()[0]);
47  		getDao().mergeSongs(getSong1(),getSong2());
48  		log.debug("Done");
49  	}
50  	
51  	
52  	//TODO Align table equal for all songs
53  	//TODO Enable some caching for songs, this page seems to be unneccecarily heavy to generate.
54  
55  	public void mergeSongsInverse(IRequestCycle cycle) {
56  		log.debug("Merginginverse songid: "+getPair()[0]+" into this songid: "+getPair()[1]);
57  		getDao().mergeSongs(getSong2(),getSong1());
58  		log.debug("Done");
59  	}
60  
61  }