Database design 在Alfresco内容模型中创建方面
我现在开始使用Alfresco CMS。我需要在我的内容模型中创建一个“方面”,它必须包含许多属性,如:Database design 在Alfresco内容模型中创建方面,database-design,content-management-system,database-schema,alfresco,content-model,Database Design,Content Management System,Database Schema,Alfresco,Content Model,我现在开始使用Alfresco CMS。我需要在我的内容模型中创建一个“方面”,它必须包含许多属性,如: Aspect: property 1 : String property 2 : int property 3 : int property 4 : long Format: FormatProperty1: int FormatProperty2: int FormatProperty3: int Metadata: list
Aspect:
property 1 : String
property 2 : int
property 3 : int
property 4 : long
Format:
FormatProperty1: int
FormatProperty2: int
FormatProperty3: int
Metadata:
list1: List<String>
list2: List<String>
MetadataProperty 3: boolean
此外,它还必须包含两个以上的属性,这些属性由以下任意数量的属性组成:
Aspect:
property 1 : String
property 2 : int
property 3 : int
property 4 : long
Format:
FormatProperty1: int
FormatProperty2: int
FormatProperty3: int
Metadata:
list1: List<String>
list2: List<String>
MetadataProperty 3: boolean
格式:
FormatProperty1:int
FormatProperty2:int
FormatProperty3:int
元数据:
列表1:列表
列表2:列表
MetadataProperty 3:布尔值
我既没有创建简单的内容模型,也没有在Alfresco中创建方面。基于我以前在关系数据库方面的知识,我认为上面的结构是表之间的关联。如何在具有方面或更多方面的Alfresco内容模型中实现这一点 你应该先看看。
在露天创建模型离数据库很远
它只是一个定义良好的XML。您必须首先编写XML,然后通过引导初始化它
示例XML模型cmodModel.XML:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Definition of new Model -->
<model name="custom:custommodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<!-- Optional meta-data about the model -->
<description>Custom Model</description>
<author>Whatever</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.alfresco.org/model/system/1.0" prefix="sys" />
</imports>
<!-- Introduction of new namespaces defined by this model -->
<namespaces>
<namespace uri="custom.model" prefix="cmod" />
</namespaces>
<!-- Lists <String> -->
<constraints>
<constraint name="cmod:liststring1" type="LIST">
<parameter name="allowedValues">
<list>
<value>value 1</value>
<value>value 2</value>
</list>
</parameter>
</constraint>
<constraint name="cmod:liststring2" type="LIST">
<parameter name="allowedValues">
<list>
<value>value 1</value>
<value>value 2</value>
</list>
</parameter>
</constraint>
</constraints>
<types>
<!-- Document Type -->
<type name="cmod:customDoc">
<title>Document</title>
<description>Document</description>
<parent>cm:content</parent>
<mandatory-aspects>
<aspect>cmod:aspectBase</aspect>
<aspect>cmod:aspectFormat</aspect>
<aspect>cmod:aspectMetadata</aspect>
</mandatory-aspects>
</type>
</types>
<!-- Definition of custom aspects -->
<aspects>
<aspect name="cmod:aspectBase">
<title>Aspect base properties</title>
<properties>
<property name="cmod:property1">
<title>p1</title>
<description>p1</description>
<type>d:text</type>
</property>
<property name="cmod:property2">
<title>p2</title>
<description>p2</description>
<type>d:int</type>
</property>
<property name="cmod:property3">
<title>p3</title>
<description>p3</description>
<type>d:int</type>
</property>
<property name="cmod:property4">
<title>p4</title>
<description>p4</description>
<type>d:text</type>
</property>
</properties>
</aspect>
<aspect name="cmod:aspectFormat">
<title>Aspect Format</title>
<properties>
<property name="cmod:formatProperty1">
<title>fp1</title>
<description>fp1</description>
<type>d:int</type>
</property>
<property name="cmod:formatProperty2">
<title>fp2</title>
<description>fp2</description>
<type>d:int</type>
</property>
<property name="cmod:formatProperty3">
<title>fp3</title>
<description>fp3</description>
<type>d:int</type>
</property>
</properties>
</aspect>
<aspect name="cmod:aspectMetadata">
<title>Aspetto Metadata</title>
<properties>
<property name="cmod:metadataProperty1">
<title>mp1</title>
<description>mp1</description>
<type>d:text</type>
<constraints>
<constraint ref="cmod:liststring1" />
</constraints>
</property>
<property name="cmod:metadataProperty2">
<title>mp2</title>
<description>mp2</description>
<type>d:text</type>
<constraints>
<constraint ref="cmod:liststring2" />
</constraints>
</property>
<property name="cmod:metadataProperty3">
<title>mp3</title>
<description>mp3</description>
<type>d:boolean</type>
</property>
</properties>
</aspect>
</aspects>
</model>
自定义模型
无论什么
1
值1
价值2
值1
价值2
文件
文件
cm:内容
cmod:aspectBase
cmod:aspectFormat
cmod:aspectMetadata
方面基属性
p1
p1
d:文本
p2
p2
d:int
p3
p3
d:int
p4
p4
d:文本
方面格式
fp1
fp1
d:int
fp2
fp2
d:int
fp3
fp3
d:int
Aspetto元数据
mp1
mp1
d:文本
mp2
mp2
d:文本
mp3
mp3
d:布尔型
名为cmod-model-context.xml的模型上下文
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<!-- Registration of new models -->
<bean id="extension.dictionaryBootstrap"
parent="dictionaryModelBootstrap"
depends-on="dictionaryBootstrap">
<property name="models">
<list>
<value>alfresco/extension/model/cmodModel.xml</value>
</list>
</property>
</bean>
</beans>
alfresco/extension/model/cmodModel.xml
希望能有所帮助。根据您的评论,让我尝试在@Alch3mi5t的答案中添加一些额外的信息。我用的是一个虚构的商业案例 基本上,Alfresco模型由3个部分组成:约束、类型和方面。另外,我将在混合中添加关联
- 类型
<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>
小贩
cm:文件夹
供应商名称
d:文本
供应商税号
d:int
这就是您的类型,与具有字符串和int类型的vendorName和vendorTaxID列的db表没有什么不同
- 约束
<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>
^ID[1-9](\-[1-9])*
真的
现在,我们只需要修改我们的taxId属性:
<property name="myCompany:vendorTaxID">
<title>Vendor Tax ID</title>
<type>d:int</type>
<constraints>
<constraint ref="myCompany:taxIdConstraint">
</constraints>
</property>
供应商税号
d:int
现在,您在该属性上放置了一个约束
- 方面 现在您需要一个方面——在Alfresco中,这就好像您希望向该表添加几个额外的列一样
<aspect name="myCompany:myAspect">
<title>Address aspect</title>
<properties>
<property name="myCompany:city">
<title>City</title>
<type>d:text</type>
</property>
</properties>
</aspect>
地址方面
城市
d:文本
如果将其添加到类型定义中(就在“属性”部分之后),则可以将其作为强制特性:
myCompany:myAspect
现在,您可以将一个“记录”添加到基本“表”中,如果您将其作为一个强制性方面添加,那么每个记录将有3个道具:名称、税号和城市。如果不是强制性的,则每个记录将有两个基本列,但您可以添加第三个以选择少数。无论是通过编程还是手动,都无所谓
- 关联 现在我们还可以在混合中添加关联:这只是两个节点(或“记录”)之间的链接。 因此,在类型的properties部分之后,可以添加associations部分。假设您想将(某些)供应商与其创建者(主要客户)联系起来
<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>
假的
真的
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.