better implementation for the fix

This commit is contained in:
Miriam Baglioni 2023-04-06 12:22:38 +02:00
parent b42abc9904
commit 287753417d
2 changed files with 3 additions and 3 deletions

View File

@ -16,7 +16,7 @@ public class Community implements Serializable {
private List<String> subjects = new ArrayList<>(); private List<String> subjects = new ArrayList<>();
private List<Provider> providers = new ArrayList<>(); private List<Provider> providers = new ArrayList<>();
private List<ZenodoCommunity> zenodoCommunities = new ArrayList<>(); private List<ZenodoCommunity> zenodoCommunities = new ArrayList<>();
private SelectionConstraints constraints = new SelectionConstraints(); private SelectionConstraints constraints;
public String toJson() { public String toJson() {
final Gson g = new Gson(); final Gson g = new Gson();
@ -27,7 +27,7 @@ public class Community implements Serializable {
return !getSubjects().isEmpty() return !getSubjects().isEmpty()
|| !getProviders().isEmpty() || !getProviders().isEmpty()
|| !getZenodoCommunities().isEmpty() || !getZenodoCommunities().isEmpty()
|| constraints != null; || !getConstraints().getCriteria().isEmpty();
} }
public String getId() { public String getId() {

View File

@ -92,7 +92,7 @@ public class CommunityConfigurationFactory {
private static SelectionConstraints parseConstrains(Node node) { private static SelectionConstraints parseConstrains(Node node) {
Node advConstsNode = node.selectSingleNode("./advancedConstraints"); Node advConstsNode = node.selectSingleNode("./advancedConstraints");
if (advConstsNode == null || StringUtils.isBlank(StringUtils.trim(advConstsNode.getText()))) { if (advConstsNode == null || StringUtils.isBlank(StringUtils.trim(advConstsNode.getText()))) {
return null; return new SelectionConstraints();
} }
SelectionConstraints selectionConstraints = new Gson() SelectionConstraints selectionConstraints = new Gson()
.fromJson(advConstsNode.getText(), SelectionConstraints.class); .fromJson(advConstsNode.getText(), SelectionConstraints.class);