Usage of UserSession in the DataLoadCoordinator

Hi…
Is it possible to use the UserSession in the DataLoadContext…? like the following…?

        <collection id="collectionDc"
                    class="com.company.example.entity.Pet"
                    view="pet-browse">
            <loader id="petDl">
                <query>
                    <![CDATA[select e from example_Pet e]]>
                    <condition>
                        <and>
                            <c:jpql>
                                <c:where>e.petType IN :component_TypeField</c:where>
                            </c:jpql>
                            <c:jpql>
                                <c:where>e.status IN :component_statusField</c:where>
                            </c:jpql>
                            <c:jpql>
                                <c:where>e.doctor = :session$userLogin</c:where>
                            </c:jpql>
                        </and>
                    </condition>
                </query>
            </loader>
        </collection>

In the above example, the doctor is the current Session user… Is it possible to filter above…?

Thanks in advance…

Hi.

You should define variable for UserSession in your JPQL-condition in XML-descriptor and set parameter to CollectionLoader in screen controller.
Here is an example how it could be implemented:

XML-descriptor:

<condition>
  <c:jpql>
       <c:where>e.creator = :creator</c:where>
   </c:jpql>
 </condition>

Screen controller:

@Inject
private UserSession userSession;
@Inject
private CollectionLoader<NewEntity> newEntitiesDl;

@Subscribe
public void onBeforeShow(BeforeShowEvent event) {
   User user = userSession.getUser();
   newEntitiesDl.setParameter("creator", user);
   newEntitiesDl.load();
}

Regards,
Nadezhda.