Class Recordset.BatchEditor
- java.lang.Object
-
- com.supermap.data.Recordset.BatchEditor
-
- Enclosing class:
- Recordset
public class Recordset.BatchEditor extends java.lang.Object
This class is the nested class of the Recordset class which provides the batch edit of the records.Supports add, delete and modify.
Tabular dataset isn't supported to update in batch.
- Example:
- The following code demonstrates how to use batch update to add geometry object and filed value in dataset.
public void recordBatchTest() { // Supposes opening an object workspace which has a datasource object. // Gets the vector dataset "World" DatasetVector dataset_world = (DatasetVector) datasets.get("World"); // Creates a vector dataset named "example" String name = "example"; DatasetVector dataset = (DatasetVector)datasets.createFromTemplate(name, dataset_world); //Gets the record set Recordset recordset_world = dataset_world.getRecordset(false, CursorType.STATIC); Recordset recordset = dataset.getRecordset(false, CursorType.DYNAMIC); // Gets the objects to be updated in batches BatchEditor editor = recordset.getBatch(); // Sets the number of records sumbitted in a batch editor.setMaxRecordCount(50); // Reads geometrical objects and field values from World dataset and update them to example dataset editor.begin(); while (!recordset_world.isEOF()) { Geometry geometry = recordset_world.getGeometry(); java.util.Map
map = new java.util.HashMap (); FieldInfos fieldInfos = recordset_world.getFieldInfos(); for (int i = 0; i < fieldInfos.getCount(); i++) { FieldInfo fieldInfo = fieldInfos.get(i); if (!fieldInfo.getName().equalsIgnoreCase("SMID")) map.put(fieldInfo.getName(), recordset_world.getFieldValue(fieldInfo.getName())); } recordset.addNew(geometry, map); geometry.dispose(); recordset_world.moveNext(); } // Submitted in bulk editor.update(); // Release the record set recordset_world.dispose(); recordset.dispose(); }
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
begin()
Sets the starting for batch updates.int
getMaxRecordCount()
Returns the maximum number of the records for submitting the result of batch edit automatically.void
setMaxRecordCount(int value)
Sets the maximum number of the records for submitting the result of batch edit.void
update()
Submits the batch edit uniformly.
-
-
-
Method Detail
-
getMaxRecordCount
public int getMaxRecordCount()
Returns the maximum number of the records for submitting the result of batch edit automatically. In the course of the batch edit, if the number of the records updated equals the MaxRecordCount value set and it will begin update the next record, it will submit these records updated automatically. For example, if there are 200 records to be updated and the MaxRecordCount is set to 100, when you doing the batch edit, if the number of the records done equals 100 and it will begin update the 101th record, it will submit the result of updating these 100 records automatically; in this instance the system will submit one time. However the 100 records remained will be submitted by the methodBatchEditor
ofupdate()
because there is not 201th record. In addition, if the number of the records updated is less than the value of MaxRecordCount, you can call the methodBatchEditor
of theBatchEditor
class to submit.update()
Note: the default value of the
getMaxRecordCount()
method is 1024, thesetMaxRecordCount()
method must be called before calling theBatchEditor.begin()
method, otherwise it will occur the exception.- Returns:
- The maximum number of the records for submitting the result of batch edit.
-
setMaxRecordCount
public void setMaxRecordCount(int value)
Sets the maximum number of the records for submitting the result of batch edit. When all the records finish batch edit and submit the update result, if the record number of updating exceeds the largest record number, the system will batch submit the update results, namely, each time submit records of the largest record number until all the update results are submitted. For example, if the largest record number is set to 1000 and the records need to update is 3800, the system will be divided into four parts to submit the results, namely, first submit 1000 records, second 1000 records, third 1000 records and fourth 8000 records.Sets the maximum number of the records for submitting the result of batch edit. When all the records finish batch edit and submit the update result, if the record number of updating exceeds the largest record number, the system will batch submit the update results, namely, each time submit records of the largest record number until all the update results are submitted. For example, if the largest record number is set to 1000 and the records need to update is 3800, the system will be divided into four parts to submit the results, namely, first submit 1000 records, second 1000 records, third 1000 records and fourth 8000 records.- Parameters:
value
- The maximum number of the records for submitting the result of batch edit.
-
begin
public void begin()
Sets the starting for batch updates.This method identifies the current update operation will be performed in the batch mode, namely, the update operation will not take effect immediately after calling this method, but to update until the
update()
method is called.Note: After this method is called, submit the changes of recordset by calling
update()
method. But the update values won't be written into the results. When all the updates are submitted, you can call theupdate()
method to input the results.
-
update
public void update()
Submits the batch edit uniformly.The batch updating will be took effect after calling this method. After calling this method, the batch status will come to an end and if you want to perform batch operation, you need to call the
BatchEditor.begin()
method again.
-
-