|
31 | 31 | import org.apache.logging.log4j.Logger; |
32 | 32 | import org.eclipse.emf.common.command.Command; |
33 | 33 | import org.eclipse.emf.common.command.IdentityCommand; |
| 34 | +import org.eclipse.emf.common.util.Enumerator; |
34 | 35 | import org.eclipse.emf.common.util.URI; |
35 | 36 | import org.eclipse.emf.ecore.EAttribute; |
36 | 37 | import org.eclipse.emf.ecore.EClass; |
37 | 38 | import org.eclipse.emf.ecore.EClassifier; |
38 | 39 | import org.eclipse.emf.ecore.EDataType; |
39 | 40 | import org.eclipse.emf.ecore.EEnum; |
40 | | -import org.eclipse.emf.ecore.EEnumLiteral; |
41 | 41 | import org.eclipse.emf.ecore.EFactory; |
42 | 42 | import org.eclipse.emf.ecore.EObject; |
43 | 43 | import org.eclipse.emf.ecore.EReference; |
@@ -392,28 +392,25 @@ protected Object getEMFValue(final String modelURI, final ResourceSet resourceSe |
392 | 392 | if (feature instanceof EAttribute) { |
393 | 393 | // Attributes |
394 | 394 | if (feature.getEType() instanceof EEnum) { |
395 | | - getEMFEnumValue((EEnum) feature.getEType(), value); |
396 | | - } else { |
397 | | - return getPrimitiveEMFValue((EAttribute) feature, value); |
398 | | - } |
399 | | - } else { |
400 | | - // References |
401 | | - JsonNode refNode = value.get(JsonConstants.REF_ATTR); |
402 | | - JsonNode idNode = value.get(JsonConstants.ID_ATTR); |
403 | | - if (refNode == null && idNode == null) { |
404 | | - throw new JsonPatchException("Reference values should include a $ref or an $id attribute"); |
| 395 | + return getEMFEnumValue((EEnum) feature.getEType(), value); |
405 | 396 | } |
406 | | - String objectId = refNode == null ? idNode.asText() : refNode.asText(); |
407 | | - return getEObject(modelURI, URI.createURI(objectId)); |
| 397 | + return getPrimitiveEMFValue((EAttribute) feature, value); |
| 398 | + } |
| 399 | + // References |
| 400 | + JsonNode refNode = value.get(JsonConstants.REF_ATTR); |
| 401 | + JsonNode idNode = value.get(JsonConstants.ID_ATTR); |
| 402 | + if (refNode == null && idNode == null) { |
| 403 | + throw new JsonPatchException("Reference values should include a $ref or an $id attribute"); |
408 | 404 | } |
| 405 | + String objectId = refNode == null ? idNode.asText() : refNode.asText(); |
| 406 | + return getEObject(modelURI, URI.createURI(objectId)); |
409 | 407 | // TODO Support custom datatypes & array-values. See |
410 | 408 | // https://github.com/eclipse-emfcloud/emfcloud-modelserver/issues/162 |
411 | | - return null; |
412 | 409 | } |
413 | 410 |
|
414 | | - protected EEnumLiteral getEMFEnumValue(final EEnum enumType, final JsonNode value) throws JsonPatchException { |
| 411 | + protected Enumerator getEMFEnumValue(final EEnum enumType, final JsonNode value) throws JsonPatchException { |
415 | 412 | if (value.isTextual()) { |
416 | | - EEnumLiteral literal = enumType.getEEnumLiteral(value.asText()); |
| 413 | + Enumerator literal = enumType.getEEnumLiteral(value.asText()).getInstance(); |
417 | 414 | if (literal != null) { |
418 | 415 | return literal; |
419 | 416 | } |
|
0 commit comments