1

我已经尝试了一天左右的时间来扩展具有额外属性的人模型,但到目前为止,还没有成功。我遵循了这个旧教程,但无法正常工作。查看页面上的一些回复表明有人在 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:authority的错误,说找不到。肯定所有 cm:* 命名空间对象都会在可扩展对象之前加载,因此 cm:authority 本身是否可用?

4

2 回答 2

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 来添加您的属性。

最好的解决方案是创建方面而不是自定义类型,并通过行为添加您的方面并设置属性。

创建自定义行为的好教程是

http://alfrescoblog.com/2014/06/02/alfresco-creating-custom-behavior-tutorial/

这将是如何扩展 cm:person 并使用它。

于 2014-06-08T11:50:53.840 回答
0

ECMA 架构师指南示例有效。我下载了代码示例并根据我的情况进行了调整。

于 2013-03-26T10:01:19.873 回答