-
Notifications
You must be signed in to change notification settings - Fork 22
CouchDB側についてのメモ(Devin生成、未評価)
Ishii Akinori edited this page May 12, 2025
·
1 revision
bjornlokaはNemakiWareのインストール時にCouchDBを初期化するためだけに使用されるツールです。具体的には:
- bjornlokaは
setup/couchdb/bjornloka
ディレクトリに存在するJavaツールです - インストーラー(
setup/installer/install.xml
)によって呼び出され、初期データをCouchDBにインポートします - 主な機能は
LoadAction.java
に実装されており、JSONドキュメントとその添付ファイルをCouchDBにロードします - 初期データは
setup/couchdb/initial_import
ディレクトリのダンプファイル(例:bedroom_init.dump
)に含まれています - インストール後は使用されません
NemakiWareは以下のCouchDBデータベースを使用します:
-
メインリポジトリデータベース(例:
bedroom
):ドキュメント、フォルダ、ユーザー、グループなどのコンテンツを格納 -
アーカイブデータベース(例:
bedroom_closet
):削除されたコンテンツのアーカイブを格納 -
設定データベース(
nemaki_conf
):システム全体の設定を格納
すべてのデータベースは単一のデザインドキュメント_design/_repo
を使用し、多数のビューを定義しています。このデザインドキュメントは初期インポート時に作成され、必要に応じて更新されます。
CouchDBには以下のドキュメントタイプが格納されています:
- 属性:versionSeriesId, latestVersion, majorVersion, attachmentNodeId, renditionIds など
- クラス:
CouchDocument.java
- 属性:parentId, path など
- クラス:
CouchFolder.java
- 属性:sourceId, targetId など
- クラス:
CouchRelationship.java
- 属性:appliedIds など
- クラス:
CouchPolicy.java
- クラス:
CouchItem.java
- 属性:userId, name, firstName, lastName, email, passwordHash, admin など
- クラス:
CouchUser.java
- 属性:groupId, users など
- クラス:
CouchGroupItem.java
- クラス:
CouchAttachmentNode.java
- クラス:
CouchRendition.java
- クラス:
CouchVersionSeries.java
- 属性:typeId, displayName, description, baseId, parentId, properties など
- クラス:
CouchTypeDefinition.java
- 属性:propertyId, queryName, propertyType, cardinality など
- クラス:
CouchPropertyDefinitionCore.java
- 属性:coreNodeId, displayName, description, required, orderable, updatability など
- クラス:
CouchPropertyDefinitionDetail.java
- 属性:objectId, changeType, token など
- クラス:
CouchChange.java
- クラス:
CouchConfiguration.java
_design/_repo
デザインドキュメントには以下のビューが定義されています:
function(doc) { if (doc.type == 'attachment') emit(doc._id, doc) }
function(doc) { if (['cmis:document', 'cmis:folder', 'cmis:relationship', 'cmis:policy', 'cmis:item','cmis:secondary'].indexOf(doc.type) >= 0) emit(doc.objectType, doc) }
reduce: function(key,values){return values.length}
function(doc) { if (doc.type == 'propertyDefinitionCore') emit(doc.propertyId, doc) }
function(doc) { if (doc.type == 'cmis:folder' || doc.type == 'cmis:document' && doc.latestVersion || doc.type == 'cmis:item') emit(doc.parentId, doc) }
function(doc) { if (doc.type == 'cmis:relationship') emit(doc._id, doc) }
function(doc) { if (doc.type == 'group') emit(doc.groupId, doc) }
function(doc) { if (doc.type == 'cmis:document') emit(doc._id, doc) }
function(doc) { if (doc.type == 'cmis:document' && doc.privateWorkingCopy) emit(doc.parentId, doc) }
function(doc) { if (doc.type == 'cmis:folder' || doc.type == 'cmis:document' && doc.latestVersion) emit({parentId: doc.parentId, name:doc.name}, doc) }
function(doc) { if (doc.type == 'user') emit(doc.userId, doc) }
function(doc) { if (doc.type == 'propertyDefinitionCore') emit(doc._id, doc) }
function(doc) { if (doc.type == 'cmis:folder') emit(doc._id, doc) }
function(doc) { if (doc.type == 'user') emit(doc._id, doc) }
function(doc) { if (doc.type == 'propertyDefinitionDetail') emit(doc.coreNodeId, doc) }
function(doc) { if (['cmis:document', 'cmis:folder', 'cmis:relationship', 'cmis:policy', 'cmis:item','cmis:secondary'].indexOf(doc.type) >= 0) emit(doc._id, doc) }
function(doc) { if (doc.type == 'cmis:relationship') emit(doc.targetId, doc) }
function(doc) { if (doc.type == 'cmis:policy') for(i in doc.appliedIds){emit(i, doc)} }
function(doc) { if (doc.type == 'group') emit(doc._id, doc) }
function(doc) { if (doc.type == 'cmis:document') emit(doc.versionSeriesId, doc) }
function(doc) { if (doc.type == 'cmis:folder') emit(doc.path, doc) }
function(doc) { if (doc.type == 'versionSeries') emit(doc._id, doc) }
function(doc) { if (doc.type == 'cmis:relationship') emit(doc.sourceId, doc) }
function(doc) { if (doc.type == 'propertyDefinitionDetail') emit(doc._id, doc) }
function(doc) { if (doc.type == 'user' && doc.admin) emit(doc._id, doc) }
function(doc) { if (doc.type == 'cmis:item') emit(doc._id, doc) }
function(doc) { if (doc.type == 'cmis:document' && doc.latestMajorVersion) emit(doc.versionSeriesId, doc) }
function(doc) { if (doc.type == 'typeDefinition') emit(doc.typeId, doc) }
function(doc) { if (doc.type == 'cmis:policy') emit(doc._id, doc) }
function(doc) { if (doc.type == 'rendition') emit(doc._id, doc) }
function(doc) { if (doc.type == 'cmis:document' && doc.latestVersion) emit(doc.versionSeriesId, doc) }
function(doc) { if (doc.type == 'change') emit(doc.token, doc) }
function(doc) { if (doc.type == 'change') emit(doc._id, doc) }
function(doc) {var result={}; result[doc.name]=doc._id; if (doc.type == 'cmis:document' && doc.latestVersion || doc.type == 'cmis:folder') emit(doc.parentId, doc.name);}
- URL: nemakiware.propertiesファイルの
db.couchdb.url
で設定 - 認証情報:
db.couchdb.auth.enabled
,db.couchdb.auth.username
,db.couchdb.auth.password
で設定
- メインリポジトリデータベース(例:
bedroom
) - アーカイブデータベース(例:
bedroom_closet
) - 設定データベース(
nemaki_conf
)
- すべてのドキュメントは
_id
と_rev
(リビジョン)を持つ - typeフィールドでドキュメントタイプを識別
- 上記のビューを使用してドキュメントにアクセス
- ドキュメントの実際のコンテンツは添付ファイルとして保存
- 添付ファイル名は常に
content
- CouchAttachmentNodeオブジェクトを通じてアクセス
- versionSeriesオブジェクトがバージョン管理情報を保持
- ドキュメントは
versionSeriesId
で関連付け - latestVersionと
latestMajorVersion
フラグで最新バージョンを識別