リファクタリング, 実装いろいろ

This commit is contained in:
r-ca 2024-01-24 15:49:17 +09:00
parent dafb49cca0
commit b6f0a5554a
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9

View File

@ -157,12 +157,12 @@ public class LacertaVcsImpl implements LacertaVcs {
@Override @Override
public CompletableFuture<ArrayList<VcsLogModel>> getLogHistoryInRev(String revId) { public CompletableFuture<ArrayList<VcsLogModel>> getLogHistoryInRev(String revId) {
return CompletableFuture.supplyAsync(() -> { return CompletableFuture.supplyAsync(() -> {
logger.debug(TAG, "getLogHistoryAtRev"); logger.debug(TAG, "getLogHistoryInRev");
ArrayList<VcsLogModel> vcsLogModels = new ArrayList<>(); ArrayList<VcsLogModel> vcsLogModels = new ArrayList<>();
VcsRevEntity vcsRevEntity = database.vcsRevDao().findById(revId); VcsRevEntity vcsRevEntity = database.vcsRevDao().findById(revId);
vcsRevEntity.logIds.forEach(logId -> { ArrayList<VcsLogEntity> vcsLogEntities = getLogInRev(vcsRevEntity);
VcsLogEntity vcsLogEntity = database.vcsLogDao().findById(logId); vcsLogEntities.forEach(vcsLogEntity -> {
VcsLogModel vcsLogModel = new VcsLogModel(); VcsLogModel vcsLogModel = new VcsLogModel();
vcsLogModel.setId(vcsLogEntity.id); vcsLogModel.setId(vcsLogEntity.id);
vcsLogModel.setDocumentId(vcsLogEntity.documentId); vcsLogModel.setDocumentId(vcsLogEntity.documentId);
@ -176,9 +176,49 @@ public class LacertaVcsImpl implements LacertaVcs {
}); });
} }
private ArrayList<VcsRevEntity> getRevBeforeTargetId(String revId){
ArrayList<VcsRevEntity> vcsRevEntities = new ArrayList<>(database.vcsRevDao().findByDocumentId(this.documentId));
ArrayList<VcsRevEntity> vcsRevEntitiesBeforeTarget = new ArrayList<>();
vcsRevEntities.forEach(vcsRevEntity -> {
if(vcsRevEntity.id.equals(revId)){
vcsRevEntitiesBeforeTarget.add(vcsRevEntity);
return;
}
vcsRevEntitiesBeforeTarget.add(vcsRevEntity);
});
return vcsRevEntitiesBeforeTarget;
}
private ArrayList<VcsLogEntity> getLogInRevs(ArrayList<VcsRevEntity> vcsRevEntities){
ArrayList<VcsLogEntity> vcsLogEntities = new ArrayList<>();
vcsRevEntities.forEach(vcsRevEntity -> {
vcsRevEntity.logIds.forEach(logId -> {
VcsLogEntity vcsLogEntity = database.vcsLogDao().findById(logId);
vcsLogEntities.add(vcsLogEntity);
});
});
return vcsLogEntities;
}
private ArrayList<VcsLogEntity> getLogInRev(VcsRevEntity revEntity) {
ArrayList<VcsLogEntity> vcsLogEntities = new ArrayList<>();
revEntity.logIds.forEach(logId -> {
VcsLogEntity vcsLogEntity = database.vcsLogDao().findById(logId);
vcsLogEntities.add(vcsLogEntity);
});
return vcsLogEntities;
}
@Override @Override
public CompletableFuture<ArrayList<DocumentDetail>> getDocumentDetailAtRev(String revId) { public CompletableFuture<ArrayList<DocumentDetail>> getDocumentDetailAtRev(String revId) {
return null; return CompletableFuture.supplyAsync(() -> {
ArrayList<VcsRevEntity> vcsRevEntities = getRevBeforeTargetId(revId);
});
} }
@Override @Override