Announcement

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

    Bug in serverside DSRequest.getOutputs() (always null)?

    Hi Isomorphic,

    I subclassed the SQLDataSource as follows:

    Code:
    	@Override
    	public DSResponse executeFetch(DSRequest req) throws Exception {
    		// T_USER.fetchUserIdForLoginname occurs before session parameter are set,
    		// so do not try to modify.
    		req.getOperationId().equals("fetchUserIdForLoginname");
    		if (!req.getDataSourceName().equals("T_USER") || !req.getOperationId().equals("fetchUserIdForLoginname"))
    			modifyCriteria(req);
    		return super.executeFetch(req);
    	}
    If I put a breakpoint in the method right before this operation binding is executed:
    ds.xml
    Code:
    <operationBinding operationType="fetch" operationId="fetchChildResellers" serverMethod="fetchChildResellers" outputs="NAME">
    Java:
    Code:
    public DSResponse fetchChildResellers(DSRequest dsRequest, HttpServletRequest servletRequest) throws Exception {
    		HashMap<String, ArrayList<Long>> childCompanies = User.getChildCompanies(dsRequest);
    		SetCriterion resellerChildCriterion = null;
    		if (childCompanies.get("RESELLER_IDS").size() > 0) {
    			resellerChildCriterion = new SetCriterion("ID", DefaultOperators.InSet.getID(),
    					childCompanies.get("RESELLER_IDS"));
    			dsRequest.addToCriteria(resellerChildCriterion);
    		}
    		return dsRequest.execute();
    , the following happens:
    The generated SQL includes only the name field from outputs="NAME" (as expected), but req.getOutputs() (as expression in the Eclipse debugger) returns always null.
    Could you please check if this is true for you as well? I'd expect it to be a java.util.List with 1 element in it.

    I'm using SNAPSHOT_v9.1d_2014-01-19/EVAL Deployment with GWT 2.6.0rc4 and Eclipse Kepler.

    Thank you & Best regards,
    Blama

    #2
    As additional information:
    I do not change dropExtraFields anywhere in my code, ds.xml or server.properties, so it is at it's factory settings, if this is important.

    If you need a minimal testcase I can try to build one, but I think that it should be pretty easy for you to just breakpoint in executeFetch and see what happens.

    Best regards,
    Blama

    Comment


      #3
      Please do try making minimal changes to a sample and see if you can reproduce the issue there.

      Comment


        #4
        Hi Isomorphic,

        I could reproduce in minimal testcase:

        Use BuiltInDS-sample and replace/add the following files:
        com.smartgwt.sample.server.listener.TestSQLDataSource.java (put breakpoint on outputsIsNull = true;)
        Code:
        package com.smartgwt.sample.server.listener;
        
        import com.isomorphic.datasource.DSRequest;
        import com.isomorphic.datasource.DSResponse;
        import com.isomorphic.sql.SQLDataSource;
        
        public class TestSQLDataSource extends SQLDataSource {
        	private static final long serialVersionUID = 3994104605640773331L;
        
        	@Override
        	public DSResponse executeFetch(DSRequest req) throws Exception {
        		Boolean outputsIsNull = null;
        		if (req.getOutputs() == null)
        			outputsIsNull = true;
        		return super.executeFetch(req);
        	}
        }
        animals.ds.xml:
        Code:
        <DataSource ID="animals" serverType="sql" tableName="animals" testFileName="animals.data.xml" serverConstructor="com.smartgwt.sample.server.listener.TestSQLDataSource">
        	<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" />
        		<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>
        	<operationBindings>
        		<operationBinding operationType="fetch" outputs="commonName" />
        	</operationBindings>
        </DataSource>
        Start the sample in Debug DevMode and click animals. See that the breakpoint is hit where I'd say it shouldn't be.

        Best regards,
        Blama

        Comment


          #5
          getOutputs() only returns the "outputs" specified on the DSRequest, so it is expected that it would return null in this case because your "outputs" are specified on the OperationBinding. If you want to find out what "outputs" were specified on the OperationBinding, you can read that off the DataSource config.

          We do recognize that you probably want to find out what "outputs" are in force, regardless of where they came from. There is an undocumented API to do this - DSRequest.getConsolidatedOutputs(). This returns the definitive list of fields that will be returned to the client, considering all factors: DSRequest "outputs", OperationBinding "outputs", includeFrom definitions, and the effects of any declarative security rules you have defined. We will be exposing this as a supported API from 4.1 onwards, so although it is undocumented right now, you can safely use it.

          Regards,
          Isomorphic Software Support

          Comment


            #6
            Hi Isomorphic,

            that's great news. Thanks. I'll try it tomorrow.

            Best regards,
            Blama

            Comment


              #7
              Hi Isomorphic,

              it works in my usecase. Thanks a lot.

              Best regards,
              Blama

              Comment

              Working...
              X