org.squashtest.csp.tm.domain.report
Class ReportFactory

java.lang.Object
  extended by org.squashtest.csp.tm.domain.report.ReportFactory

public final class ReportFactory
extends Object

This class is the front-end to which a service needs to talk to register or find a report category. You can basically think of it like for a repository, except that it doesn't read the ReportCategories and Reports directly, something else must load them then register them against the ReportFactory. Each ReportCategory and Report, once registered, are assigned an id. The user can query for a specific ReportCategory or Report based on its id, or get the whole list on demand. More about the id later. This singleton factory manages ReportCategories just like the ReportCategories manage the Reports : like beans. Like the bean they are, each ReportCategory and Report should be instanciated and registered only once. By default this is ensured by Spring IoC using @Component and @Resource annotations. A third party program can use the method addCategory() to register a new ReportCategory instance, however it falls under its responsibilities to ensure that each ReportCategory and Report are instanciated only once. When a ReportCategory is registered against the ReportFactory, the ReportFactory assigns it an id. As expected this id is meant to uniquely identify the said ReportCategory or Report, within the same application run. However the implementation doesn't garantee that the ReportCategories or Reports will have exactly the same id between different application run. When a ReportCategory is unregistered the id doesn't become available again.

Author:
bsiri

Method Summary
static void addCategory(ReportCategory category)
          register a new ReportCategory
 ReportCategory findCategoryById(Integer id)
          Will return the bean instance of the ReportCategory referred to with this id.
 Report findReportById(Integer reportId)
          Will return the bean instance of the Report referred to with this id.
 List<ReportCategory> getAllReportCategories()
           
static ReportFactory getInstance()
           
static void removeCategory(Integer categoryId)
          remove a ReportCategory from the list of registered ReportCategory
static void removeCategory(ReportCategory category)
          remove a ReportCategory from the list of registered ReportCategory
static void removeReport(Integer reportId)
          Will unregister a Report from its ReportCategory
static void removeReport(Report report)
          Will unregister a Report from its ReportCategory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ReportFactory getInstance()
Returns:
the runnning instance of the ReportFactory

getAllReportCategories

public List<ReportCategory> getAllReportCategories()
Returns:
the list of all registered ReportCategory

addCategory

public static void addCategory(ReportCategory category)
register a new ReportCategory

Parameters:
category - : a newly created instance of ReportCategory

removeCategory

public static void removeCategory(ReportCategory category)
remove a ReportCategory from the list of registered ReportCategory

Parameters:
category - : a previously registered ReportCategory to unregister.

removeCategory

public static void removeCategory(Integer categoryId)
remove a ReportCategory from the list of registered ReportCategory

Parameters:
categoryId - : the id of the said category.

removeReport

public static void removeReport(Report report)
Will unregister a Report from its ReportCategory

Parameters:
report - : a previously registered Report to unregister

removeReport

public static void removeReport(Integer reportId)
Will unregister a Report from its ReportCategory

Parameters:
reportId - : the id of the said Report

findCategoryById

public ReportCategory findCategoryById(Integer id)
Will return the bean instance of the ReportCategory referred to with this id.

Parameters:
id - the numeric id of the bean
Returns:
the bean if the id have been found, null otherwise.

findReportById

public Report findReportById(Integer reportId)
Will return the bean instance of the Report referred to with this id.

Parameters:
reportId - the numeric id of the bean
Returns:
the bean if the id have been found, null otherwise.


Copyright © 2010-2012 Squashtest TM, Squashtest.org. All Rights Reserved.