From bc19dd22d868d03ff1a80db01bce5106c0ecd0e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Tue, 16 Jan 2024 12:35:19 +0900 Subject: [PATCH 01/14] =?UTF-8?q?DocumentMeta=E3=81=AB=E3=82=B3=E3=83=B3?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=83=A9=E3=82=AF=E3=82=BF=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/model/document/DocumentMeta.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/model/src/main/java/one/nem/lacerta/model/document/DocumentMeta.java b/model/src/main/java/one/nem/lacerta/model/document/DocumentMeta.java index 038b625e..2fc0f4bc 100644 --- a/model/src/main/java/one/nem/lacerta/model/document/DocumentMeta.java +++ b/model/src/main/java/one/nem/lacerta/model/document/DocumentMeta.java @@ -48,6 +48,17 @@ public class DocumentMeta { // TODO-rca: JavaDoc対応 public DocumentMeta() { } + public DocumentMeta(String title) { + this.id = UUID.randomUUID().toString(); + this.title = title; + this.tags = new ArrayList<>(); + this.author = ""; // TODO-rca: 作者のデフォルト値を設定できるようにする + this.defaultBranch = "main"; // TODO-rca: デフォルトブランチのデフォルト値を設定できるようにする + this.path = new PublicPath().getRoot(); + this.updatedAt = new Date(); + this.createdAt = new Date(); + } + public DocumentMeta(String title, List tags, String author, String defaultBranch) { this.id = UUID.randomUUID().toString(); this.title = title; From a61c0443915b2d88c6c5600a996a04b1436be328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Tue, 16 Jan 2024 12:36:28 +0900 Subject: [PATCH 02/14] =?UTF-8?q?=E6=96=B0=E3=83=89=E3=82=AD=E3=83=A5?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E3=82=92=E7=94=9F=E6=88=90=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/component/scanner/ScannerManagerActivity.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerActivity.java b/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerActivity.java index b8ab64bf..fe69ea60 100644 --- a/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerActivity.java +++ b/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerActivity.java @@ -26,6 +26,7 @@ import java.util.Objects; import javax.inject.Inject; import dagger.hilt.android.AndroidEntryPoint; +import one.nem.lacerta.model.document.DocumentMeta; import one.nem.lacerta.utils.LacertaLogger; import one.nem.lacerta.data.Document; @@ -143,7 +144,8 @@ public class ScannerManagerActivity extends AppCompatActivity { private void saveNewDocument() { logger.debug(TAG, "saveNewDocument"); - + DocumentMeta documentMeta = new DocumentMeta("Untitled"); // TODO-rca: デフォルトタイトルを指定できるようにする + document.createDocument(documentMeta); } private void insertToExistDocument() { From e1b43a5f22b3c8f9667e0ec25862567086d41360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 10:37:42 +0900 Subject: [PATCH 03/14] =?UTF-8?q?Entity=E3=81=ABisIncluded=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/source/database/entity/VcsLogEntity.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/src/main/java/one/nem/lacerta/source/database/entity/VcsLogEntity.java b/source/src/main/java/one/nem/lacerta/source/database/entity/VcsLogEntity.java index de1ed13a..17628e8e 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/entity/VcsLogEntity.java +++ b/source/src/main/java/one/nem/lacerta/source/database/entity/VcsLogEntity.java @@ -45,4 +45,10 @@ public class VcsLogEntity { */ @ColumnInfo(name = "action") public String action; + + /** + * Revに含まれてるかどうか + */ + @ColumnInfo(name = "is_included") + public boolean isIncluded; } From 678c9730ef65bf07e13bba0b548b162310c2bfd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 10:39:17 +0900 Subject: [PATCH 04/14] =?UTF-8?q?Dao=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/source/database/dao/VcsLogDao.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java index cd15c89a..3c1936bf 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java @@ -24,6 +24,14 @@ public interface VcsLogDao { @Query("SELECT * FROM vcs_log WHERE document_id = :documentId") List findByDocumentId(String documentId); + @Query("SELECT * FROM vcs_log WHERE document_id = :documentId AND is_included = :isIncluded ORDER BY created_at") + List findByDocumentIdAndIncluded(String documentId, boolean isIncluded); + + @Query("SELECT * FROM vcs_log WHERE document_id = :documentId AND branch_name = :branchName") + List findByDocumentIdAndBranchName(String documentId, String branchName); + + @Query("SELECT * FROM vcs_log WHERE document_id = :documentId AND branch_name = :branchName AND is_included = :isIncluded ORDER BY created_at") + List findByDocumentIdAndBranchNameAndIncluded(String documentId, String branchName, boolean isIncluded); // Insert @Insert From 0487553f3be2080c965dc163b363f70ee5d95cbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 10:40:01 +0900 Subject: [PATCH 05/14] =?UTF-8?q?Dao=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/source/database/dao/VcsLogDao.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java b/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java index 3c1936bf..7721555f 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java +++ b/source/src/main/java/one/nem/lacerta/source/database/dao/VcsLogDao.java @@ -3,6 +3,7 @@ package one.nem.lacerta.source.database.dao; import androidx.room.Dao; import androidx.room.Insert; import androidx.room.Query; +import androidx.room.Update; import java.util.List; @@ -43,5 +44,12 @@ public interface VcsLogDao { @Insert void insert(VcsLogEntity vcsLog); - // TODO-rca: Update, Deleteが必要か検討 + @Update + void update(VcsLogEntity vcsLog); + + @Update + void updateAll(VcsLogEntity... vcsLogs); + + @Update + void updateAll(List vcsLogs); } From d832438f8f1fcf6f14689631b9556a4bd87b5e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 10:46:31 +0900 Subject: [PATCH 06/14] =?UTF-8?q?Vcs=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/vcs/LacertaVcs.java | 2 + .../nem/lacerta/vcs/impl/LacertaVcsImpl.java | 58 ++++++++++++++++++- 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java b/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java index 46640d37..3a47e45a 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java @@ -11,6 +11,8 @@ public interface LacertaVcs { public void createDocument(String documentId); + public void generateRevisionAtCurrent(String message); + // debug public void printLog(); diff --git a/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java b/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java index 15e343da..cea5728b 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java @@ -1,5 +1,7 @@ package one.nem.lacerta.vcs.impl; +import java.util.ArrayList; +import java.util.List; import java.util.UUID; import javax.inject.Inject; @@ -8,6 +10,7 @@ import dagger.assisted.Assisted; import dagger.assisted.AssistedInject; import one.nem.lacerta.source.database.LacertaDatabase; import one.nem.lacerta.source.database.entity.VcsLogEntity; +import one.nem.lacerta.source.database.entity.VcsRevEntity; import one.nem.lacerta.utils.LacertaLogger; import one.nem.lacerta.vcs.LacertaVcs; @@ -26,7 +29,9 @@ public class LacertaVcsImpl implements LacertaVcs { public LacertaVcsImpl(LacertaLogger logger, LacertaDatabase database, @Assisted String documentId) { this.logger = logger; this.database = database; - this.documentId = documentId; + if (documentId != null) { + this.documentId = documentId; + } logger.debug(TAG, "LacertaVcsImpl constructor"); } @@ -54,7 +59,58 @@ public class LacertaVcsImpl implements LacertaVcs { @Override public void createDocument(String documentId) { + logger.debug(TAG, "createDocument"); + VcsLogEntity vcsLogEntity = new VcsLogEntity(); + vcsLogEntity.id = UUID.randomUUID().toString(); + vcsLogEntity.documentId = documentId; + vcsLogEntity.branchName = "master"; + vcsLogEntity.createdAt = new java.util.Date(); + vcsLogEntity.action = "placeholder"; + database.vcsLogDao().insert(vcsLogEntity); + } + // Internal + private ArrayList getNonIncludedVcsLogEntities() { + return new ArrayList<>(database.vcsLogDao().findByDocumentIdAndIncluded(documentId, false)); + } + + private ArrayList getNonIncludedVcsLogEntities(String branchName) { + return new ArrayList<>(database.vcsLogDao().findByDocumentIdAndBranchNameAndIncluded(documentId, branchName, false)); + } + + private void setIncludedVcsLogEntities(ArrayList vcsLogEntities) { + vcsLogEntities.forEach(vcsLogEntity -> { + vcsLogEntity.isIncluded = true; + database.vcsLogDao().update(vcsLogEntity); + }); + + logger.debug(TAG, "setIncludedVcsLogEntities updated: " + vcsLogEntities.size() + " entities"); + } + + @Override + public void generateRevisionAtCurrent(String message) { + logger.debug(TAG, "generateRevisionAtCurrent"); + + ArrayList vcsLogEntities = getNonIncludedVcsLogEntities(); + + ArrayList logIds = new ArrayList<>(); + vcsLogEntities.forEach(vcsLogEntity -> { + logIds.add(vcsLogEntity.id); + }); + + VcsRevEntity vcsRevEntity = new VcsRevEntity(); + vcsRevEntity.id = UUID.randomUUID().toString(); + vcsRevEntity.documentId = documentId; + vcsRevEntity.branchName = "master"; + vcsRevEntity.createdAt = new java.util.Date(); + vcsRevEntity.commitMessage = message; + vcsRevEntity.logIds = logIds; + + database.vcsRevDao().insert(vcsRevEntity); + + setIncludedVcsLogEntities(vcsLogEntities); + + logger.debug(TAG, "generateRevisionAtCurrent finished"); } @Override From 151911d0b2d83c496eb34104236585c58e2f244f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 10:46:55 +0900 Subject: [PATCH 07/14] =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=82=B3=E3=83=BC=E3=83=89=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/one/nem/lacerta/source/database/LacertaDatabase.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/src/main/java/one/nem/lacerta/source/database/LacertaDatabase.java b/source/src/main/java/one/nem/lacerta/source/database/LacertaDatabase.java index d009d8c0..bb8667ab 100644 --- a/source/src/main/java/one/nem/lacerta/source/database/LacertaDatabase.java +++ b/source/src/main/java/one/nem/lacerta/source/database/LacertaDatabase.java @@ -17,7 +17,7 @@ import one.nem.lacerta.source.database.dao.LibraryDao; import one.nem.lacerta.source.database.dao.VcsRevDao; import one.nem.lacerta.source.database.dao.VcsLogDao; -@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class, VcsRevEntity.class, VcsLogEntity.class}, version = 2) +@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class, VcsRevEntity.class, VcsLogEntity.class}, version = 3) public abstract class LacertaDatabase extends RoomDatabase { public abstract TagDao tagDao(); public abstract DocumentDao documentDao(); From 2ec4b96c14287fc82ea8b3ba722fe04a59a9ff13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 10:55:39 +0900 Subject: [PATCH 08/14] =?UTF-8?q?Vcs=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java | 1 + .../main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java b/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java index 3a47e45a..5ac6fc41 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java @@ -13,6 +13,7 @@ public interface LacertaVcs { public void generateRevisionAtCurrent(String message); + // debug public void printLog(); diff --git a/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java b/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java index cea5728b..f2b845c2 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java @@ -29,9 +29,7 @@ public class LacertaVcsImpl implements LacertaVcs { public LacertaVcsImpl(LacertaLogger logger, LacertaDatabase database, @Assisted String documentId) { this.logger = logger; this.database = database; - if (documentId != null) { - this.documentId = documentId; - } + this.documentId = documentId; logger.debug(TAG, "LacertaVcsImpl constructor"); } From b6a30d5cbf89872a05930613d76fd65e3b7bca57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 10:57:08 +0900 Subject: [PATCH 09/14] =?UTF-8?q?Document=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/one/nem/lacerta/data/impl/DocumentImpl.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 10eb8265..194fbe22 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 @@ -24,6 +24,7 @@ import one.nem.lacerta.utils.LacertaLogger; // Lacerta/vcs import one.nem.lacerta.vcs.LacertaVcs; +import one.nem.lacerta.vcs.factory.LacertaVcsFactory; public class DocumentImpl implements Document { @@ -36,8 +37,8 @@ public class DocumentImpl implements Document { @Inject LacertaDatabase database; -// @Inject -// LacertaVcs vcs; + @Inject + LacertaVcsFactory vcsFactory; @Inject @@ -69,7 +70,8 @@ public class DocumentImpl implements Document { database.documentDao().insert(documentEntity); // Vcs -// vcs.createDocument(meta.getId()); + LacertaVcs vcs = vcsFactory.create(meta.getId()); + vcs.createDocument(meta.getId()); return detail; } From 119771a7f97506db8dcfd8b3ccb92b22fdb9cc11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 11:00:20 +0900 Subject: [PATCH 10/14] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0,=20=E3=83=87=E3=83=90=E3=83=83=E3=82=B0?= =?UTF-8?q?=E7=94=A8=E3=81=AE=E5=AE=9F=E8=A3=85=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java | 2 ++ .../java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java b/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java index 5ac6fc41..1f5d31ea 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/LacertaVcs.java @@ -17,4 +17,6 @@ public interface LacertaVcs { // debug public void printLog(); + public void printRev(); + } diff --git a/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java b/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java index f2b845c2..dabcbfed 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java @@ -88,6 +88,7 @@ public class LacertaVcsImpl implements LacertaVcs { @Override public void generateRevisionAtCurrent(String message) { logger.debug(TAG, "generateRevisionAtCurrent"); + // TODO-rca: ブランチを考慮する ArrayList vcsLogEntities = getNonIncludedVcsLogEntities(); @@ -109,6 +110,7 @@ public class LacertaVcsImpl implements LacertaVcs { setIncludedVcsLogEntities(vcsLogEntities); logger.debug(TAG, "generateRevisionAtCurrent finished"); + logger.debug(TAG, "New revision inserted: " + vcsRevEntity.id); } @Override @@ -118,4 +120,12 @@ public class LacertaVcsImpl implements LacertaVcs { logger.debug(TAG, vcsLog.id); }); } + + @Override + public void printRev() { + logger.debug(TAG, "printRev"); + database.vcsRevDao().findAll().forEach(vcsRev -> { + logger.debug(TAG, vcsRev.id); + }); + } } From dea5f240f085a116d3a3e3bbcb50111a387d6d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 11:05:25 +0900 Subject: [PATCH 11/14] =?UTF-8?q?=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1?= =?UTF-8?q?=E3=83=B3=E3=83=88=E6=96=B0=E8=A6=8F=E4=BF=9D=E5=AD=98=E3=81=AE?= =?UTF-8?q?=E3=83=AD=E3=82=B8=E3=83=83=E3=82=AF=E3=82=92=E5=AE=9F=E8=A3=85?= =?UTF-8?q?=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scanner/ScannerManagerActivity.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerActivity.java b/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerActivity.java index fe69ea60..1488f87d 100644 --- a/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerActivity.java +++ b/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerActivity.java @@ -26,9 +26,12 @@ import java.util.Objects; import javax.inject.Inject; import dagger.hilt.android.AndroidEntryPoint; +import one.nem.lacerta.model.document.DocumentDetail; import one.nem.lacerta.model.document.DocumentMeta; +import one.nem.lacerta.processor.factory.DocumentProcessorFactory; import one.nem.lacerta.utils.LacertaLogger; import one.nem.lacerta.data.Document; +import one.nem.lacerta.vcs.factory.LacertaVcsFactory; @AndroidEntryPoint public class ScannerManagerActivity extends AppCompatActivity { @@ -41,6 +44,11 @@ public class ScannerManagerActivity extends AppCompatActivity { @Inject Document document; + @Inject + DocumentProcessorFactory documentProcessorFactory; + + @Inject + LacertaVcsFactory lacertaVcsFactory; // Variables private ArrayList croppedImages = new ArrayList<>(); @@ -145,7 +153,18 @@ public class ScannerManagerActivity extends AppCompatActivity { private void saveNewDocument() { logger.debug(TAG, "saveNewDocument"); DocumentMeta documentMeta = new DocumentMeta("Untitled"); // TODO-rca: デフォルトタイトルを指定できるようにする - document.createDocument(documentMeta); + DocumentDetail documentDetail = document.createDocument(documentMeta); + Bitmap[] bitmaps = new Bitmap[this.croppedImages.size()]; + this.croppedImages.toArray(bitmaps); + try { + documentProcessorFactory.create(documentDetail).addNewPagesToLast(bitmaps); + Toast.makeText(this, "Saved.", Toast.LENGTH_SHORT).show(); + lacertaVcsFactory.create(documentDetail.getMeta().getId()).generateRevisionAtCurrent("Initial commit"); + finish(); + } catch (Exception e) { + logger.error(TAG, "Error: " + e.getMessage()); + logger.e_code("9dff2a28-20e8-4ccd-9d04-f0c7646faa6a"); + } } private void insertToExistDocument() { From 58d6ae17c6ed09f47da1e7507604fc20ed996a01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 11:07:54 +0900 Subject: [PATCH 12/14] =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=9F=E3=83=B3?= =?UTF-8?q?=E3=82=B0=E3=81=AE=E9=83=BD=E5=90=88=E3=81=A7=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=81=8C=E5=87=BA=E3=82=8B=E3=81=AE=E3=81=A7logger?= =?UTF-8?q?=E3=82=92=E4=BD=BF=E3=82=8F=E3=81=AA=E3=81=84=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 194fbe22..1253d0a4 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 @@ -44,7 +44,7 @@ public class DocumentImpl implements Document { @Inject public DocumentImpl() { // Init - logger.debug(TAG, "called"); +// logger.debug(TAG, "called"); } From 74becab37b523db7ecdf6d18689fb4518a0a06dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 11:09:33 +0900 Subject: [PATCH 13/14] =?UTF-8?q?=E3=83=87=E3=83=90=E3=83=83=E3=82=B0?= =?UTF-8?q?=E7=94=A8=E3=81=AE=E3=83=AD=E3=82=B0=E3=83=9D=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=83=88=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/component/scanner/ScannerManagerActivity.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerActivity.java b/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerActivity.java index 1488f87d..f55484a1 100644 --- a/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerActivity.java +++ b/component/scanner/src/main/java/one/nem/lacerta/component/scanner/ScannerManagerActivity.java @@ -160,6 +160,8 @@ public class ScannerManagerActivity extends AppCompatActivity { documentProcessorFactory.create(documentDetail).addNewPagesToLast(bitmaps); Toast.makeText(this, "Saved.", Toast.LENGTH_SHORT).show(); lacertaVcsFactory.create(documentDetail.getMeta().getId()).generateRevisionAtCurrent("Initial commit"); + lacertaVcsFactory.create(documentDetail.getMeta().getId()).printLog(); // Debug + lacertaVcsFactory.create(documentDetail.getMeta().getId()).printRev(); // Debug finish(); } catch (Exception e) { logger.error(TAG, "Error: " + e.getMessage()); From 744a2bef65dca60307ba56cf5be110fa75d00d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 11:25:41 +0900 Subject: [PATCH 14/14] =?UTF-8?q?action=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/vcs/impl/LacertaVcsImpl.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java b/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java index dabcbfed..89cd8d2d 100644 --- a/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java +++ b/vcs/src/main/java/one/nem/lacerta/vcs/impl/LacertaVcsImpl.java @@ -12,7 +12,10 @@ import one.nem.lacerta.source.database.LacertaDatabase; import one.nem.lacerta.source.database.entity.VcsLogEntity; import one.nem.lacerta.source.database.entity.VcsRevEntity; import one.nem.lacerta.utils.LacertaLogger; +import one.nem.lacerta.vcs.ActionType; import one.nem.lacerta.vcs.LacertaVcs; +import one.nem.lacerta.vcs.internal.JsonUtils; +import one.nem.lacerta.vcs.model.action.InsertPage; public class LacertaVcsImpl implements LacertaVcs { @@ -41,12 +44,17 @@ public class LacertaVcsImpl implements LacertaVcs { @Override public void insertPage(int index, String fileName) { logger.debug(TAG, "insertPage"); + + // InsertPage + InsertPage insertPage = new InsertPage(index, fileName); + insertPage.setActionType(ActionType.INSERT_PAGE); + VcsLogEntity vcsLogEntity = new VcsLogEntity(); vcsLogEntity.id = UUID.randomUUID().toString(); vcsLogEntity.documentId = documentId; vcsLogEntity.branchName = "master"; vcsLogEntity.createdAt = new java.util.Date(); - vcsLogEntity.action = "placeholder"; + vcsLogEntity.action = JsonUtils.toJson(insertPage); database.vcsLogDao().insert(vcsLogEntity); } @@ -58,12 +66,13 @@ public class LacertaVcsImpl implements LacertaVcs { @Override public void createDocument(String documentId) { logger.debug(TAG, "createDocument"); + VcsLogEntity vcsLogEntity = new VcsLogEntity(); vcsLogEntity.id = UUID.randomUUID().toString(); vcsLogEntity.documentId = documentId; vcsLogEntity.branchName = "master"; vcsLogEntity.createdAt = new java.util.Date(); - vcsLogEntity.action = "placeholder"; + vcsLogEntity.action = "ph-createDocument"; database.vcsLogDao().insert(vcsLogEntity); } @@ -118,6 +127,8 @@ public class LacertaVcsImpl implements LacertaVcs { logger.debug(TAG, "printLog"); database.vcsLogDao().findAll().forEach(vcsLog -> { logger.debug(TAG, vcsLog.id); + logger.debug(TAG, vcsLog.documentId + " " + vcsLog.branchName); + logger.debug(TAG, vcsLog.action); }); } @@ -126,6 +137,9 @@ public class LacertaVcsImpl implements LacertaVcs { logger.debug(TAG, "printRev"); database.vcsRevDao().findAll().forEach(vcsRev -> { logger.debug(TAG, vcsRev.id); + logger.debug(TAG, vcsRev.documentId + " " + vcsRev.branchName); + logger.debug(TAG, vcsRev.commitMessage); + logger.debug(TAG, vcsRev.logIds.toString()); }); } }