getRevisionHistoryByDocumentId実装

This commit is contained in:
r-ca 2024-01-23 01:27:11 +09:00
parent b13f048c7e
commit 07e14eb90c
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9
2 changed files with 29 additions and 0 deletions

View File

@ -1,5 +1,10 @@
package one.nem.lacerta.vcs; package one.nem.lacerta.vcs;
import java.util.ArrayList;
import java.util.concurrent.CompletableFuture;
import one.nem.lacerta.model.VcsRevModel;
public interface LacertaVcs { public interface LacertaVcs {
// Actions // Actions
@ -13,6 +18,8 @@ public interface LacertaVcs {
public void generateRevisionAtCurrent(String message); public void generateRevisionAtCurrent(String message);
public CompletableFuture<ArrayList<VcsRevModel>> getRevisionHistoryByDocumentId(String documentId);
// debug // debug
public void printLog(); public void printLog();

View File

@ -3,11 +3,13 @@ package one.nem.lacerta.vcs.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import javax.inject.Inject; import javax.inject.Inject;
import dagger.assisted.Assisted; import dagger.assisted.Assisted;
import dagger.assisted.AssistedInject; import dagger.assisted.AssistedInject;
import one.nem.lacerta.model.VcsRevModel;
import one.nem.lacerta.source.database.LacertaDatabase; import one.nem.lacerta.source.database.LacertaDatabase;
import one.nem.lacerta.source.database.entity.VcsLogEntity; import one.nem.lacerta.source.database.entity.VcsLogEntity;
import one.nem.lacerta.source.database.entity.VcsRevEntity; import one.nem.lacerta.source.database.entity.VcsRevEntity;
@ -122,6 +124,26 @@ public class LacertaVcsImpl implements LacertaVcs {
logger.debug(TAG, "New revision inserted: " + vcsRevEntity.id); logger.debug(TAG, "New revision inserted: " + vcsRevEntity.id);
} }
@Override
public CompletableFuture<ArrayList<VcsRevModel>> getRevisionHistoryByDocumentId(String documentId) {
return CompletableFuture.supplyAsync(() -> {
logger.debug(TAG, "getRevisionHistoryByDocumentId");
ArrayList<VcsRevModel> vcsRevModels = new ArrayList<>();
List<VcsRevEntity> vcsRevEntities = database.vcsRevDao().findByDocumentId(documentId);
vcsRevEntities.forEach(vcsRevEntity -> {
VcsRevModel vcsRevModel = new VcsRevModel();
vcsRevModel.setDocumentId(vcsRevEntity.documentId);
vcsRevModel.setBranchName(vcsRevEntity.branchName);
vcsRevModel.setCommitMessage(vcsRevEntity.commitMessage);
vcsRevModel.setLogIds(vcsRevEntity.logIds);
vcsRevModels.add(vcsRevModel);
});
return vcsRevModels;
});
}
@Override @Override
public void printLog() { public void printLog() {
logger.debug(TAG, "printLog"); logger.debug(TAG, "printLog");