Skip to content

Commit 6260ed8

Browse files
committed
- Sprinklr: Tag Mapping
1 parent 8be0482 commit 6260ed8

File tree

6 files changed

+45
-21
lines changed

6 files changed

+45
-21
lines changed

turing-sprinklr/sprinklr-app/src/main/java/com/viglet/turing/connector/sprinklr/export/TurSprinklrExchangeProcess.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public StreamingResponseBody exportObject(HttpServletResponse response) {
8686
.locale(turSprinklrSource.getLocale())
8787
.localeClass(turSprinklrSource.getLocaleClass())
8888
.turSNSites(turSprinklrSource.getTurSNSites())
89+
.tagMapping(turSprinklrSource.getTagMapping())
8990
.build()).toList()));
9091

9192
File zipFile = new File(tmpDir.getAbsolutePath().concat(File.separator + folderName + ".zip"));

turing-sprinklr/sprinklr-app/src/main/java/com/viglet/turing/connector/sprinklr/export/bean/TurSprinklrSourceExchange.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class TurSprinklrSourceExchange {
2020
private String environment;
2121
private String secretKey;
2222
private String apiKey;
23+
private String tagMapping;
2324
@Builder.Default
2425
private Collection<String> turSNSites = new HashSet<>();
2526
@Builder.Default

turing-sprinklr/sprinklr-app/src/main/java/com/viglet/turing/connector/sprinklr/persistence/model/TurSprinklrSource.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public class TurSprinklrSource implements Serializable {
4848
private String apiKey;
4949
@Column
5050
private String secretKey;
51-
51+
@Column
52+
private String tagMapping;
5253
@Builder.Default
5354
@ElementCollection(targetClass = String.class, fetch = FetchType.EAGER)
5455
@CollectionTable(name = "sprinklr_sn_site", joinColumns = @JoinColumn(name = "source_id"))

turing-sprinklr/sprinklr-app/src/test/java/com/viglet/turing/connector/sprinklr/plugins/TurSprinklrKeyValueTransformerTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void loadMapping() {
2929
assertFalse(mapping.isEmpty(), "Mapping should not be empty after loading");
3030

3131
// Checks if a specific key was loaded correctly
32-
assertEquals("action", mapping.get("424123421312"), "Value for key '424123421312' should be 'ação'");
32+
assertEquals("action", mapping.get("424123421312"), "Value for key '424123421312' should be 'action'");
3333
}
3434

3535
@Test
@@ -60,7 +60,7 @@ void transform() {
6060

6161
// Test the transformation
6262
String transformedValue = transformer.transform("424123421312", testFile);
63-
assertEquals("action", transformedValue, "Transformed value should be 'ação'");
63+
assertEquals("action", transformedValue, "Transformed value should be 'action'");
6464
}
6565

6666
@Test
@@ -72,10 +72,10 @@ void loadMappingTransFromLoadSameMapTransform() {
7272
transformer.loadMapping(testFile);
7373

7474
var transformedValue = transformer.transform("424123421312", testFile);
75-
assertEquals("action", transformedValue, "Transformed value should be 'ação'");
75+
assertEquals("action", transformedValue, "Transformed value should be 'action'");
7676
transformer.loadMapping(testFile);
7777
transformedValue = transformer.transform("235521957944", testFile);
78-
assertEquals("adventure", transformedValue, "Transformed value should be 'aventura'");
78+
assertEquals("adventure", transformedValue, "Transformed value should be 'adventure'");
7979
}
8080

8181
@Test

turing-sprinklr/sprinklr-commons/src/main/java/com/viglet/turing/connector/sprinklr/commons/plugins/TurSprinklrKeyValueTransformer.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
/**
2828
* @author Gabriel F. Gomazako
29+
* @since 0.3.9
2930
*/
3031
@Slf4j
3132
public class TurSprinklrKeyValueTransformer implements TurSprinklrPlugin {
@@ -34,21 +35,9 @@ public class TurSprinklrKeyValueTransformer implements TurSprinklrPlugin {
3435

3536
private final Map<String, Map<String, String>> mappings = new HashMap<>();
3637

37-
/**
38-
* Enum representing the actions to take when a key is not found.
39-
* <ul>
40-
* <li>DEFAULT_VALUE: Returns a default value</li>
41-
* <li>KEEP_KEY: Returns the key itself</li>
42-
* <li>NULL: Returns null</li>
43-
* </ul>
44-
*/
45-
enum NotFoundAction {
46-
DEFAULT_VALUE,
47-
KEEP_KEY,
48-
NULL
49-
}
5038

51-
NotFoundAction notFoundAction = NotFoundAction.DEFAULT_VALUE;
39+
40+
TurSprinklrNotFound notFoundAction = TurSprinklrNotFound.DEFAULT_VALUE;
5241

5342
String defaultNotFoundText = "Key Value Transformer Plugin: Key not found";
5443

@@ -129,7 +118,7 @@ private String treatNotFound(String key, String file) {
129118
};
130119
}
131120

132-
public void configure(NotFoundAction action) {
121+
public void configure(TurSprinklrNotFound action) {
133122
notFoundAction = action;
134123
}
135124

@@ -139,7 +128,7 @@ public void configure(NotFoundAction action) {
139128
* @param action the action to be taken when a key is not found
140129
* @param defaultText the default text to be used when a key is not found
141130
*/
142-
public void configure(NotFoundAction action, String defaultText) {
131+
public void configure(TurSprinklrNotFound action, String defaultText) {
143132
notFoundAction = action;
144133
defaultNotFoundText = defaultText;
145134
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
*
3+
* Copyright (C) 2016-2024 the original author or authors.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
package com.viglet.turing.connector.sprinklr.commons.plugins;
20+
/**
21+
* Enum representing the actions to take when a key is not found.
22+
* <ul>
23+
* <li>DEFAULT_VALUE: Returns a default value</li>
24+
* <li>KEEP_KEY: Returns the key itself</li>
25+
* <li>NULL: Returns null</li>
26+
* </ul>
27+
*/
28+
public enum TurSprinklrNotFound {
29+
DEFAULT_VALUE,
30+
KEEP_KEY,
31+
NULL
32+
}

0 commit comments

Comments
 (0)