MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

PivotViewer search (via CXML metadata)  (MonoX Roadmap )

Viewed 46933 time(s), 7 post(s) 11/28/2012 5:00:52 PMby Zoomicon
Zoomicon

Zoomicon

11/28/2012 5:00:52 PM
Please see my post:
</br>http://zoomicon.wordpress.com/2012/11/28/pivotviewer-for-a-rich-search-experience/
</br>
</br>since apart from the Silverlight PivotViewer there's also an HTML5 PivotViewer (see end of my post on that one) it would be nice if MonoX could produce CXML data for its galleries (photo, files uploads) with metadata for each gallery item (e.g. author, license, thumbnail etc). Could also produce CXML files for other stuff like blog posts, forums etc.
This content has not been rated yet. 
2793 Reputation 345 Total posts
denis

denis

11/28/2012 6:38:52 PM
cXML is one of the formats under consideration. We will let you know if it will be included in version 5.
This content has not been rated yet. 
7207 Reputation 956 Total posts
Zoomicon

Zoomicon

11/28/2012 10:16:27 PM
note that the latest version of PivotViewer doesn't require DeepZoom tiles for the images (although its nice to have if you have high quality images for items and want to zoom-in smoothly to them) which makes it much easier to generate CXML via some stored procedure (and probably then cache it for some period [if any] defined by the admin)

e.g. one could even generate CXML for the Forum topics and have one of the Facets for them be "Tag" with the facet values being the distinct tags given to forum topics so that one can filter them by a set of Tags in the PivotViewer

if you have a separate CXML generation point [a URL] for all stuff in the system, then another Facet could be "Item type", so that you could select one or more from "Gallery item, Blog article, Forum topic" etc. at that Facet and combine with a selection of tags at the "Tag" facet.

Not sure if CXMLs can be in a hierarchy and combined together, e.g. if you can have separate CXMLs for Forum topics, for Blog articles etc. and a parent CXML just refer to them instead of having to generate a separate flat one that contains all of them. Probably you can though (maybe with the help of OData) if I remember well how the PivotViewer + OData + Windows Azure Netflix browsing demo is working (http://www.ditii.com/2010/06/30/pivotviewer-silverlight-control-odata-windows-azure-visual-netflix-browsing )

btw found an interesting document from the opensource semantic web database Virtuoso (SPARQL) on RDF to/from CXML. Probably OpenSocial that MonoX supports is RDF based? (obviously all that opensocial data would be a nice source for CXML generation and visual exploration using PivotViewer or data mining with other tools too [can be useful for both social researchers and marketers])
http://www.openlinksw.com/dataspace/dav/wiki/Main/VirtSparqlCxml#AncIntroduction
that document also introduces the PivotViewer UI and concepts from the semantic web point of view
This content has not been rated yet. 
2793 Reputation 345 Total posts
pajo

pajo

11/29/2012 12:00:43 PM
Hi,

OpenSocial in MonoX is implementation of OpenSocial standard and it implements API Server v1.1. In short it's not RDF based and as I can see OpenSocial standard dosen't include RDF format specification, it requires you to support XML, Json and Atom format, but you can support additional formats in your container if you want. It's possible to implement RDF output format if you write your formatter. If you're interested in implementing it I can give guidance how you can add it to our OpenSocial container.
This content has not been rated yet. 
629 Reputation 83 Total posts
Zoomicon

Zoomicon

11/29/2012 5:38:42 PM
yes please advise so, I'd be glad to contribute extra formatters for the OpenSocial data (CXML and possibly RDF too)
This content has not been rated yet. 
2793 Reputation 345 Total posts
pajo

pajo

11/30/2012 2:46:56 PM
OpenSocial server is built on top of WCF and when you have service without configuration it can get pretty ugly.

So lets start. First you need to implement your message, easiest way is to use BaseOpenSocialMessage it would look something like this.

public class MyMessageFormat : OpenSocial.Service.BaseOpenSocialMessage
{
    public MyMessageFormat(object graph)
        : base(graph)
    {
    }
 
    protected override void OnWriteBodyContents(System.Xml.XmlDictionaryWriter writer)
    {
        var objectToSerialize = this.Graph;
 
        // write your serialization
    }
}
In order to return your type of message you need to add some behaviors to the service. Code will look like this

public class OpenSocialServiceFactoryExt : OpenSocial.Service.OpenSocialServiceFactory
{
    public override System.ServiceModel.ServiceHostBase CreateServiceHost(string constructorString, Uri[] baseAddresses)
    {
        var service = base.CreateServiceHost(constructorString, baseAddresses);
 
        service.Description.Behaviors.Add(new OpenSocialBehaviorExt());
 
        return service;
    }
}
 
public class OpenSocialBehaviorExt : System.ServiceModel.Description.IServiceBehavior
{
    #region IServiceBehavior Members
 
    public void AddBindingParameters(System.ServiceModel.Description.ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection<System.ServiceModel.Description.ServiceEndpoint> endpoints, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
    {
    }
 
    public void ApplyDispatchBehavior(System.ServiceModel.Description.ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
    {
        foreach (ServiceEndpoint endpoint in serviceHostBase.Description.Endpoints)
        {
            foreach (OperationDescription operationDescription in endpoint.Contract.Operations)
            {
                if (!operationDescription.Behaviors.Any(b => b is OpenSocialFormattingBehaviorExt))
                    operationDescription.Behaviors.Add(new OpenSocialFormattingBehaviorExt());
            }
        }
    }
 
    public void Validate(System.ServiceModel.Description.ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
    {
    }
 
    #endregion
}
 
public class OpenSocialFormattingBehaviorExt : IOperationBehavior
{
    #region IOperationBehavior Members
 
    public void AddBindingParameters(OperationDescription operationDescription, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
    {
    }
 
    public void ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation)
    {
    }
 
    public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
    {
        dispatchOperation.Formatter = new OpenSocialMessageFormatterExt(dispatchOperation.Action, dispatchOperation.Formatter);
    }
 
    public void Validate(OperationDescription operationDescription)
    {
    }
 
    #endregion
}
 
public class OpenSocialMessageFormatterExt : IDispatchMessageFormatter
{
    private string action = null;
    private IDispatchMessageFormatter innerDispatcher = null;
 
    public OpenSocialMessageFormatterExt(string action, IDispatchMessageFormatter innerDispatcher)
    {
        this.action = action;
        this.innerDispatcher = innerDispatcher;
    }
 
    #region IDispatchMessageFormatter Members
 
    public void DeserializeRequest(global::System.ServiceModel.Channels.Message message, object[] parameters)
    {
        WebOperationContext contex = WebOperationContext.Current;
 
        if (contex.IncomingRequest.ContentType == "application/my-content-type")
        {
            // Deserialize request
        }
        else
        {
            innerDispatcher.DeserializeRequest(message, parameters);
        }
    }
 
    public global::System.ServiceModel.Channels.Message SerializeReply(MessageVersion messageVersion, object[] parameters, object result)
    {
        WebOperationContext contex = WebOperationContext.Current;
 
        string format = (contex.IncomingRequest.UriTemplateMatch.QueryParameters["format"] ?? String.Empty).ToLowerInvariant();
 
        if (format == "my-format")
        {
            return new MyMessageFormat(result);
        }
        else
        {
            return innerDispatcher.SerializeReply(messageVersion, parameters, result);
        }
    }
 
    #endregion
}
As you can see there is more than few lines of code. I'll try to explain it in short. First we need to override service factory so we can attach additional behaviors in our case we need to add only formatting behavior. Since each operation can support different formats we're attaching our formatter to each operation. You can attach only one formatter to operation so you must pass previous formatter instance in your formatter. In general you're looking if you can handle requested content type, if you can you create a message to send and you're done else you just pass it to previous formatter.

And last thing to do is to set your factory in svc file. Find OpenSocial.svc inside MonoX and change Factory property to point to your factory

<%@ ServiceHost Language="C#" Debug="true" Service="OpenSocial.Service.OpenSocial" CodeBehind="OpenSocial.svc.cs" Factory="MyNameSpace.OpenSocialServiceFactoryExt" %>
Unfortunately OpenSocial service has stuck in 3.5 framework and it will not work on 4.0 framework. I've fixed all issues, but you'll need to use nightly build. Let me know if you need any additional information.
This content has not been rated yet. 
629 Reputation 83 Total posts
Zoomicon

Zoomicon

6/23/2014 1:11:42 AM

btw, can try http://gallery.clipflair.net for example of how we use PivotViewer

not using HTML5 PivotViewer port there, using Silverlight original control instead, since ClipFlair Studio is also in Silverlight so our users have it installed

This content has not been rated yet. 
2793 Reputation 345 Total posts