Skip to content

Commit

Permalink
- Export/Import MultiSelect (ArrayValue)
Browse files Browse the repository at this point in the history
  • Loading branch information
alegauss committed Mar 4, 2019
1 parent c5d86d1 commit 325a70b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public void shPostAttrExchangeIterate(ShPost shPost, Set<ShPostAttr> shPostAttrs
if (shPostAttr != null && shPostAttr.getShPostTypeAttr() != null) {
if (shPostAttr.getShPostTypeAttr().getShWidget().getName().equals(ShSystemWidget.RELATOR)) {
ShRelatorExchange shRelatorExchange = new ShRelatorExchange();
shRelatorExchange.setId(shPostAttr.getId());
shRelatorExchange.setName(shPostAttr.getStrValue());
shRelatorExchange.setId(shPostAttr.getId());
shRelatorExchange.setName(shPostAttr.getStrValue());
ShRelatorItemExchanges relators = new ShRelatorItemExchanges();
for (ShRelatorItem shRelatorItem : shPostAttr.getShChildrenRelatorItems()) {
ShRelatorItemExchange shRelatorItemExchange = new ShRelatorItemExchange();
Expand All @@ -67,7 +67,10 @@ public void shPostAttrExchangeIterate(ShPost shPost, Set<ShPostAttr> shPostAttrs
shRelatorExchange.setShSubPosts(relators);
fields.put(shPostAttr.getShPostTypeAttr().getName(), shRelatorExchange);
} else {
fields.put(shPostAttr.getShPostTypeAttr().getName(), shPostAttr.getStrValue());
if (!shPostAttr.getArrayValue().isEmpty())
fields.put(shPostAttr.getShPostTypeAttr().getName(), shPostAttr.getArrayValue());
else
fields.put(shPostAttr.getShPostTypeAttr().getName(), shPostAttr.getStrValue());
}

if (shPostAttr.getShPostTypeAttr().getName().equals(ShSystemPostTypeAttr.FILE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -203,9 +205,9 @@ private void createShPostAttrs(ShPostExchange shPostExchange, ShPost shPost, Map

ObjectMapper mapper = new ObjectMapper();
ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();
String subPostsJson = ow.writeValueAsString(relatorFields.get("shSubPosts"));
String subPostsJson = ow.writeValueAsString(relatorFields.get("shSubPosts"));
ShRelatorItemExchanges subPosts = mapper.readValue(subPostsJson, ShRelatorItemExchanges.class);

for (ShRelatorItemExchange shSubPost : subPosts) {
ShRelatorItem shRelatorItem = new ShRelatorItem();
shRelatorItem.setOrdinal(shSubPost.getPosition());
Expand All @@ -218,7 +220,11 @@ private void createShPostAttrs(ShPostExchange shPostExchange, ShPost shPost, Map
}
} else {
ShPostAttr shPostAttr = new ShPostAttr();
shPostAttr.setStrValue((String) shPostField.getValue());
System.out.println(shPostField.getValue() != null ? shPostField.getValue().getClass().getName() : null);
if (shPostField.getValue() instanceof ArrayList)
shPostAttr.setArrayValue((new HashSet<String>((ArrayList<String>) shPostField.getValue())));
else
shPostAttr.setStrValue((String) shPostField.getValue());

if (shParentRelatorItem != null) {
shPostAttr.setShPost(null);
Expand Down

0 comments on commit 325a70b

Please sign in to comment.