org.musicontroller.gui.importer
Class MusicArchive

java.lang.Object
  extended by org.apache.hivemind.impl.BaseLocatable
      extended by org.apache.tapestry.AbstractComponent
          extended by org.apache.tapestry.BaseComponent
              extended by org.apache.tapestry.AbstractPage
                  extended by org.apache.tapestry.html.BasePage
                      extended by org.musicontroller.gui.importer.MusicArchive
All Implemented Interfaces:
java.util.EventListener, org.apache.hivemind.Locatable, org.apache.hivemind.LocationHolder, org.apache.tapestry.event.PageBeginRenderListener, org.apache.tapestry.IComponent, org.apache.tapestry.IDirectEvent, org.apache.tapestry.IExternalPage, org.apache.tapestry.internal.Component, org.apache.tapestry.IPage, org.apache.tapestry.IRender, org.apache.tapestry.ITemplateComponent

public abstract class MusicArchive
extends org.apache.tapestry.html.BasePage
implements org.apache.tapestry.IExternalPage, org.apache.tapestry.event.PageBeginRenderListener

Screen for showing music archive contents, editing properties and keywords and importing the archive contents into the MusiController database.

The functions of this screen:

Page properties:

The page attempts to find a suitable cover image:

  1. If the music archive contains a cover art URL, that URL is used.
  2. If a persistent playlist with the same name and artist exist, the cover art of that playlist is used.
  3. A cover art search is performed, using search criteria derived from the information in the music archive. The first result of that search is suggested as the cover art.

Author:
Hans Drexler
See Also:
MusicArchiveBean

Field Summary
 
Fields inherited from class org.apache.tapestry.AbstractComponent
_body, _bodyCount
 
Constructor Summary
MusicArchive()
           
 
Method Summary
 void activateExternalPage(java.lang.Object[] args, org.apache.tapestry.IRequestCycle cycle)
          Interpret parameters from other pages.
 void addToExistingPlaylistChangedListener(org.apache.tapestry.event.BrowserEvent event)
           
 org.apache.tapestry.engine.ILink editCoverArt(org.apache.tapestry.IRequestCycle cycle)
          Goto the EditCoverArt page.
 void fillBandName(org.apache.tapestry.IRequestCycle cycle, MusicArchiveBean bean)
          Fill the song entries with a band name with the name entered into the first row.
 void fillKeywords(org.apache.tapestry.IRequestCycle cycle, MusicArchiveBean bean)
          Fill the song entries with keywords the same as entered into the first row.
 void fillPlaylistName(org.apache.tapestry.IRequestCycle cycle, MusicArchiveBean bean)
          Fill the song entries without a playlist name with the name inserted into the first row.
 void fillSongIndex(org.apache.tapestry.IRequestCycle cycle, MusicArchiveBean bean)
          Fill the song entries without a song index with a reasonable song index value.
abstract  MusicArchiveBean getArchive()
          This property holds the bean with information about the songs in the archive.
abstract  org.apache.tapestry.engine.IEngineService getExternalService()
           
abstract  Importer getImporter()
          The importer object knows how to import music into the database.
abstract  McService getMcService()
           
abstract  org.apache.tapestry.engine.IEngineService getPageService()
           
abstract  PlaylistImportProperties getPlaylistEntry()
          Getter for the property that iterates over the playlist entries in the archive.
abstract  org.apache.tapestry.services.ServiceMap getServiceMap()
           
 void importArchive(org.apache.tapestry.IRequestCycle cycle, MusicArchiveBean bean)
          Imports the MusicArchiveBean into the database.
 boolean isExistingPlaylist()
          Returns true if a persistent playlist with the same name as playlistEntry exists or false otherwise.
 void pageBeginRender(org.apache.tapestry.event.PageEvent event)
          Prepare rendering the page.
 void playlistNameChangedListener(org.apache.tapestry.event.BrowserEvent event)
           
abstract  void setFeedback(java.lang.String message)
          Sets a message for the user.
 
Methods inherited from class org.apache.tapestry.html.BasePage
getResponseContentType
 
Methods inherited from class org.apache.tapestry.AbstractPage
addPageAttachListener, addPageBeginRenderListener, addPageDetachListener, addPageEndRenderListener, addPageValidateListener, attach, beginPageRender, cleanupAfterRender, detach, endPageRender, firePageAttached, firePageBeginRender, firePageDetached, firePageEndRender, firePageValidate, getChangeObserver, getEngine, getExtendedId, getIdPath, getLocale, getNestedComponent, getOutputEncoding, getPageName, getRequestCycle, hasFormComponents, hasWidgets, removePageAttachListener, removePageBeginRenderListener, removePageDetachListener, removePageEndRenderListener, removePageValidateListener, renderPage, setChangeObserver, setHasFormComponents, setHasWidgets, setLocale, setPageName, validate
 
Methods inherited from class org.apache.tapestry.BaseComponent
addOuter, finishLoad, getContainedRenderers, getInnerRenderers, renderComponent
 
Methods inherited from class org.apache.tapestry.AbstractComponent
addAsset, addBody, addComponent, checkActiveLock, enterActiveState, equals, finishLoad, generateClientId, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getBody, getBodyCount, getBoundId, getClientId, getComponent, getComponents, getContainedComponent, getContainer, getEventInvoker, getId, getListeners, getMessages, getNamespace, getPage, getRenderWorker, getSpecification, getSpecifiedId, getTemplateTagName, hasEvents, hashCode, isInActiveState, isParameterBound, isRendering, isStateful, pageEndRender, peekClientId, prepareForRender, render, renderBody, renderIdAttribute, renderInformalParameters, setBinding, setClientId, setContainedComponent, setContainer, setHasEvents, setId, setNamespace, setPage, setTemplateTagName, toString, triggerEvent
 
Methods inherited from class org.apache.hivemind.impl.BaseLocatable
getLocation, setLocation
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.tapestry.IPage
addPageAttachListener, addPageBeginRenderListener, addPageDetachListener, addPageEndRenderListener, addPageValidateListener, attach, beginPageRender, detach, endPageRender, firePageAttached, getChangeObserver, getEngine, getLocale, getNestedComponent, getPageName, getPropertyChangeObserver, getRequestCycle, getResponseContentType, hasFormComponents, hasWidgets, removePageAttachListener, removePageBeginRenderListener, removePageDetachListener, removePageEndRenderListener, removePageValidateListener, renderPage, setChangeObserver, setHasFormComponents, setHasWidgets, setLocale, setPageName, validate
 
Methods inherited from interface org.apache.tapestry.IComponent
addAsset, addBody, addComponent, enterActiveState, finishLoad, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getClientId, getComponent, getComponents, getContainedComponent, getContainer, getEventInvoker, getExtendedId, getId, getIdPath, getListeners, getMessages, getNamespace, getPage, getSpecification, getSpecifiedId, getTemplateTagName, isRendering, peekClientId, renderBody, setBinding, setClientId, setContainedComponent, setContainer, setId, setNamespace, setPage, setTemplateTagName
 
Methods inherited from interface org.apache.tapestry.IRender
render
 
Methods inherited from interface org.apache.hivemind.LocationHolder
setLocation
 
Methods inherited from interface org.apache.hivemind.Locatable
getLocation
 

Constructor Detail

MusicArchive

public MusicArchive()
Method Detail

getPageService

@InjectObject(value="engine-service:page")
public abstract org.apache.tapestry.engine.IEngineService getPageService()

getExternalService

@InjectObject(value="engine-service:external")
public abstract org.apache.tapestry.engine.IEngineService getExternalService()

getServiceMap

public abstract org.apache.tapestry.services.ServiceMap getServiceMap()

getMcService

public abstract McService getMcService()

getArchive

public abstract MusicArchiveBean getArchive()
This property holds the bean with information about the songs in the archive.


setFeedback

public abstract void setFeedback(java.lang.String message)
Sets a message for the user. The message will be shown in bold face.

Parameters:
message - The message to show.

getImporter

public abstract Importer getImporter()
The importer object knows how to import music into the database.

Returns:
The importer object.

getPlaylistEntry

public abstract PlaylistImportProperties getPlaylistEntry()
Getter for the property that iterates over the playlist entries in the archive.

Returns:
The value of the playlistEntry property.

activateExternalPage

public void activateExternalPage(java.lang.Object[] args,
                                 org.apache.tapestry.IRequestCycle cycle)
Interpret parameters from other pages. This pages uses the CoverArtEdit page to select a cover art image. That page returns the selected cover art by calling back to this page with three parameters. The first is the playlist id (which is null in this case). The second is the selected CoverArtSearchResult. The third is the playlist name that was passed to the CoverArtEdit page. Test if this second parameter is non-null, and set the selected cover art if it is.

Specified by:
activateExternalPage in interface org.apache.tapestry.IExternalPage

pageBeginRender

public void pageBeginRender(org.apache.tapestry.event.PageEvent event)
Prepare rendering the page. Detect persistent playlists with the same name. Repeat the cover art search only once per hour.

Specified by:
pageBeginRender in interface org.apache.tapestry.event.PageBeginRenderListener

editCoverArt

public org.apache.tapestry.engine.ILink editCoverArt(org.apache.tapestry.IRequestCycle cycle)
Goto the EditCoverArt page. The playlist is not persistent, so we must specify the band name and playlist name using the 3rd and 4th argument. Guess the band name and playlist name. It is possible that this is a partial import of an already persistent playlist. Try to retrieve a persistent playlist with the same playlist name as the name in the first song entry. If this yields no result, guess the band name and playlist name from the first song entry. The first argument to the CoverArtEdit page must be null to indicate a non persistent playlist. The second argument is the name of the page the CoverArtEdit page should return to ("MusicArchive").


isExistingPlaylist

public boolean isExistingPlaylist()
Returns true if a persistent playlist with the same name as playlistEntry exists or false otherwise.

Returns:
True if a persistent playlist with the same name exists or false otherwise.

importArchive

public void importArchive(org.apache.tapestry.IRequestCycle cycle,
                          MusicArchiveBean bean)
Imports the MusicArchiveBean into the database. Errors while importing are reported. Upon successful import, the User is redirected to the ImportProgress-page, where he can select another MusicArchiveBean to import.

Parameters:
cycle - The Tapestry MVC cycle
bean - The MusicArchiveBean to import into the database

fillSongIndex

public void fillSongIndex(org.apache.tapestry.IRequestCycle cycle,
                          MusicArchiveBean bean)
Fill the song entries without a song index with a reasonable song index value.

Parameters:
cycle - The tapestry MVC cycle.
bean - The MusicArchive bean that holds the information about the songs in the archive.

fillPlaylistName

public void fillPlaylistName(org.apache.tapestry.IRequestCycle cycle,
                             MusicArchiveBean bean)
Fill the song entries without a playlist name with the name inserted into the first row. Updates the list of playlists shown in the screen.

Parameters:
cycle - The tapestry MVC cycle.
bean - The MusicArchive bean that holds the information about the songs in the archive.

fillBandName

public void fillBandName(org.apache.tapestry.IRequestCycle cycle,
                         MusicArchiveBean bean)
Fill the song entries with a band name with the name entered into the first row.

Parameters:
cycle - The tapestry MVC cycle.
bean - The MusicArchive bean that holds the information about the songs in the archive.

fillKeywords

public void fillKeywords(org.apache.tapestry.IRequestCycle cycle,
                         MusicArchiveBean bean)
Fill the song entries with keywords the same as entered into the first row.

Parameters:
cycle - The tapestry MVC cycle.
bean - The MusicArchive bean that holds the information about the songs in the archive.

playlistNameChangedListener

@EventListener(targets="playlistNameEditBox",
               events="onchange",
               autoSubmit=true)
public void playlistNameChangedListener(org.apache.tapestry.event.BrowserEvent event)

addToExistingPlaylistChangedListener

@EventListener(targets="addToExistingPlaylist",
               events="onchange",
               autoSubmit=true)
public void addToExistingPlaylistChangedListener(org.apache.tapestry.event.BrowserEvent event)


Copyright © 2010 A.J.V.. All Rights Reserved.