cancel
Showing results for 
Search instead for 
Did you mean: 

Get properties from custom model

luisg
Champ in-the-making
Champ in-the-making
Hi there.

I created a custom model in Alfresco. With this model I can create Alfresco documents with specific properties:

 <types>
                <!– Enterprise-wide generic document type –>
                <type name="sp:myDocument">
                        <title>My Document</title>
                        <parent>cm:content</parent>
                        <properties>
                                <property name="sp:identifier">
                                        <title>ID</title>
                                        <type>d:text</type>
                                        <mandatory>true</mandatory>
                                </property>
                                <property name="sp:CreatedDate">
                                        <title>Creation Date</title>
                                        <type>d:text</type>
                                        <mandatory>true</mandatory>
                                </property>
                                <property name="sp:DocumentType">
                                        <title>Document type</title>
                                        <type>d:text</type>
                                        <mandatory>true</mandatory>
                                </property>
                        </properties>
                </type>
        </types>

This is working fine. I can create this type of documents through a Web Services.
But my problem is, I can't access to the 'My Document' properties. I do a lucene search(using my type, and the ID property), I get the result, but I can see the custom properties…
Here is my code:

try{
   RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();

   Query query = new Query(Constants.QUERY_LANG_LUCENE,
         "TYPE:\"{http://www.sigpoa.com/model/content/1.0}myDocument\" AND @sp\\:identifier:\""+idDocument+"\"");
   
   QueryResult queryResult = repositoryService.query(STORE, query, false);
   ResultSet result = queryResult.getResultSet();
   ResultSetRow[] rows = result.getRows();

if I do a search for a normal Alfresco document, I access the property X like this: row[0].column[X Position].getValue(); But in my custom model, I only have 1 column.

Can Any of you tell me what I'm doing wrong?

Thanks in advance
2 REPLIES 2

openpj
Elite Collaborator
Elite Collaborator
Before implementing a service with a query I suggest you to test this query on the Alfresco Node Browser (selecting Lucene query from the select list).
In this way you can test easily all your custom queries for all of your custom content model.

Hope this helps.

luisg
Champ in-the-making
Champ in-the-making
I did that and it works.

But, if I want the document properties, I need to do something like:

Reference r = new Reference(STORE, uuid, null);
        Node[] a = repositoryService.get(new Predicate(new Reference[]{r}, STORE, null));

It's not possible to get the properties as I was trying.
I try some with the above solution and works fine.

Thanks