Adding new data types

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
hsjawanda
Member II

Adding new data types

Hi all,

So Alfresco supports the types listed here: http://www.alfresco.org/mediawiki/index.php/Data_Dictionary_Guide#Data_Types

How about adding new types? Is that possible? If so, how?

For example, I want to add support for saving and retrieving java.lang.List and java.lang.Map.  Is that going to be possible? What might the restrictions be?

Thanks.
4 Replies
gavinc
Member II

Re: Adding new data types

Unless you want to of course, you don't have to have explicit support for these types to store them in the repository. If you declare the property as type "any", then you can just store the List and Map directly.

The setProperty() method on the node service takes a Serializable object so you should be able to set and get any Java object (as long as it implements Serializable).

In fact, if you define a property as having multiple values the values are actually stored as a List in the repository. A word of warning though the UI does not currently support the editing of mulitple valued properties, this is something we will fix in 1.3.

Hope this helps.
hsjawanda
Member II

Re: Adding new data types

In fact, if you define a property as having multiple values the values are actually stored as a List in the repository.
I never realized that properties could be multivalued, idiot that I am!!!

Anyway, for storing multiple values, I declare <multiple>true</multiple> in the definition for the property, and then I make multiple calls to setProperty()?  If so, how do I retrieve all the values when calling getProperties() or getProperty()? Do I cast the Serializable to a List?

Or do I create a List<String> (or whatever) and then set that as the property value?

I know I can define types for properties that are statically declared in a content model file.  How do I specify a property's type when I am adding it dynamically without having first declared it in a content model file?
gavinc
Member II

Re: Adding new data types

You can pass in any collection, or indeed a single value to a property defined as multiple. However, you will always get back a List, which as you say you will need to cast to.

You can't set the type of a property when you add it dynamically (this is the benefit of defining it in the model) the property will be set with whatever you pass to setProperty, the only requirement is that it must be Serializable.

Hope that helps.
ruffp
Member II

Re: Adding new data types

Hello,

My case is quite similar except the objects I want to save are a bit different.

class Summary{
String id;
String htmlContent;

//getters and setters
}

I made a custom UISummary instanciated by a UISummaryGenerator.

My question is : where I can map the UIcomponent values coming from the web page to my object.

The serialization couldn't be automatic in that case, but :

- the UIComponent is not aware about Spring context (eg. the decode function)
- the Summary is not aware about the UI
- the generator is constructing the UI but does not seems to have a callback function after the submit to save the metadata

I have a converter which convert the ObjectToString and StringToObject, but it seems to be called on the rendering and not when I submit the edit page.

Do I need to implement my own EditProperties dialog or I can just implement another method somewhere?

If anyone can show me a link or explain what to do, am getting stuck with that problem since one day.

Thanks and best regards,
Patrick