com.sage.orion.sdata.servlet.accpac
Class ViewResourceKind

java.lang.Object
  extended by com.sage.orion.sdata.servlet.accpac.BaseResourceKind
      extended by com.sage.orion.sdata.servlet.accpac.ViewResourceKind
All Implemented Interfaces:
ResourceKind
Direct Known Subclasses:
ServiceResourceKind

public class ViewResourceKind
extends BaseResourceKind

This class extends ViewCRUDResourceKind to handle the $service requests.


Constructor Summary
ViewResourceKind(ApplicationContext applicationContext, ResourceContext resourceContext)
          constructs an instance of the ViewResourceKind class
 
Method Summary
protected  void addFieldCalculation(ResourceField field, CalculatesFieldProperty calculation)
          Specify an alternate method for calculating the value of this field.
protected  SDataViewSet createSDataViewSet(com.sage.accpac.sm.Program program, Resource resource)
          creates an instance of the SDataViewSet that will be used by the resource kind to access the underlying views.
protected static int getDefaultFeedCount()
          Gets the default number of entries to be returned by the resource kind.
protected static int getMaxFeedCount()
          Gets the maximum number of entries to be returned by the resource kind.
protected  SDataView getView(java.lang.String id)
          Gets the View with the given viewID from the list of all views within the resource.
 SDataViewSet getViewSet()
          gets the viewSet that holds the views that this resource kind uses.
 ResourceResponse handleRequest(SDataRequest request, AsyncStatusListener listener)
          Handle all the $service requests here.
protected  void removeFieldCalculation(ResourceField field)
          Removes the given calculated field from the calculated field map.
protected  void setFilter(SDataView view, java.lang.String theFilter, boolean ascending, int order)
          set the filter, direction and index for the given view
 void shutdown()
          Shut down the resource kind.
protected  Resource subresourceOfResourceElement(Resource parentResource, ResourceElement re)
          Return the resource corresponding to the resource element, or null if there is none.
 
Methods inherited from class com.sage.orion.sdata.servlet.accpac.BaseResourceKind
getApplicationContext, getInstance, getName, getResource, getResourceContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewResourceKind

public ViewResourceKind(ApplicationContext applicationContext,
                        ResourceContext resourceContext)
constructs an instance of the ViewResourceKind class

Parameters:
applicationContext - the ApplicationContext in which the resource kind will live
resourceContext - the ResourceContext in which the resource kind will live. The implementation must be a ResourceContextImpl.
Method Detail

handleRequest

public ResourceResponse handleRequest(SDataRequest request,
                                      AsyncStatusListener listener)
Handle all the $service requests here. Non-$service requests will be delegated to the super class.

Specified by:
handleRequest in interface ResourceKind
Parameters:
request - the SDataRequest
listener - the asynchronous status listener
Returns:
the resource response.

shutdown

public void shutdown()
Description copied from interface: ResourceKind
Shut down the resource kind. Note that this may be called on a shutdown thread even though a different thread is executing ResourceKind.handleRequest(SDataRequest, AsyncStatusListener).

Specified by:
shutdown in interface ResourceKind

getViewSet

public final SDataViewSet getViewSet()
gets the viewSet that holds the views that this resource kind uses.

This returns the same view set as is returned by createSDataViewSet(Program, Resource).

Do not call this method during construction of the kind.

Returns:
the viewSet
See Also:
createSDataViewSet(Program, Resource)

createSDataViewSet

protected SDataViewSet createSDataViewSet(com.sage.accpac.sm.Program program,
                                          Resource resource)
creates an instance of the SDataViewSet that will be used by the resource kind to access the underlying views. Override this method to create an application-specific subclass of the SDataViewSet class.

This implementation does not call this method during construction of the instance. This means that the subclass can use instance variables safely, without worrying if they have been initialized yet.

Parameters:
program - the Program for the views in the set
resource - the Resource corresponding to the top of the view set (the main resource).
Returns:
an SDataViewSet. Do not return null; throw an exception if something goes wrong.
See Also:
getViewSet()

addFieldCalculation

protected void addFieldCalculation(ResourceField field,
                                   CalculatesFieldProperty calculation)
Specify an alternate method for calculating the value of this field. If one is not specified, then the field's default calculation method will be used: for view fields, the value specified in the field will be used;

Parameters:
field - a ResourceField defining the name of the field that this is a calculation for
calculation - the calculation to be applied for the given field

removeFieldCalculation

protected void removeFieldCalculation(ResourceField field)
Removes the given calculated field from the calculated field map.

Parameters:
field - a ResourceField defining the name of the field that was specified in an earlier call to addFieldCalculation(ResourceField, CalculatesFieldProperty) .

subresourceOfResourceElement

protected Resource subresourceOfResourceElement(Resource parentResource,
                                                ResourceElement re)
Return the resource corresponding to the resource element, or null if there is none.

Parameters:
parentResource - the parent resource of which this is a sub-resource. This must be null if the resource element is the top resource element of the request
re - the resource element whose resource we want
Returns:
the resource corresponding to the resource element or null if there is none

getView

protected SDataView getView(java.lang.String id)
Gets the View with the given viewID from the list of all views within the resource.

Parameters:
id - the rotoid of the view
Returns:
the View.

setFilter

protected void setFilter(SDataView view,
                         java.lang.String theFilter,
                         boolean ascending,
                         int order)
set the filter, direction and index for the given view

Parameters:
view - the view whose properties are to be set
theFilter - the filter to be set, as an Accpac filter string
ascending - true if an only if the results are to be presented in ascending order according to the index
order - the number of the index or key that defines the order
Throws:
com.sage.accpac.sm.InvalidCharacterException - if the filter contains a character that cannot be mapped to the underlying code page

getDefaultFeedCount

protected static int getDefaultFeedCount()
Gets the default number of entries to be returned by the resource kind.

Returns:
the default number of entries to be returned by the resource kind.

getMaxFeedCount

protected static int getMaxFeedCount()
Gets the maximum number of entries to be returned by the resource kind.

Returns:
the maximum number of entries to be returned by the resource kind.


Copyright © 2011 Sage Software, Inc. All rights reserved.