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

java.lang.Object
  extended by com.sage.accpac.sm.view.AbstractGettableByField
      extended by com.sage.accpac.sm.view.AbstractSettableByField
          extended by com.sage.accpac.sm.View
              extended by com.sage.orion.sdata.servlet.accpac.SDataView
All Implemented Interfaces:
com.sage.accpac.sm.HasDispose, com.sage.accpac.sm.view.Composable, com.sage.accpac.sm.view.GettableByField, com.sage.accpac.sm.view.HasFieldAttributesByField, com.sage.accpac.sm.view.HasOrder, com.sage.accpac.sm.view.HasRevisionListSupport, com.sage.accpac.sm.view.HasViewAttributes, com.sage.accpac.sm.view.HasViewFieldByField, com.sage.accpac.sm.view.IView, com.sage.accpac.sm.view.Modifiable, com.sage.accpac.sm.view.Navigable, com.sage.accpac.sm.view.OrderedModifiable, com.sage.accpac.sm.view.OrderedReadable, com.sage.accpac.sm.view.Processable, com.sage.accpac.sm.view.Readable, com.sage.accpac.sm.view.SettableByField

public class SDataView
extends com.sage.accpac.sm.View

provides the SData appearance of a View, adding SData semantics

The vision is that this will be enhanced, overriding View functions as required. If you feel the need to export the Resource with a getter then STOP and think why you are exporting it. Almost certainly you would do better to override one of the View methods. For example at some point we need to override the ability to get a field by name so that the fields are known by their SData names, not their View names


Nested Class Summary
 
Nested classes/interfaces inherited from class com.sage.accpac.sm.View
com.sage.accpac.sm.View.FilterOrigin, com.sage.accpac.sm.View.OpenDirectives, com.sage.accpac.sm.View.OpenModes, com.sage.accpac.sm.View.Protocol, com.sage.accpac.sm.View.RecordGenerateMode, com.sage.accpac.sm.View.ReferentialIntegrity, com.sage.accpac.sm.View.RotoType, com.sage.accpac.sm.View.Security, com.sage.accpac.sm.View.SystemAccess
 
Constructor Summary
  SDataView(com.sage.accpac.sm.Program program, java.lang.String rotoid, Resource resource)
          Constructs an SDataView object for a Program
protected SDataView(SDataViewSet set, java.lang.String rotoid, Resource resource)
          Constructs an SDataView object for a Set.
 
Method Summary
protected  SDataViewField createField(int index, int id, java.lang.String name)
          
protected  VirtualField createVirtualField(ResourceVirtualField resourceField)
          creates an instance of the VirtualField class corresponding to the given ResourceField.
 void delete()
           
 void dispose()
           
 void emptyKeyFieldsForNavigation()
          Empties the key field(s) according to the current key order, in preparation for subsequent navigation.
 java.lang.Object getBySDataPropertyName(java.lang.String name)
          gets the value of the given field.
 java.lang.String getDefiningKey()
          Get the non-header keys of the view as a single String according to the Accpac method of splitting multi-segment keys and encoding them
 java.lang.String getDescriptor()
          returns a description of the record that can be used as an SData record descriptor
 java.util.Set<java.lang.String> getFieldNamesOfFieldIDs(java.util.Set<java.lang.Integer> deltaFields)
          returns the names of the fields whose IDs are provided
 java.lang.String getKey()
          Get the primary key of the view as a single String according to the Accpac method of splitting multi-segment keys and encoding them
 boolean getMaintainRecordNumbers()
          Indicates whether this view instance maintains record number.
 java.lang.String getName()
          returns the name by which the resource is being known
 boolean getOptionalFieldsAreCurrentlyReadOnly()
          specifies whether or not the custom (i.e.
 int getRecordNumber()
          Returns the record number of the current record, if this view instance maintains record numbers.
 RecordNumberResourceField getRecordNumberResourceField()
          Returns the resource of the record number field.
 java.lang.String getRecordTitle()
          returns a description of the record that can be used as an SData item title
 Resource getResource()
          Returns the Resource corresponding to the View
 SDataViewSet getSet()
          gets the SDataViewSet to which this SDataView belongs.
 SDataViewField getViewFieldByName(java.lang.String name)
          returns the SDataViewField identified by the given SData property name
 VirtualField getVirtualField(java.lang.String name)
          gets the named VirtualField.
 boolean goBottom()
           
 boolean goNext()
           
 boolean goPrev()
           
 boolean goTop()
           
 boolean goToRecordNumber(int targetRecordNumber)
          Move to the record identified by the record number.
protected  boolean hasNonOptionalField(java.lang.String sdataName)
          returns whether or not the view has a field or child resource with the given name, other than an optional field
 void insert()
           
 boolean putBySDataPropertyName(java.lang.String name, java.lang.Object value, boolean verify)
          put the given value, including taking care of checking results , converting types, allowing for some exceptions etc.
 boolean putBySDataPropertyName(java.lang.String name, java.lang.Object value, boolean verify, boolean viewFields, boolean optionalFields, SDataDiagnoses diagnoses, com.sage.orion.sdata.servlet.accpac.ViewSetReturnDeltaChanges deltaChanges)
          put the value specified to the field specified by the sdata field name, possibly verifying and possibly only if it is the correct implementation of field.
 void putDefiningKey(java.lang.String key)
          Put the defining key to the corresponding view fields.
 boolean putKey(int key, java.lang.String[] segments, boolean verify)
          puts the given values into the key fields.
 boolean read(boolean lockRecord)
           
 boolean readKeyedRecord(java.lang.Object[] values)
          reads the record specified by the given key values.
 void recordClear()
           
 void recordGenerate(com.sage.accpac.sm.View.RecordGenerateMode mode)
           
 java.lang.String toString()
           
 void update()
           
 
Methods inherited from class com.sage.accpac.sm.View
addNotificationListener, autocompose, blkGet, blkPut, browse, cancel, compose, confirmNativeDBLink, createTables, createTables, doBrowse, dropTables, dropTables, filterDelete, filterSelect, finalize, getCombinedFilterCount, getComposites, getDefiningKeyValues, getDefiningKeyValues, getDescription, getDirty, getETag, getExists, getField, getField, getFieldAttributes, getFieldAttributes, getFields, getFilterCount, getGettableByIndex, getGettableByName, getHasUnpostedRevisions, getInstanceNoncascading, getInstanceNonheritable, getInstancePrefetch, getInstanceProtocol, getInstanceRawPut, getInstanceReadOnly, getInstanceUnrevisioned, getInstanceUnValidated, getIProgram, getKey, getKeys, getOrder, getParent, getProgram, getReferentialIntegrity, getSecuritySettings, getSettableByIndex, getSettableByName, getSystemAccess, getTemplateDate, getTemplateVersion, getType, getViewFields, getViewID, getViewKeys, getViewSecurity, goToQueryRecord, isNotification, post, post, process, process, process, putDefiningKeyValues, putDefiningKeyValues, read, refreshSchema, removeNotificationListener, revisionCancel, revisionExists, revisionPost, revisionUnposted, setETag, setOrder, setReferentialIntegrity, setSystemAccess, shutdownExecutor, supportsETag, tableEmpty, unlock, verify
 
Methods inherited from class com.sage.accpac.sm.view.AbstractSettableByField
set, set, set, set, setBigDecimal, setBigDecimal, setBigDecimal, setBigDecimal, setBoolean, setBoolean, setBoolean, setBoolean, setBytes, setBytes, setBytes, setBytes, setDate, setDate, setDate, setDate, setDouble, setDouble, setDouble, setDouble, setInt, setInt, setInt, setInt, setShort, setShort, setShort, setShort, setString, setString, setString, setString, setTime, setTime, setTime, setTime
 
Methods inherited from class com.sage.accpac.sm.view.AbstractGettableByField
get, get, getBigDecimal, getBigDecimal, getBoolean, getBoolean, getBytes, getBytes, getDate, getDate, getDouble, getDouble, getInt, getInt, getShort, getShort, getString, getString, getTime, getTime
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.sage.accpac.sm.view.SettableByField
set, set, set, set, setBigDecimal, setBigDecimal, setBigDecimal, setBigDecimal, setBoolean, setBoolean, setBoolean, setBoolean, setBytes, setBytes, setBytes, setBytes, setDate, setDate, setDate, setDate, setDouble, setDouble, setDouble, setDouble, setInt, setInt, setInt, setInt, setShort, setShort, setShort, setShort, setString, setString, setString, setString, setTime, setTime, setTime, setTime
 
Methods inherited from interface com.sage.accpac.sm.view.GettableByField
get, get, getBigDecimal, getBigDecimal, getBoolean, getBoolean, getBytes, getBytes, getDate, getDate, getDouble, getDouble, getInt, getInt, getShort, getShort, getString, getString, getTime, getTime
 

Constructor Detail

SDataView

public SDataView(com.sage.accpac.sm.Program program,
                 java.lang.String rotoid,
                 Resource resource)
Constructs an SDataView object for a Program

Parameters:
program - the Program for which the View is opened
rotoid - the roto ID of the View to be opened
resource - the Resource that corresponds to the View

SDataView

protected SDataView(SDataViewSet set,
                    java.lang.String rotoid,
                    Resource resource)
Constructs an SDataView object for a Set.

Parameters:
set - the SDataViewSet for which the View is opened
rotoid - the roto ID of the View to be opened
resource - the Resource that corresponds to the View
Method Detail

getSet

public SDataViewSet getSet()
gets the SDataViewSet to which this SDataView belongs.

Each SDataView belongs to one and only one SDataViewSet, which is fixed for the whole time it exists.

Returns:
the SDataViewSet to which this SDataView belongs.

getResource

public final Resource getResource()
Returns the Resource corresponding to the View

Hopefully we will be able to make this obsolete

Returns:
the Resource corresponding to the View, which may be null

getRecordTitle

public java.lang.String getRecordTitle()
returns a description of the record that can be used as an SData item title

Returns:
a non-null String that is descriptive of the current record

getDescriptor

public java.lang.String getDescriptor()
returns a description of the record that can be used as an SData record descriptor

Returns:
a non-null String that is descriptive of the current record

dispose

public void dispose()
Specified by:
dispose in interface com.sage.accpac.sm.HasDispose
Specified by:
dispose in interface com.sage.accpac.sm.view.IView
Overrides:
dispose in class com.sage.accpac.sm.View

getDefiningKey

public java.lang.String getDefiningKey()
Get the non-header keys of the view as a single String according to the Accpac method of splitting multi-segment keys and encoding them

Returns:
the defining part of the key

getKey

public java.lang.String getKey()
Get the primary key of the view as a single String according to the Accpac method of splitting multi-segment keys and encoding them

Returns:
the primary key of the view as a string

putDefiningKey

public void putDefiningKey(java.lang.String key)
Put the defining key to the corresponding view fields. This method expects a single String representation of the entire key to be passed in, but will put only non-header key values to the view.

Parameters:
key - a single String representation of the entire key

getName

public java.lang.String getName()
returns the name by which the resource is being known

Returns:
the name by which the resource is being known

getOptionalFieldsAreCurrentlyReadOnly

public boolean getOptionalFieldsAreCurrentlyReadOnly()
specifies whether or not the custom (i.e. optional) fields are currently read-only

Override this to modify behavior for your view.

This will be called when building a schema during a stateful single resource request, including:

Under these circumstances it is reasonable to return true, indicating that at this current moment in the stateful conversation the custom properties are read-only but a later stateful operation might make them editable.

If the request specifies that a schema change is to be returned (as opposed to a full schema) this may be called once before the changes and once afterwards. Alternatively the system may remember the value from the last operation. Do not assume either pattern.

This is not called during stateless schema requests

Returns:
true if the custom fields are currently read-only.

putKey

public boolean putKey(int key,
                      java.lang.String[] segments,
                      boolean verify)
puts the given values into the key fields.

The values are put into the key fields according to the specified key, which need not be the primary or even a defining key.

Parameters:
key - the index/order/key to use
segments - the values to put, all in string form
verify - whether or not to perform verify when putting. Remember that even if you specify false the code is permitted to ignore you.
Returns:
whether or not the attempt was successful

createField

protected SDataViewField createField(int index,
                                     int id,
                                     java.lang.String name)

This version returns an SDataViewField subclass. If you override this method the ViewField you return should also subclass SDataViewField.

Overrides:
createField in class com.sage.accpac.sm.View

createVirtualField

protected VirtualField createVirtualField(ResourceVirtualField resourceField)
creates an instance of the VirtualField class corresponding to the given ResourceField. This is called to create the value that will be returned by getVirtualField(String). Override this method to create your application-specific implementation.

Parameters:
resourceField - the ResourceVirtualField that the created instance implements
Returns:
a VirtualField that implements the given ResourceField

getVirtualField

public VirtualField getVirtualField(java.lang.String name)
gets the named VirtualField.

Parameters:
name - the name of the field
Returns:
a non-null VirtualField that implements the named virtual field
Throws:
java.lang.IllegalArgumentException - if there is no virtual field with that name

getBySDataPropertyName

public java.lang.Object getBySDataPropertyName(java.lang.String name)
gets the value of the given field.

The field may be a field in the underlying view, an optional field, or a virtual field.

Parameters:
name - the SData name of the field
Returns:
the value of the field.
Throws:
MalformedPayloadException - if the name is not a valid field name for this SDataView
See Also:
AbstractGettableByField.get(String)

putBySDataPropertyName

public boolean putBySDataPropertyName(java.lang.String name,
                                      java.lang.Object value,
                                      boolean verify)
put the given value, including taking care of checking results , converting types, allowing for some exceptions etc.

Parameters:
name - the SData property name of the field
value - the value to put in the field
verify - whether or not to perform verify when putting. Remember that even if you specify false the code is permitted to ignore you.
Returns:
whether or not the attempt was successful

putBySDataPropertyName

public boolean putBySDataPropertyName(java.lang.String name,
                                      java.lang.Object value,
                                      boolean verify,
                                      boolean viewFields,
                                      boolean optionalFields,
                                      SDataDiagnoses diagnoses,
                                      com.sage.orion.sdata.servlet.accpac.ViewSetReturnDeltaChanges deltaChanges)
put the value specified to the field specified by the sdata field name, possibly verifying and possibly only if it is the correct implementation of field.

If the field is not of the correct type then the method returns true indicating that there was not actually a problem.

The viewFields and optionalFields specification allows for putting optional fields after generating the default values

Parameters:
name - the sdata name of the field
value - the value to put in the field
verify - whether or not to verify the field
viewFields - if true then if this is an accpac view field then put it
optionalFields - if true then if this is an optional field then put it
diagnoses - a list of diagnoses to which this method can add warnings and information
deltaChanges - the ViewSetReturnDeltaChanges that is listening during the operation. Since the trigger field does not get a notification we need to do that ourselves. This should be null if there is none listening.
Returns:
true if and only if the operation was successful (but see the main description)

readKeyedRecord

public boolean readKeyedRecord(java.lang.Object[] values)
reads the record specified by the given key values. These values are in terms of the identifying key of the resource.

This returns with the current order unchanged. However it may temporarily change the order if the current order is not that of the identifying index, and it is not clear what the consequences will be.

If an exception is thrown the resulting order is ill-defined.

Parameters:
values - the values of the key fields
Returns:
true if the record exists
Throws:
java.lang.NullPointerException - if a null Resource was provided to the constructor.
java.lang.IllegalArgumentException - if the number of values does not match the expected number.

getFieldNamesOfFieldIDs

@NonNull
public java.util.Set<java.lang.String> getFieldNamesOfFieldIDs(@NonNull
                                                                       java.util.Set<java.lang.Integer> deltaFields)
returns the names of the fields whose IDs are provided

Parameters:
deltaFields - the field IDs of the fields
Returns:
the names of the fields specified by ID

getViewFieldByName

public SDataViewField getViewFieldByName(java.lang.String name)
returns the SDataViewField identified by the given SData property name

Parameters:
name - the name of the property
Returns:
the SDataViewField identified by the property name
Throws:
java.lang.IndexOutOfBoundsException - if the name does not correspond to an SDataViewField of this view

hasNonOptionalField

protected final boolean hasNonOptionalField(java.lang.String sdataName)
returns whether or not the view has a field or child resource with the given name, other than an optional field

Parameters:
sdataName - the SData name to check for
Returns:
true if the view has a non-custom field or child resource with this SData name

toString

public java.lang.String toString()
Overrides:
toString in class com.sage.accpac.sm.View

getMaintainRecordNumbers

public boolean getMaintainRecordNumbers()
Indicates whether this view instance maintains record number. Record numbering is specific to views using sequenced revision lists. Whether a view maintains record numbers depend on whether it was specified in the view mapping, as well as whether the view is participating in a Stateful SData connection

Returns:
Whether this view instance maintains record number.

getRecordNumber

public int getRecordNumber()
Returns the record number of the current record, if this view instance maintains record numbers. See getMaintainRecordNumbers(). Otherwise, this method always returns 0.

Returns:
Record number of the current record if this view instance maintains record numbers. Returns 0 otherwise.

getRecordNumberResourceField

public RecordNumberResourceField getRecordNumberResourceField()
Returns the resource of the record number field.

Returns:
The resource of the record number field. Returns null if the view is not set up to maintain record numbers.

goToRecordNumber

public boolean goToRecordNumber(int targetRecordNumber)
Move to the record identified by the record number.

Parameters:
targetRecordNumber - The record number to position to.
Returns:
Whether the view successfully found and moved to the specified record number. Returns false if the view is not set up to maintain record numbers.

goTop

public boolean goTop()
Specified by:
goTop in interface com.sage.accpac.sm.view.Navigable
Overrides:
goTop in class com.sage.accpac.sm.View

goBottom

public boolean goBottom()
Specified by:
goBottom in interface com.sage.accpac.sm.view.Navigable
Overrides:
goBottom in class com.sage.accpac.sm.View

goNext

public boolean goNext()
Specified by:
goNext in interface com.sage.accpac.sm.view.Navigable
Overrides:
goNext in class com.sage.accpac.sm.View

goPrev

public boolean goPrev()
Specified by:
goPrev in interface com.sage.accpac.sm.view.Navigable
Overrides:
goPrev in class com.sage.accpac.sm.View

read

public boolean read(boolean lockRecord)
Specified by:
read in interface com.sage.accpac.sm.view.Modifiable
Overrides:
read in class com.sage.accpac.sm.View

insert

public void insert()
Specified by:
insert in interface com.sage.accpac.sm.view.Modifiable
Overrides:
insert in class com.sage.accpac.sm.View

update

public void update()
Specified by:
update in interface com.sage.accpac.sm.view.Modifiable
Overrides:
update in class com.sage.accpac.sm.View

delete

public void delete()
Specified by:
delete in interface com.sage.accpac.sm.view.Modifiable
Overrides:
delete in class com.sage.accpac.sm.View

recordClear

public void recordClear()
Specified by:
recordClear in interface com.sage.accpac.sm.view.Navigable
Overrides:
recordClear in class com.sage.accpac.sm.View

recordGenerate

public void recordGenerate(com.sage.accpac.sm.View.RecordGenerateMode mode)
Specified by:
recordGenerate in interface com.sage.accpac.sm.view.Modifiable
Overrides:
recordGenerate in class com.sage.accpac.sm.View

emptyKeyFieldsForNavigation

public void emptyKeyFieldsForNavigation()
Empties the key field(s) according to the current key order, in preparation for subsequent navigation. This method empties the key fields by setting the values to the "min" value. If the view is a detail which is composed to a header view, only the key fields that define the detail are emptied, and key fields common to the header view are untouched.

See Also:
ViewField.setToMin()


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