让我尝试根据您的评论向 @Alch3mi5t 的答案添加一些额外的信息。我在这里使用一个虚构的商业案例。
基本上,Alfresco 模型由 3 个部分组成:约束、类型和方面。另外,我会在其中添加关联。
露天中的每个节点(您可能错误地将其视为“记录”)都有一个类型。所以这个类型有属性(“列”)。所以你有了你的基本类型,假设它被称为Vendor。它有两个属性,名称和税号(字符串和整数)。
您的类型定义如下所示:
<type name="myCompany:vendor">
<title>Vendor</type>
<parent>cm:folder</parent>
<properties>
<property name="myCompany:vendorName">
<title>Vendor name</title>
<type>d:text</type>
</property>
<property name="myCompany:vendorTaxID">
<title>Vendor Tax ID</title>
<type>d:int</type>
</property>
</properties>
</type>
这就是您的类型,与包含字符串和 int 类型的供应商名称和供应商税号列的数据库表不同。
假设您现在必须对税号添加一些约束 - 简单的正则表达式示例。
所以你有一个这样定义的约束:
<constraint name="myCompany:taxIdConstraint" type="REGEX">
<parameter name="expression">
<value>^ID[1-9](\-[1-9])*</value>
</parameter>
<parameter name="requiresMatch">
<value>true</value>
</parameter>
</constraint>
现在我们只需要修改你的tax Id属性:
<property name="myCompany:vendorTaxID">
<title>Vendor Tax ID</title>
<type>d:int</type>
<constraints>
<constraint ref="myCompany:taxIdConstraint">
</constraints>
</property>
因此,您现在对该属性施加了约束。
-
Aspect现在您想要一个方面 - 在 Alfresco 中,这就像您想向该表添加一些额外的列。
不 - 更好的类比,您需要原始表中的关系。所以如果它为空,它就是空的。但或者,它会创建您的记录与其他表的 1-1(通常)关系。
这里的基线是,您永远不会单独将任何内容添加到方面表中 - 它只是作为基本类型的补充。一个示例方面:
<aspect name="myCompany:myAspect">
<title>Address aspect</title>
<properties>
<property name="myCompany:city">
<title>City</title>
<type>d:text</type>
</property>
</properties>
</aspect>
如果将其添加到类型定义中(就在特性部分):
<mandatory-aspects>
<aspect>myCompany:myAspect</aspect>
</mandatory-aspects>
现在,您可以将一条“记录”添加到您的基本“表”中,如果您将其添加为强制方面,则每条记录将有 3 个属性:名称、税号和城市。如果不是强制性的,则每个记录将有两个基本列,但您将能够添加第三个以选择几个。以编程方式或手动方式,并不重要。
-
协会现在我们还可以在组合中添加关联:这只是两个节点(或“记录”)之间的链接。
所以,之后特性您的类型部分,您可以添加协会部分。假设您想要将(某些)供应商与其创建者(关键帐户)连接起来。
您将其添加到您的类型中:
<associations>
<association name="myCompany:keyAccountManager">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm:person</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
你有它!现在,您可以将供应商表中的部分或全部供应商连接到其各自的 KAM(这样,当供应商出现问题时,您可以向 KAM 发送电子邮件)。基本上,供应商表和用户表之间存在 1-n 连接。
1-n 表示您可以将一个供应商连接到多个人员。您还可以将不同的供应商连接到一个人。 (许多参数)。
您还可以以相同的方式将关联添加到方面:
<aspect name="myCompany:stateAspect">
<properties>
...
</properties>
<associations>
<association name="myCompany:myState">
<source>
<mandatory>true</mandatory>
<many>true</many>
</source>
<target>
<class>cm:folder</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
</aspect>
现在,您可以创建常规的露天文件夹(cm:文件夹类型)并以州名称命名它们,并将每个城市连接到其中一个文件夹。 (不是最好的方法,但表明了我的观点。)
所以这个关联是强制性的,这意味着如果您添加其他方面(不是原始的),这不是强制性的,您必须创建一个关联。
因此,请使用各种组合来完成您需要的操作。
现在您有了示例模型:
<?xml version="1.0" encoding="UTF-8"?>
<model name="myCompany:myContentModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<description>Custom Content Model</description>
<author>Zlatko Đurić</author>
<published>2013-03-22</published>
<version>1.0</version>
<imports>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
</imports>
<namespaces>
<namespace uri="myCompany.model" prefix="bv"/>
</namespaces>
<constraints>
<constraint name="myCompany:taxIdConstraint" type="REGEX">
<parameter name="expression">
<value>^ID[1-9](\-[1-9])*</value>
</parameter>
<parameter name="requiresMatch">
<value>true</value>
</parameter>
</constraint>
</constraints>
<types>
<type name="myCompany:vendor">
<title>Vendor</type>
<parent>cm:folder</parent>
<properties>
<property name="myCompany:vendorName">
<title>Vendor name</title>
<type>d:text</type>
</property>
<property name="myCompany:vendorTaxID">
<title>Vendor Tax ID</title>
<type>d:int</type>
<constraints>
<constraint ref="myCompany:taxIdConstraint">
</constraints>
</property>
</properties>
<mandatory-aspects>
<aspect>myCompany:myAspect</aspect>
</mandatory-aspects>
<associations>
<association name="myCompany:keyAccountManager">
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm:person</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
</type>
</types>
<aspects>
<aspect name="myCompany:myAspect">
<title>Address aspect</title>
<properties>
<property name="myCompany:city">
<title>City</title>
<type>d:text</type>
</property>
</properties>
<associations>
<association name="myCompany:myState">
<source>
<mandatory>true</mandatory>
<many>true</many>
</source>
<target>
<class>cm:folder</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
</aspect>
</aspects>
</model>
There, I hope this helps you.