diff --git a/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java b/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java index 406c83a6..51c0d42e 100644 --- a/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java +++ b/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java @@ -9,10 +9,12 @@ import one.nem.lacerta.data.Document; import one.nem.lacerta.model.document.DocumentMeta; import one.nem.lacerta.model.document.DocumentDetail; +import one.nem.lacerta.model.document.path.DocumentPath; import one.nem.lacerta.model.document.tag.DocumentTag; import one.nem.lacerta.source.database.LacertaDatabase; import one.nem.lacerta.source.database.entity.DocumentEntity; +import one.nem.lacerta.source.database.entity.LibraryEntity; import one.nem.lacerta.source.database.entity.TagEntity; @@ -43,7 +45,21 @@ public class DocumentImpl implements Document{ DocumentDetail documentDetail = new DocumentDetail(); DocumentEntity documentEntity = database.documentDao().findById(id); + // タグデータ作成 ArrayList tagEntities = database.tagDao().findByIds(documentEntity.tagIds); + ArrayList documentTags = new ArrayList<>(); + for (TagEntity tagEntity : tagEntities) { + DocumentTag documentTag = new DocumentTag(); + documentTag.setId(tagEntity.id); + documentTag.setName(tagEntity.tagName); + documentTag.setColor(tagEntity.color); + documentTags.add(documentTag); + } + + // パス取得 + LibraryEntity libraryEntity = database.libraryDao().findById(id) + DocumentPath documentPath = new DocumentPath(libraryEntity.rootPath, libraryEntity.path); + // 組み立て処理 // TODO-rca: 切り出すべきかも? DocumentMeta documentMeta = new DocumentMeta(); @@ -51,6 +67,10 @@ public class DocumentImpl implements Document{ documentMeta.setTitle(documentEntity.title); documentMeta.setCreatedAt(documentEntity.createdAt); documentMeta.setUpdatedAt(documentEntity.updatedAt); + documentMeta.setTags(documentTags); + documentDetail.setMeta(documentMeta); + documentDetail.setAuthor(documentEntity.author); + documentDetail.setPath(new DocumentPath(documentEntity.defaultBranch)); }