Skip to content

Commit

Permalink
Include variant comments in /api/textunits/{tmTextUnitId}/history
Browse files Browse the repository at this point in the history
Add TMTextUnitVariantComment to the TranslationHistorySummary JSON view. This API will now include the variant comments in the payload.

This will be used by in the frontend to surface more information related to leveraging, and integrity checker failures.
  • Loading branch information
aurambaj committed Jul 13, 2023
1 parent 93fc563 commit 08841d0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public void setCreatedByUser(User createdByUser) {

@JsonManagedReference
@OneToMany(mappedBy = "tmTextUnitVariant", fetch = FetchType.EAGER)
@JsonView(View.TranslationHistorySummary.class)
private Set<TMTextUnitVariantComment> tmTextUnitVariantComments = new HashSet<>();

public String getContent() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.box.l10n.mojito.entity;

import com.box.l10n.mojito.entity.security.user.User;
import com.box.l10n.mojito.rest.View;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonView;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
Expand Down Expand Up @@ -56,13 +58,16 @@ public enum Severity {

@Column(name = "severity")
@Enumerated(EnumType.STRING)
@JsonView(View.TranslationHistorySummary.class)
private Severity severity;

@Column(name = "type")
@Enumerated(EnumType.STRING)
@JsonView(View.TranslationHistorySummary.class)
private Type type;

@Column(name = "content", length = Integer.MAX_VALUE)
@JsonView(View.TranslationHistorySummary.class)
private String content;

@CreatedBy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,21 +230,21 @@ public TextUnitAndWordCount getTextUnitsCount(
/**
* Gets the translation history for a given text unit for a particular locale.
*
* @param textUnitId required
* @param tmTextUnitId required
* @param bcp47Tag required
* @return the translations that matches the search parameters
* @throws InvalidTextUnitSearchParameterException
*/
@RequestMapping(method = RequestMethod.GET, value = "/api/textunits/{textUnitId}/history")
@RequestMapping(method = RequestMethod.GET, value = "/api/textunits/{tmTextUnitId}/history")
@ResponseStatus(HttpStatus.OK)
@JsonView(View.TranslationHistorySummary.class)
public List<TMTextUnitVariant> getTextUnitHistory(
@PathVariable Long textUnitId,
@PathVariable Long tmTextUnitId,
@RequestParam(value = "bcp47Tag", required = true) String bcp47Tag)
throws InvalidTextUnitSearchParameterException {

Locale locale = localeService.findByBcp47Tag(bcp47Tag);
return tmHistoryService.findHistory(textUnitId, locale.getId());
return tmHistoryService.findHistory(tmTextUnitId, locale.getId());
}

TextUnitSearcherParameters queryParamsToTextUnitSearcherParameters(
Expand Down

0 comments on commit 08841d0

Please sign in to comment.