[alfresco]custom modelの作成

19
Custom Modelの作成 Alfresco 勉強会 第2回 …の資料を少し手直し

Upload: jun-terashita

Post on 22-Jul-2015

473 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: [Alfresco]Custom Modelの作成

Custom Modelの作成Alfresco 勉強会 第2回…の資料を少し手直し

Page 2: [Alfresco]Custom Modelの作成

目次

Custom Modelとは?

Custom Modelの定義

Custom Modelのデプロイ

UIへの反映

Page 3: [Alfresco]Custom Modelの作成

Custom Modelとは

Page 4: [Alfresco]Custom Modelの作成

Custom Modelとは

Alfrescoで扱うコンテンツ(ファイル)に対して、標準では用意されていないProperty、Association、Constraint、Aspect等を追加するために使用します。

【使用例(かつ今回のデモ)】ファイルに「プロジェクト名」、「プロジェクトリーダー」というPropertyを追加。

Page 5: [Alfresco]Custom Modelの作成

Custom Modelの定義

Page 6: [Alfresco]Custom Modelの作成

Custom Modelの定義

【デモシナリオ】プロジェクト名とプロジェクトリーダーという属性を追加するために、その2つのPropertyを持つAspectを新規に定義します。

以下のフォルダ(以下、extensionフォルダ)にあるexampleModel.xml.sampleをコピーし、exampleModel.xmlを作成します。tomcat/shared/classes/alfresco/extension

exampleModel.xmlを次ページのように書き換えます。

Page 7: [Alfresco]Custom Modelの作成

exampleModel.xmlの変更箇所

<?xml version="1.0" encoding="UTF-8"?>

...

<namespaces> <namespace uri="my.new.model" prefix="my"/></namespaces> <types> </types> <aspects> <!-- Definition of new Content Aspect: Project Information --> <aspect name="my:projectInfo"> <title>Project Information</title> <properties> <property name="my:projectName"> <type>d:text</type> </property> <property name="my:projectLeader"> <type>d:text</type> </property> </properties> </aspect> </aspects>

</model>

Page 8: [Alfresco]Custom Modelの作成

Custom Modelのデプロイ

Page 9: [Alfresco]Custom Modelの作成

2つのデプロイ方法

Custom Modelのデプロイ方法にはAlfrescoの起動時に反映させる方法(Bootstrap)とAlfrescoを起動させたまま動的に反映させる方法(Dynamic)の2通りの方法があります。

Bootstrap- 起動時にモデル定義をデプロイする方法。- Alfrescoの再起動が必要。

Dynamic- Alfrescoを起動した状態でWebブラウザから所定のスペース(フォ

ルダ)にモデル定義をアップロードし、有効化する方法。- Alfrescoの再起動は不要。

Page 10: [Alfresco]Custom Modelの作成

デプロイ方法①:Bootstrap

Dictionary Bootstrap Componentを定義し、モデル定義と共にextensionフォルダに配置してAlfrescoを起動すると、モデル定義が読み込まれます。

今回の例では、extensionフォルダにあるexample-model-context.xml.sampleをコピーしてexample-model-context.xmlを作成するだけでOKです。

※ exampleModel.xmlのファイル名や置いてあるフォルダを変更している場合はexample-model-context.xml内でモデル定義ファイルのパスを指定している部分を編集する必要があります。

Page 11: [Alfresco]Custom Modelの作成

デプロイ方法②:Dynamic

Alfrescoを起動した状態で、Webブラウザから以下のフォルダにモデル定義(今回の例ではexampleModel.xml)をアップロードし、有効化することによりモデル定義が読み込まれます。

Company Home/Data Dictionary/Models

Page 12: [Alfresco]Custom Modelの作成

デプロイ方法②:Dynamicモデルの有効化

ここにチェックを入れる

Page 13: [Alfresco]Custom Modelの作成

UIへの反映

Page 14: [Alfresco]Custom Modelの作成

UIへの反映

モデル定義のデプロイとは別に、ユーザがコンテンツにAspectを付加したり、追加したPropertyの値を参照・変更したりするためにUIをカスタマイズする必要があります。

Alfresco ExplorerとAlfresco Shareのそれぞれで設定方法が異なるので、次ページ以降で設定変更の方法を示します。

これらの設定を行うことで、「アクションの実行(Explorer)」や、「アスペクトの管理(Share)」でAspectを追加したり、コンテンツの詳細画面でPropertyを参照・変更したりできるようになります。

Page 15: [Alfresco]Custom Modelの作成

Alfresco ExplorerのUIへの反映

Alfresco ExplorerのUIへの反映は、モデル定義と同様、BootstrapとDynamicの2通りの方法があります。

準備- 次ページの内容をweb-client-config-custom.xmlというファイル名で

作成しておきます。

Bootstrap- 上記のXMLファイルをextensionフォルダに置き、Alfrescoを再起動

します。

Dynamic- Alfrescoを起動した状態で上記のXMLファイルを以下のスペース

(フォルダ)にアップロードします。 Company Home/Data Dictionary/Web Client Extension

- 以下のURLにアクセスし、”reload”を実行します。http://localhost:8080/alfresco/faces/jsp/admin/webclientconfig-console.jsp

Page 16: [Alfresco]Custom Modelの作成

Alfresco ExplorerのUIへの反映web-client-config-custom.xml

<alfresco-config>

<config evaluator="aspect-name" condition="my:projectInfo"> <property-sheet> <show-property name="my:projectName"/> <show-property name="my:projectLeader"/> </property-sheet> </config>

<config evaluator="string-compare" condition="Action Wizards"> <aspects> <aspect name="my:projectInfo"/> </aspects> </config>

</alfresco-config>

Page 17: [Alfresco]Custom Modelの作成

Alfresco ShareのUIへの反映

以下のフォルダ(以下、web-extensionフォルダ)にあるshare-config-custom.xml.sampleをコピーし、share-config-custom.xmlを作成します。tomcat/shared/classes/alfresco/web-extension

上記のファイルに次ページの内容を追記し、web-extensionフォルダに置いてAlfresco Shareを再起動します。

Page 18: [Alfresco]Custom Modelの作成

Alfresco ShareのUIへの反映share-config-custom.xmlに追記する内容

<alfresco-config> ... <!-- Document Library config section --> <config evaluator="string-compare" condition="DocumentLibrary" replace="true"> ... <aspects> <!-- Aspects that a user can see --> <visible> ... ... <aspect name="my:projectInfo" /> </visible> ... </aspects> </config> <!-- cm:content type (existing nodes) --> <config evaluator="node-type" condition="cm:content"> <forms> <!-- Additional form configuration for the cm:content type --> <form> <field-visibility> <!-- my:projectInfo aspect --> <show id="my:projectName" /> <show id="my:projectLeader" /> </field-visibility> <appearance> <field id="my:projectName"> <control template="/org/alfresco/components/form/controls/textfield.ftl" /> </field> <field id="my:projectLeader"> <control template="/org/alfresco/components/form/controls/textfield.ftl" /> </field> </appearance> </form> </forms> </config>

</alfresco-config>

Page 19: [Alfresco]Custom Modelの作成

おわり