@@ -1120,6 +1120,44 @@ class DataHarmonizer {
1120
1120
1121
1121
/***************************** PRIVATE functions *************************/
1122
1122
1123
+ /**
1124
+ * Load data into table as an array of objects. The keys of each object are
1125
+ * field names and the values are the cell values.
1126
+ *
1127
+ * @param {Array<Object> } data table data
1128
+ */
1129
+ loadDataObjects ( data ) {
1130
+ const fields = this . getFields ( ) ;
1131
+ if ( typeof data === 'object' && ! Array . isArray ( data ) && data !== null ) {
1132
+ // An object was provided, so try to pick out the grid data from
1133
+ // one of it's fields.
1134
+ const inferredIndexSlot = this . getInferredIndexSlot ( ) ;
1135
+
1136
+ if ( inferredIndexSlot ) {
1137
+ data = data [ inferredIndexSlot ] ;
1138
+ } else {
1139
+ const dataKeys = Object . keys ( data ) ;
1140
+ if ( dataKeys . length === 1 ) {
1141
+ data = data [ dataKeys [ 0 ] ] ;
1142
+ }
1143
+ }
1144
+ }
1145
+
1146
+ if ( ! Array . isArray ( data ) ) {
1147
+ console . warn ( 'Unable to get grid data from input' ) ;
1148
+ return ;
1149
+ }
1150
+ const listData = data . map ( ( row ) =>
1151
+ dataObjectToArray ( row , fields , {
1152
+ serializedDateFormat : this . dateExportBehavior ,
1153
+ dateFormat : this . dateFormat ,
1154
+ datetimeFormat : this . datetimeFormat ,
1155
+ timeFormat : this . timeFormat ,
1156
+ } )
1157
+ ) ;
1158
+ return this . matrixFieldChangeRules ( listData ) ;
1159
+ }
1160
+
1123
1161
/**
1124
1162
* Parses binary spreadsheet data into a JSON matrix and processes it for use.
1125
1163
* If header rows are detected in the data, they are removed, and any additional
@@ -1859,6 +1897,11 @@ class DataHarmonizer {
1859
1897
}
1860
1898
1861
1899
getInferredIndexSlot ( ) {
1900
+
1901
+ if ( this . class_assignment ) {
1902
+ return this . class_assignment ;
1903
+ }
1904
+
1862
1905
const classes = Object . values ( this . schema . classes ) ;
1863
1906
const treeRootClass = classes . find ( ( cls ) => cls . tree_root ) ;
1864
1907
if ( ! treeRootClass ) {
@@ -1880,42 +1923,6 @@ class DataHarmonizer {
1880
1923
return index_attrs [ 0 ] . name ;
1881
1924
}
1882
1925
1883
- /**
1884
- * Load data into table as an array of objects. The keys of each object are
1885
- * field names and the values are the cell values.
1886
- *
1887
- * @param {Array<Object> } data table data
1888
- */
1889
- loadDataObjects ( data ) {
1890
- const fields = this . getFields ( ) ;
1891
- if ( typeof data === 'object' && ! Array . isArray ( data ) && data !== null ) {
1892
- // An object was provided, so try to pick out the grid data from
1893
- // one of it's fields.
1894
- const inferredIndexSlot = this . getInferredIndexSlot ( ) ;
1895
- if ( inferredIndexSlot ) {
1896
- data = data [ inferredIndexSlot ] ;
1897
- } else {
1898
- const dataKeys = Object . keys ( data ) ;
1899
- if ( dataKeys . length === 1 ) {
1900
- data = data [ dataKeys [ 0 ] ] ;
1901
- }
1902
- }
1903
- }
1904
- if ( ! Array . isArray ( data ) ) {
1905
- console . warn ( 'Unable to get grid data from input' ) ;
1906
- return ;
1907
- }
1908
- const listData = data . map ( ( row ) =>
1909
- dataObjectToArray ( row , fields , {
1910
- serializedDateFormat : this . dateExportBehavior ,
1911
- dateFormat : this . dateFormat ,
1912
- datetimeFormat : this . datetimeFormat ,
1913
- timeFormat : this . timeFormat ,
1914
- } )
1915
- ) ;
1916
- return this . matrixFieldChangeRules ( listData ) ;
1917
- }
1918
-
1919
1926
/**
1920
1927
*
1921
1928
* From export_utils.js
0 commit comments