pl.edu.agh.cast.importer.base.template
Class ImportTemplateManager

java.lang.Object
  extended by pl.edu.agh.cast.importer.base.template.ImportTemplateManager

public class ImportTemplateManager
extends Object

A class which manages import templates.

Author:
AGH CAST Team

Constructor Summary
  ImportTemplateManager()
          Default constructor.
protected ImportTemplateManager(ITemplateProvider provider)
          Constructor (for test purpose).
 
Method Summary
 void addTemplateToGroup(ImportTemplateGroup group, IImportTemplate template)
          Adds a given template to a given group.
protected  ImportTemplateGroup createNewDefaultGroup()
           
 IImportTemplate createTemplateBasedOnImportProcess(ImportProcess process, String name, String description)
          Creates new import template based on given ImportProcess object with given name and description.
 void exportTemplateToFile(UUID templateId, File dest)
          Exports a given template to specified file using defined ITemplateProvider.
 Collection<ImportTemplateGroup> getAllTemplateGroups()
           
 IImportTemplate getTemplate(UUID templateId)
          Gets template with specified id.
 IImportTemplate importTemplateFromFile(File file, IMsgBoxHelper msgBoxHelper)
          Imports template from a given file using defined ITemplateProvider.
 void reload()
          This method clears cached data and rebuilds all templates and groups based on written data.
 void removeTemplate(UUID templateId)
          Removed a template with given id.
 void removeTemplateFromGroup(ImportTemplateGroup group, UUID templateId)
          Removes template from a given group.
 void removeTemplateGroup(UUID groupId)
          Removes template group with given id.
protected  ImportTemplateGroup retriveDefaultGroup()
           
 void saveTemplate(IImportTemplate template, ImportTemplateGroup group)
          Adds newly created template to default template group.
 void saveTemplateGroup(ImportTemplateGroup group)
          Saves template group.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImportTemplateManager

public ImportTemplateManager()
Default constructor.


ImportTemplateManager

protected ImportTemplateManager(ITemplateProvider provider)
                         throws TemplateException
Constructor (for test purpose).

Parameters:
provider - custom template provider
Throws:
TemplateException
Method Detail

saveTemplate

public void saveTemplate(IImportTemplate template,
                         ImportTemplateGroup group)
                  throws TemplateException
Adds newly created template to default template group.

Parameters:
template - a new template to add
group - group which a new template will belong to; if null a new template will be added to default group
Throws:
TemplateException

saveTemplateGroup

public void saveTemplateGroup(ImportTemplateGroup group)
                       throws TemplateException
Saves template group. If group exists before it will be overridden.

Parameters:
group - group to save
Throws:
TemplateException

removeTemplate

public void removeTemplate(UUID templateId)
                    throws TemplateException
Removed a template with given id.

Parameters:
templateId - template id to remove
Throws:
TemplateException

removeTemplateGroup

public void removeTemplateGroup(UUID groupId)
                         throws TemplateException
Removes template group with given id. If groups does not exist an IllegalArgumentException is thrown. If group is not empty an TemplateException is thrown.

Parameters:
groupId - id of group to be removed
Throws:
TemplateException - when given group is not empty

addTemplateToGroup

public void addTemplateToGroup(ImportTemplateGroup group,
                               IImportTemplate template)
                        throws TemplateException
Adds a given template to a given group.

Parameters:
group - a group
template - template to add
Throws:
TemplateException

removeTemplateFromGroup

public void removeTemplateFromGroup(ImportTemplateGroup group,
                                    UUID templateId)
                             throws TemplateException
Removes template from a given group.

Parameters:
group - a group
templateId - id of template to be removed from the group
Throws:
TemplateException

getTemplate

public IImportTemplate getTemplate(UUID templateId)
Gets template with specified id.

Parameters:
templateId - template id
Returns:
template or null if template with specified id does not exist

getAllTemplateGroups

public Collection<ImportTemplateGroup> getAllTemplateGroups()

importTemplateFromFile

public IImportTemplate importTemplateFromFile(File file,
                                              IMsgBoxHelper msgBoxHelper)
                                       throws TemplateException
Imports template from a given file using defined ITemplateProvider. If imported templates already exists method returns without import action.

Parameters:
file - file from which a new template will be imported
msgBoxHelper - message box helper which is used to show messages to user
Returns:
imported template or null if user cancelled the operation
Throws:
TemplateException

exportTemplateToFile

public void exportTemplateToFile(UUID templateId,
                                 File dest)
                          throws TemplateException
Exports a given template to specified file using defined ITemplateProvider.

Parameters:
templateId - id of template to export
dest - file where a template will be stored
Throws:
TemplateException - when an error occurs during saving template in external file

createTemplateBasedOnImportProcess

public IImportTemplate createTemplateBasedOnImportProcess(ImportProcess process,
                                                          String name,
                                                          String description)
                                                   throws TemplateException
Creates new import template based on given ImportProcess object with given name and description.

Parameters:
process - import process which is base for new template
name - template name
description - template description
Returns:
import template based on given import process
Throws:
TemplateException - when import process is not complete

reload

public void reload()
            throws TemplateException
This method clears cached data and rebuilds all templates and groups based on written data.

Throws:
TemplateException

retriveDefaultGroup

protected ImportTemplateGroup retriveDefaultGroup()
                                           throws TemplateException
Throws:
TemplateException

createNewDefaultGroup

protected ImportTemplateGroup createNewDefaultGroup()


Copyright © 2007-2009 IISG AGH-UST Krakow, Poland. All Rights Reserved.