|
26 | 26 | import org.slf4j.LoggerFactory;
|
27 | 27 |
|
28 | 28 | import com.fasterxml.jackson.databind.JsonNode;
|
| 29 | +import com.fasterxml.jackson.databind.node.ArrayNode; |
29 | 30 | import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
30 | 31 | import com.fasterxml.jackson.databind.node.ObjectNode;
|
31 |
| -import com.fasterxml.jackson.databind.node.ArrayNode; |
32 | 32 | import com.redhat.lightblue.crud.CrudConstants;
|
33 | 33 | import com.redhat.lightblue.metadata.ArrayField;
|
34 | 34 | import com.redhat.lightblue.metadata.FieldTreeNode;
|
35 | 35 | import com.redhat.lightblue.metadata.ObjectArrayElement;
|
36 | 36 | import com.redhat.lightblue.metadata.ObjectField;
|
| 37 | +import com.redhat.lightblue.metadata.ReferenceField; |
37 | 38 | import com.redhat.lightblue.metadata.SimpleArrayElement;
|
38 | 39 | import com.redhat.lightblue.metadata.SimpleField;
|
39 | 40 | import com.redhat.lightblue.metadata.Type;
|
@@ -134,14 +135,23 @@ public SetExpressionEvaluator(JsonNodeFactory factory, FieldTreeNode context, Se
|
134 | 135 |
|
135 | 136 | if (mdNode instanceof SimpleField || mdNode instanceof SimpleArrayElement) {
|
136 | 137 | data = initializeSimple(rvalue, refMdNode, mdNode, field, refPath);
|
| 138 | + setValues.add(data); |
| 139 | + } else if (mdNode instanceof ReferenceField) { |
| 140 | + if (rvalue.getValue() != null) { |
| 141 | + throw new EvaluationError(CrudConstants.ERR_ASSIGNMENT + field +" can't assign values to referenced fields"); |
| 142 | + } else { |
| 143 | + // ignore if null |
| 144 | + } |
137 | 145 | } else if (mdNode instanceof ObjectField || mdNode instanceof ObjectArrayElement) {
|
138 | 146 | data = initializeObject(rvalue, refMdNode, mdNode, field, refPath);
|
| 147 | + setValues.add(data); |
139 | 148 | } else if (mdNode instanceof ArrayField) {
|
140 | 149 | data = initializeArray(rvalue, refMdNode, mdNode, field, refPath);
|
141 |
| - } |
142 |
| - if (data != null) { |
143 | 150 | setValues.add(data);
|
| 151 | + } else { |
| 152 | + throw new EvaluationError(CrudConstants.ERR_ASSIGNMENT + field + " field type "+mdNode.getClass()+" is not recognized!"); |
144 | 153 | }
|
| 154 | + |
145 | 155 | }
|
146 | 156 | }
|
147 | 157 |
|
|
0 commit comments