Skip to content

Commit fda0bbf

Browse files
author
Yoshito Umaoka
committed
Properly handle notes field in CLI and maven plugin
Updated gp-java-client version to 1.1.3. Changed CLI export command to read notes field, although current export command really does not use the value. Updated CLI import command to store notes field values parsed by the new gp-res-filter. Maven gp:upload to import notes field values returned by gp-res-filter as well.
1 parent dcd9a57 commit fda0bbf

5 files changed

Lines changed: 23 additions & 9 deletions

File tree

gp-cli/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<dependency>
9393
<groupId>com.ibm.g11n.pipeline</groupId>
9494
<artifactId>gp-java-client</artifactId>
95-
<version>1.1.2</version>
95+
<version>1.1.3</version>
9696
</dependency>
9797

9898
<dependency>

gp-cli/src/main/java/com/ibm/g11n/pipeline/tools/cli/ExportCmd.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.ibm.g11n.pipeline.resfilter.Bundle;
3030
import com.ibm.g11n.pipeline.resfilter.ResourceFilter;
3131
import com.ibm.g11n.pipeline.resfilter.ResourceFilterFactory;
32+
import com.ibm.g11n.pipeline.resfilter.ResourceString;
3233
import com.ibm.g11n.pipeline.resfilter.ResourceType;
3334

3435
/**
@@ -89,7 +90,9 @@ protected void _execute() {
8990
if (seqNum != null) {
9091
sequenceNumber = seqNum.intValue();
9192
}
92-
bundle.addResourceString(key, resVal, sequenceNumber);
93+
ResourceString resString = new ResourceString(key, resVal,
94+
sequenceNumber, data.getNotes());
95+
bundle.addResourceString(resString);
9396
}
9497
}
9598
} catch (ServiceException e) {

gp-cli/src/main/java/com/ibm/g11n/pipeline/tools/cli/ImportCmd.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ protected void _execute() {
7171
if (seqNum >= 0) {
7272
resEntryData.setSequenceNumber(Integer.valueOf(seqNum));
7373
}
74+
resEntryData.setNotes(resString.getNotes());
7475
resEntries.put(resString.getKey(), resEntryData);
7576
}
7677
} catch (IOException e) {

gp-maven-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188
<dependency>
189189
<groupId>com.ibm.g11n.pipeline</groupId>
190190
<artifactId>gp-java-client</artifactId>
191-
<version>1.1.2</version>
191+
<version>1.1.3</version>
192192
</dependency>
193193
<dependency>
194194
<groupId>com.ibm.g11n.pipeline</groupId>

gp-maven-plugin/src/main/java/com/ibm/g11n/pipeline/maven/GPUploadMojo.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
7070

7171
// Checks if the bundle already exists
7272
String bundleId = bf.getBundleId();
73+
boolean createNew = false;
7374
if (bundleIds.contains(bundleId)) {
7475
getLog().info("Found bundle:" + bundleId);
7576
// Checks if the source language matches.
@@ -82,12 +83,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
8283
}
8384
} else {
8485
getLog().info("bundle:" + bundleId + " does not exist, creating a new bundle.");
85-
NewBundleData newBundleData = new NewBundleData(srcLang);
86-
if (!tgtLangs.isEmpty()) {
87-
newBundleData.setTargetLanguages(new TreeSet<String>(tgtLangs));
88-
}
89-
client.createBundle(bundleId, newBundleData);
90-
getLog().info("Created bundle: " + bundleId);
86+
createNew = true;
9187
}
9288

9389
// Parse the resource bundle file
@@ -96,13 +92,27 @@ public void execute() throws MojoExecutionException, MojoFailureException {
9692

9793
try (FileInputStream fis = new FileInputStream(bf.getFile())) {
9894
Bundle resBundle = filter.parse(fis);
95+
96+
if (createNew) {
97+
NewBundleData newBundleData = new NewBundleData(srcLang);
98+
// set target languages
99+
if (!tgtLangs.isEmpty()) {
100+
newBundleData.setTargetLanguages(new TreeSet<String>(tgtLangs));
101+
}
102+
// set bundle notes
103+
newBundleData.setNotes(resBundle.getNotes());
104+
client.createBundle(bundleId, newBundleData);
105+
getLog().info("Created bundle: " + bundleId);
106+
}
99107
Collection<ResourceString> resStrings = resBundle.getResourceStrings();
100108
for (ResourceString resString : resStrings) {
101109
NewResourceEntryData resEntryData = new NewResourceEntryData(resString.getValue());
102110
int seqNum = resString.getSequenceNumber();
103111
if (seqNum >= 0) {
104112
resEntryData.setSequenceNumber(Integer.valueOf(seqNum));
105113
}
114+
// set resource string notes
115+
resEntryData.setNotes(resString.getNotes());
106116
resEntries.put(resString.getKey(), resEntryData);
107117
}
108118
} catch (IOException e) {

0 commit comments

Comments
 (0)