2025年6月10日火曜日

alfresco25.1 ソートのカスタマイズ

コンテンツの作成者・作成日を基準にソートできるようにする。

参照 aegif Labo Blog

1.モデルマネージャー モデルを作成

①管理ツールからモデルマネージャーを選択

②モデルの作成

③名前をクリック

④アスペクトの作成をクリック

⑤アスペクトの作成

⑥プロパティの作成をクリック

⑦プロパティの作成

⑧モデルの有効化

2.UIの設定(ソートをカスタマイズ)

sudo vi tomcat/webapps/share/WEB-INF/classes/alfresco/share-documentlibrary-config.xml

612行目 以下をコピー

 <!--
         Sorting Options
         The 'sort' config element contains the name of the content model field to sort against and can be of the form:
         - short QName string e.g. "cm:name"
         - any other valid sortable fts-alfresco special field e.g. "TYPE"
         The field can be optionally followed by |true or |false to indicate sort direction,
         where true = ascending, false = descending
      -->
      <sorting>
         <sort label="label.name">cm:name|true</sort>
         <sort label="label.popularity">cm:likesRatingSchemeCount|false</sort>
         <sort label="label.title">cm:title</sort>
         <sort label="label.description">cm:description</sort>
         <sort label="label.created">cm:created</sort>
         <sort label="label.creator">cm:creator</sort>
         <sort label="label.modified">cm:modified</sort>
         <sort label="label.modifier">cm:modifier</sort>
         <sort label="label.size">cm:content.size</sort>
         <sort label="label.mimetype">cm:content.mimetype</sort>
         <sort label="label.type">TYPE</sort>
      </sorting>

sudo vi tomcat/shared/classes/alfresco/web-extension/share-config-custom.xml
<alfresco-config>
    
#<---------------中略--------------->
 <!-- Document Library config section -->
<config evaluator="string-compare" condition="DocumentLibrary" replace="true">
#上記を貼付 ソートラベルを追加
     
<!--
         Sorting Options
         The 'sort' config element contains the name of the content model field to sort against and can be of the form:
         - short QName string e.g. "cm:name"
         - any other valid sortable fts-alfresco special field e.g. "TYPE"
         The field can be optionally followed by |true or |false to indicate sort direction,
         where true = ascending, false = descending
      -->
      <sorting>  
         <sort label="label.name">cm:name|true</sort>                                                                              <sort label="label.popularity">cm:likesRatingSchemeCount|false</sort>
         <sort label="label.title">cm:title</sort>
         <sort label="label.description">cm:description</sort>
         <sort label="label.created">cm:created</sort>
         <sort label="label.creator">cm:creator</sort>
         <sort label="label.modified">cm:modified</sort>
         <sort label="label.modifier">cm:modifier</sort>
         <sort label="label.size">cm:content.size</sort>
         <sort label="label.mimetype">cm:content.mimetype</sort>
         <sort label="label.type">TYPE</sort>

         <sort label="label.published">cs:publishDate</sort>
      </sorting>

3.アスペクトの表示名の定義ファイルを設定

vi tomcat/shared/classes/alfresco/web-extension/custom-messages-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>
    <bean id="custom.resources" class="org.springframework.extensions.surf.util.ResourceBundleBootstrapComponent">
        <property name="resourceBundles">
            <list>
                <value>alfresco.messages.custom-messages</value>
            </list>
        </property>
     </bean>
</beans>

4.アスペクトの表示名の英語表記ファイルを作成

sudo mkdir tomcat/shared/classes/alfresco/messages
sudo vi tomcat/shared/classes/alfresco/messages/custom-messages.properties
label.published=Published

5.アスペクトの表示名の日本語表記ファイルを作成

sudo vi tomcat/shared/classes/alfresco/messages/custom-messages_ja.properties
#日本語はunicodeで表記
label.published=\u767A\u884C\u65E5

5.alfrescoサーバーの再起動

sudo systemctl restart tomcat.service