cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
557
Views
0
Helpful
1
Replies

Searching and Requests

joshorva
Cisco Employee
Cisco Employee

Creating ContextBeans using a Set of DataElements makes a lot of sense. It mostly defines the ContextBean as a Set of DataElements, which is the right way to think about a ContextBean from a Developer's perspective.

Now, a DataElement is simply a key (as a String) and a value (as an Object). This is perfect. However, searching for a ContextBean requires a Map of < String, String >. The assumption here is that the toString() method of the Object will serve as the comparator. Typically, a design will use the equals() operator as the Comparator, which allows for a similar signature between construction and search ( < String, Object > ).

On the subject of searching specifically as it related to Requests, I do not seem to be able to get the runtime to search and find any Requests. That really limits me from updating or querying a Request, unless I know the URL to the Request. The returned List always comes back empty. Here is a snippet of code that I am using:

    final Map < String, Object > requestMetadata1_validDictionary = new TreeMap < String, Object > ()

    {

        {

            put ("Context_Description", "Request1 Description");

            put ("Context_Title", "Request1 Title");

        }

    };

    // Build Request bean object and persist in cloud context

    final Request request1 = new Request (DataElementUtils.convertDataMapToSet (requestMetadata1_validDictionary));

    request1.setFieldsets (Arrays.asList ("cisco.base.request"));

    contextServiceClient.encryptAndCreate (request1);

        {

            // ------- Look up Request - By description

            final Map < String, String > params1 = new TreeMap < String, String > ()

            {

                {

                    put ("Context_Description", "Request1 Description");

                }

            };

            final List < Request > requestList1 = contextServiceClient.searchAndDecrypt (Request.class, params1, Operation.AND);

            if (requestList1.size () > 0)

                for (Request request : requestList1)

                    System.out.println ("Search request returned: " + request.getRequestId ());

            else

                System.out.println ("No requests returned from search");

        }

        {

            // ------- Look up Request - By title

            final Map < String, String > params1 = new TreeMap < String, String > ()

            {

                {

                    put ("Context_Title", "Request1 Title");

                }

            };

            final List < Request > requestList1 = contextServiceClient.searchAndDecrypt (Request.class, params1, Operation.AND);

            if (requestList1.size () > 0)

                for (Request request : requestList1)

                    System.out.println ("Search request returned: " + request.getRequestId ());

            else

                System.out.println ("No requests returned from search");

        }

        {

            // ------- Look up Request - By description and title

            final Map < String, String > params1 = new TreeMap < String, String > ()

            {

                {

                    put ("Context_Description", "Request1 Description");

                    put ("Context_Title", "Request1 Title");

                }

            };

            final List < Request > requestList1 = contextServiceClient.searchAndDecrypt (Request.class, params1, Operation.AND);

            if (requestList1.size () > 0)

                for (Request request : requestList1)

                    System.out.println ("Search request returned: " + request.getRequestId ());

            else

                System.out.println ("No requests returned from search");

        }

        {

            // ------- Look up Request - By description or title

            final Map < String, String > params1 = new TreeMap < String, String > ()

            {

                {

                    put ("Context_Description", "Request1 Description");

                    put ("Context_Title", "Request1 Title");

                }

            };

            final List < Request > requestList1 = contextServiceClient.searchAndDecrypt (Request.class, params1, Operation.OR);

            if (requestList1.size () > 0)

                for (Request request : requestList1)

                    System.out.println ("Search request returned: " + request.getRequestId ());

            else

                System.out.println ("No requests returned from search");

        }

1 Accepted Solution

Accepted Solutions

ccosenti
Level 1
Level 1

Hi Joseph,

Search is not fully implemented and we will be incrementally improving it. As you discovered, search is not currently supported for Requests.  You may have noticed that the SDK guide doesn't provide any details on doing lookups for Requests.

I'll start a new running thread in this forum with current known limitations as well as new improvements.

-Chris

View solution in original post

1 Reply 1

ccosenti
Level 1
Level 1

Hi Joseph,

Search is not fully implemented and we will be incrementally improving it. As you discovered, search is not currently supported for Requests.  You may have noticed that the SDK guide doesn't provide any details on doing lookups for Requests.

I'll start a new running thread in this forum with current known limitations as well as new improvements.

-Chris