我已经尝试了一天左右的时间来扩展具有额外属性的人员模型,到目前为止,还没有成功。我跟着this old tutorial但是无法正常工作。看一下页面上的一些回复,可以看出有人曾在4.1中尝试过并且没有让它工作。我正在测试4.2。 任何见解都将不胜感激。
修改
我有以下customContentModel.xml:
<model name="cm:contentModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<!-- Optional meta-data about the model -->
<description>Professional Person Model</description>
<author></author>
<version>1.0</version>
<!-- Imports are required to allow references to definitions in other models -->
<imports>
<!-- Import Alfresco Dictionary Definitions -->
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
<!-- Import Alfresco Content Domain Model Definitions -->
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
<import uri="http://www.syn.fr/model/person/ext" prefix="ppm"/>
</imports>
<types>
<type name="cm:person">
<title>Person</title>
<parent>cm:authority</parent>
<properties>
<!-- The tokenisation set here is ignored - it is fixed for this type -->
<!-- This is so you can not break person lookup -->
<property name="cm:userName">
<type>d:text</type>
<mandatory>true</mandatory>
<constraints>
<constraint ref="cm:userNameConstraint" />
</constraints>
</property>
<property name="cm:homeFolder">
<type>d:noderef</type>
<mandatory>true</mandatory>
</property>
<property name="cm:firstName">
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<property name="cm:lastName">
<type>d:text</type>
<mandatory>true</mandatory>
</property>
<property name="cm:middleName">
<type>d:text</type>
</property>
<property name="cm:email">
<type>d:text</type>
</property>
<property name="cm:organizationId">
<type>d:text</type>
</property>
<property name="cm:homeFolderProvider">
<type>d:text</type>
</property>
<property name="cm:defaultHomeFolderPath">
<type>d:text</type>
</property>
<property name="cm:presenceProvider">
<type>d:text</type>
</property>
<property name="cm:presenceUsername">
<type>d:text</type>
</property>
<property name="cm:organization">
<type>d:text</type>
</property>
<property name="cm:jobtitle">
<type>d:text</type>
</property>
<property name="cm:location">
<type>d:text</type>
</property>
<property name="cm:persondescription">
<type>d:content</type>
</property>
<property name="cm:telephone">
<type>d:text</type>
</property>
<property name="cm:mobile">
<type>d:text</type>
</property>
<property name="cm:companyaddress1">
<type>d:text</type>
</property>
<property name="cm:companyaddress2">
<type>d:text</type>
</property>
<property name="cm:companyaddress3">
<type>d:text</type>
</property>
<property name="cm:companypostcode">
<type>d:text</type>
</property>
<property name="cm:companytelephone">
<type>d:text</type>
</property>
<property name="cm:companyfax">
<type>d:text</type>
</property>
<property name="cm:companyemail">
<type>d:text</type>
</property>
<property name="cm:skype">
<type>d:text</type>
</property>
<property name="cm:instantmsg">
<type>d:text</type>
</property>
<property name="cm:userStatus">
<type>d:text</type>
</property>
<property name="cm:userStatusTime">
<type>d:datetime</type>
</property>
<property name="cm:googleusername">
<type>d:text</type>
</property>
<property name="cm:emailFeedDisabled">
<type>d:boolean</type>
</property>
<property name="cm:subscriptionsPrivate">
<type>d:boolean</type>
</property>
<!-- system maintained / protected values -->
<property name="cm:emailFeedId">
<type>d:long</type>
<protected>true</protected>
</property>
<property name="cm:sizeCurrent">
<type>d:long</type>
<protected>true</protected>
<mandatory enforced="true">true</mandatory>
</property>
<property name="cm:sizeQuota">
<type>d:long</type>
<protected>true</protected>
</property>
</properties>
<associations>
<association name="cm:avatar">
<source>
<role>cm:avatarOf</role>
<mandatory>false</mandatory>
<many>false</many>
</source>
<target>
<class>cm:content</class>
<role>cm:hasAvatar</role>
<mandatory>false</mandatory>
<many>false</many>
</target>
</association>
</associations>
</type>
<mandatory-aspects>
<aspect>ppm:attributes</aspect>
</mandatory-aspects>
</types>
</model>
我收到有关 cm:权限的错误,说无法找到。当然所有的cm:*命名空间对象都会在可扩展的对象之前被加载,因此cm:权限本身就可用了吗?
答案 0 :(得分:3)
真的很容易做,只需创建自己的类型,扩展cm:person并添加属性。
<type name="ab:myperson">
<title>Person</title>
<parent>cm:person</parent>
<properties>
<!-- The tokenisation set here is ignored - it is fixed for this type -->
<!-- This is so you can not break person lookup -->
<property name="ab:customField">
<type>d:text</type>
<mandatory>true</mandatory>
</property>..
问题是这个属性不会在新用户上设置,因为它们不是你想要的类型ab:myperson。
您需要创建自定义行为,通过将cm:person更改为ab:myperson来添加属性。
最佳解决方案是创建方面而不是自定义类型,并使用行为添加方面和设置属性。
有关创建自定义行为的精彩教程
这将是如何扩展cm:person并使用它。
答案 1 :(得分:0)
ECMA建筑师指南示例有效。我下载了代码示例并根据我的情况进行了调整。