AdventNet Web NMS 4 API Specification

com.adventnet.nms.client
Interface NmsClientTableModel

All Superinterfaces:
javax.swing.table.TableModel

public interface NmsClientTableModel
extends javax.swing.table.TableModel

NmsClientTableModel is the core interface which represents the customized TableModel for WebNMS Client. This client model is the one which interacts with its server-side counterpart model. The updates occuring on the server are communicated to the client model by its counterpart server-side model. The updates received by the NmsClientTableModel are then routed to its listeners.

One could register with this model for updates. He/she could do so using the following method of javax.swing.table.TableModel (which this interface extends)

 void addTableModelListener(javax.swing.event.TableModelListener l) 
 
The listener class you give should implement javax.swing.event.TableModelListener which just has one method in it of the following prototype.

      void tableChanged(TableModelEvent e).
 
The tableChanged method of the listener class you write will be called whenever an update is received.

An important thing to be noted here is that the event object received as the parameter to tableChanged will be an instance of NmsClientTableModelEvent. So, updates are thrown in the form of NmsClientTableModelEvent to the registered listeners. Now you could type cast the received TableModelEvent to NmsClientTableModelEvent and leverage the info embedded in it.

The implementation of this NmsClientTableModel interface could be used in two ways.

One, as an iterator to fetch the data from the WebNMS Server. And the other is that it could be directly set as the TableModel for the JTable component.

(Note that this interface extends javax.swing.table.TableModel). The second option would be of much use if the WebNMS client implementation opts to use JTable as the UI component to display the data.

When NmsClientTableModel is set as the model directly for the JTable, the JTable (himself being a TableModelListener) registers with the model passed to him. JTable decodes the TableModelEvent passed to him and updates its User Interface accordingly after querying the model about the data involved in the update. But JTable is ignorant of the fact that the event received is of type NmsClientTableModelEvent. By the time JTable receives the event and comes back to the model to retrieve the data and update its user interface, the model would have updated its local cache with the data embedded in the event so that it could give the data to the JTable. (i.e) The NmsClientTableModel implementation, being a listener to its server-side counterpart, receives the event from the server and updates it in its local cache and only then it forwards the event to its listeners. So, when JTable comes back to get the data, the client model would retrieve it from the local cache and give it.

An instance of the implementation of this interface is returned by the createCustomView methods of the Client API's (For example, the com.adventnet.nms.topoui.ClientTopoAPIImpl).

See Also:
com.adventnet.nms.topoui.ClientTopoAPIImpl, NmsClientTableModelEvent

Method Summary
 boolean changeCriteriaProperties(java.util.Properties p)
          Changes the criteria of the custom view model.
 boolean changeName(java.lang.String newName)
          Deprecated. since changing of the viewID of a Custom View is not supported.
 boolean getAllProperties(boolean getAll)
          Option to set whether the model would fetch all the properties of the object(say Event) or just those specified through setDisplayFields method.
 java.util.Vector getBottom()
          Fetches the last set of current increment number of objects.
 java.util.Vector getBottom(int num)
          Fetches the last set of num number of objects.
 java.util.Vector getCacheData()
          This method will return entire data from the client table model.
 java.util.Properties getCriteriaProperties()
          Returns the criteria properties based on which the objects are fetched.
 java.lang.String[] getDisplayFields()
          Returns the current setting of the displayFields.
 java.lang.String[] getDisplayLabels()
          Returns the setting of the displayLabels.
 int getEndIndex()
          Returns the current end Index of the view range represented by the client model.
 int getIncrement()
          Returns the current increment value set.
 java.lang.String getKey(int index)
          Gets the key of the object at the particular index.
 java.lang.String getKeyFieldName()
          Returns the key field name of the objects retrieved.
 java.lang.String getName()
          Returns the name assigned to the Model.
 java.util.Vector getNext()
          Fetches the next set of data based on the current increment value set.
 java.util.Vector getNext(int num)
          Fetches the next set of data based on the given increment value.
 java.util.Vector getNext(int num, boolean sameStart)
          Fetches a set of data based on the given increment value and the boolean argument sameStart.
 java.lang.String getOrderByColumn()
          getOrderByColumn method returns the name of the column by which the data should be ordered.
 java.util.Vector getPrevious()
          Fetches the previous set of data based on the current increment value set.
 java.util.Vector getPrevious(int num)
          Fetches the previous set of data based on the given increment value.
 java.util.Vector getPrevious(int num, boolean sameEnd)
          Fetches a set of data based on the given increment value and the boolean argument sameEnd.
 java.util.Properties getRow(int index)
          Gets the Properties of the object at the particular index.
 int getStartIndex()
          Returns the current start Index of the view range represented by the client model.
 java.util.Vector getTop()
          Fetches the first set of current increment number of objects.
 java.util.Vector getTop(int num)
          Fetches the first set of num number of objects.
 int getTotalRowCount()
          Gets the total number of objects.
 boolean isAscendingOrder()
          isAscendingOrder method returns whether the data is sorted by ascending order based on orderByColumn.
 boolean isBottomEnabled()
          Returns the current state of the subsequent getBottom operation.
 boolean isNextEnabled()
          Returns the current state of the subsequent getNext operation.
 boolean isPreviousEnabled()
          Returns the current state of the subsequent getPrevious operation.
 boolean isShowLatest()
          Can be used to know whether showLatest is set to true or not.
 boolean isTopEnabled()
          Returns the current state of the subsequent getTop operation.
 java.util.Vector refreshModel()
          This method update the table model with whatever properties have been set for the table mdel.
 boolean registerForUpdates()
          registerForUpdates method registers this table model for receiving updates from FE.
 boolean setDisplayFields(java.lang.String[] names)
          Sets the displayFields value.
 boolean setDisplayFields(java.lang.String[] names, java.lang.String[] labels)
          Sets the displayFields and the display labels that are to be shown in the JTable.
 boolean setIncrement(int num)
          Sets the increment or the window size by which the getNext and getPrevious methods would retrieve the data.
 boolean setKeyFieldName(java.lang.String key)
          Used for internal purposes only.
 boolean setOrderByColumn(java.lang.String columnName, boolean sortByAscendingOrder)
          setOrderByColumn orders the data based on the column name and refetches the data.
 boolean setViewRange(int startIndex, int endIndex)
          This method can be used to change the view range of a custom view dynamically.
 boolean showLatest(boolean showlatest)
          To set the showLatest mode.
 boolean unRegisterForUpdates()
          unRegisterForUpdates method un-registers this table model (if already registered) to stop receiving updates from FE.
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, isCellEditable, removeTableModelListener, setValueAt
 

Method Detail

setIncrement

public boolean setIncrement(int num)
Sets the increment or the window size by which the getNext and getPrevious methods would retrieve the data.
Parameters:
num - the window size.

getAllProperties

public boolean getAllProperties(boolean getAll)
Option to set whether the model would fetch all the properties of the object(say Event) or just those specified through setDisplayFields method.

The default value for this option is false. (i.e) by default only a standard set of fields of the object will be retrieved. You need to set this option explicitly to retrieve all the properties of the object. This option overides the behaviour of setDisplayFields. (i.e) setting this option to true would fetch all the properties irrespective of the setting of displayFields. But anyhow the TableModel methods like getValueAt, getColumnName, etc would only be dependent on the displayFields value.

Returns:
a boolean indicating where the set operation was successfully made.
See Also:
setDisplayFields(String[]), setDisplayFields(String[], String[])

getTotalRowCount

public int getTotalRowCount()
Gets the total number of objects. This is different from the getRowCount method of TableModel. The getRowCount() method of TableModel would just return the current viewport size (i.e). the number of objects cached by the client table model. Whereas the getTotalRowCount returns the total no. of objects on the server.
See Also:
TableModel.getRowCount()

getNext

public java.util.Vector getNext()
Fetches the next set of data based on the current increment value set. (i.e) the next current increment number of objects are returned. Returns null when the iteration has reached the end.
Returns:
Vector of java.util.Properties. The contents of the Properties object depends on the setting of getAllProperties and displayFields.

getNext

public java.util.Vector getNext(int num)
Fetches the next set of data based on the given increment value. (i.e) it fetches the next num number of objects from the server. Returns null when the iteration has reached the end.
Returns:
Vector of java.util.Properties. The contents of the Properties object depends on the setting of getAllProperties and displayFields.

getNext

public java.util.Vector getNext(int num,
                                boolean sameStart)
Fetches a set of data based on the given increment value and the boolean argument sameStart.

When sameStart is true it fetches next num number of objects from the startIndex.

When sameStart is false it fetches next num number of objects from the endIndex which is same as the getNext(int) method.

Returns null when the iteration has reached the end.

Returns:
Vector of java.util.Properties. The contents of the Properties object depends on the setting of getAllProperties and displayFields.

getPrevious

public java.util.Vector getPrevious()
Fetches the previous set of data based on the current increment value set. Returns null when the iteration has reached the start.

Returns:
Vector of java.util.Properties. The contents of the Properties object depends on the setting of getAllProperties and displayFields.

getPrevious

public java.util.Vector getPrevious(int num)
Fetches the previous set of data based on the given increment value. (i.e) it fetches the previous num number of objects from the server. Returns null when the iteration has reached the start.

Returns:
Vector of java.util.Properties. The contents of the Properties object depends on the setting of getAllProperties and displayFields.

getPrevious

public java.util.Vector getPrevious(int num,
                                    boolean sameEnd)
Fetches a set of data based on the given increment value and the boolean argument sameEnd.

When sameEnd is true it fetches previous num number of objects from the endIndex.

When sameEnd is false it fetches previous num number of objects from the startIndex which is same as the getPrevious(int) method.

Returns null when the iteration has reached the end.

Returns:
Vector of java.util.Properties. The contents of the Properties object depends on the setting of getAllProperties and displayFields.

getTop

public java.util.Vector getTop()
Fetches the first set of current increment number of objects. Returns a Vector of no elements when there is no data .

Returns:
Vector of java.util.Properties. The contents of the Properties object depends on the setting of getAllProperties and displayFields.

getTop

public java.util.Vector getTop(int num)
Fetches the first set of num number of objects.

Returns a Vector of no elements when there is no data .

Returns:
Vector of java.util.Properties. The contents of the Properties object depends on the setting of getAllProperties and displayFields.

getBottom

public java.util.Vector getBottom()
Fetches the last set of current increment number of objects.

Returns a Vector of no elements when there is no data .

Returns:
Vector of java.util.Properties. The contents of the Properties object depends on the setting of getAllProperties and displayFields.

getBottom

public java.util.Vector getBottom(int num)
Fetches the last set of num number of objects.

Returns a Vector of no elements when there is no data .

Returns:
Vector of java.util.Properties. The contents of the Properties object depends on the setting of getAllProperties and displayFields.

getName

public java.lang.String getName()
Returns the name assigned to the Model.

changeName

public boolean changeName(java.lang.String newName)
Deprecated. since changing of the viewID of a Custom View is not supported.

Changes the name assigned to the Model.

getCriteriaProperties

public java.util.Properties getCriteriaProperties()
Returns the criteria properties based on which the objects are fetched.

changeCriteriaProperties

public boolean changeCriteriaProperties(java.util.Properties p)
Changes the criteria of the custom view model. Need to call refreshModel() to update the table model for notifying the change.

getDisplayFields

public java.lang.String[] getDisplayFields()
Returns the current setting of the displayFields. The displayFields being set is the one which decides what columns are shown on JTable.

getDisplayLabels

public java.lang.String[] getDisplayLabels()
Returns the setting of the displayLabels. displayLabels will be the ones used as the label for the JTable headers. This will be of no use when one doesn't use JTable.

setDisplayFields

public boolean setDisplayFields(java.lang.String[] names)
Sets the displayFields value. The values given here should be the field names of the object retrieved. If getAllProperties is set to false then only those fields given here will be retrieved by the iterative methods. Setting getAllProperties to true would result in model retrieving all the properties of the object but the ones displayed in the JTable would only be the given parameter values.

When this method is used the displayLabels will get the same value as displayFields.

Need to call refreshModel() to update the table model for notifying the change. Returns true on successfully changing the displayFields.


setDisplayFields

public boolean setDisplayFields(java.lang.String[] names,
                                java.lang.String[] labels)
Sets the displayFields and the display labels that are to be shown in the JTable.

Need to call refreshModel() to update the table model for notifying the change. Returns true on successfully changing the displayFields.


getKey

public java.lang.String getKey(int index)
Gets the key of the object at the particular index. index ranges from 0 to getRowCount() - 1.

getRow

public java.util.Properties getRow(int index)
Gets the Properties of the object at the particular index. index ranges from 0 to getRowCount() - 1.

setKeyFieldName

public boolean setKeyFieldName(java.lang.String key)
Used for internal purposes only. Not to be used externally.

getKeyFieldName

public java.lang.String getKeyFieldName()
Returns the key field name of the objects retrieved. For example, it returns the String "id" for Events since id is the key for Events.

getStartIndex

public int getStartIndex()
Returns the current start Index of the view range represented by the client model.

getEndIndex

public int getEndIndex()
Returns the current end Index of the view range represented by the client model.

getIncrement

public int getIncrement()
Returns the current increment value set.

isNextEnabled

public boolean isNextEnabled()
Returns the current state of the subsequent getNext operation. Returns false when the subsequent getNext operation will return null and true when the subsequent getNext operation will successfully happen.

isPreviousEnabled

public boolean isPreviousEnabled()
Returns the current state of the subsequent getPrevious operation. Returns false when the subsequent getPrevious operation will return null and true when the subsequent getPrevious operation will successfully happen.

isTopEnabled

public boolean isTopEnabled()
Returns the current state of the subsequent getTop operation. Returns false when the subsequent getTop operation will return null and true when the subsequent getTop operation will successfully happen.

isBottomEnabled

public boolean isBottomEnabled()
Returns the current state of the subsequent getBottom operation. Returns false when the subsequent getBottom operation will return null and true when the subsequent getBottom operation will successfully happen.

showLatest

public boolean showLatest(boolean showlatest)
To set the showLatest mode. This will decide whether the model gets the latest updates if the current page is table model's last page. Presently this feature is supported only for Events. If the value showLatest is set to true, it always updates the last page of the data, if it is current page.

For example, assume that the current view length is 20. And the view range is 41 to 50. And also the table is showing last page of data. ie, total count of model data is 50.

Now suppose if a new row is added as 51 th row, 41 st row will be removed and new row will be appended at the end of the table if showLatest is true.

The default value is false.

Presently this feature supports only for Events.

Returns:
true on success.

isShowLatest

public boolean isShowLatest()
Can be used to know whether showLatest is set to true or not.

setViewRange

public boolean setViewRange(int startIndex,
                            int endIndex)
This method can be used to change the view range of a custom view dynamically. Using the startIndex and endIndex the increment value is calculated

The new increment value will be calculated from the two arguments as follows.

     ViewLength = endIndex - startIndex;
 
refreshModel method should be called after setting the view range to retrieve the new set of objects.
Returns:
true on success.

refreshModel

public java.util.Vector refreshModel()
This method update the table model with whatever properties have been set for the table mdel.

getCacheData

public java.util.Vector getCacheData()
This method will return entire data from the client table model.

registerForUpdates

public boolean registerForUpdates()
registerForUpdates method registers this table model for receiving updates from FE.
Returns:
a boolean value on whether the request was successfull.

unRegisterForUpdates

public boolean unRegisterForUpdates()
unRegisterForUpdates method un-registers this table model (if already registered) to stop receiving updates from FE.
Returns:
a boolean value on whether the request was successfull.

setOrderByColumn

public boolean setOrderByColumn(java.lang.String columnName,
                                boolean sortByAscendingOrder)
setOrderByColumn orders the data based on the column name and refetches the data.
Parameters:
columnName - a String value of a valid column present in this view.
sortByAscendingOrder - a boolean value of whether to order the rows in ascending order or not.
Returns:
a boolean value

getOrderByColumn

public java.lang.String getOrderByColumn()
getOrderByColumn method returns the name of the column by which the data should be ordered.
Returns:
a String value of column by which the data should be sort.

isAscendingOrder

public boolean isAscendingOrder()
isAscendingOrder method returns whether the data is sorted by ascending order based on orderByColumn.
Returns:
true if data should be sorted in ascending order based on orderByColumn, false otherwise.

AdventNet Web NMS 4 API Specification