cancel
Showing results for 
Search instead for 
Did you mean: 

support for adding List<Object> to cmis:Document

mcs130
Champ in-the-making
Champ in-the-making
Hello,

After originally posting to the Apache Chemistry dev list, it was suggested that I post this question here since it is beginning to get Alfresco-specific.

We have a need to expand a content model so that the Document model can include a List<> where the List contains a custom type called UserNote…

Some of the original info as posed on the mailing list is as follows:

===========================================================================================

BTW - This is an all Java implementation from the client side.  Here is the scenario.

   We can currently add properties to cmisSmiley Very Happyocument …. let's say for simplicity, we add:

   categoryCode, type=String
   subCategoryCode, type=String
   displayName, type=String
   employeeID, type=String

   This works fine in both products - in one case, AF4, you extend the model with an XML configuration file whereas in Sharepoint, you can use the Library Admin page to add fields of various types to the current document model.  So far, so good.

   Now, we have a use case, where we need these same 4 properties, PLUS a List<UserNote> where:

   UserNote:

   id, type=long
   date, type=Calendar
   noteText, type=String

   As I see it we have to 1) define the UserNote object in the ECM backend somehow and 2) add this List<UserNote> property to the cmisSmiley Very Happyocument.  What they are looking to do is to keep the history of these notes made by the user on this Document whenever they retrieve it to edit, etc.  Not trying to reproduce version control as much as attaching these ad-hoc notes managed on the Document.  Notes will NOT be editable.  Once entered on the UI, they are added to this List<> and simply ride around with the Document object like any other property.

   My 2 questions are:

   Can the CMIS APIs support this use case? (confirmed that this is supported by CMIS)
   If so, can anyone suggest an example or point to document showing something similar to this?

The current model we have been using successfully looks like this (where userNote is actually just a text (String) property type:


    <types>
        <!– Enterprise-wide generic document type –>
        <type name="acme:doc">
            <title>ACME Document</title>
            <parent>cm:content</parent>
            <properties>
                <property name="acme:displayName">
                    <type>d:text</type>
                </property>
                <property name="acme:documentType">
                    <type>d:text</type>
                </property>
                <property name="acme:employeeID">
                    <type>d:text</type>
                </property>
                <property name="acme:category">
                    <type>d:text</type>
                </property>
                <property name="acme:subCategory">
                    <type>d:text</type>
                </property>
                <property name="acme:expirationDate">
                    <type>d:date</type>
                </property>
                <property name="acme:userNotes">
                    <type>d:text</type>
                </property>
                <property name="acme:keyWords">
                    <type>d:text</type>
                </property>
            </properties>

It is the following element definition above:


               <property name="acme:userNotes">
                    <type>d:text</type>
               </property>

Where we want the actual <type> to be definable as a List<UserNote>

1) we have to be able to define UserNote (obviously we can model as simple Java bean)
2) we need to be able to have this acme:doc type defined such that it can include the List<> construct

Is this even feasible to do in Alfresco4?.  We currently are doing POC work with AF4 Community 4.0.e.

Thanks in advance for your time.

Mark
3 REPLIES 3

t_sato
Champ in-the-making
Champ in-the-making
Hi,

I'm afraid no easy solution available, but I think you have two ways. I assume the problem here is not specific to CMIS, but to customizing data model on Alfresco in general. Please refer to Jeff's tutorials if you haven't read yet.

1. define your own custom data type
2. design UserNote as an embedded object

Define your own custom data type

I thought it is easy like the following, but which was not.

<property name="acme:userNotes">
    <type>acme:userNote</type>
    <multiple>true</multiple>
</property>

As described in defining your own basic data types, it is beyond simple XML editing and writing a POJO bean as its serializer/deserializer.

In 4.0, it might have been improved.

Design UserNote as an embedded object

If the UserNote doesn't need to be treated as a document, you can define UserNote as d:text, like in JSON as an embedded object.

This Add-On is an example.

If you access to Alfresco via CMIS in Java, encoding/decoding JSON should be no problem.


(confirmed that this is supported by CMIS)

Can you tell me where and how it is defined? I wasn't able to find in the specification v1.0.

mcs130
Champ in-the-making
Champ in-the-making
Thanks for the reply.  Yes I did read that document by Jeff and although a very, very helpful document for much of CMIS, I was not able to ascertain just how one could do this with a custom class definition like we are proposing. 

Your idea of using "text" property to hold a serialized JSON object as a String is interesting.  We may be constrained by the text size limit for such a property on "another" ECM they are looking at. 

As for CMIS APIs supporting this, I did not get  that from the spec.  I believe this question was posed on the Chemistry (CMIS) mailing list and there was a response that indicated passing a Document containing a custom property like this or a custom Content model in general should be supported.

Along the idea you mentioned with storing a serialized text String representation of the object (JSON or XML for that matter), do you know if one could define the property type (instead of d:text, let's say) as a binary field where one could store a serialized object instance (a class that   implements java.io.Serializable).

I see something called "content" as a type: http://wiki.alfresco.com/wiki/Type_Mechanism#Property_Types  or am I misreading this?

Thank you again for your input.

Mark

t_sato
Champ in-the-making
Champ in-the-making
Along the idea you mentioned with storing a serialized text String representation of the object (JSON or XML for that matter), do you know if one could define the property type (instead of d:text, let's say) as a binary field where one could store a serialized object instance (a class that implements java.io.Serializable).

I see something called "content" as a type: http://wiki.alfresco.com/wiki/Type_Mech … erty_Types or am I misreading this?

It is the data type of the main property of cm:content that holds its binary data.

So you define your own type that has an additional d:content data type property. I haven't tried, but it seems it can handle an arbitrary binary stream according to the official document as well.


Btw, in "Alfresco Developer Guide" by Jeff, it says:

Even though these data types are defined out of the box, if you wanted to change the Alfresco data type "text" so that it maps to your own custom class rather than java.lang.String, you could.

So I hope Jeff would chime in this discussion.