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

java.lang.Object
  extended by com.sage.orion.sdata.servlet.accpac.SDataViewSet

public class SDataViewSet
extends java.lang.Object

The SDataViewSet class provides the collection of related SDataViews. All of the SDataViews in a set are related to each other. Keeping track of the views as a collection allows us to keep track of neighbor views etc.

Subclass this class to provide an application-specific version. This allows you to override the createView(String, Resource) method so you can create instances of application-specific subclasses of the contained SDataView class. You may also override the createSchemaChange() method if you need to include additional attribute view notifications

For example:

 class MySDataViewSet extends SDataViewSet
 {
    protected SDataView createView(String rid, Resource resource)
    {
       return "MY9876".equalsIgnoreCase(rid) ? new My9876View(this, rid, resource) : new SDataView(this, rid, resource);
    }
 }
 
You may also override the onDispose() method to perform any clean-up required when the class is disposed of.

If the subclass includes public methods use checkUndisposed() and ensureViewsLoaded() to check the state of the superclass.


Constructor Summary
protected SDataViewSet(com.sage.accpac.sm.Program program, Resource resource)
          creates a new instance of the SDataViewSet class.
 
Method Summary
protected  void checkUndisposed()
          checks that dispose() has not yet been called, throwing a suitable exception if it has.
protected  SchemaChange createSchemaChange()
          creates an instance of the SchemaChange class.
protected  SDataView createView(java.lang.String rotoid, Resource resource)
          creates an instance of the given SDataView.
protected  void dispose()
          dispose of anything now that the instance is no longer needed.
protected  void ensureViewsLoaded()
          Ensure that views have actually been loaded, allowing for delayed loading.
 SDataView get(java.lang.String id)
          Gets the SDataView with the given roto id from the list of all views.
 boolean getMaintainRecordNumbers()
          gets whether the views in the set should consider maintaining record numbers.
 com.sage.accpac.sm.Program getProgram()
          gets the Program of the set.
 Resource getResource(SDataView view)
          returns the Resource corresponding to the SDataView given.
 SDataView getView(Resource res)
          returns the SDataView corresponding to the Resource given.
 java.util.Set<SDataView> getViews()
          returns the views in the set.
protected  void onDispose()
          override this method to perform any cleanup that is required during the dispose() operation.
 void setMaintainRecordNumbers(boolean maintainRecordNumbers)
          sets the value to be returned by getMaintainRecordNumbers().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SDataViewSet

protected SDataViewSet(com.sage.accpac.sm.Program program,
                       Resource resource)
creates a new instance of the SDataViewSet class.

Call dispose() when finished.

Parameters:
program - the Program supporting the ViewSet
resource - the Resource at the top of the ViewSet
Method Detail

onDispose

protected void onDispose()
override this method to perform any cleanup that is required during the dispose() operation. This will be called before the views themselves are disposed. Even if dispose is called more than once this will only be called on the first occasion.


dispose

protected final void dispose()
dispose of anything now that the instance is no longer needed. This calls onDispose() before disposing of the views.

Do not use the instance after calling this.


getProgram

public final com.sage.accpac.sm.Program getProgram()
gets the Program of the set. This is the one that was provided when the set was constructed.

Returns:
the Program that was provided to the constructor

getView

public final SDataView getView(Resource res)
returns the SDataView corresponding to the Resource given.

Parameters:
res - the Resource
Returns:
the SDataView corresponding to the resource

getViews

public java.util.Set<SDataView> getViews()
returns the views in the set. You may override this to add in any additional views that you regard as part of this set, that you are maintaining in your subclass. They will be included in some operations but not all. In particular:

Returns:
an unmodifiable Set containing the views in this set

getResource

public final Resource getResource(SDataView view)
returns the Resource corresponding to the SDataView given.

Parameters:
view - the SDataView whose resource is required.
Returns:
the Resource corresponding to the SDataView given.

get

public final SDataView get(java.lang.String id)
Gets the SDataView with the given roto id from the list of all views.

This operates off the list returned by getViews() and so can find views being maintained by the subclass.

Parameters:
id - the roto id of the view
Returns:
the view, or null if there is no such view

ensureViewsLoaded

protected final void ensureViewsLoaded()
Ensure that views have actually been loaded, allowing for delayed loading. Subclasses will want to call this unless they have some other way of knowing that the classes have been loaded.


createView

protected SDataView createView(java.lang.String rotoid,
                               Resource resource)
creates an instance of the given SDataView. Override this method to create subclasses with application-specific behavior.

Parameters:
rotoid - the roto ID of the view to be created, in upper-case
resource - the resource that corresponds to it
Returns:
the newly created view. Do not return null; throw an exception on failure.

createSchemaChange

protected SchemaChange createSchemaChange()
creates an instance of the SchemaChange class. That will be used to accumulate changes to the attributes of the set during a set of view operations.

Override this method to provide an application-specific subclass.

Returns:
the newly created SchemaChange. Do not return null; throw an exception on failure.

checkUndisposed

protected final void checkUndisposed()
checks that dispose() has not yet been called, throwing a suitable exception if it has. This should be called by all public methods, even in subclasses. However it is not needed for protected methods.

Throws:
java.lang.NullPointerException - if dispose has already been called

getMaintainRecordNumbers

public final boolean getMaintainRecordNumbers()
gets whether the views in the set should consider maintaining record numbers.

This is an immutable property of this instance of the class.

Returns:
true if, and only if, the views in the view set should consider maintaining record numbers

setMaintainRecordNumbers

public final void setMaintainRecordNumbers(boolean maintainRecordNumbers)
sets the value to be returned by getMaintainRecordNumbers().

If called, this must be called before getMaintainRecordNumbers() can be called.

If not called, false will be assumed.

Parameters:
maintainRecordNumbers - the value to be returned by getMaintainRecordNumbers().


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