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

java.lang.Object
  extended by com.sage.orion.sdata.servlet.accpac.Resource
All Implemented Interfaces:
JiBXConfigurationResource

public class Resource
extends java.lang.Object
implements JiBXConfigurationResource

The Resource class wraps the resource definition files and exposes their content in a usable fashion, including defaulting, checking validity etc. This class is tied to the JiBX binding file viewResourceBinding.xml. It should not be changed without studying the ramifications in the binding file.

See the binding file for documentation on the structure.


Constructor Summary
Resource()
           
 
Method Summary
 void addChildResource(Resource resource)
          Adds the given resource as a child resource.
 Resource getChildResource(java.lang.String name)
          get the child Resource with the given name.
 java.util.List<Resource> getChildResources()
          Gets all the child resources.
 java.util.Collection<java.lang.String> getConfigurationErrors()
          gets a list of the configuration errors that occurred during parsing the configuration file
 int getDefiningIndex()
          gets the defining index for the view
 java.lang.String getDescription()
          Gets the resource's description.
 java.lang.String getDescriptorField()
          gets the name of the field that describes a record
 java.lang.String getFieldIDOfName(java.lang.String name)
          Gets the accpac view field name (viewID) for the given sdata field name.
 java.lang.String getKind()
          returns the resource kind name of the resource.
 java.lang.String getName()
          Gets the resource's name.
 OptionalFieldsView getOptionalFields()
          gets the optional fields view of the resource, or null if there is none
 Resource getParentResource()
          Gets the resource's parent resource.
 java.lang.String getPluralName()
          Gets the plural name of the resource.
 java.util.Collection<ReferencedResource> getReferencedResources()
          returns the ReferencedResource of this object
 ReferencedResource getRelatedResource(java.lang.String property)
          gets the related resource corresponding to the resource property name
 java.lang.String getRenamedField(java.lang.String viewFieldID)
          Gets the renamed field for the given view field ID for the resource.
 java.lang.String getReportName()
          Gets the report name value.
 java.lang.String getServiceMapFile()
          Gets the service map file or null if there is no service map file.
 java.lang.String getType()
          Gets the type of the resource.
 java.util.List<ResourceViewField> getViewFieldsList(com.sage.accpac.sm.view.IView view)
          Returns the list of view fields that are specified for this resource.
 java.lang.String getViewID()
          Gets the resource's viewID.
 java.util.List<ResourceVirtualField> getVirtualFieldsList()
          Gets a List of the virtual fields for the resource.
 boolean hasChildren()
           
 boolean hasNonOptionalFieldWithName(java.lang.String sdataName, com.sage.accpac.sm.view.IViewFields fields)
          checks whether the resource already has a non-optional item with the given SData name (i.e.
 boolean hasParent()
           
 boolean isList()
          returns whether or not the resource is a list resource.
 boolean lookupUsesKey(java.lang.String viewFieldID)
          returns whether or not the given field is used as a key field for a foreign reference involved in a lookup
 void setName(java.lang.String name)
          Sets the name of the resource.
 void setPluralName(java.lang.String pluralName)
          Sets the plural name of the resource.
 void setServiceMapFile(java.lang.String serviceMapFile)
           
 boolean supportsRecordNumbers()
          Returns whether or not the resource supports record numbers.
 boolean usesKeyedPaging()
          returns whether or not the resource uses keyed paging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Resource

public Resource()
Method Detail

getConfigurationErrors

public java.util.Collection<java.lang.String> getConfigurationErrors()
gets a list of the configuration errors that occurred during parsing the configuration file

Specified by:
getConfigurationErrors in interface JiBXConfigurationResource
Returns:
a non-null collection of errors that occurred during construction

getDefiningIndex

public int getDefiningIndex()
gets the defining index for the view

Returns:
the defining index

getOptionalFields

public OptionalFieldsView getOptionalFields()
gets the optional fields view of the resource, or null if there is none

Returns:
null or the optional fields view

getReportName

public java.lang.String getReportName()
Gets the report name value.

Returns:
the report name or null or blank

addChildResource

public void addChildResource(Resource resource)
Adds the given resource as a child resource.

Parameters:
resource - the resource to add

getVirtualFieldsList

public java.util.List<ResourceVirtualField> getVirtualFieldsList()
Gets a List of the virtual fields for the resource.

Returns:
a List of virtual fields or an empty List if there are no virtual fields.

getType

public java.lang.String getType()
Gets the type of the resource. Note: The type will be defaulted by the resource name - if it has not already been set. @See setName(String).

Returns:
the type

getDescription

public java.lang.String getDescription()
Gets the resource's description.

Returns:
the resource's description.

getViewID

public java.lang.String getViewID()
Gets the resource's viewID.

Returns:
the resource's viewID.

getName

public java.lang.String getName()
Gets the resource's name.

Returns:
the resource's name.

getPluralName

public java.lang.String getPluralName()
Gets the plural name of the resource. Note: The plural name will be defaulted by the resource name - if it has not already been set. @See setName(String).

Returns:
the plural name of the resource.

getRenamedField

public java.lang.String getRenamedField(java.lang.String viewFieldID)
Gets the renamed field for the given view field ID for the resource.

Parameters:
viewFieldID - the ID of the field.
Returns:
the renamed field for the given view field ID for the resource.

getFieldIDOfName

public java.lang.String getFieldIDOfName(java.lang.String name)
Gets the accpac view field name (viewID) for the given sdata field name.

Parameters:
name - the external SData name for the field
Returns:
the accpac viewID for the sdata name

getChildResources

public java.util.List<Resource> getChildResources()
Gets all the child resources.

Returns:
all the child resources.

hasChildren

public boolean hasChildren()
Returns:
true if the Resource has children.

setPluralName

public void setPluralName(java.lang.String pluralName)
Sets the plural name of the resource. Note: If not set directly, the pluralName will be set to the name + 's'.

Parameters:
pluralName - the plural name of the resource

getParentResource

public Resource getParentResource()
Gets the resource's parent resource.

Returns:
the resource's parent resource.

hasParent

public boolean hasParent()
Returns:
true if the resource has a parent.

setName

public void setName(java.lang.String name)
Sets the name of the resource.

Also default the pluralName & type properties if they are currently null or empty.

Parameters:
name - the name of the resource

getChildResource

public Resource getChildResource(java.lang.String name)
get the child Resource with the given name. Return null if there is no such child resource. Do not throw an exception if there is no such child.

Parameters:
name - name of the resource
Returns:
null if there is no such child resource and the resource otherwise

getReferencedResources

public java.util.Collection<ReferencedResource> getReferencedResources()
returns the ReferencedResource of this object

Returns:
a Collection of the ReferencedResource

getRelatedResource

public ReferencedResource getRelatedResource(java.lang.String property)
gets the related resource corresponding to the resource property name

Parameters:
property - the property name whose related resource we are seeking
Returns:
null if there is no such related resource, or the ReferencedResource which relates to this property

getServiceMapFile

public java.lang.String getServiceMapFile()
Gets the service map file or null if there is no service map file.

Returns:
the serviceMapFile or null if there is no service map file.

setServiceMapFile

public void setServiceMapFile(java.lang.String serviceMapFile)
Parameters:
serviceMapFile - the serviceMapFile to set

usesKeyedPaging

public boolean usesKeyedPaging()
returns whether or not the resource uses keyed paging. Keyed paging is an Accpac extension and is not part of the SData protocol. Due to design difficulties it should not be used unless absolutely necesary.

Returns:
true if and only if the resource supports keyed paging.

getKind

public java.lang.String getKind()
returns the resource kind name of the resource.

For the top resource of the resource tree the resource name and the resource kind name should be the same. However for a sub-resource the resource name reflects the name of the property that refers to it in the parent while the kind name is the name that it appears as at the top level of the schema

Returns:
the name of the resource kind for this resource, which will be non-null.

isList

public boolean isList()
returns whether or not the resource is a list resource.

Returns:
true if and only if the resource is a list.

getViewFieldsList

public java.util.List<ResourceViewField> getViewFieldsList(com.sage.accpac.sm.view.IView view)
Returns the list of view fields that are specified for this resource.

This list includes only view fields, not virtual fields.

Parameters:
view - the View that relates to the resource
Returns:
a (non-null possibly empty) list containing the fields

lookupUsesKey

public boolean lookupUsesKey(java.lang.String viewFieldID)
returns whether or not the given field is used as a key field for a foreign reference involved in a lookup

Parameters:
viewFieldID - the view field ID of the field in this resource that might be part of a reference
Returns:
true if and only if the given field is part of a reference to a foreign resource that has a lookup field defined

hasNonOptionalFieldWithName

public boolean hasNonOptionalFieldWithName(java.lang.String sdataName,
                                           com.sage.accpac.sm.view.IViewFields fields)
checks whether the resource already has a non-optional item with the given SData name (i.e. an optional field with this name will collide)

Parameters:
sdataName - the SData name to be checked
fields - the IViewFields containing the actual fields of the view
Returns:
true if the resource has a non-optional/custom field or child resource etc, which is exposed from this resource with the given name.

supportsRecordNumbers

public boolean supportsRecordNumbers()
Returns whether or not the resource supports record numbers. An Accpac resource supports record numbers only if the underlying uses a sequenced revision list.

Returns:
true if the resource supports record numbers.

getDescriptorField

public java.lang.String getDescriptorField()
gets the name of the field that describes a record

Returns:
null if there is no such field or the name of the field


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