Forum Stats

  • 3,740,600 Users
  • 2,248,280 Discussions
  • 7,861,338 Comments

Discussions

Working with Social Objects in Oracle Social Network Cloud

Aparna Gaonkar-Oracle
Aparna Gaonkar-Oracle Member Posts: 7
edited Jul 7, 2016 8:08PM in Developer Solutions

Social Objects in Oracle Social Network Cloud are generally used to add Collaboration features to your Business Objects i.e. System of record (for e.g. to carry out a conversation regarding a particular opportunity in Sales Cloud).  Social Objects have their own metadata (attributes), "wall", a documents area where you can upload documents, and provisions to attach other related conversations/objects.

You can limit visibility or share a Social Object between other people in your organization by adding individuals or groups.

For simple scenarios, where not much relational data is needed, a Social Object can also directly be used as a system-of-record.

In this blog post I will explore one such case - using the Social Object API to implement a simple Kanban board with collaboration features.

Creating a Social Definition

The first step is to create a Social Definition of a Kanban task.  We will call it "KanbanTask" and have three attributes in it

- Status (TODO, DONE, DOING)

- Title

- Description

- Assigned

The definition of a Social Object can be uploaded by an Administrator using the Social Network UI ( Administration -> Social Objects -> Create ).  This can also be done programmatically using REST APIs.  If you have a staging instance, this can also be done via the Social Definiton Builder available at https://<staging-instance>/osndevelopers/ui/integrations/integrations.jsp.  This is a one time activity and I am using the upload option to seed a simple Social Definition. 


<?xml version="1.0" encoding="UTF-8"?>
<Module>
 <ModulePrefs title="KanbanTask" description="A Kanban Task representation" height="175">
 <Require feature="rpc" />
 <Require feature="waggle" />
 <Require feature="jquery" version="1.3.2" />
 <Require feature="jquery-ui" version="1.8.12" />
 <Require feature="osnutils" />
 <Locale country="ALL" lang="all">
            <msg name="osn.group.name">Tools</msg>
            <msg name="osn.group.name.lowercase">tools</msg>
            <msg name="osn.gadget.name">KanbanTask</msg>
            <msg name="osn.gadget.name.lowercase">kanbantask</msg>
            <msg name="osn.gadget.name.plural">KanbanTasks</msg>
            <msg name="osn.gadget.name.plural.lowercase">kanbantasks</msg>
            <msg name="osn.gadget.create.short">New Kanban task</msg>
            <msg name="osn.gadget.create.long">Create a new Kanban Task</msg>
            <msg name="osn.gadget.create.tooltip">Create a new Kanban Task</msg>
            <msg name="osn.field.name.TITLE">Title</msg>
 <msg name="osn.field.name.STATUS">Status</msg>
            <msg name="osn.field.name.ASSIGNED">Assigned</msg>
            <msg name="osn.field.name.DESCRIPTION">Description</msg>
 </Locale>
 <Locale country="ALL" lang="de" />
 <Locale country="ALL" lang="es" />
 <Locale country="ALL" lang="fr" />
 <Locale country="ALL" lang="it" />
 <Locale country="ALL" lang="ja" />
 <Locale country="ALL" lang="ko" />
 <Locale country="BR" lang="pt" />
 <Locale country="CN" lang="zh" />
 <Locale country="TW" lang="zh" />
 </ModulePrefs>
 <ConversationTypePrefs group="Tools" group_order="1" creatable="true" updateable="true" renameable="true" discoverable="false" closeable="true" deletable="false" customizable="true" ui="true" analytics="false" analytics_outcome="false" scoping="false" integration_adapter="none">
 <Field property_key="TITLE" type="STRING" case_sensitive="false" required="false" read_only="false" external="false" analytics="false" display_in_detail="true" display_in_summary="true" display_in_digest="false" filterable="false" sortable="true" units_prefix="false" not_nullable="false" />
 <Field property_key="DESCRIPTION" type="STRING" case_sensitive="false" required="false" read_only="false" external="false" analytics="false" display_in_detail="true" display_in_summary="true" display_in_digest="false" filterable="false" sortable="true" units_prefix="false" not_nullable="false" />
 <Field property_key="STATUS" type="STRING" case_sensitive="false" required="false" read_only="false" external="false" analytics="false" display_in_detail="true" display_in_summary="false" display_in_digest="false" filterable="false" sortable="false" units_prefix="false" not_nullable="false" />
 <Field property_key="ASSIGNED" type="STRING" case_sensitive="false" required="false" read_only="false" external="false" analytics="false" display_in_detail="true" display_in_summary="false" display_in_digest="false" filterable="false" sortable="false" units_prefix="false" not_nullable="false" />

 </ConversationTypePrefs>
 <Content type="html"><![CDATA[ 
<script type="text/javascript"> gadgets.util.registerOnLoadHandler(function() { osnutils.gadget.load(); }); </script>
 ]]></Content>
</Module>













Save the XML to the local directory and upload it via the Social Definition screen.

SocialDefinition.png

Once this XML containing the social Object Definition is uploaded you can see the option to create a new “Kanban Task” from the Navigation menu on the left hand side. Note that the Social Object “KanbanTasks” is  in a Group called Tools, since we specified the same in the XML.

social_object_options.png

Creating and Updating a Social Object

Navigating to this new menu option will take you to the “Kanban Task” Social Objects page, where you have options to create, update or view the social objects.  You can also see the type of the social object in the URL when you navigate to this page

http://<server:port>/osn/web/cList/socialObjects/type/13452

Here, 13452 is the type id of the Social Object "KanbanTask"

Create a new "KanbanTask" by clicking on the "New" button.  This will open the standard OSN gadget window where you can give a title, and manage membership to the new object that will be created.

social_object_create.png

The "KanbanTask" will be created with default values of the attributes that we used in the definition.  This is how it will look like in the UI.

social_object_created.png

Now you can "Edit" the Social Object to edit these values.  Any changes to the Social Object Data will be visible in the Wall and the members assigned to the Social Objects can collaborate and share documents pertaining to the Social Object.

REST interface

The OSN comes with a exhaustive REST API catalog to programmatically perform various tasks and can be referred here. Let us retrieve the Social Object we have just created.

The first API to be used for establishing a connection to the Social Network Cloud Service is the connections API.  This API will create a new connection or determine if there is an existing connection and also return a cookie for further communication.

POST http://<host-name>/osn/social/api/v1/connections HTTP/1.1

Accept-Encoding: gzip,deflate

Content-Type: application/json

Content-Length: 57

{

                "name" : "tenant.admin",

                "password" : "abc123"

}

and the response - a whole bunch of attributes corresponding to the logged

HTTP/1.1 200 OK

Date: Tue, 28 Jun 2016 02:02:30 GMT

Set-Cookie: OAMAuthnCookie_<hostname>:443=C3TVf6ypnEzq8RZ9G3wjax6Gq.....;

X-ORACLE-DMS-ECID: 005D^o7XiLt6eLG_IxG7yf0006nT00001R

X-Powered-By: Servlet/2.5 JSP/2.1

X-Content-Type-Options: nosniff

Keep-Alive: timeout=5, max=100

Connection: Keep-Alive

Transfer-Encoding: chunked

Content-Type: application/json;charset=UTF-8

Content-Language: en

{

  "user" :

  {

    "id" : "10190",

    "name" : "tenant.admin",

    "displayName" : "tenant.admin",

    "objectType" : "waggle/user",

    "createdByID" : "10041",

    "createdByUserName" : "System",

  ..

  ..

  "apiVersionMinimum" : 6076,

  "apiRandomID" : "b375e527c6e1bbf3b1f2f7fb96184f3e",

   "isTerseMode" : false

}

There are two things that need to be passed i the subsequent requests - the cookie and the apiRandomId.  The apiRandomID should be passed in the X-Waggle-RandomID parameter in the header

Here are the headers, payload for the request for getting all Social Objects.  You can add a filter query parameter to limit the response to certain variables (e.g. getting all Social Objects that are applicable to a certain user as shown here)

GET  /osn/social/api/v1/socialObjects ?filter={"commonMemberID" : "10190"}

HTTP/1.1 Accept-Encoding: gzip,deflate

cookie: OAMAuthnCookie_<hostname>:443=C3TVf6ypnEzq8RZ9G3wjax6Gq.....;

X-Waggle-RandomID: b375e527c6e1bbf3b1f2f7fb96184f3e


Here is the response containing the Social Object just created.

{

   "hasMore": false,

   "items":    [

            {

         "id": "13455",

         "name": "UI1 - Coding",

         "objectType": "waggle/conversation",

         "createdByID": "10190",

         "createdByUserName": "tenant.admin",

..

..

         "nFollowups": 0,

         "fields":          [

                        {

               "name": "ASSIGNED",

               "value": "Aparna"

            },

                        {

               "name": "DESCRIPTION",

               "value": "UI coding for task 1"

            },

                        {

               "name": "STATUS",

               "value": "TODO"

            },

                        {

               "name": "TITLE",

               "value": "Task1"

            }

         ],

...

..

      },

   ]

}

Embeddable UI

The OSN Web UI can be directly displayed in other applications.  This can be done by using the Social Plugins which are UI components embeddable in other applications.

The view to be shown is inserted after the root portion of the URL.  So

https://<hostname:port>/{instance}/web/cList/{view}

Example:

https://tenantname.com:1234/osn/web/cList/conversations/9877

displays the view for the conversation id 9877

The particular view can be further customized as to not show certain options

E.g.

https://tenantname.com:1234/osn/web/cList/conversations/9877?locale=en&hide=navMenu+sidebar

will hide the navigation menu and sidebar from the conversation list displayed.

For full reference please consult the Social Plugin documentation available on https://<hostame>/osn/web/cList/api 

Wrapping it all together

The output of the REST APIs and the embeddable UI can now be used in the visualization of choice.  For my project, I have created a simple JET application that will be deployed in a Java Cloud Service - SaaS Extension which is in the same identity domain as the Social network Cloud to achieve SSO.  The JET application first retrieves the Social Objects of type KanbanTask for the logged in user and then arranges them on a simple Kanban Board.  The tasks can be dragged and dropped in the To do, Done and In Progress areas. Clicking on any task will load the Social Object page for that particular task in the right hand menu.

kanban_board.png

The views expressed in this post are my own and do not necessarily reflect the views of Oracle.

Tagged:
Sign In or Register to comment.