Exemplo n.º 1
0
  private void fillEReference(EObject eObject, JsonNode root, Resource resource) {
    final EClass eClass = eObject.eClass();

    for (Iterator<Entry<String, JsonNode>> it = root.getFields(); it.hasNext(); ) {
      Entry<String, JsonNode> field = it.next();

      String key = field.getKey();
      JsonNode value = field.getValue();

      EReference reference = getEReference(eClass, key);
      if (reference != null
          && !reference.isContainment()
          && !reference.isDerived()
          && !reference.isTransient()) {

        if (value.isArray()) {
          for (Iterator<JsonNode> itEl = value.getElements(); itEl.hasNext(); ) {
            JsonNode current = itEl.next();
            createProxyReference(eObject, root, current, reference, resource);
          }
        } else {
          createProxyReference(eObject, root, value, reference, resource);
        }
      }
    }

    for (EObject content : eObject.eContents()) {
      if (processed.containsKey(content)) fillEReference(content, processed.get(content), resource);
    }
  }
Exemplo n.º 2
0
 protected void clearReference(EObject obj, EReference ref) {
   if (!ref.isContainment()
       && !ref.isContainer()
       && !ref.isDerived()
       && ref.isChangeable()
       && !ref.isTransient()) obj.eUnset(ref);
 }
Exemplo n.º 3
0
  private void fillEContainment(EObject eObject, JsonNode root, Resource resource) {
    final EClass eClass = eObject.eClass();

    for (Iterator<Entry<String, JsonNode>> it = root.getFields(); it.hasNext(); ) {
      Entry<String, JsonNode> field = it.next();

      String key = field.getKey();
      JsonNode value = field.getValue();

      EReference reference = getEReference(eClass, key);
      if (reference != null && reference.isContainment() && !reference.isTransient()) {
        if (isMapEntry(reference.getEType()) && value.isObject()) {
          createMapEntry(eObject, reference, value);
        } else {
          createContainment(eObject, reference, root, value, resource);
        }
      }
    }
  }