org.cruxframework.crux.core.client.datasource
Class RemoteStreamingDataSource<T>

java.lang.Object
  extended by org.cruxframework.crux.core.client.datasource.RemoteStreamingDataSource<T>
All Implemented Interfaces:
DataSource<T>, PagedDataSource<T>, RemoteDataSource<T>, StreamingDataSource<T>

public abstract class RemoteStreamingDataSource<T>
extends Object
implements StreamingDataSource<T>

Author:
Thiago da Rosa de Bustamante

Field Summary
protected  int currentPage
           
protected  int currentRecord
           
protected  List<DataSourceRecord<T>> data
           
protected  ColumnDefinitions<T> definitions
           
protected  org.cruxframework.crux.core.client.datasource.StreamingDataSourceOperations<T> editableOperations
           
protected  RemoteDataSourceCallback fetchCallback
           
protected  ClientMessages messages
           
protected  int pageSize
           
 
Constructor Summary
RemoteStreamingDataSource()
           
 
Method Summary
 void cancelFetching()
           
 void clearChanges()
          Undo all changes
 T cloneDTO(DataSourceRecord<?> record)
          Clones the recordObject of a given DataSourceRecord
 void copyValueToWidget(com.google.gwt.user.client.ui.HasValue<?> valueContainer, String key, DataSourceRecord<?> dataSourceRecord)
          Copies the value from data record to the given widget
protected  void ensureCurrentPageLoaded()
           
protected  void fetchCurrentPage()
           
 void firstRecord()
          Points DataSource to first record
 T getBindedObject()
          Deprecated. Use getBoundObject instead
 T getBindedObject(DataSourceRecord<T> record)
          Deprecated. Use getBoundObject instead
 T getBoundObject()
          Return a copy of the current record object.
 T getBoundObject(DataSourceRecord<T> record)
          Return a copy of the record object.
 ColumnDefinitions<T> getColumnDefinitions()
          Return the DataSource definitions object.
 int getCurrentPage()
           
 int getCurrentPageSize()
           
 DataSourceRecord<T>[] getNewRecords()
          Return all records inserted on DataSource
protected  int getPageEndRecord()
           
 int getPageSize()
           
protected  int getPageStartRecord()
           
 DataSourceRecord<T> getRecord()
          Return the DataSourceRecord object, representing the current record
 int getRecordIndex(T boundObject)
           
 DataSourceRecord<T>[] getRemovedRecords()
          Return all records removed from DataSource
 DataSourceRecord<T>[] getSelectedRecords()
          Return all records selected on DataSource
 DataSourceRecord<T>[] getUpdatedRecords()
          Return all records modified on DataSource
 Object getValue(String columnName)
          Return the column value
 Object getValue(String columnName, DataSourceRecord<?> dataSourceRecord)
          Return the column value
 boolean hasNextPage()
           
 boolean hasNextRecord()
          Verify if DataSource has more records.
 boolean hasPreviousPage()
           
 boolean hasPreviousRecord()
          Verify if DataSource has previous records.
 DataSourceRecord<T> insertRecord(int index)
          Insert a new record on DataSource
protected  boolean isCurrentPageLoaded()
           
protected  boolean isRecordOnPage(int record)
           
 boolean nextPage()
           
 void nextRecord()
          Points DataSource to next record
 boolean previousPage()
           
 void previousRecord()
          Points DataSource to previous record
 DataSourceRecord<T> removeRecord(int index)
          Remove a record from DataSource
 void reset()
          Reset DataSource, as if it was never loaded before.
 void selectRecord(int index, boolean selected)
           
 void setCallback(RemoteDataSourceCallback callback)
           
 void setColumnDefinitions(ColumnDefinitions<T> columnDefinitions)
          Sets the DataSource definitions object.
 void setPageSize(int pageSize)
           
 void setValue(Object value, String columnKey, DataSourceRecord<?> dataSourceRecord)
          Sets the value on the given column of the give record
 void sort(String columnName, boolean ascending)
          Sort dataSource records, based on column informed
 void sort(String columnName, boolean ascending, boolean caseSensitive)
          Sort dataSource records, based on column informed
protected  void sortArray(DataSourceRecord<T>[] array, String columnName, boolean ascending, boolean caseSensitive)
           
 void update(DataSourceRecord<T>[] records)
           
protected  void updateCurrentRecord()
           
 void updateData(List<T> data)
           
 void updateData(T[] data)
           
protected  int updatePageRecords(int startRecord, int endRecord, DataSourceRecord<T>[] records)
           
protected  int updateRecords(int startRecord, int endRecord, DataSourceRecord<T>[] records)
           
 void updateState(DataSourceRecord<T> record, DataSourceRecord.DataSourceRecordState previousState)
          Update a record on DataSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.cruxframework.crux.core.client.datasource.RemoteDataSource
fetch
 

Field Detail

editableOperations

protected org.cruxframework.crux.core.client.datasource.StreamingDataSourceOperations<T> editableOperations

data

protected List<DataSourceRecord<T>> data

currentRecord

protected int currentRecord

pageSize

protected int pageSize

currentPage

protected int currentPage

definitions

protected ColumnDefinitions<T> definitions

fetchCallback

protected RemoteDataSourceCallback fetchCallback

messages

protected ClientMessages messages
Constructor Detail

RemoteStreamingDataSource

public RemoteStreamingDataSource()
Method Detail

insertRecord

public DataSourceRecord<T> insertRecord(int index)
Description copied from interface: DataSource
Insert a new record on DataSource

Specified by:
insertRecord in interface DataSource<T>
Returns:
See Also:
DataSource.insertRecord(int)

removeRecord

public DataSourceRecord<T> removeRecord(int index)
Description copied from interface: DataSource
Remove a record from DataSource

Specified by:
removeRecord in interface DataSource<T>
Returns:
See Also:
DataSource.removeRecord(int)

updateState

public void updateState(DataSourceRecord<T> record,
                        DataSourceRecord.DataSourceRecordState previousState)
Description copied from interface: DataSource
Update a record on DataSource

Specified by:
updateState in interface DataSource<T>
See Also:
DataSource.updateState(org.cruxframework.crux.core.client.datasource.DataSourceRecord, org.cruxframework.crux.core.client.datasource.DataSourceRecord.DataSourceRecordState)

getNewRecords

public DataSourceRecord<T>[] getNewRecords()
Description copied from interface: DataSource
Return all records inserted on DataSource

Specified by:
getNewRecords in interface DataSource<T>
Returns:
all new records
See Also:
DataSource.getNewRecords()

getRemovedRecords

public DataSourceRecord<T>[] getRemovedRecords()
Description copied from interface: DataSource
Return all records removed from DataSource

Specified by:
getRemovedRecords in interface DataSource<T>
Returns:
all removed records
See Also:
DataSource.getRemovedRecords()

getUpdatedRecords

public DataSourceRecord<T>[] getUpdatedRecords()
Description copied from interface: DataSource
Return all records modified on DataSource

Specified by:
getUpdatedRecords in interface DataSource<T>
Returns:
all modified records
See Also:
DataSource.getUpdatedRecords()

getSelectedRecords

public DataSourceRecord<T>[] getSelectedRecords()
Description copied from interface: DataSource
Return all records selected on DataSource

Specified by:
getSelectedRecords in interface DataSource<T>
Returns:
all selected records
See Also:
DataSource.getSelectedRecords()

clearChanges

public void clearChanges()
Description copied from interface: DataSource
Undo all changes

Specified by:
clearChanges in interface DataSource<T>
See Also:
DataSource.clearChanges()

setCallback

public void setCallback(RemoteDataSourceCallback callback)
Specified by:
setCallback in interface RemoteDataSource<T>
See Also:
RemoteDataSource.setCallback(org.cruxframework.crux.core.client.datasource.RemoteDataSourceCallback)

update

public void update(DataSourceRecord<T>[] records)
Specified by:
update in interface RemoteDataSource<T>
See Also:
org.cruxframework.crux.core.client.datasource.RemoteDataSource#update(R[])

updateRecords

protected int updateRecords(int startRecord,
                            int endRecord,
                            DataSourceRecord<T>[] records)
Parameters:
startRecord -
endRecord -
records -
Returns:

updatePageRecords

protected int updatePageRecords(int startRecord,
                                int endRecord,
                                DataSourceRecord<T>[] records)
Parameters:
startRecord -
endRecord -
records -
Returns:

updateData

public void updateData(T[] data)
Specified by:
updateData in interface RemoteDataSource<T>
See Also:
org.cruxframework.crux.core.client.datasource.RemoteDataSource#updateData(E[])

updateData

public void updateData(List<T> data)
Specified by:
updateData in interface RemoteDataSource<T>

copyValueToWidget

public void copyValueToWidget(com.google.gwt.user.client.ui.HasValue<?> valueContainer,
                              String key,
                              DataSourceRecord<?> dataSourceRecord)
Description copied from interface: DataSource
Copies the value from data record to the given widget

Specified by:
copyValueToWidget in interface DataSource<T>

setValue

public void setValue(Object value,
                     String columnKey,
                     DataSourceRecord<?> dataSourceRecord)
Description copied from interface: DataSource
Sets the value on the given column of the give record

Specified by:
setValue in interface DataSource<T>

getRecordIndex

public int getRecordIndex(T boundObject)
Specified by:
getRecordIndex in interface PagedDataSource<T>

selectRecord

public void selectRecord(int index,
                         boolean selected)
Specified by:
selectRecord in interface PagedDataSource<T>

cancelFetching

public void cancelFetching()
Specified by:
cancelFetching in interface RemoteDataSource<T>
See Also:
RemoteDataSource.cancelFetching()

getColumnDefinitions

public ColumnDefinitions<T> getColumnDefinitions()
Description copied from interface: DataSource
Return the DataSource definitions object.

Specified by:
getColumnDefinitions in interface DataSource<T>
Returns:
Definitions object
See Also:
DataSource.getColumnDefinitions()

setColumnDefinitions

public void setColumnDefinitions(ColumnDefinitions<T> columnDefinitions)
Description copied from interface: DataSource
Sets the DataSource definitions object.

Specified by:
setColumnDefinitions in interface DataSource<T>
Parameters:
columnDefinitions -

getRecord

public DataSourceRecord<T> getRecord()
Description copied from interface: DataSource
Return the DataSourceRecord object, representing the current record

Specified by:
getRecord in interface DataSource<T>
Returns:
current DataSourceRecord object.
See Also:
DataSource.getRecord()

getValue

public Object getValue(String columnName)
Description copied from interface: DataSource
Return the column value

Specified by:
getValue in interface DataSource<T>
Parameters:
columnName - name of the column
Returns:
value of the column
See Also:
DataSource.getValue(java.lang.String)

hasNextRecord

public boolean hasNextRecord()
Description copied from interface: DataSource
Verify if DataSource has more records.

Specified by:
hasNextRecord in interface DataSource<T>
Returns:
true if more records exist.
See Also:
DataSource.hasNextRecord()

nextRecord

public void nextRecord()
Description copied from interface: DataSource
Points DataSource to next record

Specified by:
nextRecord in interface DataSource<T>
See Also:
DataSource.nextRecord()

firstRecord

public void firstRecord()
Description copied from interface: DataSource
Points DataSource to first record

Specified by:
firstRecord in interface DataSource<T>
See Also:
DataSource.firstRecord()

hasPreviousRecord

public boolean hasPreviousRecord()
Description copied from interface: DataSource
Verify if DataSource has previous records.

Specified by:
hasPreviousRecord in interface DataSource<T>
Returns:
true if previous records exist.
See Also:
DataSource.hasPreviousRecord()

previousRecord

public void previousRecord()
Description copied from interface: DataSource
Points DataSource to previous record

Specified by:
previousRecord in interface DataSource<T>
See Also:
DataSource.previousRecord()

reset

public void reset()
Description copied from interface: DataSource
Reset DataSource, as if it was never loaded before.

Specified by:
reset in interface DataSource<T>
See Also:
DataSource.reset()

ensureCurrentPageLoaded

protected void ensureCurrentPageLoaded()

isCurrentPageLoaded

protected boolean isCurrentPageLoaded()

isRecordOnPage

protected boolean isRecordOnPage(int record)

getPageEndRecord

protected int getPageEndRecord()

getPageStartRecord

protected int getPageStartRecord()

getCurrentPage

public int getCurrentPage()
Specified by:
getCurrentPage in interface PagedDataSource<T>
See Also:
PagedDataSource.getCurrentPage()

getCurrentPageSize

public int getCurrentPageSize()
Specified by:
getCurrentPageSize in interface PagedDataSource<T>
See Also:
PagedDataSource.getCurrentPageSize()

getPageSize

public int getPageSize()
Specified by:
getPageSize in interface PagedDataSource<T>
See Also:
PagedDataSource.getPageSize()

hasNextPage

public boolean hasNextPage()
Specified by:
hasNextPage in interface PagedDataSource<T>
See Also:
PagedDataSource.hasNextPage()

hasPreviousPage

public boolean hasPreviousPage()
Specified by:
hasPreviousPage in interface PagedDataSource<T>
See Also:
PagedDataSource.hasPreviousPage()

nextPage

public boolean nextPage()
Specified by:
nextPage in interface PagedDataSource<T>
See Also:
PagedDataSource.nextPage()

previousPage

public boolean previousPage()
Specified by:
previousPage in interface PagedDataSource<T>
See Also:
PagedDataSource.previousPage()

setPageSize

public void setPageSize(int pageSize)
Specified by:
setPageSize in interface PagedDataSource<T>
See Also:
PagedDataSource.setPageSize(int)

sort

public void sort(String columnName,
                 boolean ascending)
Description copied from interface: DataSource
Sort dataSource records, based on column informed

Specified by:
sort in interface DataSource<T>
Parameters:
columnName - Base column for sorting.
ascending - If true, sort ascending.
See Also:
DataSource.sort(java.lang.String, boolean)

sort

public void sort(String columnName,
                 boolean ascending,
                 boolean caseSensitive)
Description copied from interface: DataSource
Sort dataSource records, based on column informed

Specified by:
sort in interface DataSource<T>
Parameters:
columnName - Base column for sorting.
ascending - If true, sort ascending.
caseSensitive - indicate if the columns sort are or not key sensitive
See Also:
DataSource.sort(java.lang.String, boolean)

sortArray

protected void sortArray(DataSourceRecord<T>[] array,
                         String columnName,
                         boolean ascending,
                         boolean caseSensitive)

updateCurrentRecord

protected void updateCurrentRecord()

fetchCurrentPage

protected void fetchCurrentPage()

getValue

public Object getValue(String columnName,
                       DataSourceRecord<?> dataSourceRecord)
Description copied from interface: DataSource
Return the column value

Specified by:
getValue in interface DataSource<T>
Returns:
See Also:
DataSource.getValue(java.lang.String, org.cruxframework.crux.core.client.datasource.DataSourceRecord)

getBindedObject

@Deprecated
public T getBindedObject()
Deprecated. Use getBoundObject instead

Returns:

getBindedObject

@Deprecated
public T getBindedObject(DataSourceRecord<T> record)
Deprecated. Use getBoundObject instead

Parameters:
record -
Returns:

getBoundObject

public T getBoundObject()
Description copied from interface: DataSource
Return a copy of the current record object.

Specified by:
getBoundObject in interface DataSource<T>
Returns:
See Also:
DataSource.getBoundObject()

getBoundObject

public T getBoundObject(DataSourceRecord<T> record)
Description copied from interface: DataSource
Return a copy of the record object.

Specified by:
getBoundObject in interface DataSource<T>
Returns:
See Also:
DataSource.getBoundObject(org.cruxframework.crux.core.client.datasource.DataSourceRecord)

cloneDTO

public T cloneDTO(DataSourceRecord<?> record)
Description copied from interface: DataSource
Clones the recordObject of a given DataSourceRecord

Specified by:
cloneDTO in interface DataSource<T>
Returns:


Copyright © 2014. All rights reserved.