using output of one dataweave transformation as input for another -


i have dataweave function supposed apply flowvar input. input expected json. using sample data , preview, works fine, when executing, error i'm trying apply function binary. content of flowvar output of dataweave transformation. payload @ time set flowvar of type com.mulesoft.weave.reader.bytearrayseekablestream. how can convert consumable dataweave?

this function that's giving problem:

%var theattributes = flowvars.attributes %function supervisorattribute(id) (theattributes[?$.id ~=id].attributes[0][?($ == "indp" or $ == "thes" or $ == "urop")][0]) 

the error is:

 type mismatch 'value selector' operator  found :binary, :name  required :datetime, :name or  required :localdatetime, :name or  required :object, :name or  required :time, :name or  required :array, :name or  ... 

i tried adding object json transformer, got this:

no serializer found class com.mulesoft.weave.reader.bytearrayseekablestream , no properties discovered create beanserializer (to avoid exception, disable serializationconfig.feature.fail_on_empty_beans) ) (org.codehaus.jackson.map.jsonmappingexception). (org.mule.api.transformer.transformermessagingexception). 

i tried adding byte array object transformer, byte array object transformer followed object json transformer, , setting flowvar #[message.payloadas(java.lang.string)], got in each case:

type mismatch 'filter selector ([?()])' operator  found :string, :function required :array, :function 

this sample json data works fine preview input:

[   {     "id": "111",     "attributes": [       "thes",       "varu",       "rotc",       "cih",       "hh"     ]   },   {     "id": "222",     "attributes": [       "varu",       "biol",       "ha2",       "fsem"     ]   },    {     "id": "2",     "attributes": [       "rotc"     ]   } ] 

this transformation creates json:

%dw 1.0  %output application/json  --- payload groupby $.subject_version_id map {     id: $[0].subject_version_id,     attributes: $.attribute_code } 

the transformation appears work fine. result if return output response.

[   {     "id": "35de521c7a772317e053282701126511",     "attributes": [       "cal1",       "con"     ]   },   {     "id": "35de521c7a6c2317e053282701126511",     "attributes": [       "rest"     ]   },   {     "id": "35de521c7a692317e053282701126511",     "attributes": [       "supr"     ]   } ] 

here's full flow:

<flow name="subjects-feedflow">     <db:select config-ref="oracle_configuration" doc:name="database">         <db:parameterized-query><![cdata[select subject_version_id,   attribute_code subject_version_attribute]]></db:parameterized-query>     </db:select>     <dw:transform-message doc:name="transform message">         <dw:set-payload><![cdata[%dw 1.0             %output application/json             ---             payload groupby $.subject_version_id map {                 id: $[0].subject_version_id,                 attributes: $.attribute_code         } ]]></dw:set-payload>     </dw:transform-message>     <set-variable variablename="attributes" value="#[payload]"/>     <db:select config-ref="oracle_configuration" doc:name="database">     <db:parameterized-query><![cdata[select c.subject_container_id,           subject_level, variable_units, lecture_units, lab_units, subject_version_id         subject_container c, subject_version v         c.subject_container_id = v.subject_container_id          , v.effective_from_term = (select max(effective_from_term)  subject_version v.subject_container_id = subject_container_id)]]></db:parameterized-query>     </db:select>     <dw:transform-message>         <dw:input-payload/>         <dw:input-variable variablename="attributes"/>         <dw:set-payload><![cdata[%dw 1.0            %output application/dw            %var theattributes = flowvars.attributes            %function supervisorattribute(id) (theattributes[?$.id ~=id].attributes[0][?($ == "indp" or $ == "thes" or $ == "urop")][0])            ---              {                subjects: {                     (payload map ((payload01 , indexofpayload01) -> {                        subject @(containerid: payload01.subject_container_id :string, versionnum: payload01.version_num): {                           units: {                               (unittype: "fixed") when payload01.variable_units=='n',                               (unittype: "arranged") when payload01.variable_units=='y',                               (lectureunits: payload01.lecture_units :string) when payload01.variable_units=='n',                               (labunits: payload01.lab_units :string) when payload01.variable_units=='n',                               (prepunits: payload01.prep_units :string) when payload01.variable_units=='n'                           },                           (supervisorattribute: supervisorattribute(payload01.subject_version_id)) when supervisorattribute(payload01.subject_version_id) != null,                     }                   }            }]]></dw:set-payload>     </dw:transform-message>  </flow> 


Comments

Post a Comment

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

delphi - Take screenshot in webcam using VFrames in Console Application -

c++ - wxDataViewModel: What is it and how do i use it? -