Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    5.1d DataImport importDataSourceRecords importToRows

    Hi Isomorphic

    please see this testcase (current 5.1d BuiltInDS based).

    BuiltInDS.java:
    Code:
    package com.smartgwt.sample.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Window;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS implements EntryPoint {
        private VLayout mainLayout;
        private IButton recreateBtn;
    
        public void onModuleLoad() {
            KeyIdentifier debugKey = new KeyIdentifier();
            debugKey.setCtrlKey(true);
            debugKey.setKeyName("D");
    
            Page.registerKey(debugKey, new PageKeyHandler() {
                public void execute(String keyName) {
                    SC.showConsole();
                }
            });
    
            mainLayout = new VLayout(20);
            mainLayout.setWidth100();
            mainLayout.setHeight100();
    
            recreateBtn = new IButton("Recreate");
            recreateBtn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    recreate();
                }
            });
            mainLayout.addMember(recreateBtn);
            recreate();
            mainLayout.draw();
        }
    
        private void recreate() {
            Window w = new Window();
            w.setWidth("95%");
            w.setHeight("95%");
            w.setMembersMargin(0);
            w.setModalMaskOpacity(70);
            w.setTitle("5.1d serverside DataImport usage");
            w.setShowMinimizeButton(false);
            w.setIsModal(true);
            w.setShowModalMask(true);
            w.centerInPage();
    
            IButton b1 = new IButton("Do work", new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    DataSource.get("animals").performCustomOperation("importCsv");
                }
            });
            b1.setWidth(300);
            w.addItem(b1);
            w.show();
        }
    }[B][/B]


    animals.ds.xml:
    Code:
    <DataSource ID="animals" serverType="sql" tableName="animals" testFileName="animals.data.xml">
        <fields>
            <field name="commonName" title="Animal" type="text" />
            <field name="scientificName" title="Scientific Name" type="text" primaryKey="true" required="true" />
            <field name="lifeSpan" title="Life Span" type="integer" importStrategy="display" uploadFieldName="lifeSpan" displayField="supplyItemItemName"
                foreignKey="supplyItem.itemID" />
            <field name="supplyItemItemName" includeFrom="supplyItem.itemName" />
            <field name="status" title="Endangered Status" type="text">
                <valueMap>
                    <value>Threatened</value>
                    <value>Endangered</value>
                    <value>Not Endangered</value>
                    <value>Not currently listed</value>
                    <value>May become threatened</value>
                    <value>Protected</value>
                </valueMap>
            </field>
            <field name="diet" title="Diet" type="text" />
            <field name="information" title="Interesting Facts" type="text" length="1000" />
            <field name="picture" title="Picture" type="image" detail="true" imageURLPrefix="/isomorphic/system/reference/inlineExamples/tiles/images/" />
        </fields>
        <serverObject lookupStyle="new" className="com.smartgwt.sample.server.listener.Animals" />
        <operationBindings>
            <operationBinding operationType="custom" operationId="importCsv" serverMethod="importCsv" />
        </operationBindings>
    </DataSource>
    [B][/B]


    Animals.java:
    Code:
    package com.smartgwt.sample.server.listener;
    
    import java.io.Reader;
    import java.io.StringReader;
    import java.util.List;
    
    import javax.servlet.http.HttpServletRequest;
    
    import com.isomorphic.datasource.DSRequest;
    import com.isomorphic.datasource.DSResponse;
    import com.isomorphic.log.Logger;
    import com.isomorphic.tools.DataImport;
    import com.isomorphic.tools.DataImport.ImportFormat;
    import com.isomorphic.util.DataTools;
    
    public class Animals {
        public DSResponse importCsv(DSRequest request, HttpServletRequest servletRequest) throws Exception {
            Logger l = new Logger("com.isomorphic.datasource.DSRequest");
    
            String csvData = "scientificName;lifeSpan" + "\n" + "New Animal;Pens Stabiliner 808 Ballpoint Fine Green";
            l.warn("The data");
            l.warn("========");
            l.warn(csvData);
            Reader emailContentReader1 = new StringReader(csvData);
            Reader emailContentReader2 = new StringReader(csvData);
    
            List<?> dataImported = new DataImport(ImportFormat.CSV, ";").importDataSourceRecords(emailContentReader1, "animals");
            l.warn("importDataSourceRecords");
            l.warn("=======================");
            l.warn(DataTools.prettyPrint(dataImported));
    
            List<?> dataImported2 = new DataImport(ImportFormat.CSV, ";").importToRows(emailContentReader2, null, null, request.getDataSource());
            l.warn("importToRows");
            l.warn("============");
            l.warn(DataTools.prettyPrint(dataImported2));
    
            return new DSResponse().setSuccess();
        }
    }
    This is the server log I'm getting (see bold parts in the end):
    Code:
    === 2015-11-18 23:37:55,182 [4-33] INFO  RequestContext - URL: '/builtinds/sc/IDACall', User-Agent: 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0': Moz (Gecko) with Accept-Encoding header
    === 2015-11-18 23:37:55,182 [4-33] DEBUG IDACall - Header Name:Value pair: Cookie:isc_cState=ready; JSESSIONID=19zs6iti9lcf42wrn5hms9mw4; GLog=%7B%0D%20%20%20%20trackRPC%3Afalse%2C%20%0D%20%20%20%20isc_pageURL%3A%22http%3A//127.0.0.1%3A8888/BuiltInDS.html%3Fgwt.codesvr%3D127.0.0.1%3A9997%22%2C%20%0D%20%20%20%20isc_pageGUID%3A%222BC5BF0E-2D9A-4761-AAED-D45B724959C9%22%2C%20%0D%20%20%20%20priorityDefaults%3A%7B%0D%20%20%20%20%20%20%20%20sgwtInternal%3A1%2C%20%0D%20%20%20%20%20%20%20%20Log%3A4%0D%20%20%20%20%7D%2C%20%0D%20%20%20%20defaultPriority%3A3%2C%20%0D%20%20%20%20left%3A0%2C%20%0D%20%20%20%20top%3A0%2C%20%0D%20%20%20%20width%3A1344%2C%20%0D%20%20%20%20height%3A579%0D%7D
    === 2015-11-18 23:37:55,182 [4-33] DEBUG IDACall - Header Name:Value pair: DNT:1
    === 2015-11-18 23:37:55,183 [4-33] DEBUG IDACall - Header Name:Value pair: Host:127.0.0.1:8888
    === 2015-11-18 23:37:55,183 [4-33] DEBUG IDACall - Header Name:Value pair: Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    === 2015-11-18 23:37:55,183 [4-33] DEBUG IDACall - Header Name:Value pair: Content-Length:818
    === 2015-11-18 23:37:55,183 [4-33] DEBUG IDACall - Header Name:Value pair: Content-Type:application/x-www-form-urlencoded; charset=UTF-8
    === 2015-11-18 23:37:55,183 [4-33] DEBUG IDACall - Header Name:Value pair: Accept-Language:de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
    === 2015-11-18 23:37:55,183 [4-33] DEBUG IDACall - Header Name:Value pair: Pragma:no-cache
    === 2015-11-18 23:37:55,183 [4-33] DEBUG IDACall - Header Name:Value pair: Connection:keep-alive
    === 2015-11-18 23:37:55,183 [4-33] DEBUG IDACall - Header Name:Value pair: Referer:http://127.0.0.1:8888/BuiltInDS.html?gwt.codesvr=127.0.0.1:9997
    === 2015-11-18 23:37:55,183 [4-33] DEBUG IDACall - Header Name:Value pair: User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0
    === 2015-11-18 23:37:55,183 [4-33] DEBUG IDACall - Header Name:Value pair: Cache-Control:no-cache
    === 2015-11-18 23:37:55,184 [4-33] DEBUG IDACall - Header Name:Value pair: Accept-Encoding:gzip, deflate
    === 2015-11-18 23:37:55,184 [4-33] DEBUG IDACall - session exists: 19zs6iti9lcf42wrn5hms9mw4
    === 2015-11-18 23:37:55,184 [4-33] DEBUG IDACall - remote user: null
    === 2015-11-18 23:37:55,185 [4-33] WARN  RPCManager - client/server version mismatch.  Client is version: v10.0p_2015-11-18, server is version: SNAPSHOT_v10.1d_2015-11-17 - mixing different client/server versions is generally not supported.  If you've installed a more recent client version, try clearing the browser cache and reloading the page.
    === 2015-11-18 23:37:55,197 [4-33] DEBUG XML - Parsed XML from (in memory stream): 11ms
    === 2015-11-18 23:37:55,197 [4-33] DEBUG ISCKeyedObjectPool - Borrowing object for 'transaction'
    === 2015-11-18 23:37:55,200 [4-33] DEBUG PoolableDataSourceFactory - Tried to create DataSource  of type 'transaction' but null was returned
    === 2015-11-18 23:37:55,200 [4-33] DEBUG PoolableDataSourceFactory - Created DataSource null of type 'transaction' in the pooling flow
    === 2015-11-18 23:37:55,200 [4-33] DEBUG ISCKeyedObjectPool - Borrowing object for 'Object'
    === 2015-11-18 23:37:55,201 [4-33] DEBUG PoolableDataSourceFactory - Created DataSource 84 of type 'Object' and assigned it to thread qtp245116974-33
    === 2015-11-18 23:37:55,201 [4-33] DEBUG PoolableDataSourceFactory - Created DataSource 84 of type 'Object' in the pooling flow
    === 2015-11-18 23:37:55,201 [4-33] DEBUG PoolableDataSourceFactory - Activated DataSource 84 of type 'Object'
    === 2015-11-18 23:37:55,201 [4-33] DEBUG ISCKeyedObjectPool - Borrowing object for 'List'
    === 2015-11-18 23:37:55,207 [4-33] DEBUG PoolableDataSourceFactory - Created DataSource 85 of type 'List' and assigned it to thread qtp245116974-33
    === 2015-11-18 23:37:55,207 [4-33] DEBUG PoolableDataSourceFactory - Created DataSource 85 of type 'List' in the pooling flow
    === 2015-11-18 23:37:55,207 [4-33] DEBUG PoolableDataSourceFactory - Activated DataSource 85 of type 'List'
    === 2015-11-18 23:37:55,208 [4-33] DEBUG ISCKeyedObjectPool - Borrowing object for 'elem'
    === 2015-11-18 23:37:55,210 [4-33] DEBUG PoolableDataSourceFactory - Tried to create DataSource  of type 'elem' but null was returned
    === 2015-11-18 23:37:55,210 [4-33] DEBUG PoolableDataSourceFactory - Created DataSource null of type 'elem' in the pooling flow
    === 2015-11-18 23:37:55,211 [4-33] DEBUG RPCManager - Processing 1 requests.
    === 2015-11-18 23:37:55,211 [4-33] DEBUG ISCKeyedObjectPool - Borrowing object for 'animals'
    === 2015-11-18 23:37:55,212 [4-33] DEBUG PoolableDataSourceFactory - Activated DataSource 72 of type 'animals'
    === 2015-11-18 23:37:55,214 [4-33] DEBUG DSRequest - Caching instance 72 of DS 'animals' from DSRequest.getDataSource()
    === 2015-11-18 23:37:55,214 [4-33] DEBUG DSRequest - Caching instance 72 of DS animals
    === 2015-11-18 23:37:55,215 [4-33] DEBUG RPCManager - Request #1 (DSRequest) payload: {
        values:null,
        operationConfig:{
            dataSource:"animals",
            repo:null,
            operationType:"custom",
            textMatchStyle:"exact"
        },
        appID:"builtinApplication",
        operation:"importCsv",
        oldValues:null,
        criteria:{
        }
    }
    === 2015-11-18 23:37:55,215 [4-33] INFO  IDACall - Performing 1 operation(s)
    === 2015-11-18 23:37:55,215 [4-33] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
    === 2015-11-18 23:37:55,215 [4-33] DEBUG DeclarativeSecurity - DataSource animals is not in the pre-checked list, processing...
    === 2015-11-18 23:37:55,216 [4-33] WARN  DSRequest - The data
    === 2015-11-18 23:37:55,217 [4-33] WARN  DSRequest - ========
    === 2015-11-18 23:37:55,217 [4-33] WARN  DSRequest - scientificName;lifeSpan
    New Animal;Pens Stabiliner 808 Ballpoint Fine Green
    === 2015-11-18 23:37:55,217 [4-33] DEBUG ISCKeyedObjectPool - Borrowing object for 'animals'
    === 2015-11-18 23:37:55,222 [4-33] DEBUG ISCKeyedObjectPool - Borrowing object for 'supplyItem'
    === 2015-11-18 23:37:55,222 [4-33] DEBUG PoolableDataSourceFactory - Activated DataSource 74 of type 'supplyItem'
    === 2015-11-18 23:37:55,225 [4-33] DEBUG SQLDataSource - DataSource 86 acquired SQLDriver instance 2066234012 during initialization
    === 2015-11-18 23:37:55,226 [4-33] DEBUG PoolableDataSourceFactory - Created DataSource 86 of type 'animals' and assigned it to thread qtp245116974-33
    === 2015-11-18 23:37:55,226 [4-33] DEBUG PoolableDataSourceFactory - Created DataSource 86 of type 'animals' in the pooling flow
    === 2015-11-18 23:37:55,226 [4-33] DEBUG PoolableDataSourceFactory - Activated DataSource 86 of type 'animals'
    === 2015-11-18 23:37:55,227 [4-33] DEBUG ISCKeyedObjectPool - Borrowing object for 'Object'
    === 2015-11-18 23:37:55,228 [4-33] DEBUG PoolableDataSourceFactory - Created DataSource 87 of type 'Object' and assigned it to thread qtp245116974-33
    === 2015-11-18 23:37:55,228 [4-33] DEBUG PoolableDataSourceFactory - Created DataSource 87 of type 'Object' in the pooling flow
    === 2015-11-18 23:37:55,228 [4-33] DEBUG PoolableDataSourceFactory - Activated DataSource 87 of type 'Object'
    === 2015-11-18 23:37:55,228 [4-33] DEBUG PoolableDataSourceFactory - Cleared and passivated DataSource 87 of type 'Object'
    === 2015-11-18 23:37:55,228 [4-33] DEBUG ISCKeyedObjectPool - Borrowing object for 'Object'
    === 2015-11-18 23:37:55,228 [4-33] DEBUG PoolableDataSourceFactory - Activated DataSource 87 of type 'Object'
    === 2015-11-18 23:37:55,228 [4-33] DEBUG PoolableDataSourceFactory - Cleared and passivated DataSource 87 of type 'Object'
    === 2015-11-18 23:37:55,229 [4-33] DEBUG ISCKeyedObjectPool - Borrowing object for 'Object'
    === 2015-11-18 23:37:55,229 [4-33] DEBUG PoolableDataSourceFactory - Activated DataSource 87 of type 'Object'
    === 2015-11-18 23:37:55,229 [4-33] DEBUG PoolableDataSourceFactory - Cleared and passivated DataSource 87 of type 'Object'
    === 2015-11-18 23:37:55,229 [4-33] DEBUG ISCKeyedObjectPool - Borrowing object for 'Object'
    === 2015-11-18 23:37:55,229 [4-33] DEBUG PoolableDataSourceFactory - Activated DataSource 87 of type 'Object'
    === 2015-11-18 23:37:55,229 [4-33] DEBUG PoolableDataSourceFactory - Cleared and passivated DataSource 87 of type 'Object'
    === 2015-11-18 23:37:55,229 [4-33] DEBUG ISCKeyedObjectPool - Borrowing object for 'Object'
    === 2015-11-18 23:37:55,229 [4-33] DEBUG PoolableDataSourceFactory - Activated DataSource 87 of type 'Object'
    === 2015-11-18 23:37:55,230 [4-33] DEBUG PoolableDataSourceFactory - Cleared and passivated DataSource 87 of type 'Object'
    === 2015-11-18 23:37:55,230 [4-33] DEBUG ISCKeyedObjectPool - Borrowing object for 'Object'
    === 2015-11-18 23:37:55,230 [4-33] DEBUG PoolableDataSourceFactory - Activated DataSource 87 of type 'Object'
    === 2015-11-18 23:37:55,230 [4-33] DEBUG PoolableDataSourceFactory - Cleared and passivated DataSource 87 of type 'Object'
    === 2015-11-18 23:37:55,230 [4-33] DEBUG ISCKeyedObjectPool - Borrowing object for 'Object'
    === 2015-11-18 23:37:55,230 [4-33] DEBUG PoolableDataSourceFactory - Activated DataSource 87 of type 'Object'
    === 2015-11-18 23:37:55,230 [4-33] DEBUG PoolableDataSourceFactory - Cleared and passivated DataSource 87 of type 'Object'
    === 2015-11-18 23:37:55,230 [4-33] DEBUG ISCKeyedObjectPool - Borrowing object for 'Object'
    === 2015-11-18 23:37:55,231 [4-33] DEBUG PoolableDataSourceFactory - Activated DataSource 87 of type 'Object'
    === 2015-11-18 23:37:55,231 [4-33] DEBUG PoolableDataSourceFactory - Cleared and passivated DataSource 87 of type 'Object'
    === 2015-11-18 23:37:55,231 [4-33] DEBUG ISCKeyedObjectPool - Borrowing object for 'supplyItem'
    === 2015-11-18 23:37:55,235 [4-33] DEBUG SQLDataSource - DataSource 88 acquired SQLDriver instance 236984047 during initialization
    === 2015-11-18 23:37:55,236 [4-33] DEBUG PoolableDataSourceFactory - Created DataSource 88 of type 'supplyItem' and assigned it to thread qtp245116974-33
    === 2015-11-18 23:37:55,237 [4-33] DEBUG PoolableDataSourceFactory - Created DataSource 88 of type 'supplyItem' in the pooling flow
    === 2015-11-18 23:37:55,237 [4-33] DEBUG PoolableDataSourceFactory - Activated DataSource 88 of type 'supplyItem'
    === 2015-11-18 23:37:55,238 [4-33] DEBUG DSRequest - Caching instance 88 of DS 'supplyItem' from DSRequest.getDataSource()
    === 2015-11-18 23:37:55,238 [4-33] DEBUG DSRequest - Caching instance 88 of DS supplyItem
    === 2015-11-18 23:37:55,238 [4-33] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
    === 2015-11-18 23:37:55,238 [4-33] DEBUG DeclarativeSecurity - Request is not a client request, ignoring security checks.
    === 2015-11-18 23:37:55,238 [4-33] DEBUG AppBase - [builtinApplication.null] No userTypes defined, allowing anyone access to all operations for this application
    === 2015-11-18 23:37:55,239 [4-33] DEBUG AppBase - [builtinApplication.null] No public zero-argument method named '_null' found, performing generic datasource operation
    === 2015-11-18 23:37:55,239 [4-33] INFO  SQLDataSource - [builtinApplication.null] Performing fetch operation with
        criteria: {itemName:"Pens Stabiliner 808 Ballpoint Fine Green"}    values: {itemName:"Pens Stabiliner 808 Ballpoint Fine Green"}
    === 2015-11-18 23:37:55,241 [4-33] INFO  SQLDataSource - [builtinApplication.null] derived query: SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause
    === 2015-11-18 23:37:55,242 [4-33] INFO  SQLDataSource - [builtinApplication.null] 88: Executing SQL query on 'HSQLDB': SELECT supplyItem.itemID, supplyItem.itemName, supplyItem.SKU, supplyItem.description, supplyItem.category, supplyItem.units, supplyItem.unitCost, supplyItem.inStock, supplyItem.nextShipment FROM supplyItem WHERE (LOWER(supplyItem.itemName)='pens stabiliner 808 ballpoint fine green')
    === 2015-11-18 23:37:55,243 [4-33] DEBUG PoolableSQLConnectionFactory - [builtinApplication.null] DriverManager fetching connection for HSQLDB via jdbc url jdbc:hsqldb:hsql://localhost/isomorphic
    === 2015-11-18 23:37:55,243 [4-33] DEBUG PoolableSQLConnectionFactory - [builtinApplication.null] Passing JDBC URL only to getConnection
    === 2015-11-18 23:37:55,347 [4-33] DEBUG PoolableSQLConnectionFactory - [builtinApplication.null] makeObject() created an unpooled Connection '386938410'
    === 2015-11-18 23:37:55,347 [4-33] DEBUG SQLConnectionManager - [builtinApplication.null] Borrowed connection '386938410'
    === 2015-11-18 23:37:55,348 [4-33] INFO  SQLDriver - [builtinApplication.null] Executing SQL query on 'HSQLDB' using connection '386938410': SELECT supplyItem.itemID, supplyItem.itemName, supplyItem.SKU, supplyItem.description, supplyItem.category, supplyItem.units, supplyItem.unitCost, supplyItem.inStock, supplyItem.nextShipment FROM supplyItem WHERE (LOWER(supplyItem.itemName)='pens stabiliner 808 ballpoint fine green')
    === 2015-11-18 23:37:55,372 [4-33] INFO  DSResponse - DSResponse: List with 1 items
    === 2015-11-18 23:37:55,372 [4-33] DEBUG DSRequest - About to free up resources for request of type fetch on DataSource supplyItem
    === 2015-11-18 23:37:55,372 [4-33] DEBUG SQLDataSource - About to clear SQLDriver state for DS instance 88
    === 2015-11-18 23:37:55,372 [4-33] DEBUG SQLDriver - Freeing SQLDriver dbConnection 386938410 for SQLDriver instance 236984047
    === 2015-11-18 23:37:55,372 [4-33] DEBUG SQLConnectionManager - About to close JDBCConnection with hashcode "386938410"
    === 2015-11-18 23:37:55,373 [4-33] DEBUG SQLDataSource - About to clear SQLDriver state for DS instance 88
    === 2015-11-18 23:37:55,373 [4-33] DEBUG SQLDataSource - About to clear SQLDriver state for DS instance 88
    === 2015-11-18 23:37:55,373 [4-33] DEBUG PoolableDataSourceFactory - Cleared and passivated DataSource 88 of type 'supplyItem'
    === 2015-11-18 23:37:55,374 [4-33] DEBUG SQLDataSource - About to clear SQLDriver state for DS instance 86
    === 2015-11-18 23:37:55,374 [4-33] DEBUG SQLDataSource - About to clear SQLDriver state for DS instance 86
    === 2015-11-18 23:37:55,374 [4-33] DEBUG PoolableDataSourceFactory - Cleared and passivated DataSource 86 of type 'animals'
    [B]=== 2015-11-18 23:37:55,374 [4-33] WARN  DSRequest - importDataSourceRecords
    === 2015-11-18 23:37:55,374 [4-33] WARN  DSRequest - =======================
    === 2015-11-18 23:37:55,375 [4-33] WARN  DSRequest - [
        {
            lifeSpan:1487,
            scientificName:"New Animal"
        }
    ]
    === 2015-11-18 23:37:55,375 [4-33] WARN  DSRequest - importToRows
    === 2015-11-18 23:37:55,375 [4-33] WARN  DSRequest - ============
    === 2015-11-18 23:37:55,376 [4-33] WARN  DSRequest - [
        {
            lifeSpan:"Pens Stabiliner 808 Ballpoint Fine Green",
            scientificName:"New Animal"
        }
    ][/B]
    === 2015-11-18 23:37:55,376 [4-33] DEBUG DSRequest - About to free up resources for request of type custom on DataSource animals
    === 2015-11-18 23:37:55,376 [4-33] DEBUG DSRequest - Ignoring freeResources call because this is not a primary request!
    === 2015-11-18 23:37:55,377 [4-33] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
    === 2015-11-18 23:37:55,377 [4-33] DEBUG RPCManager - DMI response, dropExtraFields: false
    === 2015-11-18 23:37:55,379 [4-33] DEBUG DSRequest - Ignoring freeQueueResources call because this is not a primary request!
    === 2015-11-18 23:37:55,380 [4-33] INFO  Compression - /builtinds/sc/IDACall: 159 -> 142 bytes
    [B][/B]


    Could you explain when to use importDataSourceRecords and when importToRows? The docs sound to me like I'll need importToRows, but this does not translate string->ID (no SQL executed). Is this correct?
    Also, when do I use importToDataSource?

    My usecase is that I want to process mails and create DB-entries based on the content of the mails. As the mails won't contain IDs (like for itemName->lifeSpan), I need to translate these like you would do it for a CSV-upload from the clientside BatchUploader.

    Additional question: In the BatchUploader-case you would return both the string as field "supplyItemItemName" and the ID as field "lifeSpan".
    How is this union best done? Do you have helper methods for this, perhaps something from DataTools?

    Thank you & Best regards
    Blama

    #2
    Hi Blama,

    Sorry for the delayed response. importToRows imports data to list of maps, importDataSourceRecords consults data source config for field list, performs some additional checks and transforms data into data source records, importToDataSource transforms data into records and adds them to data source.

    In your case you should use importDataSourceRecords in combination with new setting setPopulateDisplayFields(true). Code below would transform display value into data value (itemName>lifeSpan) and also include display value (supplyItemItemName) in imported data:
    Code:
    DataImport di = new DataImport(ImportFormat.CSV, ";");
    di.setPopulateDisplayFields(true);
    List<?> dataImported = di.importDataSourceRecords(emailContentReader1, "animals");
    l.warn("importDataSourceRecords");
    l.warn("=======================");
    l.warn(DataTools.prettyPrint(dataImported));
    Let us know if it worked for you.

    We also linked DataImport javadoc to SmartClient Reference "dataSourceField.importStrategy" doc, which explains how display>data value mapping works.

    Note that all this is available in nightly builds from Dec 9.

    Regards,
    Isomorphic Software

    Comment


      #3
      Hi Isomorphic,

      great, thank you. I'll retry importDataSourceRecords() in combination with setPopulateDisplayFields(true). I didn't see that one before.
      It looks like these two together should solve my use case.

      I'll update here once I used it in my application or re-ran the test case.

      Best regards
      ​Blama

      Comment


        #4
        Hi Isomorphic,

        this is working in my application as expected.

        Thank you & Best regards
        Blama

        Comment


          #5
          Hi Isomorphic,

          I'm currently revisiting this as I'm now using the parameter Map columnRemap as well.
          I noticed that the parameter List columns, that is used in some overloads of all three methods (importToRows(), importDataSourceRecords(), importToDataSource()) is documented in none of the methods.

          Best regards
          Blama

          Comment


            #6
            "List columns" is just a list of the column names to use, so you can import rows that provide only a subset of DataSource data.

            Comment

            Working...
            X