-
Notifications
You must be signed in to change notification settings - Fork 64
feat(api): add project file formats api support #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110
src/main/java/com/crowdin/client/core/http/impl/json/FileFormatSettingsDeserializer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| package com.crowdin.client.core.http.impl.json; | ||
|
|
||
| import com.crowdin.client.projectsgroups.model.*; | ||
| import com.fasterxml.jackson.core.JsonParser; | ||
| import com.fasterxml.jackson.databind.DeserializationContext; | ||
| import com.fasterxml.jackson.databind.JsonDeserializer; | ||
| import com.fasterxml.jackson.databind.JsonNode; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| public class FileFormatSettingsDeserializer extends JsonDeserializer<FileFormatSettingsResource> { | ||
|
|
||
| private final ObjectMapper objectMapper; | ||
|
|
||
| public FileFormatSettingsDeserializer(ObjectMapper objectMapper) { | ||
| this.objectMapper = objectMapper; | ||
| } | ||
|
|
||
| @Override | ||
| public FileFormatSettingsResource deserialize(JsonParser parser, DeserializationContext ctx) throws IOException { | ||
| JsonNode parentNode = parser.getCodec().readTree(parser); | ||
|
|
||
| FileFormatSettingsResource resource = this.objectMapper.readValue(parentNode.toString(), FileFormatSettingsResource.class); | ||
|
|
||
| Class<? extends FileFormatSettings> classToUse; | ||
| String format = parentNode.get("format").asText(); | ||
|
|
||
| switch (format) { | ||
| case "properties": | ||
| classToUse = PropertiesFileFormatSettings.class; | ||
| break; | ||
| case "xml": | ||
| classToUse = XmlFileFormatSettings.class; | ||
| break; | ||
| case "webxml": | ||
| classToUse = WebXmlFileFormatSettings.class; | ||
| break; | ||
| case "html": | ||
| classToUse = HtmlFileFormatSettings.class; | ||
| break; | ||
| case "adoc": | ||
| classToUse = AdocFileFormatSettings.class; | ||
| break; | ||
| case "android": | ||
| classToUse = AndroidFileFormatSettings.class; | ||
| break; | ||
| case "md": | ||
| classToUse = MdFileFormatSettings.class; | ||
| break; | ||
| case "mdxV1": | ||
| classToUse = MdxV1FileFormatSettings.class; | ||
| break; | ||
| case "fmMd": | ||
| classToUse = FmMdFileFormatSettings.class; | ||
| break; | ||
| case "fmHtml": | ||
| classToUse = FmHtmlFileFormatSettings.class; | ||
| break; | ||
| case "madcapFlsnp": | ||
| classToUse = MadcapFlsnpFileFormatSettings.class; | ||
| break; | ||
| case "docx": | ||
| classToUse = DocxFileFormatSettings.class; | ||
| break; | ||
| case "idml": | ||
| classToUse = IdmlFileFormatSettings.class; | ||
| break; | ||
| case "mif": | ||
| classToUse = MifFileFormatSettings.class; | ||
| break; | ||
| case "dita": | ||
| classToUse = DitaFileFormatSettings.class; | ||
| break; | ||
| case "mediawiki": | ||
| classToUse = MediaWikiFileFormatSettings.class; | ||
| break; | ||
| case "arb": | ||
| classToUse = ArbFileFormatSettings.class; | ||
| break; | ||
| case "json": | ||
| classToUse = JsonFileFormatSettings.class; | ||
| break; | ||
| case "fjs": | ||
| classToUse = FJSFileFormatSettings.class; | ||
| break; | ||
| case "macosx": | ||
| classToUse = MacOSXFileFormatSettings.class; | ||
| break; | ||
| case "chrome": | ||
| classToUse = ChromeFileFormatSettings.class; | ||
| break; | ||
| case "react_intl": | ||
| classToUse = ReactIntlFileFormatSettings.class; | ||
| break; | ||
| case "txt": | ||
| classToUse = TxtFileFormatSettings.class; | ||
| break; | ||
| default: | ||
| classToUse = OtherFileFormatSettings.class; | ||
| break; | ||
| } | ||
|
|
||
| JsonNode settingsNode = parentNode.get("settings"); | ||
| FileFormatSettings settings = this.objectMapper.readValue(settingsNode.toString(), classToUse); | ||
| resource.setSettings(settings); | ||
|
|
||
| return resource; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/com/crowdin/client/core/model/EscapeQuotesMode.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package com.crowdin.client.core.model; | ||
|
|
||
| public enum EscapeQuotesMode implements EnumConverter<EscapeQuotesMode> { | ||
| DO_NOT_ESCAPE_SINGLE_QUOTE(0), | ||
| ESCAPE_SINGLE_QUOTE_BY_ANOTHER_SINGLE_QUOTE(1), | ||
| ESCAPE_SINGLE_QUOTE_BY_BACK_SLASH(2), | ||
| ESCAPE_SINGLE_QUOTE_BY_ANOTHER_SINGLE_QUOTE_ONLY_IF_VARIABLES(3); | ||
|
|
||
| private final int value; | ||
|
|
||
| EscapeQuotesMode(int value) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| public static EscapeQuotesMode from(String value) { | ||
| return EscapeQuotesMode.values()[Integer.parseInt(value)]; | ||
| } | ||
|
|
||
| @Override | ||
| public Integer to(EscapeQuotesMode v) { | ||
| return v.value; | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/crowdin/client/core/model/EscapeSpecialCharsMode.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package com.crowdin.client.core.model; | ||
|
|
||
| public enum EscapeSpecialCharsMode implements EnumConverter<EscapeSpecialCharsMode> { | ||
| DO_NOT_ESCAPE(0), | ||
| ESCAPE_BY_BACKSLASH(1); | ||
|
|
||
| private final int value; | ||
|
|
||
| EscapeSpecialCharsMode(int value) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| public static EscapeSpecialCharsMode from(String value) { | ||
| return EscapeSpecialCharsMode.values()[Integer.parseInt(value)]; | ||
| } | ||
|
|
||
| @Override | ||
| public Object to(EscapeSpecialCharsMode v) { | ||
| return v.value; | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/crowdin/client/core/model/JsonFileType.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package com.crowdin.client.core.model; | ||
|
|
||
| public enum JsonFileType implements EnumConverter<JsonFileType> { | ||
| I18NEXT_JSON("i18next_json"), | ||
| NESTJS_I18N("nestjs_i18n"); | ||
|
|
||
| private String value; | ||
|
|
||
| JsonFileType(String value) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| public static JsonFileType from(String value) { | ||
| return JsonFileType.valueOf(value.toUpperCase()); | ||
| } | ||
|
|
||
| @Override | ||
| public String to(JsonFileType v) { | ||
| return v.value; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...ain/java/com/crowdin/client/projectsgroups/model/AddProjectFileFormatSettingsRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.crowdin.client.projectsgroups.model; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| @Data | ||
| public class AddProjectFileFormatSettingsRequest { | ||
| private String format; | ||
| private FileFormatSettings settings; | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/crowdin/client/projectsgroups/model/AdocFileFormatSettings.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.crowdin.client.projectsgroups.model; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| @Data | ||
| public class AdocFileFormatSettings extends FileFormatSettings { | ||
| private Boolean contentSegmentation; | ||
| private Long srxStorageId; | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/crowdin/client/projectsgroups/model/AndroidFileFormatSettings.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.crowdin.client.projectsgroups.model; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| @Data | ||
| public class AndroidFileFormatSettings extends FileFormatSettings { | ||
| private Boolean contentSegmentation; | ||
| private Long srxStorageId; | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/crowdin/client/projectsgroups/model/ArbFileFormatSettings.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.crowdin.client.projectsgroups.model; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| @Data | ||
| public class ArbFileFormatSettings extends FileFormatSettings { | ||
| private Boolean contentSegmentation; | ||
| private Long srxStorageId; | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/crowdin/client/projectsgroups/model/ChromeFileFormatSettings.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.crowdin.client.projectsgroups.model; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| @Data | ||
| public class ChromeFileFormatSettings extends FileFormatSettings { | ||
| private Boolean contentSegmentation; | ||
| private Long srxStorageId; | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/crowdin/client/projectsgroups/model/DitaFileFormatSettings.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.crowdin.client.projectsgroups.model; | ||
|
|
||
| import lombok.Data; | ||
|
|
||
| @Data | ||
| public class DitaFileFormatSettings extends FileFormatSettings { | ||
| private Boolean contentSegmentation; | ||
| private Long srxStorageId; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.