cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED]Adding cm:person as property (aspect) from wizard.

libman
Champ in-the-making
Champ in-the-making
Hi,

I have a wizard where I get the list of usernames. When selected, I get from personService the user. I did not get a null, so it should be good. But while adding it as property (association), the property is empty after the wizard is finished. I can select persons in the detail view.

I use the following codes:
NodeRef manager = getPersonService().getPerson(this.getManager());
projectProps.put(ProjectModel.ASPECT_PROJ_PROP_MANAGER,manager);
I also tested getId() and getStoreRef().

Other properties are set (string) correctly. The QName is checked and is correct.

What can the problem be?

Thanks very much.
6 REPLIES 6

libman
Champ in-the-making
Champ in-the-making
It worked when I first developped it, but later no more. I tested everything I could: the line is executed, the strings are correct, the QName should also be ok.

Thanks.

vsuarez
Champ in-the-making
Champ in-the-making
I think you are managing a parent-child association, like space-content one. Can you establish such type of relationship with only properties?

In the model this associations must be defined as it is said in http://wiki.alfresco.com/wiki/Data_Dictionary_Guide#Child_Associations and http://wiki.alfresco.com/wiki/Data_Dictionary_Guide#Non-Child_Associations.

I have not worked with this type of properties, so it would be very interesting to know how you resolve this problem. I guess you have to work with CML.addChild property.

I can be completely wrong  Smiley Surprisedops:. I am only supposing.

libman
Champ in-the-making
Champ in-the-making
It is not a parent-child relationship:

<associations>
<association name="project:projectmanager">
  <title>Project manager</title>
   <source>
    <mandatory>false</mandatory>
    <many>false</many>
  </source>
  <target>
   <class>cm:person</class>
   <mandatory>false</mandatory>
   <many>false</many>
  </target>
</association>
I am sure it worked before, with the same code. Very strange.

vsuarez
Champ in-the-making
Champ in-the-making
Node.getProperties() only returns a List<NamedValue>, and each NamedValue object is a pair of strings, so I can't guess how we can get a person from a String. I'll try to study a little more this case (if I get some free time).

EDIT: there is a queryAssociated method in the repository service, but I haven't time to test it.

Regards

libman
Champ in-the-making
Champ in-the-making
To clarify:

getManager() gives a String which is get by:
nodeService.getProperty(ref,
   ContentModel.PROP_USERNAME).toString());
Where ref is a NodeRef from personService.getAllPeople();
If I understood your reply, you think that I want to get a property from the aspect. This is not correct. I just want to set the person as property.

libman
Champ in-the-making
Champ in-the-making
It is not a property, but association. It cannot be added as "property", but realised with use of the "createAssociation" function of the nodeService service.