diff --git a/data/src/main/java/one/nem/lacerta/data/Document.java b/data/src/main/java/one/nem/lacerta/data/Document.java index cd38acfc..70610913 100644 --- a/data/src/main/java/one/nem/lacerta/data/Document.java +++ b/data/src/main/java/one/nem/lacerta/data/Document.java @@ -18,6 +18,8 @@ public interface Document { CompletableFuture createDocument(); + CompletableFuture renameDocument(String documentId, String name); + CompletableFuture deleteDocument(String documentId); CompletableFuture updateDocument(DocumentDetail detail); 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 888a47f6..7ee8511f 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 @@ -1,5 +1,7 @@ package one.nem.lacerta.data.impl; +import androidx.room.Update; + import java.io.IOException; import java.util.ArrayList; import java.util.Date; @@ -124,6 +126,19 @@ public class DocumentImpl implements Document { }); } + @Override + public CompletableFuture renameDocument(String documentId, String name) { + return CompletableFuture.supplyAsync(() -> { + DocumentEntity documentEntity = database.documentDao().findById(documentId); + if (documentEntity == null) { + throw new IllegalArgumentException("documentId is not found"); + } + documentEntity.title = name; + database.documentDao().update(documentEntity); + return null; + }); + } + @Override public CompletableFuture getDocument(String documentId) { return CompletableFuture.supplyAsync(() -> {