wt.vc.views
Class StandardViewService

java.lang.Object
  extended bywt.services.StandardManager
      extended bywt.vc.views.StandardViewService
All Implemented Interfaces:
Manager, NetFactor, Serializable, ViewService

public class StandardViewService
extends StandardManager
implements ViewService, Serializable

This implementation of ViewService caches the Views and ViewAssociations, so ViewService calls do not hit the database.

Use the newStandardViewService static factory method(s), not the StandardViewService constructor, to construct instances of this class. Instances must be constructed using the static factory(s), in order to ensure proper initialization of the instance.



Supported API: true

Extendable: true

See Also:
Serialized Form

Nested Class Summary
(package private) static class StandardViewService.ViewCacheUpdater
           
 
Field Summary
private static boolean CLASSIC_MODE
           
private static String CLASSNAME
           
private static String RESOURCE
           
private static StatementParameterFactory statementFactory
           
private static ViewCache viewCache
           
 
Fields inherited from class wt.services.StandardManager
 
Fields inherited from interface wt.services.Manager
MANAGER_SERVICE, STARTUP_AUTOMATIC, STARTUP_MANUAL, STATUS_EMERGENCY_SHUTDOWN, STATUS_EMERGENCY_SHUTTING_DOWN, STATUS_SHUTDOWN, STATUS_SHUTDOWN_ERRORS, STATUS_SHUTDOWN_FAILURE, STATUS_SHUTTING_DOWN, STATUS_STARTED, STATUS_STARTED_ERRORS, STATUS_STARTING_UP, STATUS_STARTUP_FAILURE
 
Constructor Summary
StandardViewService()
           
 
Method Summary
private static void createViewCache()
           
 View[] getAllChildren(View view)
          Returns all the children of this view.
 View[] getAllParents(View view)
          Returns all the parents of the view, if any.
 View[] getAllRootViews()
          Return all root views, that is all views with no parent views.
 View[] getAllViews()
          Return all defined views.
 View[] getChildren(View view)
          Returns the immediate children of this view.
 String getConceptualClassname()
          Deprecated.  
 View[] getEligibleViews(ViewManageable viewManageable)
          For a particular version, returns all the valid views the version may be branched into.
 View getParent(View view)
          Gets the immediate parent of this view, if one exists.
 View getView(ObjectIdentifier objId)
          Returns the view object for this view identifier, if one exists.
 View getView(String viewName)
          Returns the view object for this view name, if it exists.
private static ViewCache getViewCache()
           
 void insert(View parent, View child, View viewToInsert)
          Inserts a view between other associated views.
 boolean isChildOf(View view, View viewToCheck)
          Returns true if the viewToCheck is a child of the view, false otherwise.
 boolean isMemberOf(View view, View viewToCheck)
          Returns true if the viewToCheck is contained in the same view association as the view, false otherwise.
 boolean isParentOf(View view, View viewToCheck)
          Returns true if the viewToCheck is a parent of the view, false otherwise.
 ViewManageable newBranchForView(ViewManageable version, ObjectIdentifier viewId)
          Creates a new version from the original version and assigns it to the specified view.
 ViewManageable newBranchForView(ViewManageable version, String viewName)
          Creates a new version from the original version and assigns it to the specified view.
 ViewManageable newBranchForView(ViewManageable version, View view)
          Creates a new version from the original version and assigns it to the specified view.
static StandardViewService newStandardViewService()
          Default factory for the class.
protected  void performStartupProcess()
          The cache is affected by any change to views/view associations.
protected  void processViewDeletion(View view)
          Handles validation and cleanup associated with deleting a view.
protected  void validateNewViewAssociation(ViewAssociation vA)
          Validates that the new association does not cause recursion or a view to have more than one parent.
 
Methods inherited from class wt.services.StandardManager
emergencyShutdown, emergencyShutdownComplete, emergencyShuttingDown, getClassInfo, getManagerService, getManagerStatus, getName, getStartupType, init, initialize, initialize, isStarted, newStandardManager, newStandardManager, performEmergencyShutdownProcess, performShutdownProcess, registerEvents, setManagerService, shutdown, shutdownFailure, shutdownSuccess, shuttingDown, started, startedErrors, startingUp, startup, startupFailure, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

CLASSIC_MODE

private static final boolean CLASSIC_MODE

statementFactory

private static StatementParameterFactory statementFactory

viewCache

private static ViewCache viewCache
Constructor Detail

StandardViewService

public StandardViewService()
Method Detail

getConceptualClassname

public String getConceptualClassname()
Deprecated.  

Returns the conceptual (modeled) name for the class.

Supported API: false

Specified by:
getConceptualClassname in interface NetFactor
Overrides:
getConceptualClassname in class StandardManager
Returns:
String

newStandardViewService

public static StandardViewService newStandardViewService()
                                                  throws WTException
Default factory for the class.

Supported API: false

Returns:
StandardViewService
Throws:
WTException

newBranchForView

public ViewManageable newBranchForView(ViewManageable version,
                                       String viewName)
                                throws WTPropertyVetoException,
                                       WTException,
                                       ViewException
Creates a new version from the original version and assigns it to the specified view. The original version must not be null, and the view must be a child view of the view the original was assigned to. The classic behavior of newViewVersion is to branch from the upstream node. If we have a part with versions Rev A (Eng), Rev A.A (Mfg) (branched from Rev A (Eng)), and Rev B (Eng) (revised from Rev A (Eng)), new view version of Rev B (Eng) would result in a B.A (Mfg) branched from Rev B (Eng). This preserves all the changes from Rev A (Eng) to Rev B (Eng), but loses the changes (restructuring, etc.) made to A.A (Mfg). By setting the wt.properties entry wt.vc.views.newViewVersionClassicBehavior to false, you can change this behavior: rather than creating B.A (Mfg) from B (Eng), the new version will be created from A.A (Mfg). The result will still be B.A (Mfg), but the Mfg changes will be preserved.

Supported API: true

Specified by:
newBranchForView in interface ViewService
Parameters:
version - The version the new version is to be derived from.
viewName - The view name of the view to assign the new version to.
Returns:
ViewManageable
Throws:
WTPropertyVetoException
WTException
ViewException

newBranchForView

public ViewManageable newBranchForView(ViewManageable version,
                                       View view)
                                throws WTPropertyVetoException,
                                       WTException,
                                       ViewException
Creates a new version from the original version and assigns it to the specified view. The original version must not be null, and the view must be a child view of the view the original was assigned to. The classic behavior of newViewVersion is to branch from the upstream node. If we have a part with versions Rev A (Eng), Rev A.A (Mfg) (branched from Rev A (Eng)), and Rev B (Eng) (revised from Rev A (Eng)), new view version of Rev B (Eng) would result in a B.A (Mfg) branched from Rev B (Eng). This preserves all the changes from Rev A (Eng) to Rev B (Eng), but loses the changes (restructuring, etc.) made to A.A (Mfg). By setting the wt.properties entry wt.vc.views.newViewVersionClassicBehavior to false, you can change this behavior: rather than creating B.A (Mfg) from B (Eng), the new version will be created from A.A (Mfg). The result will still be B.A (Mfg), but the Mfg changes will be preserved.

Supported API: true

Specified by:
newBranchForView in interface ViewService
Parameters:
version - The version the new version is to be derived from.
view - The view to assign the new version to.
Returns:
ViewManageable
Throws:
WTPropertyVetoException
WTException
ViewException

newBranchForView

public ViewManageable newBranchForView(ViewManageable version,
                                       ObjectIdentifier viewId)
                                throws WTPropertyVetoException,
                                       WTException,
                                       ViewException
Creates a new version from the original version and assigns it to the specified view. The original version must not be null, and the view must be a child view of the view the original was assigned to. The classic behavior of newViewVersion is to branch from the upstream node. If we have a part with versions Rev A (Eng), Rev A.A (Mfg) (branched from Rev A (Eng)), and Rev B (Eng) (revised from Rev A (Eng)), new view version of Rev B (Eng) would result in a B.A (Mfg) branched from Rev B (Eng). This preserves all the changes from Rev A (Eng) to Rev B (Eng), but loses the changes (restructuring, etc.) made to A.A (Mfg). By setting the wt.properties entry wt.vc.views.newViewVersionClassicBehavior to false, you can change this behavior: rather than creating B.A (Mfg) from B (Eng), the new version will be created from A.A (Mfg). The result will still be B.A (Mfg), but the Mfg changes will be preserved.

Supported API: true

Specified by:
newBranchForView in interface ViewService
Parameters:
version - The version the new version will be derived from.
viewId - The Id of the view to assign the version from.
Returns:
ViewManageable
Throws:
WTPropertyVetoException
WTException
ViewException

getView

public View getView(String viewName)
             throws WTException,
                    ViewException
Returns the view object for this view name, if it exists. If no view matches this name, a ViewException is thrown.

Supported API: true

Specified by:
getView in interface ViewService
Parameters:
viewName -
Returns:
View
Throws:
WTException
ViewException

getView

public View getView(ObjectIdentifier objId)
             throws WTException,
                    ViewException
Returns the view object for this view identifier, if one exists. If no views match this identifier, a ViewException is thrown.

Supported API: true

Specified by:
getView in interface ViewService
Parameters:
objId -
Returns:
View
Throws:
WTException
ViewException

getParent

public View getParent(View view)
               throws WTException,
                      ViewException
Gets the immediate parent of this view, if one exists.

Supported API: true

Specified by:
getParent in interface ViewService
Parameters:
view - The view to get the parent of; it must exist
Returns:
View
Throws:
WTException
ViewException

getAllParents

public View[] getAllParents(View view)
                     throws WTException,
                            ViewException
Returns all the parents of the view, if any.

Supported API: true

Specified by:
getAllParents in interface ViewService
Parameters:
view - The view to get the parents of; it must exist
Returns:
View[]
Throws:
WTException
ViewException

isParentOf

public boolean isParentOf(View view,
                          View viewToCheck)
                   throws WTException,
                          ViewException
Returns true if the viewToCheck is a parent of the view, false otherwise. Both views need to exist (or a ViewException will be thrown).

Supported API: true

Specified by:
isParentOf in interface ViewService
Parameters:
view -
viewToCheck -
Returns:
boolean
Throws:
WTException
ViewException

getChildren

public View[] getChildren(View view)
                   throws WTException,
                          ViewException
Returns the immediate children of this view.

Supported API: true

Specified by:
getChildren in interface ViewService
Parameters:
view - View to get children of; it must exist.
Returns:
View[]
Throws:
WTException
ViewException

getAllChildren

public View[] getAllChildren(View view)
                      throws WTException,
                             ViewException
Returns all the children of this view.

Supported API: true

Specified by:
getAllChildren in interface ViewService
Parameters:
view - View to get all children of; it must exist.
Returns:
View[]
Throws:
WTException
ViewException

isChildOf

public boolean isChildOf(View view,
                         View viewToCheck)
                  throws WTException,
                         ViewException
Returns true if the viewToCheck is a child of the view, false otherwise. Both views need to exist (or a ViewException will be thrown).

Supported API: true

Specified by:
isChildOf in interface ViewService
Parameters:
view -
viewToCheck -
Returns:
boolean
Throws:
WTException
ViewException

isMemberOf

public boolean isMemberOf(View view,
                          View viewToCheck)
                   throws WTException,
                          ViewException
Returns true if the viewToCheck is contained in the same view association as the view, false otherwise. Both views need to exist (or a ViewException will be thrown).

Supported API: true

Specified by:
isMemberOf in interface ViewService
Parameters:
view -
viewToCheck -
Returns:
boolean
Throws:
WTException
ViewException

getAllViews

public View[] getAllViews()
                   throws WTException,
                          ViewException
Return all defined views.

Supported API: true

Specified by:
getAllViews in interface ViewService
Returns:
View[]
Throws:
WTException
ViewException

getAllRootViews

public View[] getAllRootViews()
                       throws WTException,
                              ViewException
Return all root views, that is all views with no parent views.

Supported API: true

Specified by:
getAllRootViews in interface ViewService
Returns:
View[]
Throws:
WTException
ViewException

insert

public void insert(View parent,
                   View child,
                   View viewToInsert)
            throws WTException,
                   ViewException
Inserts a view between other associated views. If the child is not null, the child must be a child of the parent; the viewToInsert is inserted between the parent and the child. If the child is null, the viewToInsert becomes a child of the parent and all the parent's children become children of the viewToInsert.

Supported API: true

Specified by:
insert in interface ViewService
Parameters:
parent - The parent view in a ViewAssociation.
child - A child of the parent. May be null, in which case the viewToInsert is inserted above all the parent's children.
viewToInsert - The view to insert.
Throws:
WTException
ViewException

getEligibleViews

public View[] getEligibleViews(ViewManageable viewManageable)
                        throws WTException,
                               ViewException
For a particular version, returns all the valid views the version may be branched into. If the version is view-independent (or is assigned to a leaf view), returns an empty array.

Supported API: true

Specified by:
getEligibleViews in interface ViewService
Parameters:
viewManageable -
Returns:
View[]
Throws:
WTException
ViewException

getViewCache

private static ViewCache getViewCache()

createViewCache

private static void createViewCache()

validateNewViewAssociation

protected void validateNewViewAssociation(ViewAssociation vA)
                                   throws WTException,
                                          ViewException
Validates that the new association does not cause recursion or a view to have more than one parent.

Throws:
WTException
ViewException

processViewDeletion

protected void processViewDeletion(View view)
                            throws WTException
Handles validation and cleanup associated with deleting a view.

Throws:
WTException

performStartupProcess

protected void performStartupProcess()
                              throws ManagerException
The cache is affected by any change to views/view associations. This is a single-server mechanism to chuck the cache when changes to these objects are made.

Overrides:
performStartupProcess in class StandardManager
Throws:
ManagerException