German

Ning Apps: Creating cross-network applications

Until now I've been teaching you how to create Ning apps that exchange information with your network, both receiving information about the viewer and sending back results through the creation of user activities.

In this article, I'll show you how you can create an application that can be added from different networks, storing information identifying the source network so as to filter data later.

This kind of applications will store all the information in a single database schema. Another valid approach would be to have a new schema created for each Ning network, using the multitenancy capability of JRapid apps. However, we'll choose the single-schema approach to keep this example simple, but also thinking of a hidden strength of our resulting app. I will comment on that in the end of the article.

The idea is quite straightforward: JRapid apps receive parameters through subsetparams and defaultsetparams, so that's what we'll do. We will use the network object to send network's id. Optionally, we could need more information, like the network domain (if using a private domain) or subdomain (if using subdomain.ning.com).

So, let's start with a data model based on our example from Creating Ning apps in 10 steps with JRapid tutorial.


Here we have an entity named Company. The issue we had was that in the end, if this application was added by more than one network, the information would be shared (we never identified the source network), showing all companies in all networks.

Let's add the following elements:
  1. A networkId property that will store the source network.
  2. A networkId parameter for the subsets we will use in ning, which will filter the displayed records.
  3. A networkId parameter for the defaultset, which will send the source network Id in the moment we create a new Entity.
The resulting XML for the entity will look like the following one:

<entity label="Company" name="Company">
<listing displayproperties="name;address;personThumbnailUrl" name="icons" noadd="noadd" noremove="noremove" subset="forPublic" view="tableicons"/>
<subset displayproperties="name,address,city,url,personProfileUrl,personThumbnailUrl" name="forPublic">
<param name="networkId"/>
<condition field="networkId" value="networkId"/>
</subset>
<defaultset name="withParams">
<param name="remoteNetworkId"/>
<param name="remotePersonId"/>
<param name="remotePersonName"/>
<param name="remotePersonThumbnailURL"/>
<default name="networkId" value="remoteNetworkId"/>
<default name="personId" value="remotePersonId"/>
<default name="personName" value="remotePersonName"/>
<default name="personThumbnailUrl" value="remotePersonThumbnailURL"/>
<default name="name" value="remotePersonName"/>
</defaultset>
<property hidden="hidden" name="networkId"/>
<property display="primary" label="Name" name="name"/>
<property display="secondary" label="Address" name="address"/>
<property display="secondary" label="City" name="city"/>
<property label="Email" name="email" type="email"/>
<property label="URL" name="url" type="url"/>
<property label="Person ID" name="personId"/>
<property label="Person NAME" name="personName"/>
<property label="Person THUMBNAIL_URL" name="personThumbnailUrl" widget="imageurl"/>
</entity>


The last thing we need to do is adapting our <ning> transformer definition, adding network.id param wherever needed.

<ning label="Companies" name="Companies" url="http://www1.jrapidcloud.com/ningtutorial5/forms.Main/">
<links>
<link entity="Company" label="Companies" listing="icons" subset="forPublic" type="listing" subsetparams="network.id"/>
<link defaultset="withParams" defaultsetparams="network.id,viewer.id,viewer.displayName,viewer.opensocial.Person.Field.THUMBNAIL_URL"
entity="Company" label="Register" type="form" />
</links>
<views>
<view entity="Company" listing="icons" name="canvas" subset="forPublic" type="listing" subsetparams="network.id" />
</views>
</ning>


So we end up having a filtered list for each network were we add our Ning App:



In conclusion, we have achieved a real cross-network application. As I suggested at the beginning of this post, there is a hidden advantage when choosing this single-schema approach. What we have now is a single database, where we have a compilation of the companies from all networks. This could be extra information to show as part of the application (obviously hiding sensible data), but at least through reports and charts that could be done with, for instance, googlecharts view.

Views: 23

Tags: JRapid, Network, NingApps, Transformer, Widgets

Comment

You need to be a member of JRapid Community to add comments!

Join JRapid Community

© 2012   Created by JRapid Community Manager.   Powered by .

Badges  |  Report an Issue  |  Terms of Service