Skip to content

Commit

Permalink
NotesRestController works
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBestPessimist committed Apr 22, 2020
1 parent b060661 commit 85512a4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/main/java/de/metas/ui/web/notes/NotesRestController.java
Expand Up @@ -32,8 +32,8 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
Expand Down Expand Up @@ -76,7 +76,7 @@ public List<JSONNote> getAll(
public void addNote(
@PathVariable("windowId") final String windowIdStr,
@PathVariable("documentId") final String documentId,
@RequestParam("text") final String characterData
@RequestBody final String text
)
{
// userSession.assertLoggedIn(); // TODO tbp: this needs to be enabled
Expand All @@ -85,6 +85,6 @@ public void addNote(

final TableRecordReference tableRecordReference = documentDescriptorFactory.getTableRecordReference(documentPath);

notesService.addNote(tableRecordReference, characterData);
notesService.addNote(tableRecordReference, text);
}
}
6 changes: 3 additions & 3 deletions src/main/java/de/metas/ui/web/notes/NotesService.java
Expand Up @@ -60,16 +60,16 @@ public List<JSONNote> getNotesFor(@NonNull final ITableRecordReference tableReco
final I_AD_User user = userDAO.getById(UserId.ofRepoId(it.getCreatedBy()));

return JSONNote.builder()
.characterData(it.getCharacterData())
.text(it.getCharacterData())
.created(it.getCreated().toString())
.createdBy(user.getName())
.build();
})
.collect(GuavaCollectors.toImmutableList());
}

public void addNote(@NonNull final TableRecordReference tableRecordReference, @NonNull final String characterData)
public void addNote(@NonNull final TableRecordReference tableRecordReference, @NonNull final String text)
{
notesRepository.createNote(characterData, tableRecordReference);
notesRepository.createNote(text, tableRecordReference);
}
}
4 changes: 3 additions & 1 deletion src/main/java/de/metas/ui/web/notes/json/JSONNote.java
Expand Up @@ -24,14 +24,16 @@

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import lombok.Builder;
import lombok.Value;

@Builder
@Value
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
public class JSONNote
{
String createdBy;

String created;

String characterData;
String text;
}

0 comments on commit 85512a4

Please sign in to comment.