edu.northwestern.at.wordhoard.swing.calculator.modelutils
Class WorkUtils

java.lang.Object
  extended by edu.northwestern.at.wordhoard.swing.calculator.modelutils.WorkUtils

public class WorkUtils
extends java.lang.Object

Work and work part utilities.


Field Summary
protected static boolean workPartMapsAvailable
          True if work part maps are created.
 
Constructor Summary
protected WorkUtils()
          Don't allow instantiation but do allow overrides.
 
Method Summary
static void createWorkPartMaps(java.util.Collection workParts)
          Create work part Id to work part tag maps.
static java.util.Collection expandWorkParts(WorkPart[] workParts)
          Convert mixed list of works and work parts to lowest level work parts.
static WorkPart[] expandWorkPartsToArray(WorkPart[] workParts)
          Convert mixed list of works and work parts to lowest level work parts.
static java.util.Collection getAncestors(WorkPart workPart)
          Get ancestor work parts.
static WorkPart[] getUniqueWorkParts(java.util.List workParts)
          Get list of unique work parts in a listr of work parts.
static WorkPart[] getUniqueWorkParts(java.util.Map workPartsMap)
          Get list of unique work parts in a map of work parts.
static WorkPart[] getUniqueWorkParts(WorkPart[] workParts)
          Get list of unique work parts in an array of work parts.
static WorkPart[] getUniqueWorkParts(WorkPart[] workParts1, WorkPart[] workParts2)
          Get list of unique work parts from two work part arrays.
static Work getWork(java.lang.String title)
          Get a work by full title.
static Work getWorkById(java.lang.Long workId)
          Get a work by Id.
static Work getWorkByShortTitle(java.lang.String title)
          Get a work by short title.
static Work getWorkByTag(java.lang.String tag)
          Get a work by tag.
static java.lang.Long getWorkIDByTag(java.lang.String tag)
          Get a work ID by tag.
static WorkPart getWorkPartByTag(java.lang.String tag)
          Gets a work part by tag.
static WorkPart[] getWorkParts()
          Get array of all work parts for all works.
static WorkPart[] getWorkParts(Work work)
          Get array of all work parts for a work.
static WorkPart[] getWorkPartsById(java.lang.Long[] workPartIds)
          Get array of work parts for a list of work part IDs.
static WorkPart[] getWorkPartsByTag(java.util.Collection workPartTags)
          Get array of work parts for a list of work part tags.
static WorkPart[] getWorkPartsByTag(java.util.Collection workPartTags, org.hibernate.Session session)
          Get array of work parts for a list of work part tags.
static WorkPart[] getWorkPartsByTag(java.lang.String[] workPartTags)
          Get array of work parts for a list of work part tags.
static java.lang.String getWorkPartTagById(java.lang.Long workPartId)
          Get work part tag for a work part ID.
static java.lang.String[] getWorkPartTagsById(java.util.Collection workPartIds)
          Get array of work part tags for a list of work part IDs.
static Work[] getWorks()
          Get array of all available works.
static Work[] getWorksByTag(java.util.Collection workTags)
          Get array of works for a list of work tags.
static java.lang.String[] getWorkTagsById(java.util.Collection workIds)
          Get array of work tags for a list of work part IDs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

workPartMapsAvailable

protected static boolean workPartMapsAvailable
True if work part maps are created.

Constructor Detail

WorkUtils

protected WorkUtils()
Don't allow instantiation but do allow overrides.

Method Detail

createWorkPartMaps

public static void createWorkPartMaps(java.util.Collection workParts)
Create work part Id to work part tag maps.


getWork

public static Work getWork(java.lang.String title)
Get a work by full title.

Parameters:
title - The full title of the work to fetch.
Returns:
The work with the requested full title, or null if not found. If more than one work has the title, only the first is returned.

getWorkByShortTitle

public static Work getWorkByShortTitle(java.lang.String title)
Get a work by short title.

Parameters:
title - The short title of the work to fetch.
Returns:
The work with the requested short title, or null if not found. If more than one work has the title, only the first is returned.

getWorkByTag

public static Work getWorkByTag(java.lang.String tag)
Get a work by tag.

Parameters:
tag - The tag of the work to fetch.
Returns:
The work with the requested tag, or null if not found.

getWorkIDByTag

public static java.lang.Long getWorkIDByTag(java.lang.String tag)
Get a work ID by tag.

Parameters:
tag - The tag of the work to fetch.
Returns:
The work ID of the work with the requested tag. Null if not found.

getWorkPartByTag

public static WorkPart getWorkPartByTag(java.lang.String tag)
Gets a work part by tag.

Parameters:
tag - The tag of the work part to fetch.
Returns:
The work part with the specified tag, or null if not found.

getWorkById

public static Work getWorkById(java.lang.Long workId)
Get a work by Id.

Parameters:
workId - The Id of the work to fetch.
Returns:
The work with the requested workId, or null if not found.

getWorks

public static Work[] getWorks()
Get array of all available works.

Returns:
Array of Work for all available works.

getWorkParts

public static WorkPart[] getWorkParts(Work work)
Get array of all work parts for a work.

Parameters:
work - The work.
Returns:
Array of WorkPart for all work parts in work.

The returned array does not include the work part entry for the work itself.


getWorkPartsById

public static WorkPart[] getWorkPartsById(java.lang.Long[] workPartIds)
Get array of work parts for a list of work part IDs.

Parameters:
workPartIds - The work part Ids.
Returns:
Array of WorkPart for the work parts.

getWorkTagsById

public static java.lang.String[] getWorkTagsById(java.util.Collection workIds)
Get array of work tags for a list of work part IDs.

Parameters:
workIds - The work Ids.
Returns:
Array of work tags as strings .

getWorkPartTagsById

public static java.lang.String[] getWorkPartTagsById(java.util.Collection workPartIds)
Get array of work part tags for a list of work part IDs.

Parameters:
workPartIds - The work part Ids.
Returns:
Array of work part tags as strings .

getWorkPartsByTag

public static WorkPart[] getWorkPartsByTag(java.util.Collection workPartTags,
                                           org.hibernate.Session session)
Get array of work parts for a list of work part tags.

Parameters:
workPartTags - The work part tags.
session - Persistence manager session.
Returns:
Array of WorkPart for the work parts.

getWorkPartsByTag

public static WorkPart[] getWorkPartsByTag(java.util.Collection workPartTags)
Get array of work parts for a list of work part tags.

Parameters:
workPartTags - The work part tags.
Returns:
Array of WorkPart for the work parts.

getWorksByTag

public static Work[] getWorksByTag(java.util.Collection workTags)
Get array of works for a list of work tags.

Parameters:
workTags - The work tags.
Returns:
Array of Work for the works.

getWorkPartTagById

public static java.lang.String getWorkPartTagById(java.lang.Long workPartId)
Get work part tag for a work part ID.

Parameters:
workPartId - The work part Id.
Returns:
Work part tag as string .

getWorkPartsByTag

public static WorkPart[] getWorkPartsByTag(java.lang.String[] workPartTags)
Get array of work parts for a list of work part tags.

Parameters:
workPartTags - The work part tags.
Returns:
Array of WorkPart for the work parts.

getWorkParts

public static WorkPart[] getWorkParts()
Get array of all work parts for all works.

Returns:
Array of WorkPart for all work parts.

getUniqueWorkParts

public static WorkPart[] getUniqueWorkParts(java.util.Map workPartsMap)
Get list of unique work parts in a map of work parts.

Parameters:
workPartsMap - Map with work part ID of work parts.
Returns:
Array of WorkPart eliminating duplicate work parts and parts which are descendants of other parts.

getUniqueWorkParts

public static WorkPart[] getUniqueWorkParts(WorkPart[] workParts)
Get list of unique work parts in an array of work parts.

Parameters:
workParts - Array of work parts.
Returns:
Array of WorkPart eliminating duplicate work parts and parts which are descendants of other parts.

getUniqueWorkParts

public static WorkPart[] getUniqueWorkParts(java.util.List workParts)
Get list of unique work parts in a listr of work parts.

Parameters:
workParts - List of work parts.
Returns:
Array of WorkPart eliminating duplicate work parts and parts which are descendants of other parts.

getUniqueWorkParts

public static WorkPart[] getUniqueWorkParts(WorkPart[] workParts1,
                                            WorkPart[] workParts2)
Get list of unique work parts from two work part arrays.

Parameters:
workParts1 - First array of work parts.
workParts2 - Second array of work parts.
Returns:
Array of WorkPart for all work parts in workParts1 and workParts2 eliminating duplicate work parts.

getAncestors

public static java.util.Collection getAncestors(WorkPart workPart)
Get ancestor work parts.

Returns:
Collection of ancestor work parts. Empty (not null) if work part is a work.

expandWorkParts

public static java.util.Collection expandWorkParts(WorkPart[] workParts)
Convert mixed list of works and work parts to lowest level work parts.

Parameters:
workParts - The mixed works and work parts.
Returns:
The lowest level work parts as a collection. Only those containing text are returned.

expandWorkPartsToArray

public static WorkPart[] expandWorkPartsToArray(WorkPart[] workParts)
Convert mixed list of works and work parts to lowest level work parts.

Parameters:
workParts - The mixed works and work parts.
Returns:
The lowest level work parts as an array. Only those containing text are returned.