mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-23 00:13:16 +00:00
一部を非同期にした
This commit is contained in:
parent
cd1a58dcc0
commit
8c4e651a79
|
@ -5,6 +5,7 @@ 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 java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.CompletionException;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@ -180,26 +181,31 @@ public class LacertaVcsImpl implements LacertaVcs {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<VcsRevEntity> getRevBeforeTargetId(String revId){
|
private CompletableFuture<ArrayList<VcsRevEntity>> getRevBeforeTargetIdAsync(String revId){
|
||||||
ArrayList<VcsRevEntity> vcsRevEntities = new ArrayList<>(database.vcsRevDao().findByDocumentId(this.documentId));
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
ArrayList<VcsRevEntity> vcsRevEntitiesBeforeTarget = new ArrayList<>();
|
ArrayList<VcsRevEntity> vcsRevEntities = new ArrayList<>(database.vcsRevDao().findByDocumentId(this.documentId));
|
||||||
vcsRevEntities.forEach(vcsRevEntity -> {
|
ArrayList<VcsRevEntity> vcsRevEntitiesBeforeTarget = new ArrayList<>();
|
||||||
if(vcsRevEntity.id.equals(revId)){
|
vcsRevEntities.forEach(vcsRevEntity -> {
|
||||||
|
if(vcsRevEntity.id.equals(revId)){
|
||||||
|
vcsRevEntitiesBeforeTarget.add(vcsRevEntity);
|
||||||
|
return;
|
||||||
|
}
|
||||||
vcsRevEntitiesBeforeTarget.add(vcsRevEntity);
|
vcsRevEntitiesBeforeTarget.add(vcsRevEntity);
|
||||||
return;
|
});
|
||||||
}
|
|
||||||
vcsRevEntitiesBeforeTarget.add(vcsRevEntity);
|
|
||||||
});
|
|
||||||
|
|
||||||
return vcsRevEntitiesBeforeTarget;
|
return vcsRevEntitiesBeforeTarget;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<VcsLogEntity> getLogInRevs(ArrayList<VcsRevEntity> vcsRevEntities){
|
private CompletableFuture<ArrayList<VcsLogEntity>> getLogInRevs(ArrayList<VcsRevEntity> vcsRevEntities){
|
||||||
List<String> logIds = new ArrayList<>();
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
vcsRevEntities.forEach(vcsRevEntity -> {
|
List<String> logIds = new ArrayList<>();
|
||||||
logIds.addAll(vcsRevEntity.logIds);
|
vcsRevEntities.forEach(vcsRevEntity -> {
|
||||||
|
logIds.addAll(vcsRevEntity.logIds);
|
||||||
|
});
|
||||||
|
// TODO-rca: ソートしないといけないかも(順番が保証されているわけではない + 順番が変わるとほぼ確実に壊れる)
|
||||||
|
return new ArrayList<>(database.vcsLogDao().findByIds(logIds));
|
||||||
});
|
});
|
||||||
return new ArrayList<>(database.vcsLogDao().findByIds(logIds));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<VcsLogEntity> getLogInRev(VcsRevEntity revEntity) {
|
private ArrayList<VcsLogEntity> getLogInRev(VcsRevEntity revEntity) {
|
||||||
|
@ -209,8 +215,8 @@ public class LacertaVcsImpl implements LacertaVcs {
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<ArrayList<String>> getDocumentPagePathListRev(String revId) {
|
public CompletableFuture<ArrayList<String>> getDocumentPagePathListRev(String revId) {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
ArrayList<VcsRevEntity> vcsRevEntities = getRevBeforeTargetId(revId);
|
ArrayList<VcsRevEntity> vcsRevEntities = getRevBeforeTargetIdAsync(revId).join();
|
||||||
ArrayList<VcsLogEntity> vcsLogEntities = getLogInRevs(vcsRevEntities);
|
ArrayList<VcsLogEntity> vcsLogEntities = getLogInRevs(vcsRevEntities).join();
|
||||||
|
|
||||||
// finalで宣言しないとLambda式内で扱えないので
|
// finalで宣言しないとLambda式内で扱えないので
|
||||||
final ArrayList<String>[] fileNameList = new ArrayList[]{new ArrayList<>()};
|
final ArrayList<String>[] fileNameList = new ArrayList[]{new ArrayList<>()};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user