Converts a json object to an entity.
@param entityType Class of entity
@param id Id of entity
@param document Raw entity
@return Entity instance
173258
@SuppressWarnings("unchecked")
    public Object convertToEntity(Class entityType, String id, ObjectNode document) {
        try {
            if (ObjectNode.class.equals(entityType)) {
                return document;
            }

            Object defaultValue = InMemoryDocumentSessionOperations.getDefaultValue(entityType);
            Object entity = defaultValue;

            String documentType =_session.getConventions().getJavaClass(id, document);
            if (documentType != null) {
                Class type = Class.forName(documentType);
                if (entityType.isAssignableFrom(type)) {
                    entity = _session.getConventions().getEntityMapper().treeToValue(document, type);
                }
            }

            if (entity == defaultValue) {
                entity = _session.getConventions().getEntityMapper().treeToValue(document, entityType);
            }

            if (id != null) {
                _session.getGenerateEntityIdOnTheClient().trySetIdentity(entity, id);
            }

            return entity;
        } catch (Exception e) {
            throw new IllegalStateException("Could not convert document " + id + " to entity of type " + entityType.getName(), e);
        }
    }
648467
public Object trackEntity(Class entityType, String id, ObjectNode document, ObjectNode metadata, boolean noTracking) {

        noTracking = this.noTracking || noTracking;  // if noTracking is session-wide then we want to override the passed argument

        if (StringUtils.isEmpty(id)) {
            return deserializeFromTransformer(entityType, null, document);
        }

        DocumentInfo docInfo = documentsById.getValue(id);
        if (docInfo != null) {
            // the local instance may have been changed, we adhere to the current Unit of Work
            // instance, and return that, ignoring anything new.

            if (docInfo.getEntity() == null) {
                docInfo.setEntity(entityToJson.convertToEntity(entityType, id, document));
            }

            if (!noTracking) {
                includedDocumentsById.remove(id);
                documentsByEntity.put(docInfo.getEntity(), docInfo);
            }

            return docInfo.getEntity();
        }

        docInfo = includedDocumentsById.get(id);
        if (docInfo != null) {
            if (docInfo.getEntity() == null) {
                docInfo.setEntity(entityToJson.convertToEntity(entityType, id, document));
            }

            if (!noTracking) {
                includedDocumentsById.remove(id);
                documentsById.add(docInfo);
                documentsByEntity.put(docInfo.getEntity(), docInfo);
            }

            return docInfo.getEntity();
        }

        Object entity = entityToJson.convertToEntity(entityType, id, document);

        String changeVector = metadata.get(Constants.Documents.Metadata.CHANGE_VECTOR).asText();
        if (changeVector == null) {
            throw new IllegalStateException("Document " + id + " must have Change Vector");
        }

        if (!noTracking) {
            DocumentInfo newDocumentInfo = new DocumentInfo();
            newDocumentInfo.setId(id);
            newDocumentInfo.setDocument(document);
            newDocumentInfo.setMetadata(metadata);
            newDocumentInfo.setEntity(entity);
            newDocumentInfo.setChangeVector(changeVector);

            documentsById.add(newDocumentInfo);
            documentsByEntity.put(entity, newDocumentInfo);
        }

        return entity;
    }
351213
public static CreateUpdateEntitiesResult fromJson(String json) throws AtlasServiceException {

        GuidMapping guidMapping = AtlasType.fromJson(json, GuidMapping.class);
        EntityResult entityResult = EntityResult.fromString(json);
        CreateUpdateEntitiesResult result = new CreateUpdateEntitiesResult();
        result.setEntityResult(entityResult);
        result.setGuidMapping(guidMapping);
        return result;
    }
322302
private void buildEntityFromCursor(Object entity, HashMap obj, EntityType entityType)
    {
        Iterator<Attribute> iter = entityType.getAttributes().iterator();
        while (iter.hasNext())
        {
            Attribute attribute = iter.next();
            Field field = (Field) attribute.getJavaMember();
            if (field.isAnnotationPresent(Id.class))
            {
                PropertyAccessorHelper.set(entity, field, obj.get(ID));
            }
            else
            {
                PropertyAccessorHelper.set(entity, field, obj.get(((AbstractAttribute) attribute).getJPAColumnName()));
            }

        }
    }
516744
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'document_id' in _dict:
            args['document_id'] = _dict.get('document_id')
        if 'field' in _dict:
            args['field'] = _dict.get('field')
        if 'start_offset' in _dict:
            args['start_offset'] = _dict.get('start_offset')
        if 'end_offset' in _dict:
            args['end_offset'] = _dict.get('end_offset')
        if 'entities' in _dict:
            args['entities'] = [
                QueryEvidenceEntity._from_dict(x)
                for x in (_dict.get('entities'))
            ]
        return cls(**args)
83738
public function getByEntity($entityClass, $id, $locale, $object = null)
    {
        if (!$object) {
            $object = $this->documentManager->find($id, $locale);
        }

        $pageNumber = $object->getPageNumber();
        if ($object instanceof ArticlePageDocument) {
            // the article contains the seo/excerpt data and the controller handles the page-number automatically
            $object = $object->getParent();
        }

        $metadata = $this->structureMetadataFactory->getStructureMetadata('article', $object->getStructureType());

        // this parameter should not be used
        // but the sulu-collector for the profiler needs it to determine data from request
        $structure = $this->structureManager->wrapStructure('article', $metadata);
        $structure->setDocument($object);

        return [
            'object' => $object,
            'view' => $metadata->view,
            'pageNumber' => $pageNumber,
            'structure' => $structure,
            '_cacheLifetime' => $this->getCacheLifetime($metadata),
            '_controller' => $metadata->controller,
        ];
    }
1036124
@PostMapping(
      value = "/{entityTypeId}/{id}/{refAttributeName}",
      params = "_method=GET",
      produces = APPLICATION_JSON_VALUE)
  public Object retrieveEntityAttributePost(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      @PathVariable("refAttributeName") String refAttributeName,
      @Valid @RequestBody EntityCollectionRequest request) {
    Set<String> attributesSet = toAttributeSet(request.getAttributes());
    Map<String, Set<String>> attributeExpandSet = toExpandMap(request.getExpand());

    return retrieveEntityAttributeInternal(
        entityTypeId, untypedId, refAttributeName, request, attributesSet, attributeExpandSet);
  }
423008
function createEntity(id, json) {

    const originStates = json.dat[0].track.z1.map(mapRow)
    const destinStates = json.dat[0].track.z2 ? json.dat[0].track.z1.map(mapRow) : null

    return new EntityInfo({
        id: id,
        states: originStates,
        destinStates: destinStates
    })
}
1053441
public JsonDocument insert(String documentId, String json) {
        return this.bucket.insert(JsonDocument.create(documentId, JsonObject.fromJson(json)));
    }
182441
public static JsonDocument create(String id, JsonObject content) {
        return new JsonDocument(id, 0, content, 0, null);
    }
281906
public EntityResult updateEntity(String guid, Referenceable entity) throws AtlasServiceException {
        String entityJson = InstanceSerialization.toJson(entity, true);
        LOG.debug("Updating entity id {} with {}", guid, entityJson);
        JSONObject response = callAPIWithBodyAndParams(API.UPDATE_ENTITY_PARTIAL, entityJson, guid);
        return extractEntityResult(response);
    }
1233663
def get_entity(self, etype, entity_id):
        
        r = fapi.get_entity(self.namespace, self.name, etype,
                               entity_id, self.api_url)
        fapi._check_response_code(r, 200)
        dresp = r.json()
        return Entity(etype, entity_id, dresp['attributes'])
497888
public Document fromJsoup(org.jsoup.nodes.Document in) {
        Validate.notNull(in);
        DocumentBuilder builder;
        try {
        	//set the factory to be namespace-aware
        	factory.setNamespaceAware(true);
            builder = factory.newDocumentBuilder();
            Document out = builder.newDocument();
            convert(in, out);
            return out;
        } catch (ParserConfigurationException e) {
            throw new IllegalStateException(e);
        }
    }
1137052
@Nonnull
  public T create(@Nonnull DocumentReference documentReference, @Nonnull Object pojo) {
    Object data = CustomClassMapper.convertToPlainJavaTypes(pojo);
    if (!(data instanceof Map)) {
      FirestoreException.invalidState("Can't set a document's data to an array or primitive");
    }
    return performCreate(documentReference, (Map<String, Object>) data);
  }
432309
private static DocumentType getDocType(final InputStream body)
        throws IOException {
        final DocumentBuilderFactory factory =
            DocumentBuilderFactory.newInstance();
        try {
            factory.setFeature(RsPrettyXml.LOAD_EXTERNAL_DTD, false);
            final DocumentBuilder builder = factory.newDocumentBuilder();
            return builder.parse(body).getDoctype();
        } catch (final ParserConfigurationException | SAXException ex) {
            throw new IOException(ex);
        }
    }
771030
public Response update(String id, Object document) {
        Misc.checkNotNullOrEmpty(id, "id");
        Misc.checkNotNull(document, "Document");

        // Get the latest rev, will throw if doc doesn't exist
        getDocumentRev(id);

        return putUpdate(id, document);
    }
1318981
@PostMapping(value = "/{entityTypeId}", params = "_method=GET", produces = APPLICATION_JSON_VALUE)
  public EntityCollectionResponse retrieveEntityCollectionPost(
      @PathVariable("entityTypeId") String entityTypeId,
      @Valid @RequestBody EntityCollectionRequest request) {
    Set<String> attributesSet = toAttributeSet(request.getAttributes());
    Map<String, Set<String>> attributeExpandSet = toExpandMap(request.getExpand());

    return retrieveEntityCollectionInternal(
        entityTypeId, request, attributesSet, attributeExpandSet);
  }