2 Replies Latest reply: Sep 12, 2013 1:53 AM by user590668 RSS

    Endeca how to fetch index data based on Profile

    user590668

      Can anybody tell me How to fetch index data based on profile using Business Rule in Developer studio

      I have created style & zone in the developer studio & created Business Rule. Also created profile which is map with business rue, but how can i check my rule is correct.

       

      I wanted to create rule for user1 -

      Rule1 - if user1 is login and attribute value = Y then display some category

      if anonymous login then show all data etc

       

      Thanks

      Shailesh

        • 1. Re: Endeca how to fetch index data based on Profile
          SunilN

          Hi Shailesh,

           

          You can get the logged in user from request and use the below code

          Set profiles = new HashSet();

          String userType = ("user");

          if(userType.equals("user1"))

          {

            profiles.add(userTypePro);

            oENEQuery.setProfiles(profiles);

          }

           

          Thanks,

          Sunil N

          • 2. Re: Endeca how to fetch index data based on Profile
            user590668

            Thanks Sunil,

            I am already setting the profiles in query.Please see below code

            ENEConnection nec = new HttpENEConnection("localhost","18000");

            try {

            usq1 = new UrlENEQuery("N=0", "UTF-8");

                        Set profiles = new HashSet();

                        String userType = ("bob");

                        if(userType.equals("bob"))

                        {

                          profiles.add(userType);

                            usq1.setProfiles(profiles);

                        }

            usq1.setNavAllRefinements(false);

                    ENEQueryResults qr = nec.query(usq1);

                    request.setAttribute("eneQueryResults", qr);

            if (qr.containsNavigation()) {

            request.setAttribute("navigation", qr.getNavigation());

            Navigation nav = (Navigation)request.getAttribute("navigation");

             

                                    ERecList recs = nav.getERecs();

                                    System.out.println("Reecccccco"+recs.size());

                                    for (int i=0; i<recs.size(); i++) {

                                        ERec rec = (ERec)recs.get(i);

                                        PropertyMap propsMap = rec.getProperties();

                                        Iterator props = propsMap.entrySet().iterator();

                                            String recordName = "Record " + rec.getSpec();

            }                   

            }

                    } catch (UrlENEQueryParseException e) {

                    } catch (ENEQueryException e) {

                    }

             

            Please let me know do I need to add any more parameter in the query. or if u have any idea on how to create simple business rule in studio developer & display on JSP.

             

            Thanks

            Shailesh